@vibedeckx/darwin-arm64 0.1.27 → 0.1.28

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.
Files changed (29) hide show
  1. package/dist/bin.js +746 -438
  2. package/dist/ui/404/index.html +1 -1
  3. package/dist/ui/404.html +1 -1
  4. package/dist/ui/__next.__PAGE__.txt +2 -2
  5. package/dist/ui/__next._full.txt +6 -6
  6. package/dist/ui/__next._head.txt +1 -1
  7. package/dist/ui/__next._index.txt +5 -5
  8. package/dist/ui/__next._tree.txt +2 -2
  9. package/dist/ui/_next/static/chunks/{2ba1d2b55b82f4da.js → 0dc6cf26b91a20e8.js} +6 -6
  10. package/dist/ui/_next/static/chunks/206325729c6b437c.js +29 -0
  11. package/dist/ui/_next/static/chunks/373ecc09d993b339.css +1 -0
  12. package/dist/ui/_next/static/chunks/{122685bfad07ee14.js → 57495168178cb0c6.js} +4 -4
  13. package/dist/ui/_next/static/chunks/{020d675d21be28d4.js → 73d9cd102c21dc34.js} +1 -1
  14. package/dist/ui/_not-found/__next._full.txt +5 -5
  15. package/dist/ui/_not-found/__next._head.txt +1 -1
  16. package/dist/ui/_not-found/__next._index.txt +5 -5
  17. package/dist/ui/_not-found/__next._not-found.__PAGE__.txt +1 -1
  18. package/dist/ui/_not-found/__next._not-found.txt +1 -1
  19. package/dist/ui/_not-found/__next._tree.txt +2 -2
  20. package/dist/ui/_not-found/index.html +1 -1
  21. package/dist/ui/_not-found/index.txt +5 -5
  22. package/dist/ui/index.html +1 -1
  23. package/dist/ui/index.txt +6 -6
  24. package/package.json +1 -1
  25. package/dist/ui/_next/static/chunks/249ad99126262bb9.css +0 -1
  26. package/dist/ui/_next/static/chunks/aa03f5892ce4bb52.js +0 -29
  27. /package/dist/ui/_next/static/{rSLUXluGKIuxoFbaUSXLP → c3XhyFJJbnxGICK0cg7UN}/_buildManifest.js +0 -0
  28. /package/dist/ui/_next/static/{rSLUXluGKIuxoFbaUSXLP → c3XhyFJJbnxGICK0cg7UN}/_clientMiddlewareManifest.json +0 -0
  29. /package/dist/ui/_next/static/{rSLUXluGKIuxoFbaUSXLP → c3XhyFJJbnxGICK0cg7UN}/_ssgManifest.js +0 -0
@@ -0,0 +1,29 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,837031,e=>{"use strict";let r,s,i,n,o,a,l,c,d,h,u,f,p,m,g,v,x;var _,y,b,w,S,C,k,j,N,E,R,M,D,T,P,L,A,B,I,O,z,F=e.i(813443),W=e.i(629109),$=e.i(331053),H=e.i(322387),H=H,U=e.i(538422);function K(e,r=[]){let s=[],i=()=>{let r=s.map(e=>W.createContext(e));return function(s){let i=s?.[e]||r;return W.useMemo(()=>({[`__scope${e}`]:{...s,[e]:i}}),[s,i])}};return i.scopeName=e,[function(r,i){let n=W.createContext(i),o=s.length;s=[...s,i];let a=r=>{let{scope:s,children:i,...a}=r,l=s?.[e]?.[o]||n,c=W.useMemo(()=>a,Object.values(a));return(0,F.jsx)(l.Provider,{value:c,children:i})};return a.displayName=r+"Provider",[a,function(s,a){let l=a?.[e]?.[o]||n,c=W.useContext(l);if(c)return c;if(void 0!==i)return i;throw Error(`\`${s}\` must be used within \`${r}\``)}]},function(...e){let r=e[0];if(1===e.length)return r;let s=()=>{let s=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let i=s.reduce((r,{useScope:s,scopeName:i})=>{let n=s(e)[`__scope${i}`];return{...r,...n}},{});return W.useMemo(()=>({[`__scope${r.scopeName}`]:i}),[i])}};return s.scopeName=r.scopeName,s}(i,...r)]}function q(e,r,{checkForDefaultPrevented:s=!0}={}){return function(i){if(e?.(i),!1===s||!i.defaultPrevented)return r?.(i)}}"undefined"!=typeof window&&window.document&&window.document.createElement;var V=globalThis?.document?W.useLayoutEffect:()=>{};W[" useEffectEvent ".trim().toString()],W[" useInsertionEffect ".trim().toString()];var Y=W[" useInsertionEffect ".trim().toString()]||V;function X({prop:e,defaultProp:r,onChange:s=()=>{},caller:i}){let[n,o,a]=function({defaultProp:e,onChange:r}){let[s,i]=W.useState(e),n=W.useRef(s),o=W.useRef(r);return Y(()=>{o.current=r},[r]),W.useEffect(()=>{n.current!==s&&(o.current?.(s),n.current=s)},[s,n]),[s,i,o]}({defaultProp:r,onChange:s}),l=void 0!==e,c=l?e:n;{let r=W.useRef(void 0!==e);W.useEffect(()=>{let e=r.current;if(e!==l){let r=l?"controlled":"uncontrolled";console.warn(`${i} is changing from ${e?"controlled":"uncontrolled"} to ${r}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`)}r.current=l},[l,i])}return[c,W.useCallback(r=>{if(l){let s="function"==typeof r?r(e):r;s!==e&&a.current?.(s)}else o(r)},[l,e,o,a])]}function G(e){let r=W.useRef({value:e,previous:e});return W.useMemo(()=>(r.current.value!==e&&(r.current.previous=r.current.value,r.current.value=e),r.current.previous),[e])}function J(e){let[r,s]=W.useState(void 0);return V(()=>{if(e){s({width:e.offsetWidth,height:e.offsetHeight});let r=new ResizeObserver(r=>{let i,n;if(!Array.isArray(r)||!r.length)return;let o=r[0];if("borderBoxSize"in o){let e=o.borderBoxSize,r=Array.isArray(e)?e[0]:e;i=r.inlineSize,n=r.blockSize}else i=e.offsetWidth,n=e.offsetHeight;s({width:i,height:n})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}s(void 0)},[e]),r}Symbol("RADIX:SYNC_STATE");var Z=e=>{var r;let s,i,{present:n,children:o}=e,a=function(e){var r,s;let[i,n]=W.useState(),o=W.useRef(null),a=W.useRef(e),l=W.useRef("none"),[c,d]=(r=e?"mounted":"unmounted",s={mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}},W.useReducer((e,r)=>s[e][r]??e,r));return W.useEffect(()=>{let e=Q(o.current);l.current="mounted"===c?e:"none"},[c]),V(()=>{let r=o.current,s=a.current;if(s!==e){let i=l.current,n=Q(r);e?d("MOUNT"):"none"===n||r?.display==="none"?d("UNMOUNT"):s&&i!==n?d("ANIMATION_OUT"):d("UNMOUNT"),a.current=e}},[e,d]),V(()=>{if(i){let e,r=i.ownerDocument.defaultView??window,s=s=>{let n=Q(o.current).includes(CSS.escape(s.animationName));if(s.target===i&&n&&(d("ANIMATION_END"),!a.current)){let s=i.style.animationFillMode;i.style.animationFillMode="forwards",e=r.setTimeout(()=>{"forwards"===i.style.animationFillMode&&(i.style.animationFillMode=s)})}},n=e=>{e.target===i&&(l.current=Q(o.current))};return i.addEventListener("animationstart",n),i.addEventListener("animationcancel",s),i.addEventListener("animationend",s),()=>{r.clearTimeout(e),i.removeEventListener("animationstart",n),i.removeEventListener("animationcancel",s),i.removeEventListener("animationend",s)}}d("ANIMATION_END")},[i,d]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:W.useCallback(e=>{o.current=e?getComputedStyle(e):null,n(e)},[])}}(n),l="function"==typeof o?o({present:a.isPresent}):W.Children.only(o),c=(0,U.useComposedRefs)(a.ref,(r=l,(i=(s=Object.getOwnPropertyDescriptor(r.props,"ref")?.get)&&"isReactWarning"in s&&s.isReactWarning)?r.ref:(i=(s=Object.getOwnPropertyDescriptor(r,"ref")?.get)&&"isReactWarning"in s&&s.isReactWarning)?r.props.ref:r.props.ref||r.ref));return"function"==typeof o||a.isPresent?W.cloneElement(l,{ref:c}):null};function Q(e){return e?.animationName||"none"}Z.displayName="Presence";var ee=e.i(492521),et=e.i(475299),er=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,r)=>{let s=(0,et.createSlot)(`Primitive.${r}`),i=W.forwardRef((e,i)=>{let{asChild:n,...o}=e;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,F.jsx)(n?s:r,{...o,ref:i})});return i.displayName=`Primitive.${r}`,{...e,[r]:i}},{});function es(e,r){e&&ee.flushSync(()=>e.dispatchEvent(r))}var ei="Checkbox",[en,eo]=K(ei),[ea,el]=en(ei);function ec(e){let{__scopeCheckbox:r,checked:s,children:i,defaultChecked:n,disabled:o,form:a,name:l,onCheckedChange:c,required:d,value:h="on",internal_do_not_use_render:u}=e,[f,p]=X({prop:s,defaultProp:n??!1,onChange:c,caller:ei}),[m,g]=W.useState(null),[v,x]=W.useState(null),_=W.useRef(!1),y=!m||!!a||!!m.closest("form"),b={checked:f,disabled:o,setChecked:p,control:m,setControl:g,name:l,form:a,value:h,hasConsumerStoppedPropagationRef:_,required:d,defaultChecked:!ev(n)&&n,isFormControl:y,bubbleInput:v,setBubbleInput:x};return(0,F.jsx)(ea,{scope:r,...b,children:"function"==typeof u?u(b):i})}var ed="CheckboxTrigger",eh=W.forwardRef(({__scopeCheckbox:e,onKeyDown:r,onClick:s,...i},n)=>{let{control:o,value:a,disabled:l,checked:c,required:d,setControl:h,setChecked:u,hasConsumerStoppedPropagationRef:f,isFormControl:p,bubbleInput:m}=el(ed,e),g=(0,U.useComposedRefs)(n,h),v=W.useRef(c);return W.useEffect(()=>{let e=o?.form;if(e){let r=()=>u(v.current);return e.addEventListener("reset",r),()=>e.removeEventListener("reset",r)}},[o,u]),(0,F.jsx)(er.button,{type:"button",role:"checkbox","aria-checked":ev(c)?"mixed":c,"aria-required":d,"data-state":ex(c),"data-disabled":l?"":void 0,disabled:l,value:a,...i,ref:g,onKeyDown:q(r,e=>{"Enter"===e.key&&e.preventDefault()}),onClick:q(s,e=>{u(e=>!!ev(e)||!e),m&&p&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})});eh.displayName=ed;var eu=W.forwardRef((e,r)=>{let{__scopeCheckbox:s,name:i,checked:n,defaultChecked:o,required:a,disabled:l,value:c,onCheckedChange:d,form:h,...u}=e;return(0,F.jsx)(ec,{__scopeCheckbox:s,checked:n,defaultChecked:o,disabled:l,required:a,onCheckedChange:d,name:i,form:h,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(eh,{...u,ref:r,__scopeCheckbox:s}),e&&(0,F.jsx)(eg,{__scopeCheckbox:s})]})})});eu.displayName=ei;var ef="CheckboxIndicator",ep=W.forwardRef((e,r)=>{let{__scopeCheckbox:s,forceMount:i,...n}=e,o=el(ef,s);return(0,F.jsx)(Z,{present:i||ev(o.checked)||!0===o.checked,children:(0,F.jsx)(er.span,{"data-state":ex(o.checked),"data-disabled":o.disabled?"":void 0,...n,ref:r,style:{pointerEvents:"none",...e.style}})})});ep.displayName=ef;var em="CheckboxBubbleInput",eg=W.forwardRef(({__scopeCheckbox:e,...r},s)=>{let{control:i,hasConsumerStoppedPropagationRef:n,checked:o,defaultChecked:a,required:l,disabled:c,name:d,value:h,form:u,bubbleInput:f,setBubbleInput:p}=el(em,e),m=(0,U.useComposedRefs)(s,p),g=G(o),v=J(i);W.useEffect(()=>{if(!f)return;let e=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"checked").set,r=!n.current;if(g!==o&&e){let s=new Event("click",{bubbles:r});f.indeterminate=ev(o),e.call(f,!ev(o)&&o),f.dispatchEvent(s)}},[f,g,o,n]);let x=W.useRef(!ev(o)&&o);return(0,F.jsx)(er.input,{type:"checkbox","aria-hidden":!0,defaultChecked:a??x.current,required:l,disabled:c,name:d,value:h,form:u,...r,tabIndex:-1,ref:m,style:{...r.style,...v,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});function ev(e){return"indeterminate"===e}function ex(e){return ev(e)?"indeterminate":e?"checked":"unchecked"}eg.displayName=em,e.s(["Checkbox",()=>eu,"CheckboxIndicator",()=>ep,"Indicator",()=>ep,"Root",()=>eu,"createCheckboxScope",()=>eo,"unstable_BubbleInput",()=>eg,"unstable_CheckboxBubbleInput",()=>eg,"unstable_CheckboxProvider",()=>ec,"unstable_CheckboxTrigger",()=>eh,"unstable_Provider",()=>ec,"unstable_Trigger",()=>eh],85402);var e_=e.i(85402),e_=e_,ey=e.i(803545);function eb({className:e,...r}){return(0,F.jsx)(e_.Root,{"data-slot":"checkbox",className:(0,ey.cn)("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...r,children:(0,F.jsx)(e_.Indicator,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none",children:(0,F.jsx)(H.default,{className:"size-3.5"})})})}var ew=e.i(198631);let eS=(0,ew.default)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);var eC=W[" useId ".trim().toString()]||(()=>void 0),ek=0;function ej(e){let[r,s]=W.useState(eC());return V(()=>{e||s(e=>e??String(ek++))},[e]),e||(r?`radix-${r}`:"")}function eN(e){let r=W.useRef(e);return W.useEffect(()=>{r.current=e}),W.useMemo(()=>(...e)=>r.current?.(...e),[])}var eE="dismissableLayer.update",eR=W.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),eM=W.forwardRef((e,r)=>{let{disableOutsidePointerEvents:s=!1,onEscapeKeyDown:i,onPointerDownOutside:n,onFocusOutside:o,onInteractOutside:a,onDismiss:l,...c}=e,d=W.useContext(eR),[h,u]=W.useState(null),f=h?.ownerDocument??globalThis?.document,[,p]=W.useState({}),m=(0,U.useComposedRefs)(r,e=>u(e)),g=Array.from(d.layers),[v]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),x=g.indexOf(v),_=h?g.indexOf(h):-1,y=d.layersWithOutsidePointerEventsDisabled.size>0,b=_>=x,w=function(e,r=globalThis?.document){let s=eN(e),i=W.useRef(!1),n=W.useRef(()=>{});return W.useEffect(()=>{let e=e=>{if(e.target&&!i.current){let i=function(){eT("dismissableLayer.pointerDownOutside",s,o,{discrete:!0})},o={originalEvent:e};"touch"===e.pointerType?(r.removeEventListener("click",n.current),n.current=i,r.addEventListener("click",n.current,{once:!0})):i()}else r.removeEventListener("click",n.current);i.current=!1},o=window.setTimeout(()=>{r.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(o),r.removeEventListener("pointerdown",e),r.removeEventListener("click",n.current)}},[r,s]),{onPointerDownCapture:()=>i.current=!0}}(e=>{let r=e.target,s=[...d.branches].some(e=>e.contains(r));b&&!s&&(n?.(e),a?.(e),e.defaultPrevented||l?.())},f),S=function(e,r=globalThis?.document){let s=eN(e),i=W.useRef(!1);return W.useEffect(()=>{let e=e=>{e.target&&!i.current&&eT("dismissableLayer.focusOutside",s,{originalEvent:e},{discrete:!1})};return r.addEventListener("focusin",e),()=>r.removeEventListener("focusin",e)},[r,s]),{onFocusCapture:()=>i.current=!0,onBlurCapture:()=>i.current=!1}}(e=>{let r=e.target;![...d.branches].some(e=>e.contains(r))&&(o?.(e),a?.(e),e.defaultPrevented||l?.())},f);return!function(e,r=globalThis?.document){let s=eN(e);W.useEffect(()=>{let e=e=>{"Escape"===e.key&&s(e)};return r.addEventListener("keydown",e,{capture:!0}),()=>r.removeEventListener("keydown",e,{capture:!0})},[s,r])}(e=>{_===d.layers.size-1&&(i?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))},f),W.useEffect(()=>{if(h)return s&&(0===d.layersWithOutsidePointerEventsDisabled.size&&(cK=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(h)),d.layers.add(h),eD(),()=>{s&&1===d.layersWithOutsidePointerEventsDisabled.size&&(f.body.style.pointerEvents=cK)}},[h,f,s,d]),W.useEffect(()=>()=>{h&&(d.layers.delete(h),d.layersWithOutsidePointerEventsDisabled.delete(h),eD())},[h,d]),W.useEffect(()=>{let e=()=>p({});return document.addEventListener(eE,e),()=>document.removeEventListener(eE,e)},[]),(0,F.jsx)(er.div,{...c,ref:m,style:{pointerEvents:y?b?"auto":"none":void 0,...e.style},onFocusCapture:q(e.onFocusCapture,S.onFocusCapture),onBlurCapture:q(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:q(e.onPointerDownCapture,w.onPointerDownCapture)})});function eD(){let e=new CustomEvent(eE);document.dispatchEvent(e)}function eT(e,r,s,{discrete:i}){let n=s.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:s});r&&n.addEventListener(e,r,{once:!0}),i?es(n,o):n.dispatchEvent(o)}eM.displayName="DismissableLayer",W.forwardRef((e,r)=>{let s=W.useContext(eR),i=W.useRef(null),n=(0,U.useComposedRefs)(r,i);return W.useEffect(()=>{let e=i.current;if(e)return s.branches.add(e),()=>{s.branches.delete(e)}},[s.branches]),(0,F.jsx)(er.div,{...e,ref:n})}).displayName="DismissableLayerBranch";var eP="focusScope.autoFocusOnMount",eL="focusScope.autoFocusOnUnmount",eA={bubbles:!1,cancelable:!0},eB=W.forwardRef((e,r)=>{let{loop:s=!1,trapped:i=!1,onMountAutoFocus:n,onUnmountAutoFocus:o,...a}=e,[l,c]=W.useState(null),d=eN(n),h=eN(o),u=W.useRef(null),f=(0,U.useComposedRefs)(r,e=>c(e)),p=W.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;W.useEffect(()=>{if(i){let e=function(e){if(p.paused||!l)return;let r=e.target;l.contains(r)?u.current=r:ez(u.current,{select:!0})},r=function(e){if(p.paused||!l)return;let r=e.relatedTarget;null!==r&&(l.contains(r)||ez(u.current,{select:!0}))};document.addEventListener("focusin",e),document.addEventListener("focusout",r);let s=new MutationObserver(function(e){if(document.activeElement===document.body)for(let r of e)r.removedNodes.length>0&&ez(l)});return l&&s.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",r),s.disconnect()}}},[i,l,p.paused]),W.useEffect(()=>{if(l){eF.add(p);let e=document.activeElement;if(!l.contains(e)){let r=new CustomEvent(eP,eA);l.addEventListener(eP,d),l.dispatchEvent(r),r.defaultPrevented||(function(e,{select:r=!1}={}){let s=document.activeElement;for(let i of e)if(ez(i,{select:r}),document.activeElement!==s)return}(eI(l).filter(e=>"A"!==e.tagName),{select:!0}),document.activeElement===e&&ez(l))}return()=>{l.removeEventListener(eP,d),setTimeout(()=>{let r=new CustomEvent(eL,eA);l.addEventListener(eL,h),l.dispatchEvent(r),r.defaultPrevented||ez(e??document.body,{select:!0}),l.removeEventListener(eL,h),eF.remove(p)},0)}}},[l,d,h,p]);let m=W.useCallback(e=>{if(!s&&!i||p.paused)return;let r="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,n=document.activeElement;if(r&&n){var o;let r,i=e.currentTarget,[a,l]=[eO(r=eI(o=i),o),eO(r.reverse(),o)];a&&l?e.shiftKey||n!==l?e.shiftKey&&n===a&&(e.preventDefault(),s&&ez(l,{select:!0})):(e.preventDefault(),s&&ez(a,{select:!0})):n===i&&e.preventDefault()}},[s,i,p.paused]);return(0,F.jsx)(er.div,{tabIndex:-1,...a,ref:f,onKeyDown:m})});function eI(e){let r=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let r="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||r?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;s.nextNode();)r.push(s.currentNode);return r}function eO(e,r){for(let s of e)if(!function(e,{upTo:r}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e&&(void 0===r||e!==r);){if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}(s,{upTo:r}))return s}function ez(e,{select:r=!1}={}){if(e&&e.focus){var s;let i=document.activeElement;e.focus({preventScroll:!0}),e!==i&&(s=e)instanceof HTMLInputElement&&"select"in s&&r&&e.select()}}eB.displayName="FocusScope";var eF=(x=[],{add(e){let r=x[0];e!==r&&r?.pause(),(x=eW(x,e)).unshift(e)},remove(e){x=eW(x,e),x[0]?.resume()}});function eW(e,r){let s=[...e],i=s.indexOf(r);return -1!==i&&s.splice(i,1),s}var e$=W.forwardRef((e,r)=>{let{container:s,...i}=e,[n,o]=W.useState(!1);V(()=>o(!0),[]);let a=s||n&&globalThis?.document?.body;return a?ee.default.createPortal((0,F.jsx)(er.div,{...i,ref:r}),a):null});e$.displayName="Portal";var eH=0;function eU(){W.useEffect(()=>{let e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??eK()),document.body.insertAdjacentElement("beforeend",e[1]??eK()),eH++,()=>{1===eH&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),eH--}},[])}function eK(){let e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var eq=function(){return(eq=Object.assign||function(e){for(var r,s=1,i=arguments.length;s<i;s++)for(var n in r=arguments[s])Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n]);return e}).apply(this,arguments)};function eV(e,r){var s={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&0>r.indexOf(i)&&(s[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,i=Object.getOwnPropertySymbols(e);n<i.length;n++)0>r.indexOf(i[n])&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(s[i[n]]=e[i[n]]);return s}var eY=("function"==typeof SuppressedError&&SuppressedError,"right-scroll-bar-position"),eX="width-before-scroll-bar";function eG(e,r){return"function"==typeof e?e(r):e&&(e.current=r),e}var eJ="undefined"!=typeof window?W.useLayoutEffect:W.useEffect,eZ=new WeakMap,eQ=(void 0===cI&&(cI={}),(void 0===cO&&(cO=function(e){return e}),cz=[],cF=!1,cW={read:function(){if(cF)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return cz.length?cz[cz.length-1]:null},useMedium:function(e){var r=cO(e,cF);return cz.push(r),function(){cz=cz.filter(function(e){return e!==r})}},assignSyncMedium:function(e){for(cF=!0;cz.length;){var r=cz;cz=[],r.forEach(e)}cz={push:function(r){return e(r)},filter:function(){return cz}}},assignMedium:function(e){cF=!0;var r=[];if(cz.length){var s=cz;cz=[],s.forEach(e),r=cz}var i=function(){var s=r;r=[],s.forEach(e)},n=function(){return Promise.resolve().then(i)};n(),cz={push:function(e){r.push(e),n()},filter:function(e){return r=r.filter(e),cz}}}}).options=eq({async:!0,ssr:!1},cI),cW),e0=function(){},e1=W.forwardRef(function(e,r){var s,i,n,o,a=W.useRef(null),l=W.useState({onScrollCapture:e0,onWheelCapture:e0,onTouchMoveCapture:e0}),c=l[0],d=l[1],h=e.forwardProps,u=e.children,f=e.className,p=e.removeScrollBar,m=e.enabled,g=e.shards,v=e.sideCar,x=e.noRelative,_=e.noIsolation,y=e.inert,b=e.allowPinchZoom,w=e.as,S=e.gapMode,C=eV(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=(s=[a,r],i=function(e){return s.forEach(function(r){return eG(r,e)})},(n=(0,W.useState)(function(){return{value:null,callback:i,facade:{get current(){return n.value},set current(value){var e=n.value;e!==value&&(n.value=value,n.callback(value,e))}}}})[0]).callback=i,o=n.facade,eJ(function(){var e=eZ.get(o);if(e){var r=new Set(e),i=new Set(s),n=o.current;r.forEach(function(e){i.has(e)||eG(e,null)}),i.forEach(function(e){r.has(e)||eG(e,n)})}eZ.set(o,s)},[s]),o),j=eq(eq({},C),c);return W.createElement(W.Fragment,null,m&&W.createElement(v,{sideCar:eQ,removeScrollBar:p,shards:g,noRelative:x,noIsolation:_,inert:y,setCallbacks:d,allowPinchZoom:!!b,lockRef:a,gapMode:S}),h?W.cloneElement(W.Children.only(u),eq(eq({},j),{ref:k})):W.createElement(void 0===w?"div":w,eq({},j,{className:f,ref:k}),u))});e1.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},e1.classNames={fullWidth:eX,zeroRight:eY};var e2=function(e){var r=e.sideCar,s=eV(e,["sideCar"]);if(!r)throw Error("Sidecar: please provide `sideCar` property to import the right car");var i=r.read();if(!i)throw Error("Sidecar medium not found");return W.createElement(i,eq({},s))};e2.isSideCarExport=!0;var e5=function(){var e=0,r=null;return{add:function(s){if(0==e&&(r=function(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var r=cq||("undefined"!=typeof __webpack_nonce__?__webpack_nonce__:void 0);return r&&e.setAttribute("nonce",r),e}())){var i,n;(i=r).styleSheet?i.styleSheet.cssText=s:i.appendChild(document.createTextNode(s)),n=r,(document.head||document.getElementsByTagName("head")[0]).appendChild(n)}e++},remove:function(){--e||!r||(r.parentNode&&r.parentNode.removeChild(r),r=null)}}},e3=function(){var e=e5();return function(r,s){W.useEffect(function(){return e.add(r),function(){e.remove()}},[r&&s])}},e4=function(){var e=e3();return function(r){return e(r.styles,r.dynamic),null}},e6={left:0,top:0,right:0,gap:0},e8=function(e){return parseInt(e||"",10)||0},e7=function(e){var r=window.getComputedStyle(document.body),s=r["padding"===e?"paddingLeft":"marginLeft"],i=r["padding"===e?"paddingTop":"marginTop"],n=r["padding"===e?"paddingRight":"marginRight"];return[e8(s),e8(i),e8(n)]},e9=function(e){if(void 0===e&&(e="margin"),"undefined"==typeof window)return e6;var r=e7(e),s=document.documentElement.clientWidth,i=window.innerWidth;return{left:r[0],top:r[1],right:r[2],gap:Math.max(0,i-s+r[2]-r[0])}},te=e4(),tt="data-scroll-locked",tr=function(e,r,s,i){var n=e.left,o=e.top,a=e.right,l=e.gap;return void 0===s&&(s="margin"),"\n .".concat("with-scroll-bars-hidden"," {\n overflow: hidden ").concat(i,";\n padding-right: ").concat(l,"px ").concat(i,";\n }\n body[").concat(tt,"] {\n overflow: hidden ").concat(i,";\n overscroll-behavior: contain;\n ").concat([r&&"position: relative ".concat(i,";"),"margin"===s&&"\n padding-left: ".concat(n,"px;\n padding-top: ").concat(o,"px;\n padding-right: ").concat(a,"px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(l,"px ").concat(i,";\n "),"padding"===s&&"padding-right: ".concat(l,"px ").concat(i,";")].filter(Boolean).join(""),"\n }\n \n .").concat(eY," {\n right: ").concat(l,"px ").concat(i,";\n }\n \n .").concat(eX," {\n margin-right: ").concat(l,"px ").concat(i,";\n }\n \n .").concat(eY," .").concat(eY," {\n right: 0 ").concat(i,";\n }\n \n .").concat(eX," .").concat(eX," {\n margin-right: 0 ").concat(i,";\n }\n \n body[").concat(tt,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(l,"px;\n }\n")},ts=function(){var e=parseInt(document.body.getAttribute(tt)||"0",10);return isFinite(e)?e:0},ti=function(){W.useEffect(function(){return document.body.setAttribute(tt,(ts()+1).toString()),function(){var e=ts()-1;e<=0?document.body.removeAttribute(tt):document.body.setAttribute(tt,e.toString())}},[])},tn=function(e){var r=e.noRelative,s=e.noImportant,i=e.gapMode,n=void 0===i?"margin":i;ti();var o=W.useMemo(function(){return e9(n)},[n]);return W.createElement(te,{styles:tr(o,!r,n,s?"":"!important")})},to=!1;if("undefined"!=typeof window)try{var ta=Object.defineProperty({},"passive",{get:function(){return to=!0,!0}});window.addEventListener("test",ta,ta),window.removeEventListener("test",ta,ta)}catch(e){to=!1}var tl=!!to&&{passive:!1},tc=function(e,r){if(!(e instanceof Element))return!1;var s=window.getComputedStyle(e);return"hidden"!==s[r]&&(s.overflowY!==s.overflowX||"TEXTAREA"===e.tagName||"visible"!==s[r])},td=function(e,r){var s=r.ownerDocument,i=r;do{if("undefined"!=typeof ShadowRoot&&i instanceof ShadowRoot&&(i=i.host),th(e,i)){var n=tu(e,i);if(n[1]>n[2])return!0}i=i.parentNode}while(i&&i!==s.body)return!1},th=function(e,r){return"v"===e?tc(r,"overflowY"):tc(r,"overflowX")},tu=function(e,r){return"v"===e?[r.scrollTop,r.scrollHeight,r.clientHeight]:[r.scrollLeft,r.scrollWidth,r.clientWidth]},tf=function(e,r,s,i,n){var o,a=(o=window.getComputedStyle(r).direction,"h"===e&&"rtl"===o?-1:1),l=a*i,c=s.target,d=r.contains(c),h=!1,u=l>0,f=0,p=0;do{if(!c)break;var m=tu(e,c),g=m[0],v=m[1]-m[2]-a*g;(g||v)&&th(e,c)&&(f+=v,p+=g);var x=c.parentNode;c=x&&x.nodeType===Node.DOCUMENT_FRAGMENT_NODE?x.host:x}while(!d&&c!==document.body||d&&(r.contains(c)||r===c))return u&&(n&&1>Math.abs(f)||!n&&l>f)?h=!0:!u&&(n&&1>Math.abs(p)||!n&&-l>p)&&(h=!0),h},tp=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},tm=function(e){return[e.deltaX,e.deltaY]},tg=function(e){return e&&"current"in e?e.current:e},tv=0,tx=[];let t_=(c$=function(e){var r=W.useRef([]),s=W.useRef([0,0]),i=W.useRef(),n=W.useState(tv++)[0],o=W.useState(e4)[0],a=W.useRef(e);W.useEffect(function(){a.current=e},[e]),W.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(n));var r=(function(e,r,s){if(s||2==arguments.length)for(var i,n=0,o=r.length;n<o;n++)!i&&n in r||(i||(i=Array.prototype.slice.call(r,0,n)),i[n]=r[n]);return e.concat(i||Array.prototype.slice.call(r))})([e.lockRef.current],(e.shards||[]).map(tg),!0).filter(Boolean);return r.forEach(function(e){return e.classList.add("allow-interactivity-".concat(n))}),function(){document.body.classList.remove("block-interactivity-".concat(n)),r.forEach(function(e){return e.classList.remove("allow-interactivity-".concat(n))})}}},[e.inert,e.lockRef.current,e.shards]);var l=W.useCallback(function(e,r){if("touches"in e&&2===e.touches.length||"wheel"===e.type&&e.ctrlKey)return!a.current.allowPinchZoom;var n,o=tp(e),l=s.current,c="deltaX"in e?e.deltaX:l[0]-o[0],d="deltaY"in e?e.deltaY:l[1]-o[1],h=e.target,u=Math.abs(c)>Math.abs(d)?"h":"v";if("touches"in e&&"h"===u&&"range"===h.type)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===h||p.contains(h)))return!1;var m=td(u,h);if(!m)return!0;if(m?n=u:(n="v"===u?"h":"v",m=td(u,h)),!m)return!1;if(!i.current&&"changedTouches"in e&&(c||d)&&(i.current=n),!n)return!0;var g=i.current||n;return tf(g,r,e,"h"===g?c:d,!0)},[]),c=W.useCallback(function(e){if(tx.length&&tx[tx.length-1]===o){var s="deltaY"in e?tm(e):tp(e),i=r.current.filter(function(r){var i;return r.name===e.type&&(r.target===e.target||e.target===r.shadowParent)&&(i=r.delta,i[0]===s[0]&&i[1]===s[1])})[0];if(i&&i.should){e.cancelable&&e.preventDefault();return}if(!i){var n=(a.current.shards||[]).map(tg).filter(Boolean).filter(function(r){return r.contains(e.target)});(n.length>0?l(e,n[0]):!a.current.noIsolation)&&e.cancelable&&e.preventDefault()}}},[]),d=W.useCallback(function(e,s,i,n){var o={name:e,delta:s,target:i,should:n,shadowParent:function(e){for(var r=null;null!==e;)e instanceof ShadowRoot&&(r=e.host,e=e.host),e=e.parentNode;return r}(i)};r.current.push(o),setTimeout(function(){r.current=r.current.filter(function(e){return e!==o})},1)},[]),h=W.useCallback(function(e){s.current=tp(e),i.current=void 0},[]),u=W.useCallback(function(r){d(r.type,tm(r),r.target,l(r,e.lockRef.current))},[]),f=W.useCallback(function(r){d(r.type,tp(r),r.target,l(r,e.lockRef.current))},[]);W.useEffect(function(){return tx.push(o),e.setCallbacks({onScrollCapture:u,onWheelCapture:u,onTouchMoveCapture:f}),document.addEventListener("wheel",c,tl),document.addEventListener("touchmove",c,tl),document.addEventListener("touchstart",h,tl),function(){tx=tx.filter(function(e){return e!==o}),document.removeEventListener("wheel",c,tl),document.removeEventListener("touchmove",c,tl),document.removeEventListener("touchstart",h,tl)}},[]);var p=e.removeScrollBar,m=e.inert;return W.createElement(W.Fragment,null,m?W.createElement(o,{styles:"\n .block-interactivity-".concat(n," {pointer-events: none;}\n .allow-interactivity-").concat(n," {pointer-events: all;}\n")}):null,p?W.createElement(tn,{noRelative:e.noRelative,gapMode:e.gapMode}):null)},eQ.useMedium(c$),e2);var ty=W.forwardRef(function(e,r){return W.createElement(e1,eq({},e,{ref:r,sideCar:t_}))});ty.classNames=e1.classNames;var tb=new WeakMap,tw=new WeakMap,tS={},tC=0,tk=function(e){return e&&(e.host||tk(e.parentNode))},tj=function(e,r,s,i){var n=(Array.isArray(e)?e:[e]).map(function(e){if(r.contains(e))return e;var s=tk(e);return s&&r.contains(s)?s:(console.error("aria-hidden",e,"in not contained inside",r,". Doing nothing"),null)}).filter(function(e){return!!e});tS[s]||(tS[s]=new WeakMap);var o=tS[s],a=[],l=new Set,c=new Set(n),d=function(e){!e||l.has(e)||(l.add(e),d(e.parentNode))};n.forEach(d);var h=function(e){!e||c.has(e)||Array.prototype.forEach.call(e.children,function(e){if(l.has(e))h(e);else try{var r=e.getAttribute(i),n=null!==r&&"false"!==r,c=(tb.get(e)||0)+1,d=(o.get(e)||0)+1;tb.set(e,c),o.set(e,d),a.push(e),1===c&&n&&tw.set(e,!0),1===d&&e.setAttribute(s,"true"),n||e.setAttribute(i,"true")}catch(r){console.error("aria-hidden: cannot operate on ",e,r)}})};return h(r),l.clear(),tC++,function(){a.forEach(function(e){var r=tb.get(e)-1,n=o.get(e)-1;tb.set(e,r),o.set(e,n),r||(tw.has(e)||e.removeAttribute(i),tw.delete(e)),n||e.removeAttribute(s)}),--tC||(tb=new WeakMap,tb=new WeakMap,tw=new WeakMap,tS={})}},tN=function(e,r,s){void 0===s&&(s="data-aria-hidden");var i=Array.from(Array.isArray(e)?e:[e]),n=r||("undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body);return n?(i.push.apply(i,Array.from(n.querySelectorAll("[aria-live], script"))),tj(i,n,s,"aria-hidden")):function(){return null}},tE="Dialog",[tR,tM]=K(tE),[tD,tT]=tR(tE),tP=e=>{let{__scopeDialog:r,children:s,open:i,defaultOpen:n,onOpenChange:o,modal:a=!0}=e,l=W.useRef(null),c=W.useRef(null),[d,h]=X({prop:i,defaultProp:n??!1,onChange:o,caller:tE});return(0,F.jsx)(tD,{scope:r,triggerRef:l,contentRef:c,contentId:ej(),titleId:ej(),descriptionId:ej(),open:d,onOpenChange:h,onOpenToggle:W.useCallback(()=>h(e=>!e),[h]),modal:a,children:s})};tP.displayName=tE;var tL="DialogTrigger";W.forwardRef((e,r)=>{let{__scopeDialog:s,...i}=e,n=tT(tL,s),o=(0,U.useComposedRefs)(r,n.triggerRef);return(0,F.jsx)(er.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":t0(n.open),...i,ref:o,onClick:q(e.onClick,n.onOpenToggle)})}).displayName=tL;var tA="DialogPortal",[tB,tI]=tR(tA,{forceMount:void 0}),tO=e=>{let{__scopeDialog:r,forceMount:s,children:i,container:n}=e,o=tT(tA,r);return(0,F.jsx)(tB,{scope:r,forceMount:s,children:W.Children.map(i,e=>(0,F.jsx)(Z,{present:s||o.open,children:(0,F.jsx)(e$,{asChild:!0,container:n,children:e})}))})};tO.displayName=tA;var tz="DialogOverlay",tF=W.forwardRef((e,r)=>{let s=tI(tz,e.__scopeDialog),{forceMount:i=s.forceMount,...n}=e,o=tT(tz,e.__scopeDialog);return o.modal?(0,F.jsx)(Z,{present:i||o.open,children:(0,F.jsx)(t$,{...n,ref:r})}):null});tF.displayName=tz;var tW=(0,et.createSlot)("DialogOverlay.RemoveScroll"),t$=W.forwardRef((e,r)=>{let{__scopeDialog:s,...i}=e,n=tT(tz,s);return(0,F.jsx)(ty,{as:tW,allowPinchZoom:!0,shards:[n.contentRef],children:(0,F.jsx)(er.div,{"data-state":t0(n.open),...i,ref:r,style:{pointerEvents:"auto",...i.style}})})}),tH="DialogContent",tU=W.forwardRef((e,r)=>{let s=tI(tH,e.__scopeDialog),{forceMount:i=s.forceMount,...n}=e,o=tT(tH,e.__scopeDialog);return(0,F.jsx)(Z,{present:i||o.open,children:o.modal?(0,F.jsx)(tK,{...n,ref:r}):(0,F.jsx)(tq,{...n,ref:r})})});tU.displayName=tH;var tK=W.forwardRef((e,r)=>{let s=tT(tH,e.__scopeDialog),i=W.useRef(null),n=(0,U.useComposedRefs)(r,s.contentRef,i);return W.useEffect(()=>{let e=i.current;if(e)return tN(e)},[]),(0,F.jsx)(tV,{...e,ref:n,trapFocus:s.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:q(e.onCloseAutoFocus,e=>{e.preventDefault(),s.triggerRef.current?.focus()}),onPointerDownOutside:q(e.onPointerDownOutside,e=>{let r=e.detail.originalEvent,s=0===r.button&&!0===r.ctrlKey;(2===r.button||s)&&e.preventDefault()}),onFocusOutside:q(e.onFocusOutside,e=>e.preventDefault())})}),tq=W.forwardRef((e,r)=>{let s=tT(tH,e.__scopeDialog),i=W.useRef(!1),n=W.useRef(!1);return(0,F.jsx)(tV,{...e,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:r=>{e.onCloseAutoFocus?.(r),r.defaultPrevented||(i.current||s.triggerRef.current?.focus(),r.preventDefault()),i.current=!1,n.current=!1},onInteractOutside:r=>{e.onInteractOutside?.(r),r.defaultPrevented||(i.current=!0,"pointerdown"===r.detail.originalEvent.type&&(n.current=!0));let o=r.target;s.triggerRef.current?.contains(o)&&r.preventDefault(),"focusin"===r.detail.originalEvent.type&&n.current&&r.preventDefault()}})}),tV=W.forwardRef((e,r)=>{let{__scopeDialog:s,trapFocus:i,onOpenAutoFocus:n,onCloseAutoFocus:o,...a}=e,l=tT(tH,s),c=W.useRef(null),d=(0,U.useComposedRefs)(r,c);return eU(),(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(eB,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:n,onUnmountAutoFocus:o,children:(0,F.jsx)(eM,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":t0(l.open),...a,ref:d,onDismiss:()=>l.onOpenChange(!1)})}),(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(t3,{titleId:l.titleId}),(0,F.jsx)(t4,{contentRef:c,descriptionId:l.descriptionId})]})]})}),tY="DialogTitle",tX=W.forwardRef((e,r)=>{let{__scopeDialog:s,...i}=e,n=tT(tY,s);return(0,F.jsx)(er.h2,{id:n.titleId,...i,ref:r})});tX.displayName=tY;var tG="DialogDescription",tJ=W.forwardRef((e,r)=>{let{__scopeDialog:s,...i}=e,n=tT(tG,s);return(0,F.jsx)(er.p,{id:n.descriptionId,...i,ref:r})});tJ.displayName=tG;var tZ="DialogClose",tQ=W.forwardRef((e,r)=>{let{__scopeDialog:s,...i}=e,n=tT(tZ,s);return(0,F.jsx)(er.button,{type:"button",...i,ref:r,onClick:q(e.onClick,()=>n.onOpenChange(!1))})});function t0(e){return e?"open":"closed"}tQ.displayName=tZ;var t1="DialogTitleWarning",[t2,t5]=(cH={contentName:tH,titleName:tY,docsSlug:"dialog"},s=W.createContext(cH),(i=e=>{let{children:r,...i}=e,n=W.useMemo(()=>i,Object.values(i));return(0,F.jsx)(s.Provider,{value:n,children:r})}).displayName=t1+"Provider",[i,function(e){let r=W.useContext(s);if(r)return r;if(void 0!==cH)return cH;throw Error(`\`${e}\` must be used within \`${t1}\``)}]),t3=({titleId:e})=>{let r=t5(t1),s=`\`${r.contentName}\` requires a \`${r.titleName}\` for the component to be accessible for screen reader users.
2
+
3
+ If you want to hide the \`${r.titleName}\`, you can wrap it with our VisuallyHidden component.
4
+
5
+ For more information, see https://radix-ui.com/primitives/docs/components/${r.docsSlug}`;return W.useEffect(()=>{e&&(document.getElementById(e)||console.error(s))},[s,e]),null},t4=({contentRef:e,descriptionId:r})=>{let s=t5("DialogDescriptionWarning"),i=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${s.contentName}}.`;return W.useEffect(()=>{let s=e.current?.getAttribute("aria-describedby");r&&s&&(document.getElementById(r)||console.warn(i))},[i,e,r]),null};let t6=(0,ew.default)("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function t8({...e}){return(0,F.jsx)(tP,{"data-slot":"dialog",...e})}function t7({...e}){return(0,F.jsx)(tO,{"data-slot":"dialog-portal",...e})}function t9({className:e,...r}){return(0,F.jsx)(tF,{"data-slot":"dialog-overlay",className:(0,ey.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...r})}function re({className:e,children:r,showCloseButton:s=!0,...i}){return(0,F.jsxs)(t7,{"data-slot":"dialog-portal",children:[(0,F.jsx)(t9,{}),(0,F.jsxs)(tU,{"data-slot":"dialog-content",className:(0,ey.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 outline-none sm:max-w-lg",e),...i,children:[r,s&&(0,F.jsxs)(tQ,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[(0,F.jsx)(t6,{}),(0,F.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function rt({className:e,...r}){return(0,F.jsx)("div",{"data-slot":"dialog-header",className:(0,ey.cn)("flex flex-col gap-2 text-center sm:text-left",e),...r})}function rr({className:e,...r}){return(0,F.jsx)("div",{"data-slot":"dialog-footer",className:(0,ey.cn)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...r})}function rs({className:e,...r}){return(0,F.jsx)(tX,{"data-slot":"dialog-title",className:(0,ey.cn)("text-lg leading-none font-semibold",e),...r})}function ri({className:e,...r}){return(0,F.jsx)(tJ,{"data-slot":"dialog-description",className:(0,ey.cn)("text-muted-foreground text-sm",e),...r})}function rn({className:e,type:r,...s}){return(0,F.jsx)("input",{type:r,"data-slot":"input",className:(0,ey.cn)("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...s})}function ro({className:e,...r}){return(0,F.jsx)("textarea",{"data-slot":"textarea",className:(0,ey.cn)("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),...r})}let ra=(0,ew.default)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);function rl({open:e,onOpenChange:r,rule:s,onSave:i,onDelete:n}){let[o,a]=(0,W.useState)(""),[l,c]=(0,W.useState)(""),[d,h]=(0,W.useState)(!0);(0,W.useEffect)(()=>{e&&(a(s?.name??""),c(s?.content??""),h(!s||1===s.enabled))},[e,s]);let u=!!s;return(0,F.jsx)(t8,{open:e,onOpenChange:r,children:(0,F.jsxs)(re,{className:"sm:max-w-md",children:[(0,F.jsx)(rt,{children:(0,F.jsx)(rs,{children:u?"Edit Rule":"Add Rule"})}),(0,F.jsxs)("div",{className:"space-y-4",children:[(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Name"}),(0,F.jsx)(rn,{value:o,onChange:e=>a(e.target.value),placeholder:"e.g. Auto-commit on finish"})]}),(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Rule"}),(0,F.jsx)(ro,{value:l,onChange:e=>c(e.target.value),placeholder:"e.g. When the coding agent finishes, run git commit executor",rows:3})]}),(0,F.jsxs)("div",{className:"flex items-center gap-2",children:[(0,F.jsx)(eb,{id:"rule-enabled",checked:d,onCheckedChange:e=>h(!0===e)}),(0,F.jsx)("label",{htmlFor:"rule-enabled",className:"text-sm",children:"Enabled"})]})]}),(0,F.jsxs)(rr,{className:"flex justify-between",children:[(0,F.jsx)("div",{children:u&&n&&(0,F.jsxs)($.Button,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>{n(s.id),r(!1)},children:[(0,F.jsx)(ra,{className:"h-4 w-4 mr-1"}),"Delete"]})}),(0,F.jsxs)("div",{className:"flex gap-2",children:[(0,F.jsx)($.Button,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),(0,F.jsx)($.Button,{onClick:()=>{o.trim()&&l.trim()&&(i({name:o.trim(),content:l.trim(),enabled:d}),r(!1))},disabled:!o.trim()||!l.trim(),children:"Save"})]})]})]})})}let rc=(0,W.forwardRef)(function({rules:e,hideHeader:r,onCreateRule:s,onUpdateRule:i,onDeleteRule:n},o){let[a,l]=(0,W.useState)(!1),[c,d]=(0,W.useState)(null);(0,W.useImperativeHandle)(o,()=>({openAdd:()=>{d(null),l(!0)}}));let h=()=>{d(null),l(!0)},u=async e=>{c?await i(c.id,e):await s(e)},f=async(e,r)=>{await i(e.id,{enabled:r})};return(0,F.jsxs)("div",{className:r?void 0:"space-y-1",children:[!r&&(0,F.jsxs)("div",{className:"flex items-center justify-between",children:[(0,F.jsx)("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Rules"}),(0,F.jsx)($.Button,{variant:"ghost",size:"icon-sm",className:"h-6 w-6",onClick:h,title:"Add rule",children:(0,F.jsx)(eS,{className:"h-3.5 w-3.5"})})]}),0===e.length?(0,F.jsx)("button",{onClick:h,className:"w-full text-center py-3 text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer",children:"No rules yet. Click to add one."}):(0,F.jsx)("div",{className:"space-y-0.5 max-h-48 overflow-y-auto",children:e.map(e=>(0,F.jsxs)("div",{className:"flex items-center gap-2 px-1.5 py-1 rounded-md hover:bg-muted/50 group cursor-pointer",onClick:()=>{d(e),l(!0)},children:[(0,F.jsx)("div",{onClick:e=>e.stopPropagation(),className:"shrink-0",children:(0,F.jsx)(eb,{checked:1===e.enabled,onCheckedChange:r=>f(e,!0===r)})}),(0,F.jsx)("span",{className:`text-sm truncate flex-1 ${1===e.enabled?"text-foreground":"text-muted-foreground line-through"}`,title:e.content,children:e.name})]},e.id))}),(0,F.jsx)(rl,{open:a,onOpenChange:l,rule:c,onSave:u,onDelete:async e=>{await n(e)}})]})}),rd=(0,ew.default)("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]);function rh({open:e,onOpenChange:r,command:s,onSave:i,onDelete:n}){let[o,a]=(0,W.useState)(""),[l,c]=(0,W.useState)("");(0,W.useEffect)(()=>{e&&(a(s?.name??""),c(s?.content??""))},[e,s]);let d=!!s;return(0,F.jsx)(t8,{open:e,onOpenChange:r,children:(0,F.jsxs)(re,{className:"sm:max-w-md",children:[(0,F.jsx)(rt,{children:(0,F.jsx)(rs,{children:d?"Edit Command":"Add Command"})}),(0,F.jsxs)("div",{className:"space-y-4",children:[(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Name"}),(0,F.jsx)(rn,{value:o,onChange:e=>a(e.target.value),placeholder:"e.g. Run tests"})]}),(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Command"}),(0,F.jsx)(ro,{value:l,onChange:e=>c(e.target.value),placeholder:"e.g. Run all unit tests and report any failures",rows:3})]})]}),(0,F.jsxs)(rr,{className:"flex justify-between",children:[(0,F.jsx)("div",{children:d&&n&&(0,F.jsxs)($.Button,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>{n(s.id),r(!1)},children:[(0,F.jsx)(ra,{className:"h-4 w-4 mr-1"}),"Delete"]})}),(0,F.jsxs)("div",{className:"flex gap-2",children:[(0,F.jsx)($.Button,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),(0,F.jsx)($.Button,{onClick:()=>{o.trim()&&l.trim()&&(i({name:o.trim(),content:l.trim()}),r(!1))},disabled:!o.trim()||!l.trim(),children:"Save"})]})]})]})})}let ru=(0,W.forwardRef)(function({commands:e,hideHeader:r,onCreateCommand:s,onUpdateCommand:i,onDeleteCommand:n,onExecuteCommand:o},a){let[l,c]=(0,W.useState)(!1),[d,h]=(0,W.useState)(null);(0,W.useImperativeHandle)(a,()=>({openAdd:()=>{h(null),c(!0)}}));let u=()=>{h(null),c(!0)},f=async e=>{d?await i(d.id,e):await s(e)};return(0,F.jsxs)("div",{className:r?void 0:"space-y-1",children:[!r&&(0,F.jsxs)("div",{className:"flex items-center justify-between",children:[(0,F.jsx)("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Commands"}),(0,F.jsx)($.Button,{variant:"ghost",size:"icon-sm",className:"h-6 w-6",onClick:u,title:"Add command",children:(0,F.jsx)(eS,{className:"h-3.5 w-3.5"})})]}),0===e.length?(0,F.jsx)("button",{onClick:u,className:"w-full text-center py-3 text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer",children:"No commands yet. Click to add one."}):(0,F.jsx)("div",{className:"space-y-0.5 max-h-48 overflow-y-auto",children:e.map(e=>(0,F.jsxs)("div",{className:"flex items-center gap-2 px-1.5 py-1 rounded-md hover:bg-muted/50 group",children:[(0,F.jsx)("span",{className:"text-sm truncate flex-1 cursor-pointer text-foreground",title:e.content,onClick:()=>{h(e),c(!0)},children:e.name}),(0,F.jsx)($.Button,{variant:"ghost",size:"icon-sm",className:"h-6 w-6 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>o(e.content),title:"Execute command",children:(0,F.jsx)(rd,{className:"h-3 w-3"})})]},e.id))}),(0,F.jsx)(rh,{open:l,onOpenChange:c,command:d,onSave:f,onDelete:async e=>{await n(e)}})]})});var rf=e.i(454267);let rp=(0,ew.default)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);function rm({assignedTask:e,rules:r,commands:s,onCreateRule:i,onUpdateRule:n,onDeleteRule:o,onCreateCommand:a,onUpdateCommand:l,onDeleteCommand:c,onExecuteCommand:d,onUpdateTaskTitle:h,onCompleteTask:u}){let[f,p]=(0,W.useState)("task"),m=(0,W.useRef)(null),g=(0,W.useRef)(null),[v,x]=(0,W.useState)(!1),[_,y]=(0,W.useState)(""),b=(0,W.useRef)(null);(0,W.useEffect)(()=>{e&&y(e.title),x(!1)},[e?.id,e?.title]);let w=()=>{x(!1);let r=_.trim();r&&e&&r!==e.title?h?.(e.id,r):e&&y(e.title)};return(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsxs)("div",{className:"flex items-center gap-4",children:[(0,F.jsx)("button",{onClick:()=>p("task"),className:`text-xs font-medium pb-1 border-b-2 transition-colors ${"task"===f?"text-foreground border-foreground":"text-muted-foreground border-transparent hover:text-foreground/70"}`,children:"Task"}),(0,F.jsx)("button",{onClick:()=>p("rules"),className:`text-xs font-medium pb-1 border-b-2 transition-colors ${"rules"===f?"text-foreground border-foreground":"text-muted-foreground border-transparent hover:text-foreground/70"}`,children:"Rules"}),(0,F.jsx)("button",{onClick:()=>p("commands"),className:`text-xs font-medium pb-1 border-b-2 transition-colors ${"commands"===f?"text-foreground border-foreground":"text-muted-foreground border-transparent hover:text-foreground/70"}`,children:"Commands"}),(0,F.jsx)("div",{className:"flex items-center gap-1 ml-auto",children:"task"===f&&e?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)($.Button,{variant:"ghost",size:"icon-sm",className:"h-6 w-6",onClick:()=>{e&&(y(e.title),x(!0),setTimeout(()=>{b.current?.focus(),b.current?.select()},0))},title:"Edit task title",children:(0,F.jsx)(rp,{className:"h-3.5 w-3.5"})}),(0,F.jsx)($.Button,{variant:"ghost",size:"icon-sm",className:"h-6 w-6",onClick:()=>u?.(e.id),title:"Complete task",children:(0,F.jsx)(rf.Check,{className:"h-3.5 w-3.5"})})]}):"rules"===f?(0,F.jsx)($.Button,{variant:"ghost",size:"icon-sm",className:"h-6 w-6",onClick:()=>m.current?.openAdd(),title:"Add rule",children:(0,F.jsx)(eS,{className:"h-3.5 w-3.5"})}):"commands"===f?(0,F.jsx)($.Button,{variant:"ghost",size:"icon-sm",className:"h-6 w-6",onClick:()=>g.current?.openAdd(),title:"Add command",children:(0,F.jsx)(eS,{className:"h-3.5 w-3.5"})}):(0,F.jsx)($.Button,{variant:"ghost",size:"icon-sm",className:"h-6 w-6 invisible",children:(0,F.jsx)(eS,{className:"h-3.5 w-3.5"})})})]}),(0,F.jsxs)("div",{className:"grid [&>*]:col-start-1 [&>*]:row-start-1",children:[(0,F.jsx)("div",{className:"task"!==f?"invisible":void 0,children:e?v?(0,F.jsx)("input",{ref:b,className:"w-full bg-transparent border-b border-primary outline-none text-sm py-0.5",value:_,onChange:e=>y(e.target.value),onBlur:w,onKeyDown:r=>{"Enter"===r.key&&w(),"Escape"===r.key&&(y(e.title),x(!1))}}):(0,F.jsx)("p",{className:"text-sm text-foreground truncate",title:e.title,children:e.title}):(0,F.jsx)("p",{className:"text-xs text-muted-foreground py-3 text-center",children:"No task assigned to this workspace."})}),(0,F.jsx)("div",{className:"rules"!==f?"invisible":void 0,children:(0,F.jsx)(rc,{ref:m,hideHeader:!0,rules:r,onCreateRule:i,onUpdateRule:n,onDeleteRule:o})}),(0,F.jsx)("div",{className:"commands"!==f?"invisible":void 0,children:(0,F.jsx)(ru,{ref:g,hideHeader:!0,commands:s,onCreateCommand:a,onUpdateCommand:l,onDeleteCommand:c,onExecuteCommand:d})})]})]})}var rg=e.i(165512);let rv=(0,ew.default)("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]),rx=(0,ew.default)("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]),r_=(0,ew.default)("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);var ry=e.i(156999);function rb(e){let r=e+"CollectionProvider",[s,i]=K(r),[n,o]=s(r,{collectionRef:{current:null},itemMap:new Map}),a=e=>{let{scope:r,children:s}=e,i=W.default.useRef(null),o=W.default.useRef(new Map).current;return(0,F.jsx)(n,{scope:r,itemMap:o,collectionRef:i,children:s})};a.displayName=r;let l=e+"CollectionSlot",c=(0,et.createSlot)(l),d=W.default.forwardRef((e,r)=>{let{scope:s,children:i}=e,n=o(l,s),a=(0,U.useComposedRefs)(r,n.collectionRef);return(0,F.jsx)(c,{ref:a,children:i})});d.displayName=l;let h=e+"CollectionItemSlot",u="data-radix-collection-item",f=(0,et.createSlot)(h),p=W.default.forwardRef((e,r)=>{let{scope:s,children:i,...n}=e,a=W.default.useRef(null),l=(0,U.useComposedRefs)(r,a),c=o(h,s);return W.default.useEffect(()=>(c.itemMap.set(a,{ref:a,...n}),()=>void c.itemMap.delete(a))),(0,F.jsx)(f,{...{[u]:""},ref:l,children:i})});return p.displayName=h,[{Provider:a,Slot:d,ItemSlot:p},function(r){let s=o(e+"CollectionConsumer",r);return W.default.useCallback(()=>{let e=s.collectionRef.current;if(!e)return[];let r=Array.from(e.querySelectorAll(`[${u}]`));return Array.from(s.itemMap.values()).sort((e,s)=>r.indexOf(e.ref.current)-r.indexOf(s.ref.current))},[s.collectionRef,s.itemMap])},i]}var rw=new WeakMap;function rS(e,r){var s,i;let n,o,a;if("at"in Array.prototype)return Array.prototype.at.call(e,r);let l=(s=e,i=r,n=s.length,(a=(o=rC(i))>=0?o:n+o)<0||a>=n?-1:a);return -1===l?void 0:e[l]}function rC(e){return e!=e||0===e?0:Math.trunc(e)}(class e extends Map{#e;constructor(e){super(e),this.#e=[...super.keys()],rw.set(this,!0)}set(e,r){return rw.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,r),this}insert(e,r,s){let i,n=this.has(r),o=this.#e.length,a=rC(e),l=a>=0?a:o+a,c=l<0||l>=o?-1:l;if(c===this.size||n&&c===this.size-1||-1===c)return this.set(r,s),this;let d=this.size+ +!n;a<0&&l++;let h=[...this.#e],u=!1;for(let e=l;e<d;e++)if(l===e){let o=h[e];h[e]===r&&(o=h[e+1]),n&&this.delete(r),i=this.get(o),this.set(r,s)}else{u||h[e-1]!==r||(u=!0);let s=h[u?e:e-1],n=i;i=this.get(s),this.delete(s),this.set(s,n)}return this}with(r,s,i){let n=new e(this);return n.insert(r,s,i),n}before(e){let r=this.#e.indexOf(e)-1;if(!(r<0))return this.entryAt(r)}setBefore(e,r,s){let i=this.#e.indexOf(e);return -1===i?this:this.insert(i,r,s)}after(e){let r=this.#e.indexOf(e);if(-1!==(r=-1===r||r===this.size-1?-1:r+1))return this.entryAt(r)}setAfter(e,r,s){let i=this.#e.indexOf(e);return -1===i?this:this.insert(i+1,r,s)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let r=super.delete(e);return r&&this.#e.splice(this.#e.indexOf(e),1),r}deleteAt(e){let r=this.keyAt(e);return void 0!==r&&this.delete(r)}at(e){let r=rS(this.#e,e);if(void 0!==r)return this.get(r)}entryAt(e){let r=rS(this.#e,e);if(void 0!==r)return[r,this.get(r)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return rS(this.#e,e)}from(e,r){let s=this.indexOf(e);if(-1===s)return;let i=s+r;return i<0&&(i=0),i>=this.size&&(i=this.size-1),this.at(i)}keyFrom(e,r){let s=this.indexOf(e);if(-1===s)return;let i=s+r;return i<0&&(i=0),i>=this.size&&(i=this.size-1),this.keyAt(i)}find(e,r){let s=0;for(let i of this){if(Reflect.apply(e,r,[i,s,this]))return i;s++}}findIndex(e,r){let s=0;for(let i of this){if(Reflect.apply(e,r,[i,s,this]))return s;s++}return -1}filter(r,s){let i=[],n=0;for(let e of this)Reflect.apply(r,s,[e,n,this])&&i.push(e),n++;return new e(i)}map(r,s){let i=[],n=0;for(let e of this)i.push([e[0],Reflect.apply(r,s,[e,n,this])]),n++;return new e(i)}reduce(...e){let[r,s]=e,i=0,n=s??this.at(0);for(let s of this)n=0===i&&1===e.length?s:Reflect.apply(r,this,[n,s,i,this]),i++;return n}reduceRight(...e){let[r,s]=e,i=s??this.at(-1);for(let s=this.size-1;s>=0;s--){let n=this.at(s);i=s===this.size-1&&1===e.length?n:Reflect.apply(r,this,[i,n,s,this])}return i}toSorted(r){return new e([...this.entries()].sort(r))}toReversed(){let r=new e;for(let e=this.size-1;e>=0;e--){let s=this.keyAt(e),i=this.get(s);r.set(s,i)}return r}toSpliced(...r){let s=[...this.entries()];return s.splice(...r),new e(s)}slice(r,s){let i=new e,n=this.size-1;if(void 0===r)return i;r<0&&(r+=this.size),void 0!==s&&s>0&&(n=s-1);for(let e=r;e<=n;e++){let r=this.keyAt(e),s=this.get(r);i.set(r,s)}return i}every(e,r){let s=0;for(let i of this){if(!Reflect.apply(e,r,[i,s,this]))return!1;s++}return!0}some(e,r){let s=0;for(let i of this){if(Reflect.apply(e,r,[i,s,this]))return!0;s++}return!1}});var rk=W.createContext(void 0);function rj(e){let r=W.useContext(rk);return e||r||"ltr"}var rN="rovingFocusGroup.onEntryFocus",rE={bubbles:!1,cancelable:!0},rR="RovingFocusGroup",[rM,rD,rT]=rb(rR),[rP,rL]=K(rR,[rT]),[rA,rB]=rP(rR),rI=W.forwardRef((e,r)=>(0,F.jsx)(rM.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,F.jsx)(rM.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,F.jsx)(rO,{...e,ref:r})})}));rI.displayName=rR;var rO=W.forwardRef((e,r)=>{let{__scopeRovingFocusGroup:s,orientation:i,loop:n=!1,dir:o,currentTabStopId:a,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:d,preventScrollOnEntryFocus:h=!1,...u}=e,f=W.useRef(null),p=(0,U.useComposedRefs)(r,f),m=rj(o),[g,v]=X({prop:a,defaultProp:l??null,onChange:c,caller:rR}),[x,_]=W.useState(!1),y=eN(d),b=rD(s),w=W.useRef(!1),[S,C]=W.useState(0);return W.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(rN,y),()=>e.removeEventListener(rN,y)},[y]),(0,F.jsx)(rA,{scope:s,orientation:i,dir:m,loop:n,currentTabStopId:g,onItemFocus:W.useCallback(e=>v(e),[v]),onItemShiftTab:W.useCallback(()=>_(!0),[]),onFocusableItemAdd:W.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:W.useCallback(()=>C(e=>e-1),[]),children:(0,F.jsx)(er.div,{tabIndex:x||0===S?-1:0,"data-orientation":i,...u,ref:p,style:{outline:"none",...e.style},onMouseDown:q(e.onMouseDown,()=>{w.current=!0}),onFocus:q(e.onFocus,e=>{let r=!w.current;if(e.target===e.currentTarget&&r&&!x){let r=new CustomEvent(rN,rE);if(e.currentTarget.dispatchEvent(r),!r.defaultPrevented){let e=b().filter(e=>e.focusable);r$([e.find(e=>e.active),e.find(e=>e.id===g),...e].filter(Boolean).map(e=>e.ref.current),h)}}w.current=!1}),onBlur:q(e.onBlur,()=>_(!1))})})}),rz="RovingFocusGroupItem",rF=W.forwardRef((e,r)=>{let{__scopeRovingFocusGroup:s,focusable:i=!0,active:n=!1,tabStopId:o,children:a,...l}=e,c=ej(),d=o||c,h=rB(rz,s),u=h.currentTabStopId===d,f=rD(s),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:g}=h;return W.useEffect(()=>{if(i)return p(),()=>m()},[i,p,m]),(0,F.jsx)(rM.ItemSlot,{scope:s,id:d,focusable:i,active:n,children:(0,F.jsx)(er.span,{tabIndex:u?0:-1,"data-orientation":h.orientation,...l,ref:r,onMouseDown:q(e.onMouseDown,e=>{i?h.onItemFocus(d):e.preventDefault()}),onFocus:q(e.onFocus,()=>h.onItemFocus(d)),onKeyDown:q(e.onKeyDown,e=>{if("Tab"===e.key&&e.shiftKey)return void h.onItemShiftTab();if(e.target!==e.currentTarget)return;let r=function(e,r,s){var i;let n=(i=e.key,"rtl"!==s?i:"ArrowLeft"===i?"ArrowRight":"ArrowRight"===i?"ArrowLeft":i);if(!("vertical"===r&&["ArrowLeft","ArrowRight"].includes(n))&&!("horizontal"===r&&["ArrowUp","ArrowDown"].includes(n)))return rW[n]}(e,h.orientation,h.dir);if(void 0!==r){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("last"===r)n.reverse();else if("prev"===r||"next"===r){var s,i;"prev"===r&&n.reverse();let o=n.indexOf(e.currentTarget);n=h.loop?(s=n,i=o+1,s.map((e,r)=>s[(i+r)%s.length])):n.slice(o+1)}setTimeout(()=>r$(n))}}),children:"function"==typeof a?a({isCurrentTabStop:u,hasTabStop:null!=g}):a})})});rF.displayName=rz;var rW={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function r$(e,r=!1){let s=document.activeElement;for(let i of e)if(i===s||(i.focus({preventScroll:r}),document.activeElement!==s))return}var rH="Tabs",[rU,rK]=K(rH,[rL]),rq=rL(),[rV,rY]=rU(rH),rX=W.forwardRef((e,r)=>{let{__scopeTabs:s,value:i,onValueChange:n,defaultValue:o,orientation:a="horizontal",dir:l,activationMode:c="automatic",...d}=e,h=rj(l),[u,f]=X({prop:i,onChange:n,defaultProp:o??"",caller:rH});return(0,F.jsx)(rV,{scope:s,baseId:ej(),value:u,onValueChange:f,orientation:a,dir:h,activationMode:c,children:(0,F.jsx)(er.div,{dir:h,"data-orientation":a,...d,ref:r})})});rX.displayName=rH;var rG="TabsList",rJ=W.forwardRef((e,r)=>{let{__scopeTabs:s,loop:i=!0,...n}=e,o=rY(rG,s),a=rq(s);return(0,F.jsx)(rI,{asChild:!0,...a,orientation:o.orientation,dir:o.dir,loop:i,children:(0,F.jsx)(er.div,{role:"tablist","aria-orientation":o.orientation,...n,ref:r})})});rJ.displayName=rG;var rZ="TabsTrigger",rQ=W.forwardRef((e,r)=>{let{__scopeTabs:s,value:i,disabled:n=!1,...o}=e,a=rY(rZ,s),l=rq(s),c=r2(a.baseId,i),d=r5(a.baseId,i),h=i===a.value;return(0,F.jsx)(rF,{asChild:!0,...l,focusable:!n,active:h,children:(0,F.jsx)(er.button,{type:"button",role:"tab","aria-selected":h,"aria-controls":d,"data-state":h?"active":"inactive","data-disabled":n?"":void 0,disabled:n,id:c,...o,ref:r,onMouseDown:q(e.onMouseDown,e=>{n||0!==e.button||!1!==e.ctrlKey?e.preventDefault():a.onValueChange(i)}),onKeyDown:q(e.onKeyDown,e=>{[" ","Enter"].includes(e.key)&&a.onValueChange(i)}),onFocus:q(e.onFocus,()=>{let e="manual"!==a.activationMode;h||n||!e||a.onValueChange(i)})})})});rQ.displayName=rZ;var r0="TabsContent",r1=W.forwardRef((e,r)=>{let{__scopeTabs:s,value:i,forceMount:n,children:o,...a}=e,l=rY(r0,s),c=r2(l.baseId,i),d=r5(l.baseId,i),h=i===l.value,u=W.useRef(h);return W.useEffect(()=>{let e=requestAnimationFrame(()=>u.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,F.jsx)(Z,{present:n||h,children:({present:s})=>(0,F.jsx)(er.div,{"data-state":h?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":c,hidden:!s,id:d,tabIndex:0,...a,ref:r,style:{...e.style,animationDuration:u.current?"0s":void 0},children:s&&o})})});function r2(e,r){return`${e}-trigger-${r}`}function r5(e,r){return`${e}-content-${r}`}r1.displayName=r0;let r3=W.forwardRef(({className:e,...r},s)=>(0,F.jsx)(rJ,{ref:s,className:(0,ey.cn)("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...r}));r3.displayName=rJ.displayName;let r4=W.forwardRef(({className:e,...r},s)=>(0,F.jsx)(rQ,{ref:s,className:(0,ey.cn)("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",e),...r}));r4.displayName=rQ.displayName;let r6=W.forwardRef(({className:e,...r},s)=>(0,F.jsx)(r1,{ref:s,className:(0,ey.cn)("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...r}));function r8(e){let[r,s]=(0,W.useState)([]),[i,n]=(0,W.useState)(!1),o=(0,W.useCallback)(async()=>{if(!e)return void s([]);n(!0);try{let r=await rg.api.getProjectRemotes(e);s(r)}catch(e){console.error("Failed to fetch project remotes:",e)}finally{n(!1)}},[e]);return(0,W.useEffect)(()=>{o()},[o]),{remotes:r,loading:i,refresh:o}}r6.displayName=r1.displayName;let r7=(0,ew.default)("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),r9=["top","right","bottom","left"],se=Math.min,st=Math.max,sr=Math.round,ss=Math.floor,si=e=>({x:e,y:e}),sn={left:"right",right:"left",bottom:"top",top:"bottom"},so={start:"end",end:"start"};function sa(e,r){return"function"==typeof e?e(r):e}function sl(e){return e.split("-")[0]}function sc(e){return e.split("-")[1]}function sd(e){return"x"===e?"y":"x"}function sh(e){return"y"===e?"height":"width"}let su=new Set(["top","bottom"]);function sf(e){return su.has(sl(e))?"y":"x"}function sp(e){return e.replace(/start|end/g,e=>so[e])}let sm=["left","right"],sg=["right","left"],sv=["top","bottom"],sx=["bottom","top"];function s_(e){return e.replace(/left|right|bottom|top/g,e=>sn[e])}function sy(e){return"number"!=typeof e?{top:0,right:0,bottom:0,left:0,...e}:{top:e,right:e,bottom:e,left:e}}function sb(e){let{x:r,y:s,width:i,height:n}=e;return{width:i,height:n,top:s,left:r,right:r+i,bottom:s+n,x:r,y:s}}function sw(e,r,s){let i,{reference:n,floating:o}=e,a=sf(r),l=sd(sf(r)),c=sh(l),d=sl(r),h="y"===a,u=n.x+n.width/2-o.width/2,f=n.y+n.height/2-o.height/2,p=n[c]/2-o[c]/2;switch(d){case"top":i={x:u,y:n.y-o.height};break;case"bottom":i={x:u,y:n.y+n.height};break;case"right":i={x:n.x+n.width,y:f};break;case"left":i={x:n.x-o.width,y:f};break;default:i={x:n.x,y:n.y}}switch(sc(r)){case"start":i[l]-=p*(s&&h?-1:1);break;case"end":i[l]+=p*(s&&h?-1:1)}return i}async function sS(e,r){var s;void 0===r&&(r={});let{x:i,y:n,platform:o,rects:a,elements:l,strategy:c}=e,{boundary:d="clippingAncestors",rootBoundary:h="viewport",elementContext:u="floating",altBoundary:f=!1,padding:p=0}=sa(r,e),m=sy(p),g=l[f?"floating"===u?"reference":"floating":u],v=sb(await o.getClippingRect({element:null==(s=await (null==o.isElement?void 0:o.isElement(g)))||s?g:g.contextElement||await (null==o.getDocumentElement?void 0:o.getDocumentElement(l.floating)),boundary:d,rootBoundary:h,strategy:c})),x="floating"===u?{x:i,y:n,width:a.floating.width,height:a.floating.height}:a.reference,_=await (null==o.getOffsetParent?void 0:o.getOffsetParent(l.floating)),y=await (null==o.isElement?void 0:o.isElement(_))&&await (null==o.getScale?void 0:o.getScale(_))||{x:1,y:1},b=sb(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:x,offsetParent:_,strategy:c}):x);return{top:(v.top-b.top+m.top)/y.y,bottom:(b.bottom-v.bottom+m.bottom)/y.y,left:(v.left-b.left+m.left)/y.x,right:(b.right-v.right+m.right)/y.x}}let sC=async(e,r,s)=>{let{placement:i="bottom",strategy:n="absolute",middleware:o=[],platform:a}=s,l=o.filter(Boolean),c=await (null==a.isRTL?void 0:a.isRTL(r)),d=await a.getElementRects({reference:e,floating:r,strategy:n}),{x:h,y:u}=sw(d,i,c),f=i,p={},m=0;for(let s=0;s<l.length;s++){var g;let{name:o,fn:v}=l[s],{x:x,y:_,data:y,reset:b}=await v({x:h,y:u,initialPlacement:i,placement:f,strategy:n,middlewareData:p,rects:d,platform:{...a,detectOverflow:null!=(g=a.detectOverflow)?g:sS},elements:{reference:e,floating:r}});h=null!=x?x:h,u=null!=_?_:u,p={...p,[o]:{...p[o],...y}},b&&m<=50&&(m++,"object"==typeof b&&(b.placement&&(f=b.placement),b.rects&&(d=!0===b.rects?await a.getElementRects({reference:e,floating:r,strategy:n}):b.rects),{x:h,y:u}=sw(d,f,c)),s=-1)}return{x:h,y:u,placement:f,strategy:n,middlewareData:p}};function sk(e,r){return{top:e.top-r.height,right:e.right-r.width,bottom:e.bottom-r.height,left:e.left-r.width}}function sj(e){return r9.some(r=>e[r]>=0)}let sN=new Set(["left","top"]);async function sE(e,r){let{placement:s,platform:i,elements:n}=e,o=await (null==i.isRTL?void 0:i.isRTL(n.floating)),a=sl(s),l=sc(s),c="y"===sf(s),d=sN.has(a)?-1:1,h=o&&c?-1:1,u=sa(r,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}="number"==typeof u?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return l&&"number"==typeof m&&(p="end"===l?-1*m:m),c?{x:p*h,y:f*d}:{x:f*d,y:p*h}}function sR(){return"undefined"!=typeof window}function sM(e){return sP(e)?(e.nodeName||"").toLowerCase():"#document"}function sD(e){var r;return(null==e||null==(r=e.ownerDocument)?void 0:r.defaultView)||window}function sT(e){var r;return null==(r=(sP(e)?e.ownerDocument:e.document)||window.document)?void 0:r.documentElement}function sP(e){return!!sR()&&(e instanceof Node||e instanceof sD(e).Node)}function sL(e){return!!sR()&&(e instanceof Element||e instanceof sD(e).Element)}function sA(e){return!!sR()&&(e instanceof HTMLElement||e instanceof sD(e).HTMLElement)}function sB(e){return!!sR()&&"undefined"!=typeof ShadowRoot&&(e instanceof ShadowRoot||e instanceof sD(e).ShadowRoot)}let sI=new Set(["inline","contents"]);function sO(e){let{overflow:r,overflowX:s,overflowY:i,display:n}=sX(e);return/auto|scroll|overlay|hidden|clip/.test(r+i+s)&&!sI.has(n)}let sz=new Set(["table","td","th"]),sF=[":popover-open",":modal"];function sW(e){return sF.some(r=>{try{return e.matches(r)}catch(e){return!1}})}let s$=["transform","translate","scale","rotate","perspective"],sH=["transform","translate","scale","rotate","perspective","filter"],sU=["paint","layout","strict","content"];function sK(e){let r=sq(),s=sL(e)?sX(e):e;return s$.some(e=>!!s[e]&&"none"!==s[e])||!!s.containerType&&"normal"!==s.containerType||!r&&!!s.backdropFilter&&"none"!==s.backdropFilter||!r&&!!s.filter&&"none"!==s.filter||sH.some(e=>(s.willChange||"").includes(e))||sU.some(e=>(s.contain||"").includes(e))}function sq(){return"undefined"!=typeof CSS&&!!CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")}let sV=new Set(["html","body","#document"]);function sY(e){return sV.has(sM(e))}function sX(e){return sD(e).getComputedStyle(e)}function sG(e){return sL(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function sJ(e){if("html"===sM(e))return e;let r=e.assignedSlot||e.parentNode||sB(e)&&e.host||sT(e);return sB(r)?r.host:r}function sZ(e,r,s){var i;void 0===r&&(r=[]),void 0===s&&(s=!0);let n=function e(r){let s=sJ(r);return sY(s)?r.ownerDocument?r.ownerDocument.body:r.body:sA(s)&&sO(s)?s:e(s)}(e),o=n===(null==(i=e.ownerDocument)?void 0:i.body),a=sD(n);if(o){let e=sQ(a);return r.concat(a,a.visualViewport||[],sO(n)?n:[],e&&s?sZ(e):[])}return r.concat(n,sZ(n,[],s))}function sQ(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function s0(e){let r=sX(e),s=parseFloat(r.width)||0,i=parseFloat(r.height)||0,n=sA(e),o=n?e.offsetWidth:s,a=n?e.offsetHeight:i,l=sr(s)!==o||sr(i)!==a;return l&&(s=o,i=a),{width:s,height:i,$:l}}function s1(e){return sL(e)?e:e.contextElement}function s2(e){let r=s1(e);if(!sA(r))return si(1);let s=r.getBoundingClientRect(),{width:i,height:n,$:o}=s0(r),a=(o?sr(s.width):s.width)/i,l=(o?sr(s.height):s.height)/n;return a&&Number.isFinite(a)||(a=1),l&&Number.isFinite(l)||(l=1),{x:a,y:l}}let s5=si(0);function s3(e){let r=sD(e);return sq()&&r.visualViewport?{x:r.visualViewport.offsetLeft,y:r.visualViewport.offsetTop}:s5}function s4(e,r,s,i){var n;void 0===r&&(r=!1),void 0===s&&(s=!1);let o=e.getBoundingClientRect(),a=s1(e),l=si(1);r&&(i?sL(i)&&(l=s2(i)):l=s2(e));let c=(void 0===(n=s)&&(n=!1),i&&(!n||i===sD(a))&&n)?s3(a):si(0),d=(o.left+c.x)/l.x,h=(o.top+c.y)/l.y,u=o.width/l.x,f=o.height/l.y;if(a){let e=sD(a),r=i&&sL(i)?sD(i):i,s=e,n=sQ(s);for(;n&&i&&r!==s;){let e=s2(n),r=n.getBoundingClientRect(),i=sX(n),o=r.left+(n.clientLeft+parseFloat(i.paddingLeft))*e.x,a=r.top+(n.clientTop+parseFloat(i.paddingTop))*e.y;d*=e.x,h*=e.y,u*=e.x,f*=e.y,d+=o,h+=a,n=sQ(s=sD(n))}}return sb({width:u,height:f,x:d,y:h})}function s6(e,r){let s=sG(e).scrollLeft;return r?r.left+s:s4(sT(e)).left+s}function s8(e,r){let s=e.getBoundingClientRect();return{x:s.left+r.scrollLeft-s6(e,s),y:s.top+r.scrollTop}}let s7=new Set(["absolute","fixed"]);function s9(e,r,s){var i;let n;if("viewport"===r)n=function(e,r){let s=sD(e),i=sT(e),n=s.visualViewport,o=i.clientWidth,a=i.clientHeight,l=0,c=0;if(n){o=n.width,a=n.height;let e=sq();(!e||e&&"fixed"===r)&&(l=n.offsetLeft,c=n.offsetTop)}let d=s6(i);if(d<=0){let e=i.ownerDocument,r=e.body,s=getComputedStyle(r),n="CSS1Compat"===e.compatMode&&parseFloat(s.marginLeft)+parseFloat(s.marginRight)||0,a=Math.abs(i.clientWidth-r.clientWidth-n);a<=25&&(o-=a)}else d<=25&&(o+=d);return{width:o,height:a,x:l,y:c}}(e,s);else if("document"===r){let r,s,o,a,l,c,d;i=sT(e),r=sT(i),s=sG(i),o=i.ownerDocument.body,a=st(r.scrollWidth,r.clientWidth,o.scrollWidth,o.clientWidth),l=st(r.scrollHeight,r.clientHeight,o.scrollHeight,o.clientHeight),c=-s.scrollLeft+s6(i),d=-s.scrollTop,"rtl"===sX(o).direction&&(c+=st(r.clientWidth,o.clientWidth)-a),n={width:a,height:l,x:c,y:d}}else if(sL(r)){let e,i,o,a,l,c;i=(e=s4(r,!0,"fixed"===s)).top+r.clientTop,o=e.left+r.clientLeft,a=sA(r)?s2(r):si(1),l=r.clientWidth*a.x,c=r.clientHeight*a.y,n={width:l,height:c,x:o*a.x,y:i*a.y}}else{let s=s3(e);n={x:r.x-s.x,y:r.y-s.y,width:r.width,height:r.height}}return sb(n)}function ie(e){return"static"===sX(e).position}function it(e,r){if(!sA(e)||"fixed"===sX(e).position)return null;if(r)return r(e);let s=e.offsetParent;return sT(e)===s&&(s=s.ownerDocument.body),s}function ir(e,r){var s;let i=sD(e);if(sW(e))return i;if(!sA(e)){let r=sJ(e);for(;r&&!sY(r);){if(sL(r)&&!ie(r))return r;r=sJ(r)}return i}let n=it(e,r);for(;n&&(s=n,sz.has(sM(s)))&&ie(n);)n=it(n,r);return n&&sY(n)&&ie(n)&&!sK(n)?i:n||function(e){let r=sJ(e);for(;sA(r)&&!sY(r);){if(sK(r))return r;if(sW(r))break;r=sJ(r)}return null}(e)||i}let is=async function(e){let r=this.getOffsetParent||ir,s=this.getDimensions,i=await s(e.floating);return{reference:function(e,r,s){let i=sA(r),n=sT(r),o="fixed"===s,a=s4(e,!0,o,r),l={scrollLeft:0,scrollTop:0},c=si(0);if(i||!i&&!o)if(("body"!==sM(r)||sO(n))&&(l=sG(r)),i){let e=s4(r,!0,o,r);c.x=e.x+r.clientLeft,c.y=e.y+r.clientTop}else n&&(c.x=s6(n));o&&!i&&n&&(c.x=s6(n));let d=!n||i||o?si(0):s8(n,l);return{x:a.left+l.scrollLeft-c.x-d.x,y:a.top+l.scrollTop-c.y-d.y,width:a.width,height:a.height}}(e.reference,await r(e.floating),e.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}},ii={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:r,rect:s,offsetParent:i,strategy:n}=e,o="fixed"===n,a=sT(i),l=!!r&&sW(r.floating);if(i===a||l&&o)return s;let c={scrollLeft:0,scrollTop:0},d=si(1),h=si(0),u=sA(i);if((u||!u&&!o)&&(("body"!==sM(i)||sO(a))&&(c=sG(i)),sA(i))){let e=s4(i);d=s2(i),h.x=e.x+i.clientLeft,h.y=e.y+i.clientTop}let f=!a||u||o?si(0):s8(a,c);return{width:s.width*d.x,height:s.height*d.y,x:s.x*d.x-c.scrollLeft*d.x+h.x+f.x,y:s.y*d.y-c.scrollTop*d.y+h.y+f.y}},getDocumentElement:sT,getClippingRect:function(e){let{element:r,boundary:s,rootBoundary:i,strategy:n}=e,o=[..."clippingAncestors"===s?sW(r)?[]:function(e,r){let s=r.get(e);if(s)return s;let i=sZ(e,[],!1).filter(e=>sL(e)&&"body"!==sM(e)),n=null,o="fixed"===sX(e).position,a=o?sJ(e):e;for(;sL(a)&&!sY(a);){let r=sX(a),s=sK(a);s||"fixed"!==r.position||(n=null),(o?!s&&!n:!s&&"static"===r.position&&!!n&&s7.has(n.position)||sO(a)&&!s&&function e(r,s){let i=sJ(r);return!(i===s||!sL(i)||sY(i))&&("fixed"===sX(i).position||e(i,s))}(e,a))?i=i.filter(e=>e!==a):n=r,a=sJ(a)}return r.set(e,i),i}(r,this._c):[].concat(s),i],a=o[0],l=o.reduce((e,s)=>{let i=s9(r,s,n);return e.top=st(i.top,e.top),e.right=se(i.right,e.right),e.bottom=se(i.bottom,e.bottom),e.left=st(i.left,e.left),e},s9(r,a,n));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}},getOffsetParent:ir,getElementRects:is,getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){let{width:r,height:s}=s0(e);return{width:r,height:s}},getScale:s2,isElement:sL,isRTL:function(e){return"rtl"===sX(e).direction}};function io(e,r){return e.x===r.x&&e.y===r.y&&e.width===r.width&&e.height===r.height}let ia=e=>({name:"arrow",options:e,async fn(r){let{x:s,y:i,placement:n,rects:o,platform:a,elements:l,middlewareData:c}=r,{element:d,padding:h=0}=sa(e,r)||{};if(null==d)return{};let u=sy(h),f={x:s,y:i},p=sd(sf(n)),m=sh(p),g=await a.getDimensions(d),v="y"===p,x=v?"clientHeight":"clientWidth",_=o.reference[m]+o.reference[p]-f[p]-o.floating[m],y=f[p]-o.reference[p],b=await (null==a.getOffsetParent?void 0:a.getOffsetParent(d)),w=b?b[x]:0;w&&await (null==a.isElement?void 0:a.isElement(b))||(w=l.floating[x]||o.floating[m]);let S=w/2-g[m]/2-1,C=se(u[v?"top":"left"],S),k=se(u[v?"bottom":"right"],S),j=w-g[m]-k,N=w/2-g[m]/2+(_/2-y/2),E=st(C,se(N,j)),R=!c.arrow&&null!=sc(n)&&N!==E&&o.reference[m]/2-(N<C?C:k)-g[m]/2<0,M=R?N<C?N-C:N-j:0;return{[p]:f[p]+M,data:{[p]:E,centerOffset:N-E-M,...R&&{alignmentOffset:M}},reset:R}}});var il="undefined"!=typeof document?W.useLayoutEffect:function(){};function ic(e,r){let s,i,n;if(e===r)return!0;if(typeof e!=typeof r)return!1;if("function"==typeof e&&e.toString()===r.toString())return!0;if(e&&r&&"object"==typeof e){if(Array.isArray(e)){if((s=e.length)!==r.length)return!1;for(i=s;0!=i--;)if(!ic(e[i],r[i]))return!1;return!0}if((s=(n=Object.keys(e)).length)!==Object.keys(r).length)return!1;for(i=s;0!=i--;)if(!({}).hasOwnProperty.call(r,n[i]))return!1;for(i=s;0!=i--;){let s=n[i];if(("_owner"!==s||!e.$$typeof)&&!ic(e[s],r[s]))return!1}return!0}return e!=e&&r!=r}function id(e){return"undefined"==typeof window?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function ih(e,r){let s=id(e);return Math.round(r*s)/s}function iu(e){let r=W.useRef(e);return il(()=>{r.current=e}),r}var ip=W.forwardRef((e,r)=>{let{children:s,width:i=10,height:n=5,...o}=e;return(0,F.jsx)(er.svg,{...o,ref:r,width:i,height:n,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?s:(0,F.jsx)("polygon",{points:"0,0 30,0 15,10"})})});ip.displayName="Arrow";var im="Popper",[ig,iv]=K(im),[ix,i_]=ig(im),iy=e=>{let{__scopePopper:r,children:s}=e,[i,n]=W.useState(null);return(0,F.jsx)(ix,{scope:r,anchor:i,onAnchorChange:n,children:s})};iy.displayName=im;var ib="PopperAnchor",iw=W.forwardRef((e,r)=>{let{__scopePopper:s,virtualRef:i,...n}=e,o=i_(ib,s),a=W.useRef(null),l=(0,U.useComposedRefs)(r,a),c=W.useRef(null);return W.useEffect(()=>{let e=c.current;c.current=i?.current||a.current,e!==c.current&&o.onAnchorChange(c.current)}),i?null:(0,F.jsx)(er.div,{...n,ref:l})});iw.displayName=ib;var iS="PopperContent",[iC,ik]=ig(iS),ij=W.forwardRef((e,r)=>{var s,i,n,o,a,l,c,d,h,u,f,p,m,g,v,x,_,y,b,w,S;let{__scopePopper:C,side:k="bottom",sideOffset:j=0,align:N="center",alignOffset:E=0,arrowPadding:R=0,avoidCollisions:M=!0,collisionBoundary:D=[],collisionPadding:T=0,sticky:P="partial",hideWhenDetached:L=!1,updatePositionStrategy:A="optimized",onPlaced:B,...I}=e,O=i_(iS,C),[z,$]=W.useState(null),H=(0,U.useComposedRefs)(r,e=>$(e)),[K,q]=W.useState(null),Y=J(K),X=Y?.width??0,G=Y?.height??0,Z="number"==typeof T?T:{top:0,right:0,bottom:0,left:0,...T},Q=Array.isArray(D)?D:[D],et=Q.length>0,es={padding:Z,boundary:Q.filter(iM),altBoundary:et},{refs:ei,floatingStyles:en,placement:eo,isPositioned:ea,middlewareData:el}=function(e){void 0===e&&(e={});let{placement:r="bottom",strategy:s="absolute",middleware:i=[],platform:n,elements:{reference:o,floating:a}={},transform:l=!0,whileElementsMounted:c,open:d}=e,[h,u]=W.useState({x:0,y:0,strategy:s,placement:r,middlewareData:{},isPositioned:!1}),[f,p]=W.useState(i);ic(f,i)||p(i);let[m,g]=W.useState(null),[v,x]=W.useState(null),_=W.useCallback(e=>{e!==S.current&&(S.current=e,g(e))},[]),y=W.useCallback(e=>{e!==C.current&&(C.current=e,x(e))},[]),b=o||m,w=a||v,S=W.useRef(null),C=W.useRef(null),k=W.useRef(h),j=null!=c,N=iu(c),E=iu(n),R=iu(d),M=W.useCallback(()=>{var e,i;let n,o,a;if(!S.current||!C.current)return;let l={placement:r,strategy:s,middleware:f};E.current&&(l.platform=E.current),(e=S.current,i=C.current,n=new Map,a={...(o={platform:ii,...l}).platform,_c:n},sC(e,i,{...o,platform:a})).then(e=>{let r={...e,isPositioned:!1!==R.current};D.current&&!ic(k.current,r)&&(k.current=r,ee.flushSync(()=>{u(r)}))})},[f,r,s,E,R]);il(()=>{!1===d&&k.current.isPositioned&&(k.current.isPositioned=!1,u(e=>({...e,isPositioned:!1})))},[d]);let D=W.useRef(!1);il(()=>(D.current=!0,()=>{D.current=!1}),[]),il(()=>{if(b&&(S.current=b),w&&(C.current=w),b&&w){if(N.current)return N.current(b,w,M);M()}},[b,w,M,N,j]);let T=W.useMemo(()=>({reference:S,floating:C,setReference:_,setFloating:y}),[_,y]),P=W.useMemo(()=>({reference:b,floating:w}),[b,w]),L=W.useMemo(()=>{let e={position:s,left:0,top:0};if(!P.floating)return e;let r=ih(P.floating,h.x),i=ih(P.floating,h.y);return l?{...e,transform:"translate("+r+"px, "+i+"px)",...id(P.floating)>=1.5&&{willChange:"transform"}}:{position:s,left:r,top:i}},[s,l,P.floating,h.x,h.y]);return W.useMemo(()=>({...h,update:M,refs:T,elements:P,floatingStyles:L}),[h,M,T,P,L])}({strategy:"fixed",placement:k+("center"!==N?"-"+N:""),whileElementsMounted:(...e)=>(function(e,r,s,i){let n;void 0===i&&(i={});let{ancestorScroll:o=!0,ancestorResize:a=!0,elementResize:l="function"==typeof ResizeObserver,layoutShift:c="function"==typeof IntersectionObserver,animationFrame:d=!1}=i,h=s1(e),u=o||a?[...h?sZ(h):[],...sZ(r)]:[];u.forEach(e=>{o&&e.addEventListener("scroll",s,{passive:!0}),a&&e.addEventListener("resize",s)});let f=h&&c?function(e,r){let s,i=null,n=sT(e);function o(){var e;clearTimeout(s),null==(e=i)||e.disconnect(),i=null}return!function a(l,c){void 0===l&&(l=!1),void 0===c&&(c=1),o();let d=e.getBoundingClientRect(),{left:h,top:u,width:f,height:p}=d;if(l||r(),!f||!p)return;let m={rootMargin:-ss(u)+"px "+-ss(n.clientWidth-(h+f))+"px "+-ss(n.clientHeight-(u+p))+"px "+-ss(h)+"px",threshold:st(0,se(1,c))||1},g=!0;function v(r){let i=r[0].intersectionRatio;if(i!==c){if(!g)return a();i?a(!1,i):s=setTimeout(()=>{a(!1,1e-7)},1e3)}1!==i||io(d,e.getBoundingClientRect())||a(),g=!1}try{i=new IntersectionObserver(v,{...m,root:n.ownerDocument})}catch(e){i=new IntersectionObserver(v,m)}i.observe(e)}(!0),o}(h,s):null,p=-1,m=null;l&&(m=new ResizeObserver(e=>{let[i]=e;i&&i.target===h&&m&&(m.unobserve(r),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var e;null==(e=m)||e.observe(r)})),s()}),h&&!d&&m.observe(h),m.observe(r));let g=d?s4(e):null;return d&&function r(){let i=s4(e);g&&!io(g,i)&&s(),g=i,n=requestAnimationFrame(r)}(),s(),()=>{var e;u.forEach(e=>{o&&e.removeEventListener("scroll",s),a&&e.removeEventListener("resize",s)}),null==f||f(),null==(e=m)||e.disconnect(),m=null,d&&cancelAnimationFrame(n)}})(...e,{animationFrame:"always"===A}),elements:{reference:O.anchor},middleware:[{...{name:"offset",options:n=s={mainAxis:j+G,alignmentAxis:E},async fn(e){var r,s;let{x:i,y:o,placement:a,middlewareData:l}=e,c=await sE(e,n);return a===(null==(r=l.offset)?void 0:r.placement)&&null!=(s=l.arrow)&&s.alignmentOffset?{}:{x:i+c.x,y:o+c.y,data:{...c,placement:a}}}},options:[s,i]},M&&{...{name:"shift",options:h=c={mainAxis:!0,crossAxis:!1,limiter:"partial"===P?{...(void 0===(l=o)&&(l={}),{options:l,fn(e){let{x:r,y:s,placement:i,rects:n,middlewareData:o}=e,{offset:a=0,mainAxis:c=!0,crossAxis:d=!0}=sa(l,e),h={x:r,y:s},u=sf(i),f=sd(u),p=h[f],m=h[u],g=sa(a,e),v="number"==typeof g?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(c){let e="y"===f?"height":"width",r=n.reference[f]-n.floating[e]+v.mainAxis,s=n.reference[f]+n.reference[e]-v.mainAxis;p<r?p=r:p>s&&(p=s)}if(d){var x,_;let e="y"===f?"width":"height",r=sN.has(sl(i)),s=n.reference[u]-n.floating[e]+(r&&(null==(x=o.offset)?void 0:x[u])||0)+(r?0:v.crossAxis),a=n.reference[u]+n.reference[e]+(r?0:(null==(_=o.offset)?void 0:_[u])||0)-(r?v.crossAxis:0);m<s?m=s:m>a&&(m=a)}return{[f]:p,[u]:m}}}),options:[o,a]}:void 0,...es},async fn(e){let{x:r,y:s,placement:i,platform:n}=e,{mainAxis:o=!0,crossAxis:a=!1,limiter:l={fn:e=>{let{x:r,y:s}=e;return{x:r,y:s}}},...c}=sa(h,e),d={x:r,y:s},u=await n.detectOverflow(e,c),f=sf(sl(i)),p=sd(f),m=d[p],g=d[f];if(o){let e="y"===p?"top":"left",r="y"===p?"bottom":"right",s=m+u[e],i=m-u[r];m=st(s,se(m,i))}if(a){let e="y"===f?"top":"left",r="y"===f?"bottom":"right",s=g+u[e],i=g-u[r];g=st(s,se(g,i))}let v=l.fn({...e,[p]:m,[f]:g});return{...v,data:{x:v.x-r,y:v.y-s,enabled:{[p]:o,[f]:a}}}}},options:[c,d]},M&&{...{name:"flip",options:p=u={...es},async fn(e){var r,s,i,n,o,a,l,c;let d,h,u,{placement:f,middlewareData:m,rects:g,initialPlacement:v,platform:x,elements:_}=e,{mainAxis:y=!0,crossAxis:b=!0,fallbackPlacements:w,fallbackStrategy:S="bestFit",fallbackAxisSideDirection:C="none",flipAlignment:k=!0,...j}=sa(p,e);if(null!=(r=m.arrow)&&r.alignmentOffset)return{};let N=sl(f),E=sf(v),R=sl(v)===v,M=await (null==x.isRTL?void 0:x.isRTL(_.floating)),D=w||(R||!k?[s_(v)]:(d=s_(v),[sp(v),d,sp(d)])),T="none"!==C;!w&&T&&D.push(...(h=sc(v),u=function(e,r,s){switch(e){case"top":case"bottom":if(s)return r?sg:sm;return r?sm:sg;case"left":case"right":return r?sv:sx;default:return[]}}(sl(v),"start"===C,M),h&&(u=u.map(e=>e+"-"+h),k&&(u=u.concat(u.map(sp)))),u));let P=[v,...D],L=await x.detectOverflow(e,j),A=[],B=(null==(s=m.flip)?void 0:s.overflows)||[];if(y&&A.push(L[N]),b){let e,r,s,i,n=(a=f,l=g,void 0===(c=M)&&(c=!1),e=sc(a),s=sh(r=sd(sf(a))),i="x"===r?e===(c?"end":"start")?"right":"left":"start"===e?"bottom":"top",l.reference[s]>l.floating[s]&&(i=s_(i)),[i,s_(i)]);A.push(L[n[0]],L[n[1]])}if(B=[...B,{placement:f,overflows:A}],!A.every(e=>e<=0)){let e=((null==(i=m.flip)?void 0:i.index)||0)+1,r=P[e];if(r&&("alignment"!==b||E===sf(r)||B.every(e=>sf(e.placement)!==E||e.overflows[0]>0)))return{data:{index:e,overflows:B},reset:{placement:r}};let s=null==(n=B.filter(e=>e.overflows[0]<=0).sort((e,r)=>e.overflows[1]-r.overflows[1])[0])?void 0:n.placement;if(!s)switch(S){case"bestFit":{let e=null==(o=B.filter(e=>{if(T){let r=sf(e.placement);return r===E||"y"===r}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,r)=>e+r,0)]).sort((e,r)=>e[1]-r[1])[0])?void 0:o[0];e&&(s=e);break}case"initialPlacement":s=v}if(f!==s)return{reset:{placement:s}}}return{}}},options:[u,f]},{...{name:"size",options:v=m={...es,apply:({elements:e,rects:r,availableWidth:s,availableHeight:i})=>{let{width:n,height:o}=r.reference,a=e.floating.style;a.setProperty("--radix-popper-available-width",`${s}px`),a.setProperty("--radix-popper-available-height",`${i}px`),a.setProperty("--radix-popper-anchor-width",`${n}px`),a.setProperty("--radix-popper-anchor-height",`${o}px`)}},async fn(e){var r,s;let i,n,{placement:o,rects:a,platform:l,elements:c}=e,{apply:d=()=>{},...h}=sa(v,e),u=await l.detectOverflow(e,h),f=sl(o),p=sc(o),m="y"===sf(o),{width:g,height:x}=a.floating;"top"===f||"bottom"===f?(i=f,n=p===(await (null==l.isRTL?void 0:l.isRTL(c.floating))?"start":"end")?"left":"right"):(n=f,i="end"===p?"top":"bottom");let _=x-u.top-u.bottom,y=g-u.left-u.right,b=se(x-u[i],_),w=se(g-u[n],y),S=!e.middlewareData.shift,C=b,k=w;if(null!=(r=e.middlewareData.shift)&&r.enabled.x&&(k=y),null!=(s=e.middlewareData.shift)&&s.enabled.y&&(C=_),S&&!p){let e=st(u.left,0),r=st(u.right,0),s=st(u.top,0),i=st(u.bottom,0);m?k=g-2*(0!==e||0!==r?e+r:st(u.left,u.right)):C=x-2*(0!==s||0!==i?s+i:st(u.top,u.bottom))}await d({...e,availableWidth:k,availableHeight:C});let j=await l.getDimensions(c.floating);return g!==j.width||x!==j.height?{reset:{rects:!0}}:{}}},options:[m,g]},K&&{...{name:"arrow",options:y=x={element:K,padding:R},fn(e){let{element:r,padding:s}="function"==typeof y?y(e):y;return r&&({}).hasOwnProperty.call(r,"current")?null!=r.current?ia({element:r.current,padding:s}).fn(e):{}:r?ia({element:r,padding:s}).fn(e):{}}},options:[x,_]},iD({arrowWidth:X,arrowHeight:G}),L&&{...{name:"hide",options:S=b={strategy:"referenceHidden",...es},async fn(e){let{rects:r,platform:s}=e,{strategy:i="referenceHidden",...n}=sa(S,e);switch(i){case"referenceHidden":{let i=sk(await s.detectOverflow(e,{...n,elementContext:"reference"}),r.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:sj(i)}}}case"escaped":{let i=sk(await s.detectOverflow(e,{...n,altBoundary:!0}),r.floating);return{data:{escapedOffsets:i,escaped:sj(i)}}}default:return{}}}},options:[b,w]}]}),[ec,ed]=iT(eo),eh=eN(B);V(()=>{ea&&eh?.()},[ea,eh]);let eu=el.arrow?.x,ef=el.arrow?.y,ep=el.arrow?.centerOffset!==0,[em,eg]=W.useState();return V(()=>{z&&eg(window.getComputedStyle(z).zIndex)},[z]),(0,F.jsx)("div",{ref:ei.setFloating,"data-radix-popper-content-wrapper":"",style:{...en,transform:ea?en.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:em,"--radix-popper-transform-origin":[el.transformOrigin?.x,el.transformOrigin?.y].join(" "),...el.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:(0,F.jsx)(iC,{scope:C,placedSide:ec,onArrowChange:q,arrowX:eu,arrowY:ef,shouldHideArrow:ep,children:(0,F.jsx)(er.div,{"data-side":ec,"data-align":ed,...I,ref:H,style:{...I.style,animation:ea?void 0:"none"}})})})});ij.displayName=iS;var iN="PopperArrow",iE={top:"bottom",right:"left",bottom:"top",left:"right"},iR=W.forwardRef(function(e,r){let{__scopePopper:s,...i}=e,n=ik(iN,s),o=iE[n.placedSide];return(0,F.jsx)("span",{ref:n.onArrowChange,style:{position:"absolute",left:n.arrowX,top:n.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[n.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[n.placedSide],visibility:n.shouldHideArrow?"hidden":void 0},children:(0,F.jsx)(ip,{...i,ref:r,style:{...i.style,display:"block"}})})});function iM(e){return null!==e}iR.displayName=iN;var iD=e=>({name:"transformOrigin",options:e,fn(r){let{placement:s,rects:i,middlewareData:n}=r,o=n.arrow?.centerOffset!==0,a=o?0:e.arrowWidth,l=o?0:e.arrowHeight,[c,d]=iT(s),h={start:"0%",center:"50%",end:"100%"}[d],u=(n.arrow?.x??0)+a/2,f=(n.arrow?.y??0)+l/2,p="",m="";return"bottom"===c?(p=o?h:`${u}px`,m=`${-l}px`):"top"===c?(p=o?h:`${u}px`,m=`${i.floating.height+l}px`):"right"===c?(p=`${-l}px`,m=o?h:`${f}px`):"left"===c&&(p=`${i.floating.width+l}px`,m=o?h:`${f}px`),{data:{x:p,y:m}}}});function iT(e){let[r,s="center"]=e.split("-");return[r,s]}var iP=["Enter"," "],iL=["ArrowUp","PageDown","End"],iA=["ArrowDown","PageUp","Home",...iL],iB={ltr:[...iP,"ArrowRight"],rtl:[...iP,"ArrowLeft"]},iI={ltr:["ArrowLeft"],rtl:["ArrowRight"]},iO="Menu",[iz,iF,iW]=rb(iO),[i$,iH]=K(iO,[iW,iv,rL]),iU=iv(),iK=rL(),[iq,iV]=i$(iO),[iY,iX]=i$(iO),iG=e=>{let{__scopeMenu:r,open:s=!1,children:i,dir:n,onOpenChange:o,modal:a=!0}=e,l=iU(r),[c,d]=W.useState(null),h=W.useRef(!1),u=eN(o),f=rj(n);return W.useEffect(()=>{let e=()=>{h.current=!0,document.addEventListener("pointerdown",r,{capture:!0,once:!0}),document.addEventListener("pointermove",r,{capture:!0,once:!0})},r=()=>h.current=!1;return document.addEventListener("keydown",e,{capture:!0}),()=>{document.removeEventListener("keydown",e,{capture:!0}),document.removeEventListener("pointerdown",r,{capture:!0}),document.removeEventListener("pointermove",r,{capture:!0})}},[]),(0,F.jsx)(iy,{...l,children:(0,F.jsx)(iq,{scope:r,open:s,onOpenChange:u,content:c,onContentChange:d,children:(0,F.jsx)(iY,{scope:r,onClose:W.useCallback(()=>u(!1),[u]),isUsingKeyboardRef:h,dir:f,modal:a,children:i})})})};iG.displayName=iO;var iJ=W.forwardRef((e,r)=>{let{__scopeMenu:s,...i}=e,n=iU(s);return(0,F.jsx)(iw,{...n,...i,ref:r})});iJ.displayName="MenuAnchor";var iZ="MenuPortal",[iQ,i0]=i$(iZ,{forceMount:void 0}),i1=e=>{let{__scopeMenu:r,forceMount:s,children:i,container:n}=e,o=iV(iZ,r);return(0,F.jsx)(iQ,{scope:r,forceMount:s,children:(0,F.jsx)(Z,{present:s||o.open,children:(0,F.jsx)(e$,{asChild:!0,container:n,children:i})})})};i1.displayName=iZ;var i2="MenuContent",[i5,i3]=i$(i2),i4=W.forwardRef((e,r)=>{let s=i0(i2,e.__scopeMenu),{forceMount:i=s.forceMount,...n}=e,o=iV(i2,e.__scopeMenu),a=iX(i2,e.__scopeMenu);return(0,F.jsx)(iz.Provider,{scope:e.__scopeMenu,children:(0,F.jsx)(Z,{present:i||o.open,children:(0,F.jsx)(iz.Slot,{scope:e.__scopeMenu,children:a.modal?(0,F.jsx)(i6,{...n,ref:r}):(0,F.jsx)(i8,{...n,ref:r})})})})}),i6=W.forwardRef((e,r)=>{let s=iV(i2,e.__scopeMenu),i=W.useRef(null),n=(0,U.useComposedRefs)(r,i);return W.useEffect(()=>{let e=i.current;if(e)return tN(e)},[]),(0,F.jsx)(i9,{...e,ref:n,trapFocus:s.open,disableOutsidePointerEvents:s.open,disableOutsideScroll:!0,onFocusOutside:q(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>s.onOpenChange(!1)})}),i8=W.forwardRef((e,r)=>{let s=iV(i2,e.__scopeMenu);return(0,F.jsx)(i9,{...e,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>s.onOpenChange(!1)})}),i7=(0,et.createSlot)("MenuContent.ScrollLock"),i9=W.forwardRef((e,r)=>{let{__scopeMenu:s,loop:i=!1,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:a,disableOutsidePointerEvents:l,onEntryFocus:c,onEscapeKeyDown:d,onPointerDownOutside:h,onFocusOutside:u,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...g}=e,v=iV(i2,s),x=iX(i2,s),_=iU(s),y=iK(s),b=iF(s),[w,S]=W.useState(null),C=W.useRef(null),k=(0,U.useComposedRefs)(r,C,v.onContentChange),j=W.useRef(0),N=W.useRef(""),E=W.useRef(0),R=W.useRef(null),M=W.useRef("right"),D=W.useRef(0),T=m?ty:W.Fragment;W.useEffect(()=>()=>window.clearTimeout(j.current),[]),eU();let P=W.useCallback(e=>{var r,s;return M.current===R.current?.side&&(r=e,!!(s=R.current?.area)&&function(e,r){let{x:s,y:i}=e,n=!1;for(let e=0,o=r.length-1;e<r.length;o=e++){let a=r[e],l=r[o],c=a.x,d=a.y,h=l.x,u=l.y;d>i!=u>i&&s<(h-c)*(i-d)/(u-d)+c&&(n=!n)}return n}({x:r.clientX,y:r.clientY},s))},[]);return(0,F.jsx)(i5,{scope:s,searchRef:N,onItemEnter:W.useCallback(e=>{P(e)&&e.preventDefault()},[P]),onItemLeave:W.useCallback(e=>{P(e)||(C.current?.focus(),S(null))},[P]),onTriggerLeave:W.useCallback(e=>{P(e)&&e.preventDefault()},[P]),pointerGraceTimerRef:E,onPointerGraceIntentChange:W.useCallback(e=>{R.current=e},[]),children:(0,F.jsx)(T,{...m?{as:i7,allowPinchZoom:!0}:void 0,children:(0,F.jsx)(eB,{asChild:!0,trapped:n,onMountAutoFocus:q(o,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:(0,F.jsx)(eM,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:d,onPointerDownOutside:h,onFocusOutside:u,onInteractOutside:f,onDismiss:p,children:(0,F.jsx)(rI,{asChild:!0,...y,dir:x.dir,orientation:"vertical",loop:i,currentTabStopId:w,onCurrentTabStopIdChange:S,onEntryFocus:q(c,e=>{x.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,F.jsx)(ij,{role:"menu","aria-orientation":"vertical","data-state":nk(v.open),"data-radix-menu-content":"",dir:x.dir,..._,...g,ref:k,style:{outline:"none",...g.style},onKeyDown:q(g.onKeyDown,e=>{let r=e.target.closest("[data-radix-menu-content]")===e.currentTarget,s=e.ctrlKey||e.altKey||e.metaKey,i=1===e.key.length;if(r){var n;let r,o,a,l,c,d;"Tab"===e.key&&e.preventDefault(),!s&&i&&(n=e.key,r=N.current+n,o=b().filter(e=>!e.disabled),a=document.activeElement,l=o.find(e=>e.ref.current===a)?.textValue,c=function(e,r,s){var i;let n=r.length>1&&Array.from(r).every(e=>e===r[0])?r[0]:r,o=s?e.indexOf(s):-1,a=(i=Math.max(o,0),e.map((r,s)=>e[(i+s)%e.length]));1===n.length&&(a=a.filter(e=>e!==s));let l=a.find(e=>e.toLowerCase().startsWith(n.toLowerCase()));return l!==s?l:void 0}(o.map(e=>e.textValue),r,l),d=o.find(e=>e.textValue===c)?.ref.current,function e(r){N.current=r,window.clearTimeout(j.current),""!==r&&(j.current=window.setTimeout(()=>e(""),1e3))}(r),d&&setTimeout(()=>d.focus()))}let o=C.current;if(e.target!==o||!iA.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);iL.includes(e.key)&&a.reverse(),function(e){let r=document.activeElement;for(let s of e)if(s===r||(s.focus(),document.activeElement!==r))return}(a)}),onBlur:q(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(j.current),N.current="")}),onPointerMove:q(e.onPointerMove,nE(e=>{let r=e.target,s=D.current!==e.clientX;e.currentTarget.contains(r)&&s&&(M.current=e.clientX>D.current?"right":"left",D.current=e.clientX)}))})})})})})})});i4.displayName=i2;var ne=W.forwardRef((e,r)=>{let{__scopeMenu:s,...i}=e;return(0,F.jsx)(er.div,{role:"group",...i,ref:r})});ne.displayName="MenuGroup";var nt=W.forwardRef((e,r)=>{let{__scopeMenu:s,...i}=e;return(0,F.jsx)(er.div,{...i,ref:r})});nt.displayName="MenuLabel";var nr="MenuItem",ns="menu.itemSelect",ni=W.forwardRef((e,r)=>{let{disabled:s=!1,onSelect:i,...n}=e,o=W.useRef(null),a=iX(nr,e.__scopeMenu),l=i3(nr,e.__scopeMenu),c=(0,U.useComposedRefs)(r,o),d=W.useRef(!1);return(0,F.jsx)(nn,{...n,ref:c,disabled:s,onClick:q(e.onClick,()=>{let e=o.current;if(!s&&e){let r=new CustomEvent(ns,{bubbles:!0,cancelable:!0});e.addEventListener(ns,e=>i?.(e),{once:!0}),es(e,r),r.defaultPrevented?d.current=!1:a.onClose()}}),onPointerDown:r=>{e.onPointerDown?.(r),d.current=!0},onPointerUp:q(e.onPointerUp,e=>{d.current||e.currentTarget?.click()}),onKeyDown:q(e.onKeyDown,e=>{let r=""!==l.searchRef.current;s||r&&" "===e.key||iP.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});ni.displayName=nr;var nn=W.forwardRef((e,r)=>{let{__scopeMenu:s,disabled:i=!1,textValue:n,...o}=e,a=i3(nr,s),l=iK(s),c=W.useRef(null),d=(0,U.useComposedRefs)(r,c),[h,u]=W.useState(!1),[f,p]=W.useState("");return W.useEffect(()=>{let e=c.current;e&&p((e.textContent??"").trim())},[o.children]),(0,F.jsx)(iz.ItemSlot,{scope:s,disabled:i,textValue:n??f,children:(0,F.jsx)(rF,{asChild:!0,...l,focusable:!i,children:(0,F.jsx)(er.div,{role:"menuitem","data-highlighted":h?"":void 0,"aria-disabled":i||void 0,"data-disabled":i?"":void 0,...o,ref:d,onPointerMove:q(e.onPointerMove,nE(e=>{i?a.onItemLeave(e):(a.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:q(e.onPointerLeave,nE(e=>a.onItemLeave(e))),onFocus:q(e.onFocus,()=>u(!0)),onBlur:q(e.onBlur,()=>u(!1))})})})}),no=W.forwardRef((e,r)=>{let{checked:s=!1,onCheckedChange:i,...n}=e;return(0,F.jsx)(np,{scope:e.__scopeMenu,checked:s,children:(0,F.jsx)(ni,{role:"menuitemcheckbox","aria-checked":nj(s)?"mixed":s,...n,ref:r,"data-state":nN(s),onSelect:q(n.onSelect,()=>i?.(!!nj(s)||!s),{checkForDefaultPrevented:!1})})})});no.displayName="MenuCheckboxItem";var na="MenuRadioGroup",[nl,nc]=i$(na,{value:void 0,onValueChange:()=>{}}),nd=W.forwardRef((e,r)=>{let{value:s,onValueChange:i,...n}=e,o=eN(i);return(0,F.jsx)(nl,{scope:e.__scopeMenu,value:s,onValueChange:o,children:(0,F.jsx)(ne,{...n,ref:r})})});nd.displayName=na;var nh="MenuRadioItem",nu=W.forwardRef((e,r)=>{let{value:s,...i}=e,n=nc(nh,e.__scopeMenu),o=s===n.value;return(0,F.jsx)(np,{scope:e.__scopeMenu,checked:o,children:(0,F.jsx)(ni,{role:"menuitemradio","aria-checked":o,...i,ref:r,"data-state":nN(o),onSelect:q(i.onSelect,()=>n.onValueChange?.(s),{checkForDefaultPrevented:!1})})})});nu.displayName=nh;var nf="MenuItemIndicator",[np,nm]=i$(nf,{checked:!1}),ng=W.forwardRef((e,r)=>{let{__scopeMenu:s,forceMount:i,...n}=e,o=nm(nf,s);return(0,F.jsx)(Z,{present:i||nj(o.checked)||!0===o.checked,children:(0,F.jsx)(er.span,{...n,ref:r,"data-state":nN(o.checked)})})});ng.displayName=nf;var nv=W.forwardRef((e,r)=>{let{__scopeMenu:s,...i}=e;return(0,F.jsx)(er.div,{role:"separator","aria-orientation":"horizontal",...i,ref:r})});nv.displayName="MenuSeparator";var nx=W.forwardRef((e,r)=>{let{__scopeMenu:s,...i}=e,n=iU(s);return(0,F.jsx)(iR,{...n,...i,ref:r})});nx.displayName="MenuArrow";var[n_,ny]=i$("MenuSub"),nb="MenuSubTrigger",nw=W.forwardRef((e,r)=>{let s=iV(nb,e.__scopeMenu),i=iX(nb,e.__scopeMenu),n=ny(nb,e.__scopeMenu),o=i3(nb,e.__scopeMenu),a=W.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:c}=o,d={__scopeMenu:e.__scopeMenu},h=W.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);return W.useEffect(()=>h,[h]),W.useEffect(()=>{let e=l.current;return()=>{window.clearTimeout(e),c(null)}},[l,c]),(0,F.jsx)(iJ,{asChild:!0,...d,children:(0,F.jsx)(nn,{id:n.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":n.contentId,"data-state":nk(s.open),...e,ref:(0,U.composeRefs)(r,n.onTriggerChange),onClick:r=>{e.onClick?.(r),e.disabled||r.defaultPrevented||(r.currentTarget.focus(),s.open||s.onOpenChange(!0))},onPointerMove:q(e.onPointerMove,nE(r=>{o.onItemEnter(r),!r.defaultPrevented&&(e.disabled||s.open||a.current||(o.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{s.onOpenChange(!0),h()},100)))})),onPointerLeave:q(e.onPointerLeave,nE(e=>{h();let r=s.content?.getBoundingClientRect();if(r){let i=s.content?.dataset.side,n="right"===i,a=r[n?"left":"right"],c=r[n?"right":"left"];o.onPointerGraceIntentChange({area:[{x:e.clientX+(n?-5:5),y:e.clientY},{x:a,y:r.top},{x:c,y:r.top},{x:c,y:r.bottom},{x:a,y:r.bottom}],side:i}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(e),e.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:q(e.onKeyDown,r=>{let n=""!==o.searchRef.current;e.disabled||n&&" "===r.key||iB[i.dir].includes(r.key)&&(s.onOpenChange(!0),s.content?.focus(),r.preventDefault())})})})});nw.displayName=nb;var nS="MenuSubContent",nC=W.forwardRef((e,r)=>{let s=i0(i2,e.__scopeMenu),{forceMount:i=s.forceMount,...n}=e,o=iV(i2,e.__scopeMenu),a=iX(i2,e.__scopeMenu),l=ny(nS,e.__scopeMenu),c=W.useRef(null),d=(0,U.useComposedRefs)(r,c);return(0,F.jsx)(iz.Provider,{scope:e.__scopeMenu,children:(0,F.jsx)(Z,{present:i||o.open,children:(0,F.jsx)(iz.Slot,{scope:e.__scopeMenu,children:(0,F.jsx)(i9,{id:l.contentId,"aria-labelledby":l.triggerId,...n,ref:d,align:"start",side:"rtl"===a.dir?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{a.isUsingKeyboardRef.current&&c.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:q(e.onFocusOutside,e=>{e.target!==l.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:q(e.onEscapeKeyDown,e=>{a.onClose(),e.preventDefault()}),onKeyDown:q(e.onKeyDown,e=>{let r=e.currentTarget.contains(e.target),s=iI[a.dir].includes(e.key);r&&s&&(o.onOpenChange(!1),l.trigger?.focus(),e.preventDefault())})})})})})});function nk(e){return e?"open":"closed"}function nj(e){return"indeterminate"===e}function nN(e){return nj(e)?"indeterminate":e?"checked":"unchecked"}function nE(e){return r=>"mouse"===r.pointerType?e(r):void 0}nC.displayName=nS;var nR="DropdownMenu",[nM,nD]=K(nR,[iH]),nT=iH(),[nP,nL]=nM(nR),nA=e=>{let{__scopeDropdownMenu:r,children:s,dir:i,open:n,defaultOpen:o,onOpenChange:a,modal:l=!0}=e,c=nT(r),d=W.useRef(null),[h,u]=X({prop:n,defaultProp:o??!1,onChange:a,caller:nR});return(0,F.jsx)(nP,{scope:r,triggerId:ej(),triggerRef:d,contentId:ej(),open:h,onOpenChange:u,onOpenToggle:W.useCallback(()=>u(e=>!e),[u]),modal:l,children:(0,F.jsx)(iG,{...c,open:h,onOpenChange:u,dir:i,modal:l,children:s})})};nA.displayName=nR;var nB="DropdownMenuTrigger",nI=W.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,disabled:i=!1,...n}=e,o=nL(nB,s),a=nT(s);return(0,F.jsx)(iJ,{asChild:!0,...a,children:(0,F.jsx)(er.button,{type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":i?"":void 0,disabled:i,...n,ref:(0,U.composeRefs)(r,o.triggerRef),onPointerDown:q(e.onPointerDown,e=>{!i&&0===e.button&&!1===e.ctrlKey&&(o.onOpenToggle(),o.open||e.preventDefault())}),onKeyDown:q(e.onKeyDown,e=>{!i&&(["Enter"," "].includes(e.key)&&o.onOpenToggle(),"ArrowDown"===e.key&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(e.key)&&e.preventDefault())})})})});nI.displayName=nB;var nO=e=>{let{__scopeDropdownMenu:r,...s}=e,i=nT(r);return(0,F.jsx)(i1,{...i,...s})};nO.displayName="DropdownMenuPortal";var nz="DropdownMenuContent",nF=W.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=nL(nz,s),o=nT(s),a=W.useRef(!1);return(0,F.jsx)(i4,{id:n.contentId,"aria-labelledby":n.triggerId,...o,...i,ref:r,onCloseAutoFocus:q(e.onCloseAutoFocus,e=>{a.current||n.triggerRef.current?.focus(),a.current=!1,e.preventDefault()}),onInteractOutside:q(e.onInteractOutside,e=>{let r=e.detail.originalEvent,s=0===r.button&&!0===r.ctrlKey,i=2===r.button||s;(!n.modal||i)&&(a.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)"}})});nF.displayName=nz,W.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=nT(s);return(0,F.jsx)(ne,{...n,...i,ref:r})}).displayName="DropdownMenuGroup",W.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=nT(s);return(0,F.jsx)(nt,{...n,...i,ref:r})}).displayName="DropdownMenuLabel";var nW=W.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=nT(s);return(0,F.jsx)(ni,{...n,...i,ref:r})});nW.displayName="DropdownMenuItem",W.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=nT(s);return(0,F.jsx)(no,{...n,...i,ref:r})}).displayName="DropdownMenuCheckboxItem";var n$=W.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=nT(s);return(0,F.jsx)(nd,{...n,...i,ref:r})});n$.displayName="DropdownMenuRadioGroup";var nH=W.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=nT(s);return(0,F.jsx)(nu,{...n,...i,ref:r})});nH.displayName="DropdownMenuRadioItem";var nU=W.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=nT(s);return(0,F.jsx)(ng,{...n,...i,ref:r})});nU.displayName="DropdownMenuItemIndicator";var nK=W.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=nT(s);return(0,F.jsx)(nv,{...n,...i,ref:r})});nK.displayName="DropdownMenuSeparator",W.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=nT(s);return(0,F.jsx)(nx,{...n,...i,ref:r})}).displayName="DropdownMenuArrow",W.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=nT(s);return(0,F.jsx)(nw,{...n,...i,ref:r})}).displayName="DropdownMenuSubTrigger",W.forwardRef((e,r)=>{let{__scopeDropdownMenu:s,...i}=e,n=nT(s);return(0,F.jsx)(nC,{...n,...i,ref:r,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)"}})}).displayName="DropdownMenuSubContent";var H=H;let nq=(0,ew.default)("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),nV=(0,ew.default)("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);function nY({...e}){return(0,F.jsx)(nA,{"data-slot":"dropdown-menu",...e})}function nX({...e}){return(0,F.jsx)(nI,{"data-slot":"dropdown-menu-trigger",...e})}function nG({className:e,sideOffset:r=4,...s}){return(0,F.jsx)(nO,{children:(0,F.jsx)(nF,{"data-slot":"dropdown-menu-content",sideOffset:r,className:(0,ey.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 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 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",e),...s})})}function nJ({className:e,inset:r,variant:s="default",...i}){return(0,F.jsx)(nW,{"data-slot":"dropdown-menu-item","data-inset":r,"data-variant":s,className:(0,ey.cn)("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-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...i})}function nZ({...e}){return(0,F.jsx)(n$,{"data-slot":"dropdown-menu-radio-group",...e})}function nQ({className:e,children:r,...s}){return(0,F.jsxs)(nH,{"data-slot":"dropdown-menu-radio-item",className:(0,ey.cn)("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...s,children:[(0,F.jsx)("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:(0,F.jsx)(nU,{children:(0,F.jsx)(nV,{className:"size-2 fill-current"})})}),r]})}function n0({className:e,...r}){return(0,F.jsx)(nK,{"data-slot":"dropdown-menu-separator",className:(0,ey.cn)("bg-border -mx-1 my-1 h-px",e),...r})}function n1({targets:e,activeTarget:r,onTargetChange:s,onAddRemote:i,disabled:n}){if(e.length<=2)return(0,F.jsx)("div",{className:"inline-flex items-center rounded-md border bg-muted/50 px-0.5 text-xs",children:e.map(e=>{let i=e.icon;return(0,F.jsxs)("button",{onClick:()=>s(e.id),disabled:n,className:(0,ey.cn)("inline-flex items-center gap-1 rounded-sm px-2 py-0.5 transition-colors",r===e.id?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground",n&&"opacity-50 cursor-not-allowed"),children:[i&&(0,F.jsx)(i,{className:"h-3 w-3"}),e.label]},e.id)})});let o=e.find(e=>e.id===r)??e[0],a=o?.icon;return(0,F.jsxs)(nY,{children:[(0,F.jsx)(nX,{asChild:!0,children:(0,F.jsxs)("button",{disabled:n,className:(0,ey.cn)("inline-flex items-center gap-1 rounded-md border bg-muted/50 px-2 py-0.5 text-xs font-medium transition-colors hover:bg-muted",n&&"opacity-50 cursor-not-allowed"),children:[a&&(0,F.jsx)(a,{className:"h-3 w-3"}),o?.label??"Local",(0,F.jsx)(r7,{className:"h-3 w-3 text-muted-foreground"})]})}),(0,F.jsxs)(nG,{align:"start",children:[(0,F.jsx)(nZ,{value:r,onValueChange:s,children:e.map(e=>{let r=e.icon;return(0,F.jsxs)(nQ,{value:e.id,className:"text-xs",children:[r&&(0,F.jsx)(r,{className:"h-3 w-3"}),e.label]},e.id)})}),i&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(n0,{}),(0,F.jsxs)(nJ,{onClick:i,className:"text-xs",children:[(0,F.jsx)(eS,{className:"h-3 w-3"}),"Add Remote"]})]})]})]})}let n2=(0,ew.default)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);var n5=e.i(671798);let n3=(0,ew.default)("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);var n4=e.i(801836);let n6=(0,ew.default)("cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]),n8=(0,ew.default)("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);function n7(e,[r,s]){return Math.min(s,Math.max(r,e))}var n9="ScrollArea",[oe,ot]=K(n9),[or,os]=oe(n9),oi=W.forwardRef((e,r)=>{let{__scopeScrollArea:s,type:i="hover",dir:n,scrollHideDelay:o=600,...a}=e,[l,c]=W.useState(null),[d,h]=W.useState(null),[u,f]=W.useState(null),[p,m]=W.useState(null),[g,v]=W.useState(null),[x,_]=W.useState(0),[y,b]=W.useState(0),[w,S]=W.useState(!1),[C,k]=W.useState(!1),j=(0,U.useComposedRefs)(r,e=>c(e)),N=rj(n);return(0,F.jsx)(or,{scope:s,type:i,dir:N,scrollHideDelay:o,scrollArea:l,viewport:d,onViewportChange:h,content:u,onContentChange:f,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:w,onScrollbarXEnabledChange:S,scrollbarY:g,onScrollbarYChange:v,scrollbarYEnabled:C,onScrollbarYEnabledChange:k,onCornerWidthChange:_,onCornerHeightChange:b,children:(0,F.jsx)(er.div,{dir:N,...a,ref:j,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":y+"px",...e.style}})})});oi.displayName=n9;var on="ScrollAreaViewport",oo=W.forwardRef((e,r)=>{let{__scopeScrollArea:s,children:i,nonce:n,...o}=e,a=os(on,s),l=W.useRef(null),c=(0,U.useComposedRefs)(r,l,a.onViewportChange);return(0,F.jsxs)(F.Fragment,{children:[(0,F.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:n}),(0,F.jsx)(er.div,{"data-radix-scroll-area-viewport":"",...o,ref:c,style:{overflowX:a.scrollbarXEnabled?"scroll":"hidden",overflowY:a.scrollbarYEnabled?"scroll":"hidden",...e.style},children:(0,F.jsx)("div",{ref:a.onContentChange,style:{minWidth:"100%",display:"table"},children:i})})]})});oo.displayName=on;var oa="ScrollAreaScrollbar",ol=W.forwardRef((e,r)=>{let{forceMount:s,...i}=e,n=os(oa,e.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:a}=n,l="horizontal"===e.orientation;return W.useEffect(()=>(l?o(!0):a(!0),()=>{l?o(!1):a(!1)}),[l,o,a]),"hover"===n.type?(0,F.jsx)(oc,{...i,ref:r,forceMount:s}):"scroll"===n.type?(0,F.jsx)(od,{...i,ref:r,forceMount:s}):"auto"===n.type?(0,F.jsx)(oh,{...i,ref:r,forceMount:s}):"always"===n.type?(0,F.jsx)(ou,{...i,ref:r}):null});ol.displayName=oa;var oc=W.forwardRef((e,r)=>{let{forceMount:s,...i}=e,n=os(oa,e.__scopeScrollArea),[o,a]=W.useState(!1);return W.useEffect(()=>{let e=n.scrollArea,r=0;if(e){let s=()=>{window.clearTimeout(r),a(!0)},i=()=>{r=window.setTimeout(()=>a(!1),n.scrollHideDelay)};return e.addEventListener("pointerenter",s),e.addEventListener("pointerleave",i),()=>{window.clearTimeout(r),e.removeEventListener("pointerenter",s),e.removeEventListener("pointerleave",i)}}},[n.scrollArea,n.scrollHideDelay]),(0,F.jsx)(Z,{present:s||o,children:(0,F.jsx)(oh,{"data-state":o?"visible":"hidden",...i,ref:r})})}),od=W.forwardRef((e,r)=>{var s;let{forceMount:i,...n}=e,o=os(oa,e.__scopeScrollArea),a="horizontal"===e.orientation,l=oM(()=>d("SCROLL_END"),100),[c,d]=(s={hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}},W.useReducer((e,r)=>s[e][r]??e,"hidden"));return W.useEffect(()=>{if("idle"===c){let e=window.setTimeout(()=>d("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(e)}},[c,o.scrollHideDelay,d]),W.useEffect(()=>{let e=o.viewport,r=a?"scrollLeft":"scrollTop";if(e){let s=e[r],i=()=>{let i=e[r];s!==i&&(d("SCROLL"),l()),s=i};return e.addEventListener("scroll",i),()=>e.removeEventListener("scroll",i)}},[o.viewport,a,d,l]),(0,F.jsx)(Z,{present:i||"hidden"!==c,children:(0,F.jsx)(ou,{"data-state":"hidden"===c?"hidden":"visible",...n,ref:r,onPointerEnter:q(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:q(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),oh=W.forwardRef((e,r)=>{let s=os(oa,e.__scopeScrollArea),{forceMount:i,...n}=e,[o,a]=W.useState(!1),l="horizontal"===e.orientation,c=oM(()=>{if(s.viewport){let e=s.viewport.offsetWidth<s.viewport.scrollWidth,r=s.viewport.offsetHeight<s.viewport.scrollHeight;a(l?e:r)}},10);return oD(s.viewport,c),oD(s.content,c),(0,F.jsx)(Z,{present:i||o,children:(0,F.jsx)(ou,{"data-state":o?"visible":"hidden",...n,ref:r})})}),ou=W.forwardRef((e,r)=>{let{orientation:s="vertical",...i}=e,n=os(oa,e.__scopeScrollArea),o=W.useRef(null),a=W.useRef(0),[l,c]=W.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),d=ok(l.viewport,l.content),h={...i,sizes:l,onSizesChange:c,hasThumb:!!(d>0&&d<1),onThumbChange:e=>o.current=e,onThumbPointerUp:()=>a.current=0,onThumbPointerDown:e=>a.current=e};function u(e,r){return function(e,r,s,i="ltr"){let n=oj(s),o=r||n/2,a=s.scrollbar.paddingStart+o,l=s.scrollbar.size-s.scrollbar.paddingEnd-(n-o),c=s.content-s.viewport;return oE([a,l],"ltr"===i?[0,c]:[-1*c,0])(e)}(e,a.current,l,r)}return"horizontal"===s?(0,F.jsx)(of,{...h,ref:r,onThumbPositionChange:()=>{if(n.viewport&&o.current){let e=oN(n.viewport.scrollLeft,l,n.dir);o.current.style.transform=`translate3d(${e}px, 0, 0)`}},onWheelScroll:e=>{n.viewport&&(n.viewport.scrollLeft=e)},onDragScroll:e=>{n.viewport&&(n.viewport.scrollLeft=u(e,n.dir))}}):"vertical"===s?(0,F.jsx)(op,{...h,ref:r,onThumbPositionChange:()=>{if(n.viewport&&o.current){let e=oN(n.viewport.scrollTop,l);o.current.style.transform=`translate3d(0, ${e}px, 0)`}},onWheelScroll:e=>{n.viewport&&(n.viewport.scrollTop=e)},onDragScroll:e=>{n.viewport&&(n.viewport.scrollTop=u(e))}}):null}),of=W.forwardRef((e,r)=>{let{sizes:s,onSizesChange:i,...n}=e,o=os(oa,e.__scopeScrollArea),[a,l]=W.useState(),c=W.useRef(null),d=(0,U.useComposedRefs)(r,c,o.onScrollbarXChange);return W.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),(0,F.jsx)(ov,{"data-orientation":"horizontal",...n,ref:d,sizes:s,style:{bottom:0,left:"rtl"===o.dir?"var(--radix-scroll-area-corner-width)":0,right:"ltr"===o.dir?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":oj(s)+"px",...e.style},onThumbPointerDown:r=>e.onThumbPointerDown(r.x),onDragScroll:r=>e.onDragScroll(r.x),onWheelScroll:(r,s)=>{if(o.viewport){var i,n;let a=o.viewport.scrollLeft+r.deltaX;e.onWheelScroll(a),i=a,n=s,i>0&&i<n&&r.preventDefault()}},onResize:()=>{c.current&&o.viewport&&a&&i({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:oC(a.paddingLeft),paddingEnd:oC(a.paddingRight)}})}})}),op=W.forwardRef((e,r)=>{let{sizes:s,onSizesChange:i,...n}=e,o=os(oa,e.__scopeScrollArea),[a,l]=W.useState(),c=W.useRef(null),d=(0,U.useComposedRefs)(r,c,o.onScrollbarYChange);return W.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),(0,F.jsx)(ov,{"data-orientation":"vertical",...n,ref:d,sizes:s,style:{top:0,right:"ltr"===o.dir?0:void 0,left:"rtl"===o.dir?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":oj(s)+"px",...e.style},onThumbPointerDown:r=>e.onThumbPointerDown(r.y),onDragScroll:r=>e.onDragScroll(r.y),onWheelScroll:(r,s)=>{if(o.viewport){var i,n;let a=o.viewport.scrollTop+r.deltaY;e.onWheelScroll(a),i=a,n=s,i>0&&i<n&&r.preventDefault()}},onResize:()=>{c.current&&o.viewport&&a&&i({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:oC(a.paddingTop),paddingEnd:oC(a.paddingBottom)}})}})}),[om,og]=oe(oa),ov=W.forwardRef((e,r)=>{let{__scopeScrollArea:s,sizes:i,hasThumb:n,onThumbChange:o,onThumbPointerUp:a,onThumbPointerDown:l,onThumbPositionChange:c,onDragScroll:d,onWheelScroll:h,onResize:u,...f}=e,p=os(oa,s),[m,g]=W.useState(null),v=(0,U.useComposedRefs)(r,e=>g(e)),x=W.useRef(null),_=W.useRef(""),y=p.viewport,b=i.content-i.viewport,w=eN(h),S=eN(c),C=oM(u,10);function k(e){x.current&&d({x:e.clientX-x.current.left,y:e.clientY-x.current.top})}return W.useEffect(()=>{let e=e=>{let r=e.target;m?.contains(r)&&w(e,b)};return document.addEventListener("wheel",e,{passive:!1}),()=>document.removeEventListener("wheel",e,{passive:!1})},[y,m,b,w]),W.useEffect(S,[i,S]),oD(m,C),oD(p.content,C),(0,F.jsx)(om,{scope:s,scrollbar:m,hasThumb:n,onThumbChange:eN(o),onThumbPointerUp:eN(a),onThumbPositionChange:S,onThumbPointerDown:eN(l),children:(0,F.jsx)(er.div,{...f,ref:v,style:{position:"absolute",...f.style},onPointerDown:q(e.onPointerDown,e=>{0===e.button&&(e.target.setPointerCapture(e.pointerId),x.current=m.getBoundingClientRect(),_.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),k(e))}),onPointerMove:q(e.onPointerMove,k),onPointerUp:q(e.onPointerUp,e=>{let r=e.target;r.hasPointerCapture(e.pointerId)&&r.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=_.current,p.viewport&&(p.viewport.style.scrollBehavior=""),x.current=null})})})}),ox="ScrollAreaThumb",o_=W.forwardRef((e,r)=>{let{forceMount:s,...i}=e,n=og(ox,e.__scopeScrollArea);return(0,F.jsx)(Z,{present:s||n.hasThumb,children:(0,F.jsx)(oy,{ref:r,...i})})}),oy=W.forwardRef((e,r)=>{let{__scopeScrollArea:s,style:i,...n}=e,o=os(ox,s),a=og(ox,s),{onThumbPositionChange:l}=a,c=(0,U.useComposedRefs)(r,e=>a.onThumbChange(e)),d=W.useRef(void 0),h=oM(()=>{d.current&&(d.current(),d.current=void 0)},100);return W.useEffect(()=>{let e=o.viewport;if(e){let r=()=>{h(),d.current||(d.current=oR(e,l),l())};return l(),e.addEventListener("scroll",r),()=>e.removeEventListener("scroll",r)}},[o.viewport,h,l]),(0,F.jsx)(er.div,{"data-state":a.hasThumb?"visible":"hidden",...n,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...i},onPointerDownCapture:q(e.onPointerDownCapture,e=>{let r=e.target.getBoundingClientRect(),s=e.clientX-r.left,i=e.clientY-r.top;a.onThumbPointerDown({x:s,y:i})}),onPointerUp:q(e.onPointerUp,a.onThumbPointerUp)})});o_.displayName=ox;var ob="ScrollAreaCorner",ow=W.forwardRef((e,r)=>{let s=os(ob,e.__scopeScrollArea),i=!!(s.scrollbarX&&s.scrollbarY);return"scroll"!==s.type&&i?(0,F.jsx)(oS,{...e,ref:r}):null});ow.displayName=ob;var oS=W.forwardRef((e,r)=>{let{__scopeScrollArea:s,...i}=e,n=os(ob,s),[o,a]=W.useState(0),[l,c]=W.useState(0),d=!!(o&&l);return oD(n.scrollbarX,()=>{let e=n.scrollbarX?.offsetHeight||0;n.onCornerHeightChange(e),c(e)}),oD(n.scrollbarY,()=>{let e=n.scrollbarY?.offsetWidth||0;n.onCornerWidthChange(e),a(e)}),d?(0,F.jsx)(er.div,{...i,ref:r,style:{width:o,height:l,position:"absolute",right:"ltr"===n.dir?0:void 0,left:"rtl"===n.dir?0:void 0,bottom:0,...e.style}}):null});function oC(e){return e?parseInt(e,10):0}function ok(e,r){let s=e/r;return isNaN(s)?0:s}function oj(e){let r=ok(e.viewport,e.content),s=e.scrollbar.paddingStart+e.scrollbar.paddingEnd;return Math.max((e.scrollbar.size-s)*r,18)}function oN(e,r,s="ltr"){let i=oj(r),n=r.scrollbar.paddingStart+r.scrollbar.paddingEnd,o=r.scrollbar.size-n,a=r.content-r.viewport,l=n7(e,"ltr"===s?[0,a]:[-1*a,0]);return oE([0,a],[0,o-i])(l)}function oE(e,r){return s=>{if(e[0]===e[1]||r[0]===r[1])return r[0];let i=(r[1]-r[0])/(e[1]-e[0]);return r[0]+i*(s-e[0])}}var oR=(e,r=()=>{})=>{let s={left:e.scrollLeft,top:e.scrollTop},i=0;return!function n(){let o={left:e.scrollLeft,top:e.scrollTop},a=s.left!==o.left,l=s.top!==o.top;(a||l)&&r(),s=o,i=window.requestAnimationFrame(n)}(),()=>window.cancelAnimationFrame(i)};function oM(e,r){let s=eN(e),i=W.useRef(0);return W.useEffect(()=>()=>window.clearTimeout(i.current),[]),W.useCallback(()=>{window.clearTimeout(i.current),i.current=window.setTimeout(s,r)},[s,r])}function oD(e,r){let s=eN(r);V(()=>{let r=0;if(e){let i=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(s)});return i.observe(e),()=>{window.cancelAnimationFrame(r),i.unobserve(e)}}},[e,s])}function oT({className:e,children:r,...s}){return(0,F.jsxs)(oi,{"data-slot":"scroll-area",className:(0,ey.cn)("relative",e),...s,children:[(0,F.jsx)(oo,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:r}),(0,F.jsx)(oP,{}),(0,F.jsx)(ow,{})]})}function oP({className:e,orientation:r="vertical",...s}){return(0,F.jsx)(ol,{"data-slot":"scroll-area-scrollbar",orientation:r,className:(0,ey.cn)("flex touch-none p-px transition-colors select-none","vertical"===r&&"h-full w-2.5 border-l border-l-transparent","horizontal"===r&&"h-2.5 flex-col border-t border-t-transparent",e),...s,children:(0,F.jsx)(o_,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}let oL=(0,ew.default)("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),oA=(0,ew.default)("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);function oB({serverId:e,onSelect:r,selectedPath:s}){let[i,n]=(0,W.useState)("/"),[o,a]=(0,W.useState)([]),[l,c]=(0,W.useState)(!1),[d,h]=(0,W.useState)("");return((0,W.useEffect)(()=>{e?(async()=>{c(!0),h("");try{let r=await rg.api.browseRemoteServerDirectory(e,i);a(r.items??[])}catch(e){h(e instanceof Error?e.message:"Failed to load directory"),a([])}finally{c(!1)}})():a([])},[e,i]),e)?(0,F.jsxs)("div",{className:"border rounded-md",children:[(0,F.jsxs)("div",{className:"flex items-center gap-2 p-2 border-b bg-muted/50",children:[(0,F.jsx)($.Button,{variant:"ghost",size:"sm",onClick:()=>{n(i.split("/").slice(0,-1).join("/")||"/")},disabled:"/"===i||l,children:(0,F.jsx)(oA,{className:"h-4 w-4"})}),(0,F.jsx)("span",{className:"text-sm font-mono truncate flex-1",children:i})]}),l?(0,F.jsx)("div",{className:"flex items-center justify-center p-8",children:(0,F.jsx)(n2,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):d?(0,F.jsx)("div",{className:"p-4 text-sm text-red-500",children:d}):0===o.length?(0,F.jsx)("div",{className:"p-4 text-sm text-muted-foreground text-center",children:"No directories found"}):(0,F.jsx)(oT,{className:"h-[200px]",children:(0,F.jsx)("div",{className:"p-1",children:o.map(e=>(0,F.jsxs)("div",{className:`flex items-center gap-2 p-2 rounded-md cursor-pointer hover:bg-muted ${s===e.path?"bg-muted":""}`,children:[(0,F.jsxs)("button",{className:"flex items-center gap-2 flex-1 text-left",onClick:()=>{r(e.path)},children:[(0,F.jsx)(oL,{className:"h-4 w-4 text-muted-foreground"}),(0,F.jsx)("span",{className:"text-sm truncate",children:e.name})]}),(0,F.jsx)($.Button,{variant:"ghost",size:"sm",onClick:()=>{n(e.path)},title:"Open folder",children:(0,F.jsx)(nq,{className:"h-4 w-4"})})]},e.path))})})]}):(0,F.jsx)("div",{className:"text-sm text-muted-foreground p-4 text-center border rounded-md",children:"Select a remote server to browse directories"})}let oI={actionType:"command",executionMode:"local",content:""};function oO(e){return e?{actionType:e.actionType,executionMode:e.executionMode,content:e.content}:{...oI}}function oz(e){return{actionType:e.actionType,executionMode:e.executionMode,content:e.content}}function oF({actionType:e,onActionTypeChange:r}){return(0,F.jsxs)("div",{className:"inline-flex items-center rounded-md border bg-muted/50 p-0.5 text-xs",children:[(0,F.jsxs)("button",{onClick:()=>r("command"),className:(0,ey.cn)("inline-flex items-center gap-1 rounded-sm px-2 py-0.5 transition-colors","command"===e?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[(0,F.jsx)(n5.Terminal,{className:"h-3 w-3"}),"Command"]}),(0,F.jsxs)("button",{onClick:()=>r("prompt"),className:(0,ey.cn)("inline-flex items-center gap-1 rounded-sm px-2 py-0.5 transition-colors","prompt"===e?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[(0,F.jsx)(n3,{className:"h-3 w-3"}),"Prompt"]})]})}function oW({config:e,onChange:r,label:s,targets:i}){return(0,F.jsxs)("div",{className:"space-y-4 py-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:s}),i.length>0&&(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-xs text-muted-foreground",children:"Execution Environment"}),(0,F.jsx)("div",{children:(0,F.jsx)(n1,{targets:i,activeTarget:e.executionMode,onTargetChange:s=>r({...e,executionMode:s})})})]}),(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-xs text-muted-foreground",children:"Action Type"}),(0,F.jsx)("div",{children:(0,F.jsx)(oF,{actionType:e.actionType,onActionTypeChange:s=>r({...e,actionType:s})})})]}),(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-xs text-muted-foreground",children:"command"===e.actionType?"Shell Command":"Agent Prompt"}),(0,F.jsx)(ro,{value:e.content,onChange:s=>r({...e,content:s.target.value}),placeholder:"command"===e.actionType?"git push origin HEAD":"Please pull the latest changes and rebase...",rows:3})]})]})}function o$({project:e,onSave:r,onCancel:s}){let{remotes:i,refresh:n}=r8(e.id),o=[];for(let r of(e.path&&o.push({id:"local",label:"Local",icon:n4.Monitor}),i))o.push({id:r.remote_server_id,label:r.server_name,icon:n6});let[a,l]=(0,W.useState)(e.name),[c,d]=(0,W.useState)(e.path??""),[h,u]=(0,W.useState)(!1),[f,p]=(0,W.useState)(""),[m,g]=(0,W.useState)(oO(e.sync_up_config)),[v,x]=(0,W.useState)(oO(e.sync_down_config)),[_,y]=(0,W.useState)("closed"),[b,w]=(0,W.useState)([]),[S,C]=(0,W.useState)(null),[k,j]=(0,W.useState)(""),[N,E]=(0,W.useState)(""),[R,M]=(0,W.useState)(""),[D,T]=(0,W.useState)(""),[P,L]=(0,W.useState)("idle"),[A,B]=(0,W.useState)(""),I=()=>{y("closed"),C(null),j(""),E(""),M(""),T(""),L("idle"),B("")};(0,W.useEffect)(()=>{l(e.name),d(e.path??""),p(""),g(oO(e.sync_up_config)),x(oO(e.sync_down_config)),I()},[e.id]);let O=async()=>{let e=await rg.api.selectFolder();e.path&&d(e.path)},z=async()=>{y("pick-server");try{let e=await rg.api.getRemoteServers();w(e)}catch{w([])}},H=async()=>{if(!R||!D)return void B("URL and API key are required");L("testing"),B("");try{await rg.api.testRemoteConnection(R,D),L("success")}catch(e){L("error"),B(e instanceof Error?e.message:"Connection failed")}},U=async()=>{if(N.trim()&&R.trim())try{let e=await rg.api.createRemoteServer({name:N.trim(),url:R.trim(),apiKey:D.trim()||void 0});C(e),j(""),y("pick-path")}catch(e){B(e instanceof Error?e.message:"Failed to create server")}},K=async()=>{if(S&&k)try{await rg.api.addProjectRemote(e.id,{remoteServerId:S.id,remotePath:k}),await n(),I()}catch(e){p(e instanceof Error?e.message:"Failed to add remote")}},q=async r=>{try{await rg.api.removeProjectRemote(e.id,r),await n()}catch(e){p(e instanceof Error?e.message:"Failed to remove remote")}},V=c.trim().length>0,Y=async()=>{if(!a.trim())return void p("Project name is required");if(!V&&0===i.length)return void p("Project must have at least a local folder or remote server");u(!0),p("");try{let s={};a.trim()!==e.name&&(s.name=a.trim());let i=V?c.trim():null;i!==(e.path??null)&&(s.path=i);let n=oz(m),o=e.sync_up_config;JSON.stringify(n)!==JSON.stringify(o)&&(s.syncUpConfig=n);let l=oz(v),d=e.sync_down_config;JSON.stringify(l)!==JSON.stringify(d)&&(s.syncDownConfig=l),await r(e.id,s)}catch(e){p(e instanceof Error?e.message:"Failed to update project")}finally{u(!1)}};return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(rX,{defaultValue:"settings",children:[(0,F.jsxs)(r3,{className:"w-full",children:[(0,F.jsx)(r4,{value:"settings",className:"flex-1",children:"Project Settings"}),(0,F.jsx)(r4,{value:"sync-up",className:"flex-1",children:"Sync Up"}),(0,F.jsx)(r4,{value:"sync-down",className:"flex-1",children:"Sync Down"})]}),(0,F.jsx)(r6,{value:"settings",children:(0,F.jsxs)("div",{className:"space-y-5 py-2",children:[(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Project Name"}),(0,F.jsx)(rn,{value:a,onChange:e=>l(e.target.value),placeholder:"My Project"})]}),(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Local Folder"}),(0,F.jsxs)("div",{className:"flex gap-2",children:[(0,F.jsx)(rn,{value:c,onChange:e=>d(e.target.value),placeholder:"/path/to/project (optional)",className:"flex-1"}),(0,F.jsx)($.Button,{variant:"outline",onClick:O,children:(0,F.jsx)(rv,{className:"h-4 w-4"})})]})]}),(0,F.jsxs)("div",{className:"space-y-3",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Remote Servers"}),i.length>0&&(0,F.jsx)("div",{className:"space-y-2",children:i.map(e=>(0,F.jsxs)("div",{className:"flex items-center gap-2 rounded-md border p-2 text-sm",children:[(0,F.jsx)(rx,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,F.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,F.jsx)("p",{className:"font-medium truncate",children:e.server_name}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground font-mono truncate",children:e.remote_path})]}),(0,F.jsx)($.Button,{variant:"ghost",size:"icon-sm",className:"h-7 w-7 shrink-0",onClick:()=>q(e.id),children:(0,F.jsx)(ra,{className:"h-3.5 w-3.5 text-muted-foreground"})})]},e.id))}),"closed"===_&&(0,F.jsxs)($.Button,{variant:"outline",size:"sm",onClick:z,className:"w-full",children:[(0,F.jsx)(eS,{className:"h-4 w-4 mr-1"}),"Add Remote"]}),"pick-server"===_&&(0,F.jsxs)("div",{className:"rounded-md border p-3 space-y-3",children:[(0,F.jsxs)("div",{className:"flex items-center justify-between",children:[(0,F.jsx)("label",{className:"text-xs font-medium",children:"Select a Remote Server"}),(0,F.jsx)($.Button,{variant:"ghost",size:"sm",onClick:I,children:(0,F.jsx)(t6,{className:"h-3.5 w-3.5"})})]}),b.length>0&&(0,F.jsx)("div",{className:"space-y-1",children:b.map(e=>(0,F.jsxs)("button",{className:"flex items-center gap-2 w-full rounded-md p-2 text-sm text-left hover:bg-muted",onClick:()=>{C(e),j(""),y("pick-path")},children:[(0,F.jsx)(n8,{className:"h-4 w-4 text-muted-foreground"}),(0,F.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,F.jsx)("p",{className:"truncate",children:e.name}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:e.url})]})]},e.id))}),(0,F.jsxs)($.Button,{variant:"outline",size:"sm",onClick:()=>{y("new-server"),E(""),M(""),T(""),L("idle"),B("")},className:"w-full",children:[(0,F.jsx)(eS,{className:"h-4 w-4 mr-1"}),"New Server"]})]}),"new-server"===_&&(0,F.jsxs)("div",{className:"rounded-md border p-3 space-y-3",children:[(0,F.jsxs)("div",{className:"flex items-center justify-between",children:[(0,F.jsx)("label",{className:"text-xs font-medium",children:"Create New Server"}),(0,F.jsx)($.Button,{variant:"ghost",size:"sm",onClick:I,children:(0,F.jsx)(t6,{className:"h-3.5 w-3.5"})})]}),(0,F.jsx)(rn,{value:N,onChange:e=>E(e.target.value),placeholder:"Server name"}),(0,F.jsx)(rn,{value:R,onChange:e=>{M(e.target.value),L("idle")},placeholder:"http://remote-server:5173"}),(0,F.jsxs)("div",{className:"flex gap-2",children:[(0,F.jsx)(rn,{type:"password",value:D,onChange:e=>{T(e.target.value),L("idle")},placeholder:"API key",className:"flex-1"}),(0,F.jsx)($.Button,{variant:"outline",size:"sm",onClick:H,disabled:"testing"===P||!R||!D,children:"testing"===P?(0,F.jsx)(n2,{className:"h-4 w-4 animate-spin"}):"success"===P?(0,F.jsx)(rf.Check,{className:"h-4 w-4 text-green-500"}):"error"===P?(0,F.jsx)(t6,{className:"h-4 w-4 text-red-500"}):"Test"})]}),A&&(0,F.jsx)("p",{className:"text-xs text-red-500",children:A}),"success"===P&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)("p",{className:"text-xs text-green-500",children:"Connection successful"}),(0,F.jsx)($.Button,{size:"sm",onClick:U,disabled:!N.trim(),children:"Create & Continue"})]})]}),"pick-path"===_&&S&&(0,F.jsxs)("div",{className:"rounded-md border p-3 space-y-3",children:[(0,F.jsxs)("div",{className:"flex items-center justify-between",children:[(0,F.jsxs)("label",{className:"text-xs font-medium",children:["Select Directory on ",S.name]}),(0,F.jsx)($.Button,{variant:"ghost",size:"sm",onClick:I,children:(0,F.jsx)(t6,{className:"h-3.5 w-3.5"})})]}),(0,F.jsx)(oB,{serverId:S.id,onSelect:e=>{j(e)},selectedPath:k}),k&&(0,F.jsxs)("div",{className:"flex items-center justify-between",children:[(0,F.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Selected:"," ",(0,F.jsx)("span",{className:"font-mono",children:k})]}),(0,F.jsx)($.Button,{size:"sm",onClick:K,children:"Add"})]})]})]})]})}),(0,F.jsx)(r6,{value:"sync-up",children:(0,F.jsx)(oW,{config:m,onChange:g,label:"Sync Up Button",targets:o})}),(0,F.jsx)(r6,{value:"sync-down",children:(0,F.jsx)(oW,{config:v,onChange:x,label:"Sync Down Button",targets:o})})]}),f&&(0,F.jsx)("p",{className:"text-sm text-red-500",children:f}),(0,F.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[s&&(0,F.jsx)($.Button,{variant:"outline",onClick:s,children:"Cancel"}),(0,F.jsx)($.Button,{onClick:Y,disabled:h,children:h?"Saving...":"Save Changes"})]})]})}function oH({project:e}){let r=!!e.path,s=e.is_remote||!!e.remote_path;return r&&s?(0,F.jsx)("span",{className:"inline-flex items-center rounded-full bg-purple-500/10 px-2.5 py-0.5 text-xs font-medium text-purple-600",children:"Local + Remote"}):s?(0,F.jsx)("span",{className:"inline-flex items-center rounded-full bg-blue-500/10 px-2.5 py-0.5 text-xs font-medium text-blue-600",children:"Remote"}):(0,F.jsx)("span",{className:"inline-flex items-center rounded-full bg-muted px-2.5 py-0.5 text-xs font-medium text-muted-foreground",children:"Local"})}function oU({project:e,onProjectUpdated:r}){let{remotes:s}=r8(e.id);return(0,F.jsx)("div",{className:"h-full flex flex-col p-6 overflow-hidden",children:(0,F.jsxs)(rX,{defaultValue:"home",className:"w-full max-w-2xl mx-auto flex flex-col flex-1 min-h-0",children:[(0,F.jsxs)(r3,{children:[(0,F.jsx)(r4,{value:"home",children:"Home"}),(0,F.jsx)(r4,{value:"settings",children:"Settings"})]}),(0,F.jsx)(r6,{value:"home",className:"flex-1 flex items-center justify-center",children:(0,F.jsxs)(ry.Card,{className:"w-full max-w-md",children:[(0,F.jsx)(ry.CardHeader,{children:(0,F.jsxs)("div",{className:"flex items-center justify-between",children:[(0,F.jsx)(ry.CardTitle,{className:"text-lg",children:e.name}),(0,F.jsx)(oH,{project:e})]})}),(0,F.jsxs)(ry.CardContent,{className:"space-y-4",children:[e.path&&(0,F.jsxs)("div",{className:"flex items-start gap-3 text-sm",children:[(0,F.jsx)(rv,{className:"h-4 w-4 mt-0.5 shrink-0 text-muted-foreground"}),(0,F.jsx)("span",{className:"text-muted-foreground break-all",children:e.path})]}),s.map(e=>(0,F.jsxs)("div",{className:"flex items-start gap-3 text-sm",children:[(0,F.jsx)(rx,{className:"h-4 w-4 mt-0.5 shrink-0 text-muted-foreground"}),(0,F.jsxs)("div",{className:"min-w-0",children:[(0,F.jsx)("span",{className:"text-muted-foreground break-all",children:e.server_name}),e.server_url&&(0,F.jsx)("span",{className:"block text-xs text-muted-foreground/70 break-all",children:e.server_url})]})]},e.id)),(0,F.jsxs)("div",{className:"flex items-center gap-3 text-sm",children:[(0,F.jsx)(r_,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,F.jsxs)("span",{className:"text-muted-foreground",children:["Created ",new Date(e.created_at).toLocaleDateString()]})]})]})]})}),(0,F.jsx)(r6,{value:"settings",className:"flex-1 overflow-auto",children:(0,F.jsx)(o$,{project:e,onSave:r})})]})})}function oK({open:e,onOpenChange:r,onProjectCreated:s}){let[i,n]=(0,W.useState)(""),[o,a]=(0,W.useState)(""),[l,c]=(0,W.useState)([]),[d,h]=(0,W.useState)("closed"),[u,f]=(0,W.useState)([]),[p,m]=(0,W.useState)(null),[g,v]=(0,W.useState)(""),[x,_]=(0,W.useState)(""),[y,b]=(0,W.useState)(""),[w,S]=(0,W.useState)(""),[C,k]=(0,W.useState)("idle"),[j,N]=(0,W.useState)(""),[E,R]=(0,W.useState)(!1),[M,D]=(0,W.useState)(""),T=()=>{n(""),a(""),c([]),P(),D("")},P=()=>{h("closed"),m(null),v(""),_(""),b(""),S(""),k("idle"),N("")},L=e=>{e||T(),r(e)},A=async()=>{let e=await rg.api.selectFolder();e.path&&(a(e.path),i||n(e.path.split("/").pop()||""))},B=async()=>{h("pick-server");try{let e=await rg.api.getRemoteServers();f(e)}catch{f([])}},I=async()=>{if(!y||!w)return void N("URL and API key are required");k("testing"),N("");try{await rg.api.testRemoteConnection(y,w),k("success")}catch(e){k("error"),N(e instanceof Error?e.message:"Connection failed")}},O=async()=>{if(x.trim()&&y.trim())try{let e=await rg.api.createRemoteServer({name:x.trim(),url:y.trim(),apiKey:w.trim()||void 0});m(e),v(""),h("pick-path")}catch(e){N(e instanceof Error?e.message:"Failed to create server")}},z=o.trim().length>0,H=l.length>0,U=async()=>{if(!i.trim())return void D("Project name is required");if(!z&&!H)return void D("Please provide a local folder, remote server, or both");R(!0),D("");try{let e=await rg.api.createProject({name:i.trim(),...z?{path:o.trim()}:{},...H&&!z?{agentMode:l[0].serverId}:{}});for(let r of l)await rg.api.addProjectRemote(e.id,{remoteServerId:r.serverId,remotePath:r.remotePath});s(e),T(),r(!1)}catch(e){D(e instanceof Error?e.message:"Failed to create project")}finally{R(!1)}};return(0,F.jsx)(t8,{open:e,onOpenChange:L,children:(0,F.jsxs)(re,{className:"max-w-lg",children:[(0,F.jsx)(rt,{children:(0,F.jsx)(rs,{children:"Create New Project"})}),(0,F.jsxs)("div",{className:"space-y-5 py-2",children:[(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Project Name"}),(0,F.jsx)(rn,{value:i,onChange:e=>n(e.target.value),placeholder:"My Project"})]}),(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Local Folder"}),(0,F.jsxs)("div",{className:"flex gap-2",children:[(0,F.jsx)(rn,{value:o,onChange:e=>a(e.target.value),placeholder:"/path/to/project (optional)",className:"flex-1"}),(0,F.jsx)($.Button,{variant:"outline",onClick:A,children:(0,F.jsx)(rv,{className:"h-4 w-4"})})]})]}),(0,F.jsxs)("div",{className:"space-y-3",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Remote Servers"}),l.length>0&&(0,F.jsx)("div",{className:"space-y-2",children:l.map((e,r)=>(0,F.jsxs)("div",{className:"flex items-center gap-2 rounded-md border p-2 text-sm",children:[(0,F.jsx)(rx,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,F.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,F.jsx)("p",{className:"font-medium truncate",children:e.serverName}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground font-mono truncate",children:e.remotePath})]}),(0,F.jsx)($.Button,{variant:"ghost",size:"icon-sm",className:"h-7 w-7 shrink-0",onClick:()=>{c(e=>e.filter((e,s)=>s!==r))},children:(0,F.jsx)(ra,{className:"h-3.5 w-3.5 text-muted-foreground"})})]},`${e.serverId}-${e.remotePath}`))}),"closed"===d&&(0,F.jsxs)($.Button,{variant:"outline",size:"sm",onClick:B,className:"w-full",children:[(0,F.jsx)(eS,{className:"h-4 w-4 mr-1"}),"Add Remote"]}),"pick-server"===d&&(0,F.jsxs)("div",{className:"rounded-md border p-3 space-y-3",children:[(0,F.jsxs)("div",{className:"flex items-center justify-between",children:[(0,F.jsx)("label",{className:"text-xs font-medium",children:"Select a Remote Server"}),(0,F.jsx)($.Button,{variant:"ghost",size:"sm",onClick:P,children:(0,F.jsx)(t6,{className:"h-3.5 w-3.5"})})]}),u.length>0&&(0,F.jsx)("div",{className:"space-y-1",children:u.map(e=>(0,F.jsxs)("button",{className:"flex items-center gap-2 w-full rounded-md p-2 text-sm text-left hover:bg-muted",onClick:()=>{m(e),v(""),h("pick-path")},children:[(0,F.jsx)(n8,{className:"h-4 w-4 text-muted-foreground"}),(0,F.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,F.jsx)("p",{className:"truncate",children:e.name}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:e.url})]})]},e.id))}),(0,F.jsxs)($.Button,{variant:"outline",size:"sm",onClick:()=>{h("new-server"),_(""),b(""),S(""),k("idle"),N("")},className:"w-full",children:[(0,F.jsx)(eS,{className:"h-4 w-4 mr-1"}),"New Server"]})]}),"new-server"===d&&(0,F.jsxs)("div",{className:"rounded-md border p-3 space-y-3",children:[(0,F.jsxs)("div",{className:"flex items-center justify-between",children:[(0,F.jsx)("label",{className:"text-xs font-medium",children:"Create New Server"}),(0,F.jsx)($.Button,{variant:"ghost",size:"sm",onClick:P,children:(0,F.jsx)(t6,{className:"h-3.5 w-3.5"})})]}),(0,F.jsx)(rn,{value:x,onChange:e=>_(e.target.value),placeholder:"Server name"}),(0,F.jsx)(rn,{value:y,onChange:e=>{b(e.target.value),k("idle")},placeholder:"http://remote-server:5173"}),(0,F.jsxs)("div",{className:"flex gap-2",children:[(0,F.jsx)(rn,{type:"password",value:w,onChange:e=>{S(e.target.value),k("idle")},placeholder:"API key",className:"flex-1"}),(0,F.jsx)($.Button,{variant:"outline",size:"sm",onClick:I,disabled:"testing"===C||!y||!w,children:"testing"===C?(0,F.jsx)(n2,{className:"h-4 w-4 animate-spin"}):"success"===C?(0,F.jsx)(rf.Check,{className:"h-4 w-4 text-green-500"}):"error"===C?(0,F.jsx)(t6,{className:"h-4 w-4 text-red-500"}):"Test"})]}),j&&(0,F.jsx)("p",{className:"text-xs text-red-500",children:j}),"success"===C&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)("p",{className:"text-xs text-green-500",children:"Connection successful"}),(0,F.jsx)($.Button,{size:"sm",onClick:O,disabled:!x.trim(),children:"Create & Continue"})]})]}),"pick-path"===d&&p&&(0,F.jsxs)("div",{className:"rounded-md border p-3 space-y-3",children:[(0,F.jsxs)("div",{className:"flex items-center justify-between",children:[(0,F.jsxs)("label",{className:"text-xs font-medium",children:["Select Directory on ",p.name]}),(0,F.jsx)($.Button,{variant:"ghost",size:"sm",onClick:P,children:(0,F.jsx)(t6,{className:"h-3.5 w-3.5"})})]}),(0,F.jsx)(oB,{serverId:p.id,onSelect:e=>{v(e)},selectedPath:g}),g&&(0,F.jsxs)("div",{className:"flex items-center justify-between",children:[(0,F.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Selected: ",(0,F.jsx)("span",{className:"font-mono",children:g})]}),(0,F.jsx)($.Button,{size:"sm",onClick:()=>{p&&g&&(l.some(e=>e.serverId===p.id&&e.remotePath===g)||(c(e=>[...e,{serverId:p.id,serverName:p.name,serverUrl:p.url,remotePath:g}]),i||n(g.split("/").pop()||"")),P())},children:"Add"})]})]})]})]}),M&&(0,F.jsx)("p",{className:"text-sm text-red-500",children:M}),(0,F.jsxs)(rr,{children:[(0,F.jsx)($.Button,{variant:"outline",onClick:()=>L(!1),children:"Cancel"}),(0,F.jsx)($.Button,{onClick:U,disabled:E,children:E?"Creating...":"Create Project"})]})]})})}let oq=(0,ew.default)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),oV=(0,ew.default)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);function oY(){let[e,r]=(0,W.useState)("deepseek"),[s,i]=(0,W.useState)(""),[n,o]=(0,W.useState)(""),[a,l]=(0,W.useState)(""),[c,d]=(0,W.useState)(!0),[h,u]=(0,W.useState)(!1),[f,p]=(0,W.useState)(null),[m,g]=(0,W.useState)(!1),[v,x]=(0,W.useState)(!1);(0,W.useEffect)(()=>{d(!0),rg.api.getChatProviderSettings().then(e=>{r(e.provider),i(e.deepseekApiKey),o(e.openrouterApiKey),l(e.openrouterModel),g(!1),x(!1),d(!1)}).catch(()=>{d(!1)})},[]);let _=async()=>{u(!0),p(null);try{let r={provider:e,openrouterModel:a};m&&(r.deepseekApiKey=s),v&&(r.openrouterApiKey=n);let l=await rg.api.updateChatProviderSettings(r);i(l.deepseekApiKey),o(l.openrouterApiKey),g(!1),x(!1),p("Settings saved"),setTimeout(()=>p(null),2e3)}catch(e){p(e instanceof Error?e.message:"Failed to save")}finally{u(!1)}};return c?(0,F.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,F.jsx)(n2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):(0,F.jsxs)("div",{className:"space-y-4",children:[(0,F.jsxs)("div",{children:[(0,F.jsx)("label",{className:"text-sm font-medium mb-2 block",children:"Provider"}),(0,F.jsx)("div",{className:"space-y-2",children:[["deepseek","DeepSeek","Use DeepSeek API directly"],["openrouter","OpenRouter","Route through OpenRouter (supports many models)"]].map(([s,i,n])=>(0,F.jsxs)("label",{className:`flex items-start gap-3 p-3 rounded-lg border cursor-pointer transition-all duration-150 ${e===s?"border-primary/40 bg-primary/5 shadow-sm":"border-border/60 hover:border-border hover:bg-accent/30"}`,children:[(0,F.jsx)("input",{type:"radio",name:"chatProvider",value:s,checked:e===s,onChange:()=>{r(s),p(null)},className:"mt-0.5"}),(0,F.jsxs)("div",{children:[(0,F.jsx)("div",{className:"text-sm font-medium",children:i}),(0,F.jsx)("div",{className:"text-xs text-muted-foreground",children:n})]})]},s))})]}),"deepseek"===e&&(0,F.jsxs)("div",{children:[(0,F.jsx)("label",{className:"text-sm font-medium mb-1 block",children:"DeepSeek API Key"}),(0,F.jsx)(rn,{type:"password",placeholder:s&&!m?s:"sk-...",value:m?s:"",onChange:e=>{i(e.target.value),g(!0),p(null)}}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"Leave empty to use DEEPSEEK_API_KEY environment variable"})]}),"openrouter"===e&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)("div",{children:[(0,F.jsx)("label",{className:"text-sm font-medium mb-1 block",children:"OpenRouter API Key"}),(0,F.jsx)(rn,{type:"password",placeholder:n&&!v?n:"sk-or-...",value:v?n:"",onChange:e=>{o(e.target.value),x(!0),p(null)}}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"Leave empty to use OPENROUTER_API_KEY environment variable"})]}),(0,F.jsxs)("div",{children:[(0,F.jsx)("label",{className:"text-sm font-medium mb-1 block",children:"Model"}),(0,F.jsx)(rn,{placeholder:"deepseek/deepseek-chat-v3-0324",value:a,onChange:e=>{l(e.target.value),p(null)}}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"OpenRouter model identifier. Leave empty for default."})]})]}),f&&(0,F.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:["Settings saved"===f&&(0,F.jsx)(oq,{className:"h-4 w-4 text-green-500"}),f]}),(0,F.jsx)("div",{className:"flex justify-end pt-2",children:(0,F.jsxs)($.Button,{onClick:_,disabled:h,children:[h&&(0,F.jsx)(n2,{className:"h-4 w-4 mr-1.5 animate-spin"}),"Save"]})})]})}var oX=e.i(276949);let{scrollbackMin:oG,scrollbackMax:oJ,fontSizeMin:oZ,fontSizeMax:oQ}=rg.TERMINAL_SETTINGS_LIMITS;function o0(){let{settings:e,loaded:r,refresh:s}=(0,oX.useTerminalSettings)(),[i,n]=(0,W.useState)(String(rg.DEFAULT_TERMINAL_SETTINGS.scrollback)),[o,a]=(0,W.useState)(String(rg.DEFAULT_TERMINAL_SETTINGS.fontSize)),[l,c]=(0,W.useState)(rg.DEFAULT_TERMINAL_SETTINGS.fontFamily),[d,h]=(0,W.useState)(!1),[u,f]=(0,W.useState)(null);(0,W.useEffect)(()=>{r&&(n(String(e.scrollback)),a(String(e.fontSize)),c(e.fontFamily))},[r,e.scrollback,e.fontSize,e.fontFamily]);let p=parseInt(i,10),m=parseInt(o,10),g=Number.isFinite(p)&&p>=oG&&p<=oJ,v=Number.isFinite(m)&&m>=oZ&&m<=oQ,x=""!==l.trim(),_=g&&v&&x,y=async()=>{if(_){h(!0),f(null);try{let e={scrollback:p,fontSize:m,fontFamily:l.trim()};await rg.api.updateTerminalSettings(e),await s(),f("Settings saved"),setTimeout(()=>f(null),2e3)}catch(e){f(e instanceof Error?e.message:"Failed to save")}finally{h(!1)}}};return r?(0,F.jsxs)("div",{className:"space-y-4",children:[(0,F.jsxs)("div",{children:[(0,F.jsx)("label",{className:"text-sm font-medium mb-1 block",children:"Scrollback (lines)"}),(0,F.jsx)(rn,{type:"number",min:oG,max:oJ,value:i,onChange:e=>{n(e.target.value),f(null)}}),(0,F.jsxs)("p",{className:"text-xs text-muted-foreground mt-1",children:["How many output lines the executor terminal keeps in scroll buffer. Range ",oG,"–",oJ,". Default ",rg.DEFAULT_TERMINAL_SETTINGS.scrollback,"."]})]}),(0,F.jsxs)("div",{children:[(0,F.jsx)("label",{className:"text-sm font-medium mb-1 block",children:"Font size (px)"}),(0,F.jsx)(rn,{type:"number",min:oZ,max:oQ,value:o,onChange:e=>{a(e.target.value),f(null)}}),(0,F.jsxs)("p",{className:"text-xs text-muted-foreground mt-1",children:["Range ",oZ,"–",oQ,". Default ",rg.DEFAULT_TERMINAL_SETTINGS.fontSize,"."]})]}),(0,F.jsxs)("div",{children:[(0,F.jsx)("label",{className:"text-sm font-medium mb-1 block",children:"Font family"}),(0,F.jsx)(rn,{value:l,onChange:e=>{c(e.target.value),f(null)},placeholder:rg.DEFAULT_TERMINAL_SETTINGS.fontFamily}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"CSS font-family list. Use monospace fonts for best alignment."})]}),u&&(0,F.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:["Settings saved"===u&&(0,F.jsx)(oq,{className:"h-4 w-4 text-green-500"}),u]}),(0,F.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[(0,F.jsx)($.Button,{variant:"outline",onClick:()=>{n(String(rg.DEFAULT_TERMINAL_SETTINGS.scrollback)),a(String(rg.DEFAULT_TERMINAL_SETTINGS.fontSize)),c(rg.DEFAULT_TERMINAL_SETTINGS.fontFamily),f(null)},disabled:d,children:"Reset to defaults"}),(0,F.jsxs)($.Button,{onClick:y,disabled:d||!_,children:[d&&(0,F.jsx)(n2,{className:"h-4 w-4 mr-1.5 animate-spin"}),"Save"]})]})]}):(0,F.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,F.jsx)(n2,{className:"h-5 w-5 animate-spin text-muted-foreground"})})}function o1(){let[e,r]=(0,W.useState)("none"),[s,i]=(0,W.useState)(""),[n,o]=(0,W.useState)(""),[a,l]=(0,W.useState)(!0),[c,d]=(0,W.useState)(!1),[h,u]=(0,W.useState)(!1),[f,p]=(0,W.useState)(null),[m,g]=(0,W.useState)(null);(0,W.useEffect)(()=>{l(!0),p(null),g(null),rg.api.getProxySettings().then(e=>{r(e.type),i(e.host),o(e.port?String(e.port):""),l(!1)}).catch(()=>{l(!1)})},[]);let v=()=>({type:e,host:"none"===e?"":s.trim(),port:"none"===e?0:parseInt(n,10)||0}),x=async()=>{u(!0),p(null);try{let e=await rg.api.testProxyConnection(v());p(e)}catch(e){p({success:!1,message:e instanceof Error?e.message:"Test failed"})}finally{u(!1)}},_=async()=>{d(!0),g(null);try{await rg.api.updateProxySettings(v()),g("Settings saved")}catch(e){g(e instanceof Error?e.message:"Failed to save")}finally{d(!1)}},y="none"!==e;return(0,F.jsxs)("div",{className:"h-full flex flex-col overflow-auto",children:[(0,F.jsxs)("div",{className:"border-b border-border/60 px-6 py-4 flex-shrink-0",children:[(0,F.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:"Settings"}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Configure proxy and network settings"})]}),(0,F.jsx)("div",{className:"flex-1 px-6 py-5 flex justify-center",children:(0,F.jsx)("div",{className:"w-full max-w-2xl",children:a?(0,F.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,F.jsx)(n2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):(0,F.jsxs)("div",{className:"space-y-8",children:[(0,F.jsxs)("div",{className:"space-y-4",children:[(0,F.jsx)("h3",{className:"text-sm font-semibold",children:"AI Chat"}),(0,F.jsx)(oY,{})]}),(0,F.jsxs)("div",{className:"space-y-4",children:[(0,F.jsx)("h3",{className:"text-sm font-semibold",children:"Terminal"}),(0,F.jsx)(o0,{})]}),(0,F.jsxs)("div",{className:"space-y-4",children:[(0,F.jsx)("h3",{className:"text-sm font-semibold",children:"Proxy"}),(0,F.jsxs)("div",{children:[(0,F.jsx)("label",{className:"text-sm font-medium mb-2 block",children:"Proxy Type"}),(0,F.jsx)("div",{className:"space-y-2",children:[["none","No Proxy","Direct connection"],["http","HTTP Proxy","Route through HTTP/HTTPS proxy"],["socks5","SOCKS5 Proxy","Route through SOCKS5 proxy"]].map(([s,i,n])=>(0,F.jsxs)("label",{className:`flex items-start gap-3 p-3 rounded-lg border cursor-pointer transition-all duration-150 ${e===s?"border-primary/40 bg-primary/5 shadow-sm":"border-border/60 hover:border-border hover:bg-accent/30"}`,children:[(0,F.jsx)("input",{type:"radio",name:"proxyType",value:s,checked:e===s,onChange:()=>{r(s),p(null),g(null)},className:"mt-0.5"}),(0,F.jsxs)("div",{children:[(0,F.jsx)("div",{className:"text-sm font-medium",children:i}),(0,F.jsx)("div",{className:"text-xs text-muted-foreground",children:n})]})]},s))})]}),y&&(0,F.jsxs)("div",{className:"flex gap-3",children:[(0,F.jsxs)("div",{className:"flex-1",children:[(0,F.jsx)("label",{className:"text-sm font-medium mb-1 block",children:"Host"}),(0,F.jsx)(rn,{placeholder:"127.0.0.1",value:s,onChange:e=>{i(e.target.value),p(null),g(null)}})]}),(0,F.jsxs)("div",{className:"w-24",children:[(0,F.jsx)("label",{className:"text-sm font-medium mb-1 block",children:"Port"}),(0,F.jsx)(rn,{type:"number",placeholder:"1080",value:n,onChange:e=>{o(e.target.value),p(null),g(null)},min:1,max:65535})]})]}),f&&(0,F.jsxs)("div",{className:`flex items-center gap-2 text-sm p-2 rounded-md ${f.success?"text-green-600 bg-green-50 dark:text-green-400 dark:bg-green-950/30":"text-red-600 bg-red-50 dark:text-red-400 dark:bg-red-950/30"}`,children:[f.success?(0,F.jsx)(oq,{className:"h-4 w-4 shrink-0"}):(0,F.jsx)(oV,{className:"h-4 w-4 shrink-0"}),(0,F.jsx)("span",{className:"truncate",children:f.message})]}),m&&!f&&(0,F.jsx)("div",{className:"text-sm text-muted-foreground text-center",children:m}),(0,F.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[y&&(0,F.jsxs)($.Button,{variant:"outline",onClick:x,disabled:h||!s.trim()||!n,children:[h&&(0,F.jsx)(n2,{className:"h-4 w-4 mr-1.5 animate-spin"}),"Test Connection"]}),(0,F.jsxs)($.Button,{onClick:_,disabled:c,children:[c&&(0,F.jsx)(n2,{className:"h-4 w-4 mr-1.5 animate-spin"}),"Save"]})]})]})]})})})]})}function o2({className:e,...r}){return(0,F.jsx)("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:(0,F.jsx)("table",{"data-slot":"table",className:(0,ey.cn)("w-full caption-bottom text-sm",e),...r})})}function o5({className:e,...r}){return(0,F.jsx)("thead",{"data-slot":"table-header",className:(0,ey.cn)("[&_tr]:border-b",e),...r})}function o3({className:e,...r}){return(0,F.jsx)("tbody",{"data-slot":"table-body",className:(0,ey.cn)("[&_tr:last-child]:border-0",e),...r})}function o4({className:e,...r}){return(0,F.jsx)("tr",{"data-slot":"table-row",className:(0,ey.cn)("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",e),...r})}function o6({className:e,...r}){return(0,F.jsx)("th",{"data-slot":"table-head",className:(0,ey.cn)("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...r})}function o8({className:e,...r}){return(0,F.jsx)("td",{"data-slot":"table-cell",className:(0,ey.cn)("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...r})}let o7=(0,ew.default)("plug-zap",[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]]),o9=(0,ew.default)("key-round",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);var ae=e.i(710307);let at={name:"",url:"",apiKey:"",connectionMode:"outbound"};function ar(){let[e,r]=(0,W.useState)([]),[s,i]=(0,W.useState)(!0),[n,o]=(0,W.useState)(""),[a,l]=(0,W.useState)(!1),[c,d]=(0,W.useState)(null),[h,u]=(0,W.useState)(at),[f,p]=(0,W.useState)(""),[m,g]=(0,W.useState)(!1),[v,x]=(0,W.useState)(null),[_,y]=(0,W.useState)(!1),[b,w]=(0,W.useState)({}),[S,C]=(0,W.useState)({}),[k,j]=(0,W.useState)(null),[N,E]=(0,W.useState)(null),[R,M]=(0,W.useState)(null),[D,T]=(0,W.useState)(!1),[P,L]=(0,W.useState)(!1),A=(0,W.useCallback)(async()=>{try{let e=await rg.api.getRemoteServers();r(e),o("")}catch(e){o(e instanceof Error?e.message:"Failed to load servers")}finally{i(!1)}},[]);(0,W.useEffect)(()=>{A()},[A]),(0,W.useEffect)(()=>{let e=setInterval(A,15e3),r=()=>A();return window.addEventListener("focus",r),()=>{clearInterval(e),window.removeEventListener("focus",r)}},[A]);let B=async()=>{if(!h.name.trim())return void p("Name is required");if("outbound"===h.connectionMode&&!h.url.trim())return void p("URL is required for outbound servers");g(!0),p("");try{if(c){let e={};h.name.trim()!==c.name&&(e.name=h.name.trim()),h.url.trim()!==(c.url||"")&&(e.url=h.url.trim()),h.apiKey.trim()&&(e.apiKey=h.apiKey.trim()),await rg.api.updateRemoteServer(c.id,e)}else await rg.api.createRemoteServer({name:h.name.trim(),url:h.url.trim(),...h.apiKey.trim()?{apiKey:h.apiKey.trim()}:{},connectionMode:h.connectionMode});l(!1),await A()}catch(e){p(e instanceof Error?e.message:"Failed to save server")}finally{g(!1)}},I=async()=>{if(v){y(!0);try{await rg.api.deleteRemoteServer(v.id),x(null),await A()}catch(e){p(e instanceof Error?e.message:"Failed to delete server")}finally{y(!1)}}},O=async e=>{w(r=>({...r,[e.id]:"testing"})),C(r=>{let s={...r};return delete s[e.id],s});try{let r=await rg.api.testRemoteServer(e.id);w(s=>({...s,[e.id]:r.success?"success":"error"})),r.success||C(r=>({...r,[e.id]:"Connection failed"}))}catch(r){w(r=>({...r,[e.id]:"error"})),C(s=>({...s,[e.id]:r instanceof Error?r.message:"Test failed"}))}},z=async e=>{j(e),E(null),M(null),L(!1),T(!0);try{let r=await rg.api.generateRemoteServerToken(e.id);E(r.token),M(r.connectCommand)}catch(e){p(e instanceof Error?e.message:"Failed to generate token"),j(null)}finally{T(!1)}},H=async e=>{try{await rg.api.revokeRemoteServerToken(e.id),await A()}catch(e){o(e instanceof Error?e.message:"Failed to revoke token")}};return s?(0,F.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,F.jsx)(n2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):(0,F.jsxs)("div",{className:"space-y-4",children:[(0,F.jsxs)("div",{className:"flex items-center justify-between",children:[(0,F.jsxs)("div",{children:[(0,F.jsx)("h3",{className:"text-sm font-medium",children:"Remote Servers"}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground",children:"Manage globally available remote servers"})]}),(0,F.jsxs)($.Button,{variant:"outline",size:"sm",onClick:()=>{d(null),u(at),p(""),l(!0)},children:[(0,F.jsx)(eS,{className:"h-4 w-4 mr-1.5"}),"Add Server"]})]}),n&&(0,F.jsx)("p",{className:"text-sm text-red-500",children:n}),0===e.length?(0,F.jsxs)("div",{className:"text-center py-8 text-sm text-muted-foreground border rounded-md",children:[(0,F.jsx)(rx,{className:"h-8 w-8 mx-auto mb-2 opacity-40"}),"No remote servers configured"]}):(0,F.jsxs)(o2,{children:[(0,F.jsx)(o5,{children:(0,F.jsxs)(o4,{children:[(0,F.jsx)(o6,{children:"Name"}),(0,F.jsx)(o6,{children:"Mode"}),(0,F.jsx)(o6,{children:"URL / Status"}),(0,F.jsx)(o6,{className:"w-[180px] text-right",children:"Actions"})]})}),(0,F.jsx)(o3,{children:e.map(e=>{let r;return(0,F.jsxs)(o4,{children:[(0,F.jsx)(o8,{className:"font-medium",children:(0,F.jsxs)("div",{className:"flex items-center",children:[(e=>{if("inbound"!==e.connection_mode)return null;let r="online"===e.status;return(0,F.jsx)("span",{className:`inline-block h-2.5 w-2.5 rounded-full mr-2 ${r?"bg-green-500":"bg-gray-400"}`,title:r?"Online":"Offline"})})(e),e.name]})}),(0,F.jsx)(o8,{children:(0,F.jsx)("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${"inbound"===e.connection_mode?"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400":"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-400"}`,children:"inbound"===e.connection_mode?"Inbound":"Outbound"})}),(0,F.jsx)(o8,{className:"font-mono text-xs text-muted-foreground",children:"inbound"===e.connection_mode?"online"===e.status?"Connected":"Waiting for connection...":e.url}),(0,F.jsxs)(o8,{className:"text-right",children:[(0,F.jsxs)("div",{className:"flex items-center justify-end gap-1",children:["inbound"===e.connection_mode&&(0,F.jsx)($.Button,{variant:"ghost",size:"icon",onClick:()=>z(e),title:"Generate connect token",className:"h-8 w-8",children:(0,F.jsx)(o9,{className:"h-4 w-4"})}),(r=b[e.id]||"idle",(0,F.jsx)($.Button,{variant:"ghost",size:"icon",onClick:()=>O(e),disabled:"testing"===r,title:"Test connection",className:"h-8 w-8",children:"testing"===r?(0,F.jsx)(n2,{className:"h-4 w-4 animate-spin"}):"success"===r?(0,F.jsx)(rf.Check,{className:"h-4 w-4 text-green-500"}):"error"===r?(0,F.jsx)(t6,{className:"h-4 w-4 text-red-500"}):(0,F.jsx)(o7,{className:"h-4 w-4"})})),(0,F.jsx)($.Button,{variant:"ghost",size:"icon",onClick:()=>{d(e),u({name:e.name,url:e.url||"",apiKey:"",connectionMode:e.connection_mode}),p(""),l(!0)},title:"Edit server",className:"h-8 w-8",children:(0,F.jsx)(rp,{className:"h-4 w-4"})}),(0,F.jsx)($.Button,{variant:"ghost",size:"icon",onClick:()=>x(e),title:"Delete server",className:"h-8 w-8 text-destructive hover:text-destructive",children:(0,F.jsx)(ra,{className:"h-4 w-4"})})]}),S[e.id]&&(0,F.jsx)("p",{className:"text-xs text-red-500 mt-1 text-right",children:S[e.id]})]})]},e.id)})})]}),(0,F.jsx)(t8,{open:a,onOpenChange:l,children:(0,F.jsxs)(re,{className:"sm:max-w-md",children:[(0,F.jsxs)(rt,{children:[(0,F.jsx)(rs,{children:c?"Edit Server":"Add Remote Server"}),(0,F.jsx)(ri,{children:c?"Update the server connection details.":"Add a new remote server to the global registry."})]}),(0,F.jsxs)("div",{className:"space-y-4",children:[!c&&(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Connection Mode"}),(0,F.jsxs)("div",{className:"flex gap-2",children:[(0,F.jsx)($.Button,{type:"button",variant:"outbound"===h.connectionMode?"default":"outline",size:"sm",onClick:()=>u(e=>({...e,connectionMode:"outbound"})),children:"Outbound"}),(0,F.jsx)($.Button,{type:"button",variant:"inbound"===h.connectionMode?"default":"outline",size:"sm",onClick:()=>u(e=>({...e,connectionMode:"inbound"})),children:"Inbound"})]}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground",children:"outbound"===h.connectionMode?"Server connects outbound to the remote node (remote must have a public URL).":"Remote node connects inbound to this server (no public URL needed on remote)."})]}),(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Name"}),(0,F.jsx)(rn,{value:h.name,onChange:e=>{u(r=>({...r,name:e.target.value})),p("")},placeholder:"My Remote Server"})]}),("outbound"===h.connectionMode||c)&&(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsxs)("label",{className:"text-sm font-medium",children:["URL","inbound"!==h.connectionMode||c?"":" (optional)"]}),(0,F.jsx)(rn,{value:h.url,onChange:e=>{u(r=>({...r,url:e.target.value})),p("")},placeholder:"http://remote-server:5173"})]}),"outbound"===h.connectionMode&&(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"API Key"}),(0,F.jsx)(rn,{type:"password",value:h.apiKey,onChange:e=>{u(r=>({...r,apiKey:e.target.value})),p("")},placeholder:c?"(unchanged)":"Optional"})]}),f&&(0,F.jsx)("p",{className:"text-sm text-red-500",children:f})]}),(0,F.jsxs)(rr,{children:[(0,F.jsx)($.Button,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),(0,F.jsxs)($.Button,{onClick:B,disabled:m,children:[m&&(0,F.jsx)(n2,{className:"h-4 w-4 mr-1.5 animate-spin"}),c?"Save Changes":"Add Server"]})]})]})}),(0,F.jsx)(t8,{open:null!==k,onOpenChange:e=>{e||(j(null),E(null),M(null))},children:(0,F.jsxs)(re,{className:"sm:max-w-lg",children:[(0,F.jsxs)(rt,{children:[(0,F.jsx)(rs,{children:"Connect Token"}),(0,F.jsxs)(ri,{children:["Use this token to connect a remote node to"," ",(0,F.jsx)("span",{className:"font-semibold",children:k?.name}),". The token is shown only once."]})]}),D?(0,F.jsx)("div",{className:"flex items-center justify-center py-4",children:(0,F.jsx)(n2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):N?(0,F.jsx)("div",{className:"space-y-4",children:(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Connect Command"}),(0,F.jsxs)("div",{className:"flex gap-2",children:[(0,F.jsx)(rn,{readOnly:!0,value:R||"",className:"font-mono text-xs"}),(0,F.jsx)($.Button,{variant:"outline",size:"icon",className:"shrink-0",onClick:()=>{var e;return e=R||"",void(navigator.clipboard.writeText(e),L(!0),setTimeout(()=>L(!1),2e3))},title:"Copy command",children:P?(0,F.jsx)(rf.Check,{className:"h-4 w-4 text-green-500"}):(0,F.jsx)(ae.Copy,{className:"h-4 w-4"})})]}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground",children:"Run this command on the remote machine to establish the reverse connection."})]})}):null,(0,F.jsxs)(rr,{children:[N&&k&&(0,F.jsx)($.Button,{variant:"outline",className:"mr-auto text-destructive hover:text-destructive",onClick:()=>{H(k),j(null),E(null)},children:"Revoke Token"}),(0,F.jsx)($.Button,{variant:"outline",onClick:()=>{j(null),E(null),M(null)},children:"Close"})]})]})}),(0,F.jsx)(t8,{open:null!==v,onOpenChange:e=>{e||x(null)},children:(0,F.jsxs)(re,{className:"sm:max-w-sm",children:[(0,F.jsxs)(rt,{children:[(0,F.jsx)(rs,{children:"Delete Server"}),(0,F.jsxs)(ri,{children:["Are you sure you want to delete"," ",(0,F.jsx)("span",{className:"font-semibold",children:v?.name}),"? This will also remove it from any projects that reference it."]})]}),(0,F.jsxs)(rr,{children:[(0,F.jsx)($.Button,{variant:"outline",onClick:()=>x(null),children:"Cancel"}),(0,F.jsxs)($.Button,{variant:"destructive",onClick:I,disabled:_,children:[_&&(0,F.jsx)(n2,{className:"h-4 w-4 mr-1.5 animate-spin"}),"Delete"]})]})]})})]})}var as=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),ai=W.forwardRef((e,r)=>(0,F.jsx)(er.span,{...e,ref:r,style:{...as,...e.style}}));ai.displayName="VisuallyHidden";var an=[" ","Enter","ArrowUp","ArrowDown"],ao=[" ","Enter"],aa="Select",[al,ac,ad]=rb(aa),[ah,au]=K(aa,[ad,iv]),af=iv(),[ap,am]=ah(aa),[ag,av]=ah(aa),ax=e=>{let{__scopeSelect:r,children:s,open:i,defaultOpen:n,onOpenChange:o,value:a,defaultValue:l,onValueChange:c,dir:d,name:h,autoComplete:u,disabled:f,required:p,form:m}=e,g=af(r),[v,x]=W.useState(null),[_,y]=W.useState(null),[b,w]=W.useState(!1),S=rj(d),[C,k]=X({prop:i,defaultProp:n??!1,onChange:o,caller:aa}),[j,N]=X({prop:a,defaultProp:l,onChange:c,caller:aa}),E=W.useRef(null),R=!v||m||!!v.closest("form"),[M,D]=W.useState(new Set),T=Array.from(M).map(e=>e.props.value).join(";");return(0,F.jsx)(iy,{...g,children:(0,F.jsxs)(ap,{required:p,scope:r,trigger:v,onTriggerChange:x,valueNode:_,onValueNodeChange:y,valueNodeHasChildren:b,onValueNodeHasChildrenChange:w,contentId:ej(),value:j,onValueChange:N,open:C,onOpenChange:k,dir:S,triggerPointerDownPosRef:E,disabled:f,children:[(0,F.jsx)(al.Provider,{scope:r,children:(0,F.jsx)(ag,{scope:e.__scopeSelect,onNativeOptionAdd:W.useCallback(e=>{D(r=>new Set(r).add(e))},[]),onNativeOptionRemove:W.useCallback(e=>{D(r=>{let s=new Set(r);return s.delete(e),s})},[]),children:s})}),R?(0,F.jsxs)(a1,{"aria-hidden":!0,required:p,tabIndex:-1,name:h,autoComplete:u,value:j,onChange:e=>N(e.target.value),disabled:f,form:m,children:[void 0===j?(0,F.jsx)("option",{value:""}):null,Array.from(M)]},T):null]})})};ax.displayName=aa;var a_="SelectTrigger",ay=W.forwardRef((e,r)=>{let{__scopeSelect:s,disabled:i=!1,...n}=e,o=af(s),a=am(a_,s),l=a.disabled||i,c=(0,U.useComposedRefs)(r,a.onTriggerChange),d=ac(s),h=W.useRef("touch"),[u,f,p]=a5(e=>{let r=d().filter(e=>!e.disabled),s=r.find(e=>e.value===a.value),i=a3(r,e,s);void 0!==i&&a.onValueChange(i.value)}),m=e=>{l||(a.onOpenChange(!0),p()),e&&(a.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,F.jsx)(iw,{asChild:!0,...o,children:(0,F.jsx)(er.button,{type:"button",role:"combobox","aria-controls":a.contentId,"aria-expanded":a.open,"aria-required":a.required,"aria-autocomplete":"none",dir:a.dir,"data-state":a.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":a2(a.value)?"":void 0,...n,ref:c,onClick:q(n.onClick,e=>{e.currentTarget.focus(),"mouse"!==h.current&&m(e)}),onPointerDown:q(n.onPointerDown,e=>{h.current=e.pointerType;let r=e.target;r.hasPointerCapture(e.pointerId)&&r.releasePointerCapture(e.pointerId),0===e.button&&!1===e.ctrlKey&&"mouse"===e.pointerType&&(m(e),e.preventDefault())}),onKeyDown:q(n.onKeyDown,e=>{let r=""!==u.current;e.ctrlKey||e.altKey||e.metaKey||1!==e.key.length||f(e.key),(!r||" "!==e.key)&&an.includes(e.key)&&(m(),e.preventDefault())})})})});ay.displayName=a_;var ab="SelectValue",aw=W.forwardRef((e,r)=>{let{__scopeSelect:s,className:i,style:n,children:o,placeholder:a="",...l}=e,c=am(ab,s),{onValueNodeHasChildrenChange:d}=c,h=void 0!==o,u=(0,U.useComposedRefs)(r,c.onValueNodeChange);return V(()=>{d(h)},[d,h]),(0,F.jsx)(er.span,{...l,ref:u,style:{pointerEvents:"none"},children:a2(c.value)?(0,F.jsx)(F.Fragment,{children:a}):o})});aw.displayName=ab;var aS=W.forwardRef((e,r)=>{let{__scopeSelect:s,children:i,...n}=e;return(0,F.jsx)(er.span,{"aria-hidden":!0,...n,ref:r,children:i||"▼"})});aS.displayName="SelectIcon";var aC=e=>(0,F.jsx)(e$,{asChild:!0,...e});aC.displayName="SelectPortal";var ak="SelectContent",aj=W.forwardRef((e,r)=>{let s=am(ak,e.__scopeSelect),[i,n]=W.useState();return(V(()=>{n(new DocumentFragment)},[]),s.open)?(0,F.jsx)(aM,{...e,ref:r}):i?ee.createPortal((0,F.jsx)(aN,{scope:e.__scopeSelect,children:(0,F.jsx)(al.Slot,{scope:e.__scopeSelect,children:(0,F.jsx)("div",{children:e.children})})}),i):null});aj.displayName=ak;var[aN,aE]=ah(ak),aR=(0,et.createSlot)("SelectContent.RemoveScroll"),aM=W.forwardRef((e,r)=>{let{__scopeSelect:s,position:i="item-aligned",onCloseAutoFocus:n,onEscapeKeyDown:o,onPointerDownOutside:a,side:l,sideOffset:c,align:d,alignOffset:h,arrowPadding:u,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:g,avoidCollisions:v,...x}=e,_=am(ak,s),[y,b]=W.useState(null),[w,S]=W.useState(null),C=(0,U.useComposedRefs)(r,e=>b(e)),[k,j]=W.useState(null),[N,E]=W.useState(null),R=ac(s),[M,D]=W.useState(!1),T=W.useRef(!1);W.useEffect(()=>{if(y)return tN(y)},[y]),eU();let P=W.useCallback(e=>{let[r,...s]=R().map(e=>e.ref.current),[i]=s.slice(-1),n=document.activeElement;for(let s of e)if(s===n||(s?.scrollIntoView({block:"nearest"}),s===r&&w&&(w.scrollTop=0),s===i&&w&&(w.scrollTop=w.scrollHeight),s?.focus(),document.activeElement!==n))return},[R,w]),L=W.useCallback(()=>P([k,y]),[P,k,y]);W.useEffect(()=>{M&&L()},[M,L]);let{onOpenChange:A,triggerPointerDownPosRef:B}=_;W.useEffect(()=>{if(y){let e={x:0,y:0},r=r=>{e={x:Math.abs(Math.round(r.pageX)-(B.current?.x??0)),y:Math.abs(Math.round(r.pageY)-(B.current?.y??0))}},s=s=>{e.x<=10&&e.y<=10?s.preventDefault():y.contains(s.target)||A(!1),document.removeEventListener("pointermove",r),B.current=null};return null!==B.current&&(document.addEventListener("pointermove",r),document.addEventListener("pointerup",s,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",r),document.removeEventListener("pointerup",s,{capture:!0})}}},[y,A,B]),W.useEffect(()=>{let e=()=>A(!1);return window.addEventListener("blur",e),window.addEventListener("resize",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("resize",e)}},[A]);let[I,O]=a5(e=>{let r=R().filter(e=>!e.disabled),s=r.find(e=>e.ref.current===document.activeElement),i=a3(r,e,s);i&&setTimeout(()=>i.ref.current.focus())}),z=W.useCallback((e,r,s)=>{let i=!T.current&&!s;(void 0!==_.value&&_.value===r||i)&&(j(e),i&&(T.current=!0))},[_.value]),$=W.useCallback(()=>y?.focus(),[y]),H=W.useCallback((e,r,s)=>{let i=!T.current&&!s;(void 0!==_.value&&_.value===r||i)&&E(e)},[_.value]),K="popper"===i?aT:aD,V=K===aT?{side:l,sideOffset:c,align:d,alignOffset:h,arrowPadding:u,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:g,avoidCollisions:v}:{};return(0,F.jsx)(aN,{scope:s,content:y,viewport:w,onViewportChange:S,itemRefCallback:z,selectedItem:k,onItemLeave:$,itemTextRefCallback:H,focusSelectedItem:L,selectedItemText:N,position:i,isPositioned:M,searchRef:I,children:(0,F.jsx)(ty,{as:aR,allowPinchZoom:!0,children:(0,F.jsx)(eB,{asChild:!0,trapped:_.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:q(n,e=>{_.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,F.jsx)(eM,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:a,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>_.onOpenChange(!1),children:(0,F.jsx)(K,{role:"listbox",id:_.contentId,"data-state":_.open?"open":"closed",dir:_.dir,onContextMenu:e=>e.preventDefault(),...x,...V,onPlaced:()=>D(!0),ref:C,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:q(x.onKeyDown,e=>{let r=e.ctrlKey||e.altKey||e.metaKey;if("Tab"===e.key&&e.preventDefault(),r||1!==e.key.length||O(e.key),["ArrowUp","ArrowDown","Home","End"].includes(e.key)){let r=R().filter(e=>!e.disabled).map(e=>e.ref.current);if(["ArrowUp","End"].includes(e.key)&&(r=r.slice().reverse()),["ArrowUp","ArrowDown"].includes(e.key)){let s=e.target,i=r.indexOf(s);r=r.slice(i+1)}setTimeout(()=>P(r)),e.preventDefault()}})})})})})})});aM.displayName="SelectContentImpl";var aD=W.forwardRef((e,r)=>{let{__scopeSelect:s,onPlaced:i,...n}=e,o=am(ak,s),a=aE(ak,s),[l,c]=W.useState(null),[d,h]=W.useState(null),u=(0,U.useComposedRefs)(r,e=>h(e)),f=ac(s),p=W.useRef(!1),m=W.useRef(!0),{viewport:g,selectedItem:v,selectedItemText:x,focusSelectedItem:_}=a,y=W.useCallback(()=>{if(o.trigger&&o.valueNode&&l&&d&&g&&v&&x){let e=o.trigger.getBoundingClientRect(),r=d.getBoundingClientRect(),s=o.valueNode.getBoundingClientRect(),n=x.getBoundingClientRect();if("rtl"!==o.dir){let i=n.left-r.left,o=s.left-i,a=e.left-o,c=e.width+a,d=Math.max(c,r.width),h=n7(o,[10,Math.max(10,window.innerWidth-10-d)]);l.style.minWidth=c+"px",l.style.left=h+"px"}else{let i=r.right-n.right,o=window.innerWidth-s.right-i,a=window.innerWidth-e.right-o,c=e.width+a,d=Math.max(c,r.width),h=n7(o,[10,Math.max(10,window.innerWidth-10-d)]);l.style.minWidth=c+"px",l.style.right=h+"px"}let a=f(),c=window.innerHeight-20,h=g.scrollHeight,u=window.getComputedStyle(d),m=parseInt(u.borderTopWidth,10),_=parseInt(u.paddingTop,10),y=parseInt(u.borderBottomWidth,10),b=m+_+h+parseInt(u.paddingBottom,10)+y,w=Math.min(5*v.offsetHeight,b),S=window.getComputedStyle(g),C=parseInt(S.paddingTop,10),k=parseInt(S.paddingBottom,10),j=e.top+e.height/2-10,N=v.offsetHeight/2,E=m+_+(v.offsetTop+N);if(E<=j){let e=a.length>0&&v===a[a.length-1].ref.current;l.style.bottom="0px";let r=Math.max(c-j,N+(e?k:0)+(d.clientHeight-g.offsetTop-g.offsetHeight)+y);l.style.height=E+r+"px"}else{let e=a.length>0&&v===a[0].ref.current;l.style.top="0px";let r=Math.max(j,m+g.offsetTop+(e?C:0)+N);l.style.height=r+(b-E)+"px",g.scrollTop=E-j+g.offsetTop}l.style.margin="10px 0",l.style.minHeight=w+"px",l.style.maxHeight=c+"px",i?.(),requestAnimationFrame(()=>p.current=!0)}},[f,o.trigger,o.valueNode,l,d,g,v,x,o.dir,i]);V(()=>y(),[y]);let[b,w]=W.useState();V(()=>{d&&w(window.getComputedStyle(d).zIndex)},[d]);let S=W.useCallback(e=>{e&&!0===m.current&&(y(),_?.(),m.current=!1)},[y,_]);return(0,F.jsx)(aP,{scope:s,contentWrapper:l,shouldExpandOnScrollRef:p,onScrollButtonChange:S,children:(0,F.jsx)("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:b},children:(0,F.jsx)(er.div,{...n,ref:u,style:{boxSizing:"border-box",maxHeight:"100%",...n.style}})})})});aD.displayName="SelectItemAlignedPosition";var aT=W.forwardRef((e,r)=>{let{__scopeSelect:s,align:i="start",collisionPadding:n=10,...o}=e,a=af(s);return(0,F.jsx)(ij,{...a,...o,ref:r,align:i,collisionPadding:n,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});aT.displayName="SelectPopperPosition";var[aP,aL]=ah(ak,{}),aA="SelectViewport",aB=W.forwardRef((e,r)=>{let{__scopeSelect:s,nonce:i,...n}=e,o=aE(aA,s),a=aL(aA,s),l=(0,U.useComposedRefs)(r,o.onViewportChange),c=W.useRef(0);return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),(0,F.jsx)(al.Slot,{scope:s,children:(0,F.jsx)(er.div,{"data-radix-select-viewport":"",role:"presentation",...n,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...n.style},onScroll:q(n.onScroll,e=>{let r=e.currentTarget,{contentWrapper:s,shouldExpandOnScrollRef:i}=a;if(i?.current&&s){let e=Math.abs(c.current-r.scrollTop);if(e>0){let i=window.innerHeight-20,n=Math.max(parseFloat(s.style.minHeight),parseFloat(s.style.height));if(n<i){let o=n+e,a=Math.min(i,o),l=o-a;s.style.height=a+"px","0px"===s.style.bottom&&(r.scrollTop=l>0?l:0,s.style.justifyContent="flex-end")}}}c.current=r.scrollTop})})})]})});aB.displayName=aA;var aI="SelectGroup",[aO,az]=ah(aI);W.forwardRef((e,r)=>{let{__scopeSelect:s,...i}=e,n=ej();return(0,F.jsx)(aO,{scope:s,id:n,children:(0,F.jsx)(er.div,{role:"group","aria-labelledby":n,...i,ref:r})})}).displayName=aI;var aF="SelectLabel";W.forwardRef((e,r)=>{let{__scopeSelect:s,...i}=e,n=az(aF,s);return(0,F.jsx)(er.div,{id:n.id,...i,ref:r})}).displayName=aF;var aW="SelectItem",[a$,aH]=ah(aW),aU=W.forwardRef((e,r)=>{let{__scopeSelect:s,value:i,disabled:n=!1,textValue:o,...a}=e,l=am(aW,s),c=aE(aW,s),d=l.value===i,[h,u]=W.useState(o??""),[f,p]=W.useState(!1),m=(0,U.useComposedRefs)(r,e=>c.itemRefCallback?.(e,i,n)),g=ej(),v=W.useRef("touch"),x=()=>{n||(l.onValueChange(i),l.onOpenChange(!1))};if(""===i)throw Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return(0,F.jsx)(a$,{scope:s,value:i,disabled:n,textId:g,isSelected:d,onItemTextChange:W.useCallback(e=>{u(r=>r||(e?.textContent??"").trim())},[]),children:(0,F.jsx)(al.ItemSlot,{scope:s,value:i,disabled:n,textValue:h,children:(0,F.jsx)(er.div,{role:"option","aria-labelledby":g,"data-highlighted":f?"":void 0,"aria-selected":d&&f,"data-state":d?"checked":"unchecked","aria-disabled":n||void 0,"data-disabled":n?"":void 0,tabIndex:n?void 0:-1,...a,ref:m,onFocus:q(a.onFocus,()=>p(!0)),onBlur:q(a.onBlur,()=>p(!1)),onClick:q(a.onClick,()=>{"mouse"!==v.current&&x()}),onPointerUp:q(a.onPointerUp,()=>{"mouse"===v.current&&x()}),onPointerDown:q(a.onPointerDown,e=>{v.current=e.pointerType}),onPointerMove:q(a.onPointerMove,e=>{v.current=e.pointerType,n?c.onItemLeave?.():"mouse"===v.current&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:q(a.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:q(a.onKeyDown,e=>{(c.searchRef?.current===""||" "!==e.key)&&(ao.includes(e.key)&&x()," "===e.key&&e.preventDefault())})})})})});aU.displayName=aW;var aK="SelectItemText",aq=W.forwardRef((e,r)=>{let{__scopeSelect:s,className:i,style:n,...o}=e,a=am(aK,s),l=aE(aK,s),c=aH(aK,s),d=av(aK,s),[h,u]=W.useState(null),f=(0,U.useComposedRefs)(r,e=>u(e),c.onItemTextChange,e=>l.itemTextRefCallback?.(e,c.value,c.disabled)),p=h?.textContent,m=W.useMemo(()=>(0,F.jsx)("option",{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:g,onNativeOptionRemove:v}=d;return V(()=>(g(m),()=>v(m)),[g,v,m]),(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(er.span,{id:c.textId,...o,ref:f}),c.isSelected&&a.valueNode&&!a.valueNodeHasChildren?ee.createPortal(o.children,a.valueNode):null]})});aq.displayName=aK;var aV="SelectItemIndicator",aY=W.forwardRef((e,r)=>{let{__scopeSelect:s,...i}=e;return aH(aV,s).isSelected?(0,F.jsx)(er.span,{"aria-hidden":!0,...i,ref:r}):null});aY.displayName=aV;var aX="SelectScrollUpButton",aG=W.forwardRef((e,r)=>{let s=aE(aX,e.__scopeSelect),i=aL(aX,e.__scopeSelect),[n,o]=W.useState(!1),a=(0,U.useComposedRefs)(r,i.onScrollButtonChange);return V(()=>{if(s.viewport&&s.isPositioned){let e=function(){o(r.scrollTop>0)},r=s.viewport;return e(),r.addEventListener("scroll",e),()=>r.removeEventListener("scroll",e)}},[s.viewport,s.isPositioned]),n?(0,F.jsx)(aQ,{...e,ref:a,onAutoScroll:()=>{let{viewport:e,selectedItem:r}=s;e&&r&&(e.scrollTop=e.scrollTop-r.offsetHeight)}}):null});aG.displayName=aX;var aJ="SelectScrollDownButton",aZ=W.forwardRef((e,r)=>{let s=aE(aJ,e.__scopeSelect),i=aL(aJ,e.__scopeSelect),[n,o]=W.useState(!1),a=(0,U.useComposedRefs)(r,i.onScrollButtonChange);return V(()=>{if(s.viewport&&s.isPositioned){let e=function(){let e=r.scrollHeight-r.clientHeight;o(Math.ceil(r.scrollTop)<e)},r=s.viewport;return e(),r.addEventListener("scroll",e),()=>r.removeEventListener("scroll",e)}},[s.viewport,s.isPositioned]),n?(0,F.jsx)(aQ,{...e,ref:a,onAutoScroll:()=>{let{viewport:e,selectedItem:r}=s;e&&r&&(e.scrollTop=e.scrollTop+r.offsetHeight)}}):null});aZ.displayName=aJ;var aQ=W.forwardRef((e,r)=>{let{__scopeSelect:s,onAutoScroll:i,...n}=e,o=aE("SelectScrollButton",s),a=W.useRef(null),l=ac(s),c=W.useCallback(()=>{null!==a.current&&(window.clearInterval(a.current),a.current=null)},[]);return W.useEffect(()=>()=>c(),[c]),V(()=>{let e=l().find(e=>e.ref.current===document.activeElement);e?.ref.current?.scrollIntoView({block:"nearest"})},[l]),(0,F.jsx)(er.div,{"aria-hidden":!0,...n,ref:r,style:{flexShrink:0,...n.style},onPointerDown:q(n.onPointerDown,()=>{null===a.current&&(a.current=window.setInterval(i,50))}),onPointerMove:q(n.onPointerMove,()=>{o.onItemLeave?.(),null===a.current&&(a.current=window.setInterval(i,50))}),onPointerLeave:q(n.onPointerLeave,()=>{c()})})});W.forwardRef((e,r)=>{let{__scopeSelect:s,...i}=e;return(0,F.jsx)(er.div,{"aria-hidden":!0,...i,ref:r})}).displayName="SelectSeparator";var a0="SelectArrow";W.forwardRef((e,r)=>{let{__scopeSelect:s,...i}=e,n=af(s),o=am(a0,s),a=aE(a0,s);return o.open&&"popper"===a.position?(0,F.jsx)(iR,{...n,...i,ref:r}):null}).displayName=a0;var a1=W.forwardRef(({__scopeSelect:e,value:r,...s},i)=>{let n=W.useRef(null),o=(0,U.useComposedRefs)(i,n),a=G(r);return W.useEffect(()=>{let e=n.current;if(!e)return;let s=Object.getOwnPropertyDescriptor(window.HTMLSelectElement.prototype,"value").set;if(a!==r&&s){let i=new Event("change",{bubbles:!0});s.call(e,r),e.dispatchEvent(i)}},[a,r]),(0,F.jsx)(er.select,{...s,style:{...as,...s.style},ref:o,defaultValue:r})});function a2(e){return""===e||void 0===e}function a5(e){let r=eN(e),s=W.useRef(""),i=W.useRef(0),n=W.useCallback(e=>{let n=s.current+e;r(n),function e(r){s.current=r,window.clearTimeout(i.current),""!==r&&(i.current=window.setTimeout(()=>e(""),1e3))}(n)},[r]),o=W.useCallback(()=>{s.current="",window.clearTimeout(i.current)},[]);return W.useEffect(()=>()=>window.clearTimeout(i.current),[]),[s,n,o]}function a3(e,r,s){var i,n;let o=r.length>1&&Array.from(r).every(e=>e===r[0])?r[0]:r,a=s?e.indexOf(s):-1,l=(i=e,n=Math.max(a,0),i.map((e,r)=>i[(n+r)%i.length]));1===o.length&&(l=l.filter(e=>e!==s));let c=l.find(e=>e.textValue.toLowerCase().startsWith(o.toLowerCase()));return c!==s?c:void 0}a1.displayName="SelectBubbleInput";var H=H;function a4({...e}){return(0,F.jsx)(ax,{"data-slot":"select",...e})}function a6({...e}){return(0,F.jsx)(aw,{"data-slot":"select-value",...e})}function a8({className:e,size:r="default",children:s,...i}){return(0,F.jsxs)(ay,{"data-slot":"select-trigger","data-size":r,className:(0,ey.cn)("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...i,children:[s,(0,F.jsx)(aS,{asChild:!0,children:(0,F.jsx)(r7,{className:"size-4 opacity-50"})})]})}function a7({className:e,children:r,position:s="item-aligned",align:i="center",...n}){return(0,F.jsx)(aC,{children:(0,F.jsxs)(aj,{"data-slot":"select-content",className:(0,ey.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 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 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md","popper"===s&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:s,align:i,...n,children:[(0,F.jsx)(le,{}),(0,F.jsx)(aB,{className:(0,ey.cn)("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:r}),(0,F.jsx)(lt,{})]})})}function a9({className:e,children:r,...s}){return(0,F.jsxs)(aU,{"data-slot":"select-item",className:(0,ey.cn)("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...s,children:[(0,F.jsx)("span",{"data-slot":"select-item-indicator",className:"absolute right-2 flex size-3.5 items-center justify-center",children:(0,F.jsx)(aY,{children:(0,F.jsx)(H.default,{className:"size-4"})})}),(0,F.jsx)(aq,{children:r})]})}function le({className:e,...r}){return(0,F.jsx)(aG,{"data-slot":"select-scroll-up-button",className:(0,ey.cn)("flex cursor-default items-center justify-center py-1",e),...r,children:(0,F.jsx)(oA,{className:"size-4"})})}function lt({className:e,...r}){return(0,F.jsx)(aZ,{"data-slot":"select-scroll-down-button",className:(0,ey.cn)("flex cursor-default items-center justify-center py-1",e),...r,children:(0,F.jsx)(r7,{className:"size-4"})})}function lr({projectId:e,project:r,open:s,onOpenChange:i,onWorktreeCreated:n}){let[o,a]=(0,W.useState)(""),[l,c]=(0,W.useState)(!1),[d,h]=(0,W.useState)(null),[u,f]=(0,W.useState)(null),[p,m]=(0,W.useState)(!0),[g,v]=(0,W.useState)(!0),[x,_]=(0,W.useState)([]),[y,b]=(0,W.useState)([]),[w,S]=(0,W.useState)("main"),[C,k]=(0,W.useState)("main"),[j,N]=(0,W.useState)(!1),E=!!(r.path&&r.remote_path);(0,W.useEffect)(()=>{s&&(N(!0),E?Promise.all([rg.api.getProjectBranches(e,"local"),rg.api.getProjectBranches(e,"remote")]).then(([e,r])=>{_(e),b(r),S(e.includes("main")?"main":e[0]||"main"),k(r.includes("main")?"main":r[0]||"main"),N(!1)}):rg.api.getProjectBranches(e).then(e=>{_(e),S(e.includes("main")?"main":e[0]||"main"),N(!1)}))},[s,e,E]);let R=async()=>{if(o.trim()){c(!0),h(null),f(null);try{let r;E&&(r=[],p&&r.push("local"),g&&r.push("remote"));let s=await rg.api.createWorktree(e,o.trim(),r,w,E?C:void 0);if(s.partialSuccess){let e,r=s.results?.remote?.success===!1?"remote":"local",i=s.results?.[r],n=i?.error||"Unknown error",o=i?.errorCode,a=i?.requestId;switch(o){case"timeout":e="Connection to remote server timed out. The remote server may be slow or unreachable.";break;case"network_error":e="Cannot connect to remote server. Check that the server is running and the URL is correct.";break;case"auth_error":e="Authentication failed with remote server. Check the API key in project settings.";break;case"server_error":e=`Remote server returned an error: ${n}`;break;default:e=`Worktree created locally, but ${r} creation failed: ${n}`}a&&(e+=` (Request ID: ${a})`),f(e)}n(s.worktree.branch),s.partialSuccess||(i(!1),a(""))}catch(e){h(e instanceof Error?e.message:"Failed to create worktree")}finally{c(!1)}}},M=e=>{e||(a(""),h(null),f(null),m(!0),v(!0),_([]),b([]),S("main"),k("main")),i(e)},D=(e,r,s,i)=>(0,F.jsxs)(a4,{value:r,onValueChange:s,disabled:i||j,children:[(0,F.jsx)(a8,{size:"sm",children:(0,F.jsx)(a6,{placeholder:j?"Loading...":"Select branch"})}),(0,F.jsx)(a7,{children:e.map(e=>(0,F.jsx)(a9,{value:e,children:e},e))})]});return(0,F.jsx)(t8,{open:s,onOpenChange:M,children:(0,F.jsxs)(re,{children:[(0,F.jsxs)(rt,{children:[(0,F.jsx)(rs,{children:"Create New Worktree"}),(0,F.jsx)(ri,{children:"Create a new branch based on an existing branch"})]}),(0,F.jsxs)("div",{className:"space-y-4",children:[(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{htmlFor:"branch-name",className:"text-sm font-medium",children:"Branch Name"}),(0,F.jsx)(rn,{id:"branch-name",placeholder:"feature/my-feature",value:o,onChange:e=>a(e.target.value),disabled:l,onKeyDown:e=>{"Enter"===e.key&&o.trim()&&(!E||p||g)&&R()}})]}),E?(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Create On"}),(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsxs)("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[(0,F.jsx)("input",{type:"checkbox",checked:p,onChange:e=>{(e.target.checked||g)&&m(e.target.checked)},disabled:l,className:"h-4 w-4 rounded border-input accent-primary"}),(0,F.jsx)("span",{children:"Local"}),(0,F.jsx)("span",{className:"text-muted-foreground truncate text-xs",children:r.path})]}),p&&x.length>0&&(0,F.jsxs)("div",{className:"ml-6",children:[(0,F.jsx)("label",{className:"text-xs text-muted-foreground",children:"Base Branch"}),D(x,w,S,l)]}),(0,F.jsxs)("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[(0,F.jsx)("input",{type:"checkbox",checked:g,onChange:e=>{(e.target.checked||p)&&v(e.target.checked)},disabled:l,className:"h-4 w-4 rounded border-input accent-primary"}),(0,F.jsx)("span",{children:"Remote"}),(0,F.jsx)("span",{className:"text-muted-foreground truncate text-xs",children:r.remote_path})]}),g&&y.length>0&&(0,F.jsxs)("div",{className:"ml-6",children:[(0,F.jsx)("label",{className:"text-xs text-muted-foreground",children:"Base Branch"}),D(y,C,k,l)]})]})]}):x.length>0&&(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Base Branch"}),D(x,w,S,l)]}),u&&(0,F.jsx)("div",{className:"text-sm text-yellow-600 dark:text-yellow-500 bg-yellow-500/10 px-3 py-2 rounded-md",children:u}),d&&(0,F.jsx)("div",{className:"text-sm text-destructive bg-destructive/10 px-3 py-2 rounded-md",children:d})]}),(0,F.jsxs)(rr,{children:[(0,F.jsx)($.Button,{variant:"outline",onClick:()=>M(!1),disabled:l,children:"Cancel"}),(0,F.jsx)($.Button,{onClick:R,disabled:!o.trim()||l||E&&!p&&!g,children:l?"Creating...":"Create"})]})]})})}function ls({projectId:e,worktree:r,open:s,onOpenChange:i,onWorktreeDeleted:n}){let[o,a]=(0,W.useState)(!1),[l,c]=(0,W.useState)(null),[d,h]=(0,W.useState)(null),u=async()=>{if(r){a(!0),c(null),h(null);try{let s=await rg.api.deleteWorktree(e,r.branch);if(s.partialSuccess){let e=s.results?.remote?.error||"Unknown error";h(`Local worktree deleted, but remote deletion failed: ${e}`)}n(),s.partialSuccess||i(!1)}catch(e){c(e instanceof Error?e.message:"Failed to delete worktree")}finally{a(!1)}}},f=e=>{e||(c(null),h(null)),i(e)};return(0,F.jsx)(t8,{open:s,onOpenChange:f,children:(0,F.jsxs)(re,{children:[(0,F.jsxs)(rt,{children:[(0,F.jsx)(rs,{children:"Delete Worktree"}),(0,F.jsx)(ri,{children:"Are you sure you want to delete this worktree?"})]}),r&&(0,F.jsx)("div",{className:"space-y-2",children:(0,F.jsxs)("div",{className:"text-sm",children:[(0,F.jsx)("span",{className:"font-medium",children:"Branch:"})," ",(0,F.jsx)("span",{className:"text-muted-foreground",children:r.branch})]})}),d&&(0,F.jsx)("div",{className:"text-sm text-yellow-600 dark:text-yellow-500 bg-yellow-500/10 px-3 py-2 rounded-md",children:d}),l&&(0,F.jsx)("div",{className:"text-sm text-destructive bg-destructive/10 px-3 py-2 rounded-md",children:l}),(0,F.jsxs)(rr,{children:[(0,F.jsx)($.Button,{variant:"outline",onClick:()=>f(!1),disabled:o,children:"Cancel"}),(0,F.jsx)($.Button,{variant:"destructive",onClick:u,disabled:o,children:o?"Deleting...":"Delete"})]})]})})}e.i(247755);var li=e.i(642098),ln=e.i(423917);function lo(){let{config:e}=(0,ln.useAppConfig)();return e?.authEnabled?(0,F.jsx)("div",{className:"flex items-center",children:(0,F.jsx)(li.UserButton,{appearance:{elements:{avatarBox:"h-7 w-7 ring-1 ring-border/60"}}})}):null}let la=(0,ew.default)("git-branch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]),ll=(0,ew.default)("square-terminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]),lc=(0,ew.default)("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);var ld="Collapsible",[lh,lu]=K(ld),[lf,lp]=lh(ld),lm=W.forwardRef((e,r)=>{let{__scopeCollapsible:s,open:i,defaultOpen:n,disabled:o,onOpenChange:a,...l}=e,[c,d]=X({prop:i,defaultProp:n??!1,onChange:a,caller:ld});return(0,F.jsx)(lf,{scope:s,disabled:o,contentId:ej(),open:c,onOpenToggle:W.useCallback(()=>d(e=>!e),[d]),children:(0,F.jsx)(er.div,{"data-state":lb(c),"data-disabled":o?"":void 0,...l,ref:r})})});lm.displayName=ld;var lg="CollapsibleTrigger",lv=W.forwardRef((e,r)=>{let{__scopeCollapsible:s,...i}=e,n=lp(lg,s);return(0,F.jsx)(er.button,{type:"button","aria-controls":n.contentId,"aria-expanded":n.open||!1,"data-state":lb(n.open),"data-disabled":n.disabled?"":void 0,disabled:n.disabled,...i,ref:r,onClick:q(e.onClick,n.onOpenToggle)})});lv.displayName=lg;var lx="CollapsibleContent",l_=W.forwardRef((e,r)=>{let{forceMount:s,...i}=e,n=lp(lx,e.__scopeCollapsible);return(0,F.jsx)(Z,{present:s||n.open,children:({present:e})=>(0,F.jsx)(ly,{...i,ref:r,present:e})})});l_.displayName=lx;var ly=W.forwardRef((e,r)=>{let{__scopeCollapsible:s,present:i,children:n,...o}=e,a=lp(lx,s),[l,c]=W.useState(i),d=W.useRef(null),h=(0,U.useComposedRefs)(r,d),u=W.useRef(0),f=u.current,p=W.useRef(0),m=p.current,g=a.open||l,v=W.useRef(g),x=W.useRef(void 0);return W.useEffect(()=>{let e=requestAnimationFrame(()=>v.current=!1);return()=>cancelAnimationFrame(e)},[]),V(()=>{let e=d.current;if(e){x.current=x.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration="0s",e.style.animationName="none";let r=e.getBoundingClientRect();u.current=r.height,p.current=r.width,v.current||(e.style.transitionDuration=x.current.transitionDuration,e.style.animationName=x.current.animationName),c(i)}},[a.open,i]),(0,F.jsx)(er.div,{"data-state":lb(a.open),"data-disabled":a.disabled?"":void 0,id:a.contentId,hidden:!g,...o,ref:h,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:g&&n})});function lb(e){return e?"open":"closed"}function lw({...e}){return(0,F.jsx)(lm,{"data-slot":"collapsible",...e})}function lS({...e}){return(0,F.jsx)(lv,{"data-slot":"collapsible-trigger",...e})}function lC({...e}){return(0,F.jsx)(l_,{"data-slot":"collapsible-content",...e})}var lk=Symbol.for("react.lazy"),lj=W[" use ".trim().toString()];function lN(e){var r;return null!=e&&"object"==typeof e&&"$$typeof"in e&&e.$$typeof===lk&&"_payload"in e&&"object"==typeof(r=e._payload)&&null!==r&&"then"in r}function lE(e){var r;let s,i=(r=e,(s=W.forwardRef((e,r)=>{let{children:s,...i}=e;if(lN(s)&&"function"==typeof lj&&(s=lj(s._payload)),W.isValidElement(s)){var n;let e,o,a=(n=s,(o=(e=Object.getOwnPropertyDescriptor(n.props,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?n.ref:(o=(e=Object.getOwnPropertyDescriptor(n,"ref")?.get)&&"isReactWarning"in e&&e.isReactWarning)?n.props.ref:n.props.ref||n.ref),l=function(e,r){let s={...r};for(let i in r){let n=e[i],o=r[i];/^on[A-Z]/.test(i)?n&&o?s[i]=(...e)=>{let r=o(...e);return n(...e),r}:n&&(s[i]=n):"style"===i?s[i]={...n,...o}:"className"===i&&(s[i]=[n,o].filter(Boolean).join(" "))}return{...e,...s}}(i,s.props);return s.type!==W.Fragment&&(l.ref=r?(0,U.composeRefs)(r,a):a),W.cloneElement(s,l)}return W.Children.count(s)>1?W.Children.only(null):null})).displayName=`${r}.SlotClone`,s),n=W.forwardRef((e,r)=>{let{children:s,...n}=e;lN(s)&&"function"==typeof lj&&(s=lj(s._payload));let o=W.Children.toArray(s),a=o.find(lD);if(a){let e=a.props.children,s=o.map(r=>r!==a?r:W.Children.count(e)>1?W.Children.only(null):W.isValidElement(e)?e.props.children:null);return(0,F.jsx)(i,{...n,ref:r,children:W.isValidElement(e)?W.cloneElement(e,void 0,s):null})}return(0,F.jsx)(i,{...n,ref:r,children:s})});return n.displayName=`${e}.Slot`,n}var lR=lE("Slot"),lM=Symbol("radix.slottable");function lD(e){return W.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===lM}var lT=e.i(294237);let lP=(0,lT.cva)("inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function lL({className:e,variant:r,asChild:s=!1,...i}){return(0,F.jsx)(s?lR:"span",{"data-slot":"badge",className:(0,ey.cn)(lP({variant:r}),e),...i})}let lA=(0,ew.default)("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]),lB=(0,ew.default)("ellipsis-vertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]),lI=(0,ew.default)("grip-vertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);var lO=e.i(885101),lz=Object.defineProperty,lF=Object.getOwnPropertyDescriptor,lW=(e,r,s,i)=>{for(var n,o=i>1?void 0:i?lF(r,s):r,a=e.length-1;a>=0;a--)(n=e[a])&&(o=(i?n(r,s,o):n(o))||o);return i&&o&&lz(r,s,o),o},l$=(e,r)=>(s,i)=>r(s,i,e),lH="Terminal input",lU="Too much output to announce, navigate to rows manually to read";function lK(e,r,s,i){var n;n=e=e.replace(/\r?\n/g,"\r"),e=s.decPrivateModes.bracketedPasteMode&&!0!==i.rawOptions.ignoreBracketedPasteMode?"\x1b[200~"+n+"\x1b[201~":n,s.triggerDataEvent(e,!0),r.value=""}function lq(e,r,s){let i=s.getBoundingClientRect(),n=e.clientX-i.left-10,o=e.clientY-i.top-10;r.style.width="20px",r.style.height="20px",r.style.left=`${n}px`,r.style.top=`${o}px`,r.style.zIndex="1000",r.focus()}function lV(e,r,s,i,n){lq(e,r,s),n&&i.rightClickSelect(e),r.value=i.selectionText,r.select()}function lY(e){return e>65535?String.fromCharCode(((e-=65536)>>10)+55296)+String.fromCharCode(e%1024+56320):String.fromCharCode(e)}function lX(e,r=0,s=e.length){let i="";for(let n=r;n<s;++n){let r=e[n];r>65535?(r-=65536,i+=String.fromCharCode((r>>10)+55296)+String.fromCharCode(r%1024+56320)):i+=String.fromCharCode(r)}return i}var lG=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,r){let s=e.length;if(!s)return 0;let i=0,n=0;if(this._interim){let s=e.charCodeAt(n++);56320<=s&&s<=57343?r[i++]=(this._interim-55296)*1024+s-56320+65536:(r[i++]=this._interim,r[i++]=s),this._interim=0}for(let o=n;o<s;++o){let n=e.charCodeAt(o);if(55296<=n&&n<=56319){if(++o>=s)return this._interim=n,i;let a=e.charCodeAt(o);56320<=a&&a<=57343?r[i++]=(n-55296)*1024+a-56320+65536:(r[i++]=n,r[i++]=a);continue}65279!==n&&(r[i++]=n)}return i}},lJ=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,r){let s=e.length;if(!s)return 0;let i=0,n,o,a,l,c=0,d=0;if(this.interim[0]){let n=!1,o=this.interim[0];o&=(224&o)==192?31:(240&o)==224?15:7;let a=0,l;for(;(l=63&this.interim[++a])&&a<4;)o<<=6,o|=l;let c=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,h=c-a;for(;d<h;){if(d>=s)return 0;if((192&(l=e[d++]))!=128){d--,n=!0;break}this.interim[a++]=l,o<<=6,o|=63&l}n||(2===c?o<128?d--:r[i++]=o:3===c?o<2048||o>=55296&&o<=57343||65279===o||(r[i++]=o):o<65536||o>1114111||(r[i++]=o)),this.interim.fill(0)}let h=s-4,u=d;for(;u<s;){for(;u<h&&!(128&(n=e[u]))&&!(128&(o=e[u+1]))&&!(128&(a=e[u+2]))&&!(128&(l=e[u+3]));)r[i++]=n,r[i++]=o,r[i++]=a,r[i++]=l,u+=4;if((n=e[u++])<128)r[i++]=n;else if((224&n)==192){if(u>=s)return this.interim[0]=n,i;if((192&(o=e[u++]))!=128||(c=(31&n)<<6|63&o)<128){u--;continue}r[i++]=c}else if((240&n)==224){if(u>=s)return this.interim[0]=n,i;if((192&(o=e[u++]))!=128){u--;continue}if(u>=s)return this.interim[0]=n,this.interim[1]=o,i;if((192&(a=e[u++]))!=128){u--;continue}if((c=(15&n)<<12|(63&o)<<6|63&a)<2048||c>=55296&&c<=57343||65279===c)continue;r[i++]=c}else if((248&n)==240){if(u>=s)return this.interim[0]=n,i;if((192&(o=e[u++]))!=128){u--;continue}if(u>=s)return this.interim[0]=n,this.interim[1]=o,i;if((192&(a=e[u++]))!=128){u--;continue}if(u>=s)return this.interim[0]=n,this.interim[1]=o,this.interim[2]=a,i;if((192&(l=e[u++]))!=128){u--;continue}if((c=(7&n)<<18|(63&o)<<12|(63&a)<<6|63&l)<65536||c>1114111)continue;r[i++]=c}}return i}},lZ=class e{constructor(){this.fg=0,this.bg=0,this.extended=new lQ}static toColorRGB(e){return[e>>>16&255,e>>>8&255,255&e]}static fromColorRGB(e){return(255&e[0])<<16|(255&e[1])<<8|255&e[2]}clone(){let r=new e;return r.fg=this.fg,r.bg=this.bg,r.extended=this.extended.clone(),r}isInverse(){return 0x4000000&this.fg}isBold(){return 0x8000000&this.fg}isUnderline(){return this.hasExtendedAttrs()&&0!==this.extended.underlineStyle?1:0x10000000&this.fg}isBlink(){return 0x20000000&this.fg}isInvisible(){return 0x40000000&this.fg}isItalic(){return 0x4000000&this.bg}isDim(){return 0x8000000&this.bg}isStrikethrough(){return 0x80000000&this.fg}isProtected(){return 0x20000000&this.bg}isOverline(){return 0x40000000&this.bg}getFgColorMode(){return 0x3000000&this.fg}getBgColorMode(){return 0x3000000&this.bg}isFgRGB(){return(0x3000000&this.fg)==0x3000000}isBgRGB(){return(0x3000000&this.bg)==0x3000000}isFgPalette(){return(0x3000000&this.fg)==0x1000000||(0x3000000&this.fg)==0x2000000}isBgPalette(){return(0x3000000&this.bg)==0x1000000||(0x3000000&this.bg)==0x2000000}isFgDefault(){return(0x3000000&this.fg)==0}isBgDefault(){return(0x3000000&this.bg)==0}isAttributeDefault(){return 0===this.fg&&0===this.bg}getFgColor(){switch(0x3000000&this.fg){case 0x1000000:case 0x2000000:return 255&this.fg;case 0x3000000:return 0xffffff&this.fg;default:return -1}}getBgColor(){switch(0x3000000&this.bg){case 0x1000000:case 0x2000000:return 255&this.bg;case 0x3000000:return 0xffffff&this.bg;default:return -1}}hasExtendedAttrs(){return 0x10000000&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-0x10000001:this.bg|=0x10000000}getUnderlineColor(){if(0x10000000&this.bg&&~this.extended.underlineColor)switch(0x3000000&this.extended.underlineColor){case 0x1000000:case 0x2000000:return 255&this.extended.underlineColor;case 0x3000000:return 0xffffff&this.extended.underlineColor}return this.getFgColor()}getUnderlineColorMode(){return 0x10000000&this.bg&&~this.extended.underlineColor?0x3000000&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0x3000000:this.isFgRGB()}isUnderlineColorPalette(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0x1000000||(0x3000000&this.extended.underlineColor)==0x2000000:this.isFgPalette()}isUnderlineColorDefault(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 0x10000000&this.fg?0x10000000&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},lQ=class e{constructor(e=0,r=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=r}get ext(){return this._urlId?-0x1c000001&this._ext|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(0x1c000000&this._ext)>>26}set underlineStyle(e){this._ext&=-0x1c000001,this._ext|=e<<26&0x1c000000}get underlineColor(){return 0x3ffffff&this._ext}set underlineColor(e){this._ext&=-0x4000000,this._ext|=0x3ffffff&e}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(0xe0000000&this._ext)>>29;return e<0?0xfffffff8^e:e}set underlineVariantOffset(e){this._ext&=0x1fffffff,this._ext|=e<<29&0xe0000000}clone(){return new e(this._ext,this._urlId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId}},l0=class e extends lZ{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new lQ,this.combinedData=""}static fromCharData(r){let s=new e;return s.setFromCharData(r),s}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?lY(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(e){this.fg=e[0],this.bg=0;let r=!1;if(e[1].length>2)r=!0;else if(2===e[1].length){let s=e[1].charCodeAt(0);if(55296<=s&&s<=56319){let i=e[1].charCodeAt(1);56320<=i&&i<=57343?this.content=(s-55296)*1024+i-56320+65536|e[2]<<22:r=!0}else r=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;r&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},l1="di$target",l2="di$dependencies",l5=new Map;function l3(e){if(l5.has(e))return l5.get(e);let r=function(e,s,i){var n,o,a;if(3!=arguments.length)throw Error("@IServiceName-decorator can only be used to decorate a parameter");n=r,o=e,a=i,o[l1]===o?o[l2].push({id:n,index:a}):(o[l2]=[{id:n,index:a}],o[l1]=o)};return r._id=e,l5.set(e,r),r}var l4=l3("BufferService"),l6=l3("CoreMouseService"),l8=l3("CoreService"),l7=l3("CharsetService"),l9=l3("InstantiationService"),ce=l3("LogService"),ct=l3("OptionsService"),cr=l3("OscLinkService"),cs=l3("UnicodeService"),ci=l3("DecorationService"),cn=class{constructor(e,r,s){this._bufferService=e,this._optionsService=r,this._oscLinkService=s}provideLinks(e,r){let s=this._bufferService.buffer.lines.get(e-1);if(!s)return void r(void 0);let i=[],n=this._optionsService.rawOptions.linkHandler,o=new l0,a=s.getTrimmedLength(),l=-1,c=-1,d=!1;for(let r=0;r<a;r++)if(!(-1===c&&!s.hasContent(r))){if(s.loadCell(r,o),o.hasExtendedAttrs()&&o.extended.urlId)if(-1===c){c=r,l=o.extended.urlId;continue}else d=o.extended.urlId!==l;else -1!==c&&(d=!0);if(d||-1!==c&&r===a-1){let s=this._oscLinkService.getLinkData(l)?.uri;if(s){let o={start:{x:c+1,y:e},end:{x:r+ +(!d&&r===a-1),y:e}},l=!1;if(!n?.allowNonHttpProtocols)try{let e=new URL(s);["http:","https:"].includes(e.protocol)||(l=!0)}catch{l=!0}l||i.push({text:s,range:o,activate:(e,r)=>n?n.activate(e,r,o):function(e,r){if(confirm(`Do you want to navigate to ${r}?
6
+
7
+ WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=r}else console.warn("Opening link blocked as opener could not be cleared")}}(0,r),hover:(e,r)=>n?.hover?.(e,r,o),leave:(e,r)=>n?.leave?.(e,r,o)})}d=!1,o.hasExtendedAttrs()&&o.extended.urlId?(c=r,l=o.extended.urlId):(c=-1,l=-1)}}r(i)}};cn=lW([l$(0,l4),l$(1,ct),l$(2,cr)],cn);var co=l3("CharSizeService"),ca=l3("CoreBrowserService"),cl=l3("MouseService"),cc=l3("RenderService"),cd=l3("SelectionService"),ch=l3("CharacterJoinerService"),cu=l3("ThemeService"),cf=l3("LinkProviderService"),cp=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?cx.isErrorNoTelemetry(e)?new cx(e.message+`
8
+
9
+ `+e.stack):Error(e.message+`
10
+
11
+ `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(r=>{r(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 cm(e){var r;(r=e)instanceof cv||r instanceof Error&&r.name===cg&&r.message===cg||cp.onUnexpectedError(e)}var cg="Canceled",cv=class extends Error{constructor(){super(cg),this.name=this.message}},cx=class e extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(r){if(r instanceof e)return r;let s=new e;return s.message=r.message,s.stack=r.stack,s}static isErrorNoTelemetry(e){return"CodeExpectedError"===e.name}},c_=class e extends Error{constructor(r){super(r||"An unexpected bug occurred."),Object.setPrototypeOf(this,e.prototype)}};function cy(e,r=0){return e[e.length-(1+r)]}(cU=cV||={}).isLessThan=function(e){return e<0},cU.isLessThanOrEqual=function(e){return e<=0},cU.isGreaterThan=function(e){return e>0},cU.isNeitherLessOrGreaterThan=function(e){return 0===e},cU.greaterThan=1,cU.lessThan=-1,cU.neitherLessOrGreaterThan=0;var cb=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(r=>(e(r),!0))}toArray(){let e=[];return this.iterate(r=>(e.push(r),!0)),e}filter(r){return new e(e=>this.iterate(s=>!r(s)||e(s)))}map(r){return new e(e=>this.iterate(s=>e(r(s))))}some(e){let r=!1;return this.iterate(s=>!(r=e(s))),r}findFirst(e){let r;return this.iterate(s=>!e(s)||(r=s,!1)),r}findLast(e){let r;return this.iterate(s=>(e(s)&&(r=s),!0)),r}findLastMaxBy(e){let r,s=!0;return this.iterate(i=>((s||cV.isGreaterThan(e(i,r)))&&(s=!1,r=i),!0)),r}};cb.empty=new cb(e=>{});function cw(e){}function cS(e,r){}function cC(e){if(cY.is(e)){let r=[];for(let s of e)if(s)try{s.dispose()}catch(e){r.push(e)}if(1===r.length)throw r[0];if(r.length>1)throw AggregateError(r,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function ck(e){let r={dispose:function(e,r){let s=this,i=!1,n;return function(){if(i)return n;if(i=!0,r)try{n=e.apply(s,arguments)}finally{r()}else n=e.apply(s,arguments);return n}}(()=>{cw(r),e()})};return r}(e=>{function r(e){return e&&"object"==typeof e&&"function"==typeof e[Symbol.iterator]}e.is=r;let s=Object.freeze([]);function*i(e){yield e}e.empty=function(){return s},e.single=i,e.wrap=function(e){return r(e)?e:i(e)},e.from=function(e){return e||s},e.reverse=function*(e){for(let r=e.length-1;r>=0;r--)yield e[r]},e.isEmpty=function(e){return!e||!0===e[Symbol.iterator]().next().done},e.first=function(e){return e[Symbol.iterator]().next().value},e.some=function(e,r){let s=0;for(let i of e)if(r(i,s++))return!0;return!1},e.find=function(e,r){for(let s of e)if(r(s))return s},e.filter=function*(e,r){for(let s of e)r(s)&&(yield s)},e.map=function*(e,r){let s=0;for(let i of e)yield r(i,s++)},e.flatMap=function*(e,r){let s=0;for(let i of e)yield*r(i,s++)},e.concat=function*(...e){for(let r of e)yield*r},e.reduce=function(e,r,s){let i=s;for(let s of e)i=r(i,s);return i},e.slice=function*(e,r,s=e.length){for(r<0&&(r+=e.length),s<0?s+=e.length:s>e.length&&(s=e.length);r<s;r++)yield e[r]},e.consume=function(r,s=1/0){let i=[];if(0===s)return[i,r];let n=r[Symbol.iterator]();for(let r=0;r<s;r++){let r=n.next();if(r.done)return[i,e.empty()];i.push(r.value)}return[i,{[Symbol.iterator]:()=>n}]},e.asyncToArray=async function(e){let r=[];for await(let s of e)r.push(s);return Promise.resolve(r)}})(cY||={});var cj=class e{constructor(){var e;this._toDispose=new Set,this._isDisposed=!1,e=this}dispose(){this._isDisposed||(cw(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{cC(this._toDispose)}finally{this._toDispose.clear()}}add(r){if(!r)return r;if(r===this)throw Error("Cannot register a disposable on itself!");return cS(r,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(r),r}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),cS(e,null))}};cj.DISABLE_DISPOSED_WARNING=!1;var cN=cj,cE=class{constructor(){var e;this._store=new cN,e=this,cS(this._store,this)}dispose(){cw(this),this._store.dispose()}_register(e){if(e===this)throw Error("Cannot register a disposable on itself!");return this._store.add(e)}};cE.None=Object.freeze({dispose(){}});var cR=class{constructor(){var e;this._isDisposed=!1,e=this}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&cS(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,cw(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&cS(e,null),e}},cM="object"==typeof window?window:globalThis,cD=class e{constructor(r){this.element=r,this.next=e.Undefined,this.prev=e.Undefined}};cD.Undefined=new cD(void 0);var cT=class{constructor(){this._first=cD.Undefined,this._last=cD.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===cD.Undefined}clear(){let e=this._first;for(;e!==cD.Undefined;){let r=e.next;e.prev=cD.Undefined,e.next=cD.Undefined,e=r}this._first=cD.Undefined,this._last=cD.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,r){let s=new cD(e);if(this._first===cD.Undefined)this._first=s,this._last=s;else if(r){let e=this._last;this._last=s,s.prev=e,e.next=s}else{let e=this._first;this._first=s,s.next=e,e.prev=s}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(s))}}shift(){if(this._first!==cD.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==cD.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==cD.Undefined&&e.next!==cD.Undefined){let r=e.prev;r.next=e.next,e.next.prev=r}else e.prev===cD.Undefined&&e.next===cD.Undefined?(this._first=cD.Undefined,this._last=cD.Undefined):e.next===cD.Undefined?(this._last=this._last.prev,this._last.next=cD.Undefined):e.prev===cD.Undefined&&(this._first=this._first.next,this._first.prev=cD.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==cD.Undefined;)yield e.element,e=e.next}},cP=globalThis.performance&&"function"==typeof globalThis.performance.now,cL=class e{static create(r){return new e(r)}constructor(e){this._now=cP&&!1===e?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 -1!==this._stopTime?this._stopTime-this._startTime:this._now()-this._startTime}};(e=>{function r(e){}function s(e){return(r,s=null,i)=>{let n=!1,o;return o=e(e=>{if(!n)return o?o.dispose():n=!0,r.call(s,e)},null,i),n&&o.dispose(),o}}function i(e,r,s){return o((s,i=null,n)=>e(e=>s.call(i,r(e)),null,n),s)}function n(e,r,s){return o((s,i=null,n)=>e(e=>r(e)&&s.call(i,e),null,n),s)}function o(e,s){let i,n={onWillAddFirstListener(){i=e(o.fire,o)},onDidRemoveLastListener(){i?.dispose()}};s||r(n);let o=new c2(n);return s?.add(o),o.event}function a(e,s,i=100,n=!1,o=!1,l,c){let d,h,u,f=0,p,m={leakWarningThreshold:l,onWillAddFirstListener(){d=e(e=>{f++,h=s(h,e),n&&!u&&(g.fire(h),h=void 0),p=()=>{let e=h;h=void 0,u=void 0,(!n||f>1)&&g.fire(e),f=0},"number"==typeof i?(clearTimeout(u),u=setTimeout(p,i)):void 0===u&&(u=0,queueMicrotask(p))})},onWillRemoveListener(){o&&f>0&&p?.()},onDidRemoveLastListener(){p=void 0,d.dispose()}};c||r(m);let g=new c2(m);return c?.add(g),g.event}e.None=()=>cE.None,e.defer=function(e,r){return a(e,()=>{},0,void 0,!0,void 0,r)},e.once=s,e.map=i,e.forEach=function(e,r,s){return o((s,i=null,n)=>e(e=>{r(e),s.call(i,e)},null,n),s)},e.filter=n,e.signal=function(e){return e},e.any=function(...e){return(r,s=null,i)=>{var n,o;return n=function(...e){var r,s;let i=ck(()=>cC(e));return r=0,s=0,i}(...e.map(e=>e(e=>r.call(s,e)))),(o=i)instanceof Array?o.push(n):o&&o.add(n),n}},e.reduce=function(e,r,s,n){let o=s;return i(e,e=>o=r(o,e),n)},e.debounce=a,e.accumulate=function(r,s=0,i){return e.debounce(r,(e,r)=>e?(e.push(r),e):[r],s,void 0,!0,void 0,i)},e.latch=function(e,r=(e,r)=>e===r,s){let i=!0,o;return n(e,e=>{let s=i||!r(e,o);return i=!1,o=e,s},s)},e.split=function(r,s,i){return[e.filter(r,s,i),e.filter(r,e=>!s(e),i)]},e.buffer=function(e,r=!1,s=[],i){let n=s.slice(),o=e(e=>{n?n.push(e):l.fire(e)});i&&i.add(o);let a=()=>{n?.forEach(e=>l.fire(e)),n=null},l=new c2({onWillAddFirstListener(){o||(o=e(e=>l.fire(e)),i&&i.add(o))},onDidAddFirstListener(){n&&(r?setTimeout(a):a())},onDidRemoveLastListener(){o&&o.dispose(),o=null}});return i&&i.add(l),l.event},e.chain=function(e,r){return(s,i,n)=>{let o=r(new c);return e(function(e){let r=o.evaluate(e);r!==l&&s.call(i,r)},void 0,n)}};let l=Symbol("HaltChainable");class c{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(r=>(e(r),r)),this}filter(e){return this.steps.push(r=>e(r)?r:l),this}reduce(e,r){let s=r;return this.steps.push(r=>s=e(s,r)),this}latch(e=(e,r)=>e===r){let r=!0,s;return this.steps.push(i=>{let n=r||!e(i,s);return r=!1,s=i,n?i:l}),this}evaluate(e){for(let r of this.steps)if((e=r(e))===l)break;return e}}e.fromNodeEventEmitter=function(e,r,s=e=>e){let i=(...e)=>n.fire(s(...e)),n=new c2({onWillAddFirstListener:()=>e.on(r,i),onDidRemoveLastListener:()=>e.removeListener(r,i)});return n.event},e.fromDOMEventEmitter=function(e,r,s=e=>e){let i=(...e)=>n.fire(s(...e)),n=new c2({onWillAddFirstListener:()=>e.addEventListener(r,i),onDidRemoveLastListener:()=>e.removeEventListener(r,i)});return n.event},e.toPromise=function(e){return new Promise(r=>s(e)(r))},e.fromPromise=function(e){let r=new c2;return e.then(e=>{r.fire(e)},()=>{r.fire(void 0)}).finally(()=>{r.dispose()}),r.event},e.forward=function(e,r){return e(e=>r.fire(e))},e.runAndSubscribe=function(e,r,s){return r(s),e(e=>r(e))};class d{constructor(e,s){this._observable=e,this._counter=0,this._hasChanged=!1;let i={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};s||r(i),this.emitter=new c2(i),s&&s.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,r){this._hasChanged=!0}endUpdate(e){this._counter--,0===this._counter&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}e.fromObservable=function(e,r){return new d(e,r).emitter.event},e.fromObservableLight=function(e){return(r,s,i)=>{let n=0,o=!1,a={beginUpdate(){n++},endUpdate(){0==--n&&(e.reportChanges(),o&&(o=!1,r.call(s)))},handlePossibleChange(){},handleChange(){o=!0}};e.addObserver(a),e.reportChanges();let l={dispose(){e.removeObserver(a)}};return i instanceof cN?i.add(l):Array.isArray(i)&&i.push(l),l}}})(cX||={});var cA=class e{constructor(r){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${r}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new cL,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}}};cA.all=new Set,cA._idPool=0;var cB=class e{constructor(r,s,i=(e._idPool++).toString(16).padStart(3,"0")){this._errorHandler=r,this.threshold=s,this.name=i,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,r){let s=this.threshold;if(s<=0||r<s)return;this._stacks||(this._stacks=new Map);let i=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,i+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=.5*s;let[e,i]=this.getMostFrequentStack(),n=`[${this.name}] potential listener LEAK detected, having ${r} listeners already. MOST frequent listener (${i}):`;console.warn(n),console.warn(e);let o=new cZ(n,e);this._errorHandler(o)}return()=>{let r=this._stacks.get(e.value)||0;this._stacks.set(e.value,r-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,r=0;for(let[s,i]of this._stacks)(!e||r<i)&&(e=[s,i],r=i);return e}};cB._idPool=1;var cI,cO,cz,cF,cW,c$,cH,cU,cK,cq,cV,cY,cX,cG,cJ=class e{constructor(e){this.value=e}static create(){return new e(Error().stack??"")}print(){console.warn(this.value.split(`
12
+ `).slice(2).join(`
13
+ `))}},cZ=class extends Error{constructor(e,r){super(e),this.name="ListenerLeakError",this.stack=r}},cQ=class extends Error{constructor(e,r){super(e),this.name="ListenerRefusalError",this.stack=r}},c0=0,c1=class{constructor(e){this.value=e,this.id=c0++}},c2=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new cB(e?.onListenerError??cm,this._options?.leakWarningThreshold??-1):void 0,this._perfMon=this._options?._profName?new cA(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,r,s)=>{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 r=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],s=new cQ(`${e}. HINT: Stack shows most frequent listener (${r[1]}-times)`,r[0]);return(this._options?.onListenerError||cm)(s),cE.None}if(this._disposed)return cE.None;r&&(e=e.bind(r));let i=new c1(e),n;this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(i.stack=cJ.create(),n=this._leakageMon.check(i.stack,this._size+1)),this._listeners?this._listeners instanceof c1?(this._deliveryQueue??=new c5,this._listeners=[this._listeners,i]):this._listeners.push(i):(this._options?.onWillAddFirstListener?.(this),this._listeners=i,this._options?.onDidAddFirstListener?.(this)),this._size++;let o=ck(()=>{cG?.unregister(o),n?.(),this._removeListener(i)});if(s instanceof cN?s.add(o):Array.isArray(s)&&s.push(o),cG){let e=Error().stack.split(`
14
+ `).slice(2,3).join(`
15
+ `).trim(),r=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);cG.register(o,r?.[2]??e,o)}return o},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(1===this._size){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let r=this._listeners,s=r.indexOf(e);if(-1===s)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--,r[s]=void 0;let i=this._deliveryQueue.current===this;if(2*this._size<=r.length){let e=0;for(let s=0;s<r.length;s++)r[s]?r[e++]=r[s]:i&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);r.length=e}}_deliver(e,r){if(!e)return;let s=this._options?.onListenerError||cm;try{e.value(r)}catch(e){s(e)}}_deliverQueue(e){let r=e.current._listeners;for(;e.i<e.end;)this._deliver(r[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 c1)this._deliver(this._listeners,e);else{let r=this._deliveryQueue;r.enqueue(this,e,this._listeners.length),this._deliverQueue(r)}this._perfMon?.stop()}hasListeners(){return this._size>0}},c5=class{constructor(){this.i=-1,this.end=0}enqueue(e,r,s){this.i=0,this.end=s,this.current=e,this.value=r}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},c3=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new c2,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new c2,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,r){if(this.getZoomLevel(r)===e)return;let s=this.getWindowId(r);this.mapWindowIdToZoomLevel.set(s,e),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,r){this.mapWindowIdToZoomFactor.set(this.getWindowId(r),e)}setFullscreen(e,r){if(this.isFullscreen(r)===e)return;let s=this.getWindowId(r);this.mapWindowIdToFullScreen.set(s,e),this._onDidChangeFullscreen.fire(s)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};c3.INSTANCE=new c3,c3.INSTANCE.onDidChangeZoomLevel,c3.INSTANCE.onDidChangeFullscreen;var c4="object"==typeof navigator?navigator.userAgent:"",c6=c4.indexOf("Firefox")>=0,c8=c4.indexOf("AppleWebKit")>=0,c7=c4.indexOf("Chrome")>=0,c9=!c7&&c4.indexOf("Safari")>=0;c4.indexOf("Electron/"),c4.indexOf("Android");var de=!1;if("function"==typeof cM.matchMedia){let e=cM.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),r=cM.matchMedia("(display-mode: fullscreen)");de=e.matches,dt=e,"string"==typeof dt&&(dt=cM.matchMedia(dt)),dt.addEventListener("change",({matches:e})=>{de&&r.matches||(de=e)})}var dt,dr,ds,di=!1,dn=!1,da=!1,dl=!1,dc=!1,dd="en",dh=globalThis;"u">typeof dh.vscode&&"u">typeof dh.vscode.process?ds=dh.vscode.process:"u">typeof lO.default&&"string"==typeof lO.default?.versions?.node&&(ds=lO.default);var du="string"==typeof ds?.versions?.electron&&ds?.type==="renderer";if("object"==typeof ds){di="win32"===ds.platform,dn="darwin"===ds.platform,(da="linux"===ds.platform)&&ds.env.SNAP&&ds.env.SNAP_REVISION,ds.env.CI||ds.env.BUILD_ARTIFACTSTAGINGDIRECTORY,dd="en";let e=ds.env.VSCODE_NLS_CONFIG;if(e)try{let r=JSON.parse(e);r.userLocale,r.osLocale,dd=r.resolvedLanguage||"en",r.languagePack?.translationsConfigFile}catch{}dl=!0}else"object"!=typeof navigator||du?console.error("Unable to resolve platform."):(di=(dr=navigator.userAgent).indexOf("Windows")>=0,dn=dr.indexOf("Macintosh")>=0,(dr.indexOf("Macintosh")>=0||dr.indexOf("iPad")>=0||dr.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,da=dr.indexOf("Linux")>=0,dr?.indexOf("Mobi"),dc=!0,dd=globalThis._VSCODE_NLS_LANGUAGE||"en",navigator.language.toLowerCase());var df=di,dp=dn,dm=da,dg=dl;dc&&"function"==typeof dh.importScripts&&dh.origin;var dv,dx=dr,d_=dd;(dR=dv||={}).value=function(){return d_},dR.isDefaultVariant=function(){return 2===d_.length?"en"===d_:d_.length>=3&&"e"===d_[0]&&"n"===d_[1]&&"-"===d_[2]},dR.isDefault=function(){return"en"===d_};var dy="function"==typeof dh.postMessage&&!dh.importScripts,db=(()=>{if(dy){let e=[];dh.addEventListener("message",r=>{if(r.data&&r.data.vscodeScheduleAsyncWork)for(let s=0,i=e.length;s<i;s++){let i=e[s];if(i.id===r.data.vscodeScheduleAsyncWork){e.splice(s,1),i.callback();return}}});let r=0;return s=>{let i=++r;e.push({id:i,callback:s}),dh.postMessage({vscodeScheduleAsyncWork:i},"*")}}return e=>setTimeout(e)})(),dw=!!(dx&&dx.indexOf("Chrome")>=0);dx&&dx.indexOf("Firefox"),!dw&&dx&&dx.indexOf("Safari"),dx&&dx.indexOf("Edg/"),dx&&dx.indexOf("Android");var dS="object"==typeof navigator?navigator:{};dg||document.queryCommandSupported&&document.queryCommandSupported("copy")||dS&&dS.clipboard&&dS.clipboard.writeText,dg||dS&&dS.clipboard&&dS.clipboard.readText,dg||de||dS.keyboard,"ontouchstart"in cM||dS.maxTouchPoints,cM.PointerEvent&&("ontouchstart"in cM||navigator.maxTouchPoints);var dC=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,r){this._keyCodeToStr[e]=r,this._strToKeyCode[r.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},dk=new dC,dj=new dC,dN=new dC,dE=Array(230);(dM=dD||={}).toString=function(e){return dk.keyCodeToStr(e)},dM.fromString=function(e){return dk.strToKeyCode(e)},dM.toUserSettingsUS=function(e){return dj.keyCodeToStr(e)},dM.toUserSettingsGeneral=function(e){return dN.keyCodeToStr(e)},dM.fromUserSettings=function(e){return dj.strToKeyCode(e)||dN.strToKeyCode(e)},dM.toElectronAccelerator=function(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 dk.keyCodeToStr(e)};var dR,dM,dD,dT,dP=class e{constructor(e,r,s,i,n){this.ctrlKey=e,this.shiftKey=r,this.altKey=s,this.metaKey=i,this.keyCode=n}equals(r){return r instanceof e&&this.ctrlKey===r.ctrlKey&&this.shiftKey===r.shiftKey&&this.altKey===r.altKey&&this.metaKey===r.metaKey&&this.keyCode===r.keyCode}getHashCode(){let e=this.ctrlKey?"1":"0",r=this.shiftKey?"1":"0",s=this.altKey?"1":"0",i=this.metaKey?"1":"0";return`K${e}${r}${s}${i}${this.keyCode}`}isModifierKey(){return 0===this.keyCode||5===this.keyCode||57===this.keyCode||6===this.keyCode||4===this.keyCode}toKeybinding(){return new dL([this])}isDuplicateModifierCase(){return this.ctrlKey&&5===this.keyCode||this.shiftKey&&4===this.keyCode||this.altKey&&6===this.keyCode||this.metaKey&&57===this.keyCode}},dL=class{constructor(e){if(0===e.length)throw function(e){return e?Error(`Illegal argument: ${e}`):Error("Illegal argument")}("chords");this.chords=e}getHashCode(){let e="";for(let r=0,s=this.chords.length;r<s;r++)0!==r&&(e+=";"),e+=this.chords[r].getHashCode();return e}equals(e){if(null===e||this.chords.length!==e.chords.length)return!1;for(let r=0;r<this.chords.length;r++)if(!this.chords[r].equals(e.chords[r]))return!1;return!0}},dA=dp?256:2048,dB=dp?2048:256,dI=class{constructor(e){this._standardKeyboardEventBrand=!0,this.browserEvent=e,this.target=e.target,this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,this.altGraphKey=e.getModifierState?.("AltGraph"),this.keyCode=function(e){if(e.charCode){let r=String.fromCharCode(e.charCode).toUpperCase();return dD.fromString(r)}let r=e.keyCode;if(3===r)return 7;if(c6)switch(r){case 59:return 85;case 60:if(dm)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(dp)return 57}else if(c8&&(dp&&93===r||!dp&&92===r))return 57;return dE[r]||0}(e),this.code=e.code,this.ctrlKey=this.ctrlKey||5===this.keyCode,this.altKey=this.altKey||6===this.keyCode,this.shiftKey=this.shiftKey||4===this.keyCode,this.metaKey=this.metaKey||57===this.keyCode,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;5!==this.keyCode&&4!==this.keyCode&&6!==this.keyCode&&57!==this.keyCode&&(e=this.keyCode);let r=0;return this.ctrlKey&&(r|=dA),this.altKey&&(r|=512),this.shiftKey&&(r|=1024),this.metaKey&&(r|=dB),r|=e}_computeKeyCodeChord(){let e=0;return 5!==this.keyCode&&4!==this.keyCode&&6!==this.keyCode&&57!==this.keyCode&&(e=this.keyCode),new dP(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},dO=new WeakMap,dz=class{static getSameOriginWindowChain(e){let r=dO.get(e);if(!r){r=[],dO.set(e,r);let s=e,i;do(i=function(e){if(!e.parent||e.parent===e)return null;try{let r=e.location,s=e.parent.location;if("null"!==r.origin&&"null"!==s.origin&&r.origin!==s.origin)return null}catch{return null}return e.parent}(s))?r.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):r.push({window:new WeakRef(s),iframeElement:null}),s=i;while(s)}return r.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,r){if(!r||e===r)return{top:0,left:0};let s=0,i=0;for(let n of this.getSameOriginWindowChain(e)){let e=n.window.deref();if(s+=e?.scrollY??0,i+=e?.scrollX??0,e===r||!n.iframeElement)break;let o=n.iframeElement.getBoundingClientRect();s+=o.top,i+=o.left}return{top:s,left:i}}},dF=class{constructor(e,r){this.timestamp=Date.now(),this.browserEvent=r,this.leftButton=0===r.button,this.middleButton=1===r.button,this.rightButton=2===r.button,this.buttons=r.buttons,this.target=r.target,this.detail=r.detail||1,"dblclick"===r.type&&(this.detail=2),this.ctrlKey=r.ctrlKey,this.shiftKey=r.shiftKey,this.altKey=r.altKey,this.metaKey=r.metaKey,"number"==typeof r.pageX?(this.posx=r.pageX,this.posy=r.pageY):(this.posx=r.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=r.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let s=dz.getPositionOfChildWindowRelativeToAncestorWindow(e,r.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},dW=class{constructor(e,r=0,s=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=s,this.deltaX=r;let i=!1;if(c7){let e=navigator.userAgent.match(/Chrome\/(\d+)/);i=(e?parseInt(e[1]):123)<=122}if(e){let r=e.view?.devicePixelRatio||1;"u">typeof e.wheelDeltaY?i?this.deltaY=e.wheelDeltaY/(120*r):this.deltaY=e.wheelDeltaY/120:"u">typeof e.VERTICAL_AXIS&&e.axis===e.VERTICAL_AXIS?this.deltaY=-e.detail/3:"wheel"===e.type&&(e.deltaMode===e.DOM_DELTA_LINE?c6&&!dp?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40),"u">typeof e.wheelDeltaX?c9&&df?this.deltaX=-(e.wheelDeltaX/120):i?this.deltaX=e.wheelDeltaX/(120*r):this.deltaX=e.wheelDeltaX/120:"u">typeof e.HORIZONTAL_AXIS&&e.axis===e.HORIZONTAL_AXIS?this.deltaX=-e.detail/3:"wheel"===e.type&&(e.deltaMode===e.DOM_DELTA_LINE?c6&&!dp?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40),0===this.deltaY&&0===this.deltaX&&e.wheelDelta&&(i?this.deltaY=e.wheelDelta/(120*r):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},d$=Object.freeze(function(e,r){let s=setTimeout(e.bind(r),0);return{dispose(){clearTimeout(s)}}});(hT=dT||={}).isCancellationToken=function(e){return e===hT.None||e===hT.Cancelled||e instanceof dH||!!e&&"object"==typeof e&&"boolean"==typeof e.isCancellationRequested&&"function"==typeof e.onCancellationRequested},hT.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:cX.None}),hT.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:d$});var dH=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?d$:(this._emitter||(this._emitter=new c2),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}};Symbol("MicrotaskDelay");var dU=class{constructor(e,r){this._isDisposed=!1,this._token=-1,"function"==typeof e&&"number"==typeof r&&this.setIfNotSet(e,r)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){-1!==this._token&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,r){if(this._isDisposed)throw new c_("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},r)}setIfNotSet(e,r){if(this._isDisposed)throw new c_("Calling 'setIfNotSet' on a disposed TimeoutTimer");-1===this._token&&(this._token=setTimeout(()=>{this._token=-1,e()},r))}},dK=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,r,s=globalThis){if(this.isDisposed)throw new c_("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let i=s.setInterval(()=>{e()},r);this.disposable=ck(()=>{s.clearInterval(i),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(hP=hL||={}).settled=async function(e){let r,s=await Promise.all(e.map(e=>e.then(e=>e,e=>{r||(r=e)})));if("u">typeof r)throw r;return s},hP.withAsyncBody=function(e){return new Promise(async(r,s)=>{try{await e(r,s)}catch(e){s(e)}})};var dq=class e{static fromArray(r){return new e(e=>{e.emitMany(r)})}static fromPromise(r){return new e(async e=>{e.emitMany(await r)})}static fromPromises(r){return new e(async e=>{await Promise.all(r.map(async r=>e.emitOne(await r)))})}static merge(r){return new e(async e=>{await Promise.all(r.map(async r=>{for await(let s of r)e.emitOne(s)}))})}constructor(e,r){this._state=0,this._results=[],this._error=null,this._onReturn=r,this._onStateChanged=new c2,queueMicrotask(async()=>{let r={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(r)),this.resolve()}catch(e){this.reject(e)}finally{r.emitOne=void 0,r.emitMany=void 0,r.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{for(;;){if(2===this._state)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(1===this._state)return{done:!0,value:void 0};await cX.toPromise(this._onStateChanged.event)}},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(r,s){return new e(async e=>{for await(let i of r)e.emitOne(s(i))})}map(r){return e.map(this,r)}static filter(r,s){return new e(async e=>{for await(let i of r)s(i)&&e.emitOne(i)})}filter(r){return e.filter(this,r)}static coalesce(r){return e.filter(r,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let r=[];for await(let s of e)r.push(s);return r}toPromise(){return e.toPromise(this)}emitOne(e){0===this._state&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){0===this._state&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){0===this._state&&(this._state=1,this._onStateChanged.fire())}reject(e){0===this._state&&(this._state=2,this._error=e,this._onStateChanged.fire())}};dq.EMPTY=dq.fromArray([]);function dV(e,r){return(r<<5)-r+e|0}function dY(e,r){r=dV(149417,r);for(let s=0,i=e.length;s<i;s++)r=dV(e.charCodeAt(s),r);return r}new DataView(new ArrayBuffer(320));var{registerWindow:dX,getWindow:dG,getDocument:dJ,getWindows:dZ,getWindowsCount:dQ,getWindowId:d0,getWindowById:d1,hasWindow:d2,onDidRegisterWindow:d5,onWillUnregisterWindow:d3,onDidUnregisterWindow:d4}=(n=new Map,o={window:cM,disposables:new cN},n.set(cM.vscodeWindowId,o),a=new c2,l=new c2,c=new c2,{onDidRegisterWindow:a.event,onWillUnregisterWindow:c.event,onDidUnregisterWindow:l.event,registerWindow(e){if(n.has(e.vscodeWindowId))return cE.None;let r=new cN,s={window:e,disposables:r.add(new cN)};return n.set(e.vscodeWindowId,s),r.add(ck(()=>{n.delete(e.vscodeWindowId),l.fire(e)})),r.add(d8(e,hr.BEFORE_UNLOAD,()=>{c.fire(e)})),a.fire(s),r},getWindows:()=>n.values(),getWindowsCount:()=>n.size,getWindowId:e=>e.vscodeWindowId,hasWindow:e=>n.has(e),getWindowById:function(e,r){return("number"==typeof e?n.get(e):void 0)??(r?o:void 0)},getWindow:e=>e?.ownerDocument?.defaultView?e.ownerDocument.defaultView.window:e?.view?e.view.window:cM,getDocument:e=>dG(e).document}),d6=class{constructor(e,r,s,i){this._node=e,this._type=r,this._handler=s,this._options=i||!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,this._handler=null)}};function d8(e,r,s,i){return new d6(e,r,s,i)}var d7=function(e,r,s,i){var n;let o=s;return"click"===r||"mousedown"===r||"contextmenu"===r?(n=dG(e),o=function(e){return s(new dF(n,e))}):("keydown"===r||"keypress"===r||"keyup"===r)&&(o=function(e){return s(new dI(e))}),d8(e,r,o,i)},d9=class extends dK{constructor(e){super(),this.defaultTarget=e&&dG(e)}cancelAndSet(e,r,s){return super.cancelAndSet(e,r,s??this.defaultTarget)}},he=class{constructor(e,r=0){this._runner=e,this.priority=r,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){cm(e)}}static sort(e,r){return r.priority-e.priority}};d=new Map,h=new Map,u=new Map,f=new Map,hA=(e,r,s=0)=>{let i=d0(e),n=new he(r,s),o=d.get(i);return o||(o=[],d.set(i,o)),o.push(n),u.get(i)||(u.set(i,!0),e.requestAnimationFrame(()=>(e=>{u.set(e,!1);let r=d.get(e)??[];for(h.set(e,r),d.set(e,[]),f.set(e,!0);r.length>0;)r.sort(he.sort),r.shift().execute();f.set(e,!1)})(i))),n};var ht=class e{constructor(e,r){this.width=e,this.height=r}with(r=this.width,s=this.height){return r!==this.width||s!==this.height?new e(r,s):this}static is(e){return"object"==typeof e&&"number"==typeof e.height&&"number"==typeof e.width}static lift(r){return r instanceof e?r:new e(r.width,r.height)}static equals(e,r){return e===r||!!e&&!!r&&e.width===r.width&&e.height===r.height}};ht.None=new ht(0,0),new class{constructor(){this.mutationObservers=new Map}observe(e,r,s){let i=this.mutationObservers.get(e);i||(i=new Map,this.mutationObservers.set(e,i));let n=function e(r,s){switch(typeof r){case"object":var i,n,o,a;return null===r?dV(349,s):Array.isArray(r)?(i=r,n=dV(104579,n=s),i.reduce((r,s)=>e(s,r),n)):(o=r,a=dV(181387,a=s),Object.keys(o).sort().reduce((r,s)=>(r=dY(s,r),e(o[s],r)),a));case"string":return dY(r,s);case"boolean":return dV(r?433:863,s);case"number":return dV(r,s);case"undefined":return dV(937,s);default:return dV(617,s)}}(s,0),o=i.get(n);if(o)o.users+=1;else{let a=new c2,l=new MutationObserver(e=>a.fire(e));l.observe(e,s);let c=o={users:1,observer:l,onDidMutate:a.event};r.add(ck(()=>{c.users-=1,0===c.users&&(a.dispose(),l.disconnect(),i?.delete(n),i?.size===0&&this.mutationObservers.delete(e))})),i.set(n,o)}return o.onDidMutate}};var hr={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},hs=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 r=hi(e);this._maxWidth!==r&&(this._maxWidth=r,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let r=hi(e);this._width!==r&&(this._width=r,this.domNode.style.width=this._width)}setHeight(e){let r=hi(e);this._height!==r&&(this._height=r,this.domNode.style.height=this._height)}setTop(e){let r=hi(e);this._top!==r&&(this._top=r,this.domNode.style.top=this._top)}setLeft(e){let r=hi(e);this._left!==r&&(this._left=r,this.domNode.style.left=this._left)}setBottom(e){let r=hi(e);this._bottom!==r&&(this._bottom=r,this.domNode.style.bottom=this._bottom)}setRight(e){let r=hi(e);this._right!==r&&(this._right=r,this.domNode.style.right=this._right)}setPaddingTop(e){let r=hi(e);this._paddingTop!==r&&(this._paddingTop=r,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let r=hi(e);this._paddingLeft!==r&&(this._paddingLeft=r,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let r=hi(e);this._paddingBottom!==r&&(this._paddingBottom=r,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let r=hi(e);this._paddingRight!==r&&(this._paddingRight=r,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 r=hi(e);this._fontSize!==r&&(this._fontSize=r,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 r=hi(e);this._lineHeight!==r&&(this._lineHeight=r,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let r=hi(e);this._letterSpacing!==r&&(this._letterSpacing=r,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,r){this.domNode.classList.toggle(e,r),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,r){this.domNode.setAttribute(e,r)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function hi(e){return"number"==typeof e?`${e}px`:e}function hn(e){return new hs(e)}var ho=class{constructor(){this._hooks=new cN,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,r){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(r)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,r,s,i,n){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=i,this._onStopCallback=n;let o=e;try{e.setPointerCapture(r),this._hooks.add(ck(()=>{try{e.releasePointerCapture(r)}catch{}}))}catch{o=dG(e)}this._hooks.add(d8(o,hr.POINTER_MOVE,e=>{e.buttons!==s?this.stopMonitoring(!0):(e.preventDefault(),this._pointerMoveCallback(e))})),this._hooks.add(d8(o,hr.POINTER_UP,e=>this.stopMonitoring(!0)))}};(p=hB||={}).Tap="-xterm-gesturetap",p.Change="-xterm-gesturechange",p.Start="-xterm-gesturestart",p.End="-xterm-gesturesend",p.Contextmenu="-xterm-gesturecontextmenu";var ha=class e extends cE{constructor(){super(),this.dispatched=!1,this.targets=new cT,this.ignoreTargets=new cT,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(cX.runAndSubscribe(d5,({window:e,disposables:r})=>{r.add(d8(e.document,"touchstart",e=>this.onTouchStart(e),{passive:!1})),r.add(d8(e.document,"touchend",r=>this.onTouchEnd(e,r))),r.add(d8(e.document,"touchmove",e=>this.onTouchMove(e),{passive:!1}))},{window:cM,disposables:this._store}))}static addTarget(r){return e.isTouchDevice()?(e.INSTANCE||(e.INSTANCE=new e),ck(e.INSTANCE.targets.push(r))):cE.None}static ignoreTarget(r){return e.isTouchDevice()?(e.INSTANCE||(e.INSTANCE=new e),ck(e.INSTANCE.ignoreTargets.push(r))):cE.None}static isTouchDevice(){return"ontouchstart"in cM||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(e){let r=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,i=e.targetTouches.length;s<i;s++){let i=e.targetTouches.item(s);this.activeTouches[i.identifier]={id:i.identifier,initialTarget:i.target,initialTimeStamp:r,initialPageX:i.pageX,initialPageY:i.pageY,rollingTimestamps:[r],rollingPageX:[i.pageX],rollingPageY:[i.pageY]};let n=this.newGestureEvent(hB.Start,i.target);n.pageX=i.pageX,n.pageY=i.pageY,this.dispatchEvent(n)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}onTouchEnd(r,s){let i=Date.now(),n=Object.keys(this.activeTouches).length;for(let o=0,a=s.changedTouches.length;o<a;o++){let a=s.changedTouches.item(o);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("move of an UNKNOWN touch",a);continue}let l=this.activeTouches[a.identifier],c=Date.now()-l.initialTimeStamp;if(c<e.HOLD_DELAY&&30>Math.abs(l.initialPageX-cy(l.rollingPageX))&&30>Math.abs(l.initialPageY-cy(l.rollingPageY))){let e=this.newGestureEvent(hB.Tap,l.initialTarget);e.pageX=cy(l.rollingPageX),e.pageY=cy(l.rollingPageY),this.dispatchEvent(e)}else if(c>=e.HOLD_DELAY&&30>Math.abs(l.initialPageX-cy(l.rollingPageX))&&30>Math.abs(l.initialPageY-cy(l.rollingPageY))){let e=this.newGestureEvent(hB.Contextmenu,l.initialTarget);e.pageX=cy(l.rollingPageX),e.pageY=cy(l.rollingPageY),this.dispatchEvent(e)}else if(1===n){let e=cy(l.rollingPageX),s=cy(l.rollingPageY),n=cy(l.rollingTimestamps)-l.rollingTimestamps[0],o=e-l.rollingPageX[0],a=s-l.rollingPageY[0],c=[...this.targets].filter(e=>l.initialTarget instanceof Node&&e.contains(l.initialTarget));this.inertia(r,c,i,Math.abs(o)/n,o>0?1:-1,e,Math.abs(a)/n,a>0?1:-1,s)}this.dispatchEvent(this.newGestureEvent(hB.End,l.initialTarget)),delete this.activeTouches[a.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(e,r){let s=document.createEvent("CustomEvent");return s.initEvent(e,!1,!0),s.initialTarget=r,s.tapCount=0,s}dispatchEvent(r){if(r.type===hB.Tap){let s=new Date().getTime(),i=0;i=s-this._lastSetTapCountTime>e.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=s,r.tapCount=i}else(r.type===hB.Change||r.type===hB.Contextmenu)&&(this._lastSetTapCountTime=0);if(r.initialTarget instanceof Node){for(let e of this.ignoreTargets)if(e.contains(r.initialTarget))return;let e=[];for(let s of this.targets)if(s.contains(r.initialTarget)){let i=0,n=r.initialTarget;for(;n&&n!==s;)i++,n=n.parentElement;e.push([i,s])}for(let[s,i]of(e.sort((e,r)=>e[0]-r[0]),e))i.dispatchEvent(r),this.dispatched=!0}}inertia(r,s,i,n,o,a,l,c,d){this.handle=hA(r,()=>{let h=Date.now(),u=h-i,f=0,p=0,m=!0;n+=e.SCROLL_FRICTION*u,l+=e.SCROLL_FRICTION*u,n>0&&(m=!1,f=o*n*u),l>0&&(m=!1,p=c*l*u);let g=this.newGestureEvent(hB.Change);g.translationX=f,g.translationY=p,s.forEach(e=>e.dispatchEvent(g)),m||this.inertia(r,s,h,n,o,a+f,l,c,d+p)})}onTouchMove(e){let r=Date.now();for(let s=0,i=e.changedTouches.length;s<i;s++){let i=e.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(i.identifier))){console.warn("end of an UNKNOWN touch",i);continue}let n=this.activeTouches[i.identifier],o=this.newGestureEvent(hB.Change,n.initialTarget);o.translationX=i.pageX-cy(n.rollingPageX),o.translationY=i.pageY-cy(n.rollingPageY),o.pageX=i.pageX,o.pageY=i.pageY,this.dispatchEvent(o),n.rollingPageX.length>3&&(n.rollingPageX.shift(),n.rollingPageY.shift(),n.rollingTimestamps.shift()),n.rollingPageX.push(i.pageX),n.rollingPageY.push(i.pageY),n.rollingTimestamps.push(r)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}};ha.SCROLL_FRICTION=-.005,ha.HOLD_DELAY=700,ha.CLEAR_TAP_COUNT_TIME=400,lW([function(e,r,s){let i=null,n=null;if("function"==typeof s.value?(i="value",0!==(n=s.value).length&&console.warn("Memoize should only be used in functions with zero parameters")):"function"==typeof s.get&&(i="get",n=s.get),!n)throw Error("not supported");let o=`$memoize$${r}`;s[i]=function(...e){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:n.apply(this,e)}),this[o]}}],ha,"isTouchDevice",1);var hl=class extends cE{onclick(e,r){this._register(d8(e,hr.CLICK,s=>r(new dF(dG(e),s))))}onmousedown(e,r){this._register(d8(e,hr.MOUSE_DOWN,s=>r(new dF(dG(e),s))))}onmouseover(e,r){this._register(d8(e,hr.MOUSE_OVER,s=>r(new dF(dG(e),s))))}onmouseleave(e,r){this._register(d8(e,hr.MOUSE_LEAVE,s=>r(new dF(dG(e),s))))}onkeydown(e,r){this._register(d8(e,hr.KEY_DOWN,e=>r(new dI(e))))}onkeyup(e,r){this._register(d8(e,hr.KEY_UP,e=>r(new dI(e))))}oninput(e,r){this._register(d8(e,hr.INPUT,r))}onblur(e,r){this._register(d8(e,hr.BLUR,r))}onfocus(e,r){this._register(d8(e,hr.FOCUS,r))}onchange(e,r){this._register(d8(e,hr.CHANGE,r))}ignoreGesture(e){return ha.ignoreTarget(e)}},hc=class extends hl{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","u">typeof e.top&&(this.bgDomNode.style.top="0px"),"u">typeof e.left&&(this.bgDomNode.style.left="0px"),"u">typeof e.bottom&&(this.bgDomNode.style.bottom="0px"),"u">typeof e.right&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width="11px",this.domNode.style.height="11px","u">typeof e.top&&(this.domNode.style.top=e.top+"px"),"u">typeof e.left&&(this.domNode.style.left=e.left+"px"),"u">typeof e.bottom&&(this.domNode.style.bottom=e.bottom+"px"),"u">typeof e.right&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new ho),this._register(d7(this.bgDomNode,hr.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(d7(this.domNode,hr.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new d9),this._pointerdownScheduleRepeatTimer=this._register(new dU)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let r=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,dG(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(r,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},hd=class e{constructor(e,r,s,i,n,o,a){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(r|=0,s|=0,i|=0,n|=0,o|=0,a|=0),this.rawScrollLeft=i,this.rawScrollTop=a,r<0&&(r=0),i+r>s&&(i=s-r),i<0&&(i=0),n<0&&(n=0),a+n>o&&(a=o-n),a<0&&(a=0),this.width=r,this.scrollWidth=s,this.scrollLeft=i,this.height=n,this.scrollHeight=o,this.scrollTop=a}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(r,s){return new e(this._forceIntegerValues,"u">typeof r.width?r.width:this.width,"u">typeof r.scrollWidth?r.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,"u">typeof r.height?r.height:this.height,"u">typeof r.scrollHeight?r.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(r){return new e(this._forceIntegerValues,this.width,this.scrollWidth,"u">typeof r.scrollLeft?r.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,"u">typeof r.scrollTop?r.scrollTop:this.rawScrollTop)}createScrollEvent(e,r){let s=this.width!==e.width,i=this.scrollWidth!==e.scrollWidth,n=this.scrollLeft!==e.scrollLeft,o=this.height!==e.height,a=this.scrollHeight!==e.scrollHeight,l=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:r,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:s,scrollWidthChanged:i,scrollLeftChanged:n,heightChanged:o,scrollHeightChanged:a,scrollTopChanged:l}}},hh=class extends cE{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new c2),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new hd(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,r){let s=this._state.withScrollDimensions(e,r);this._setState(s,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let r=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(r,!1)}setScrollPositionSmooth(e,r){if(0===this._smoothScrollDuration)return this.setScrollPositionNow(e);if(this._smoothScrolling){let s;e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let i=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===i.scrollLeft&&this._smoothScrolling.to.scrollTop===i.scrollTop)return;s=r?new hp(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let r=this._state.withScrollPosition(e);this._smoothScrolling=hp.start(this._state,r,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(),r=this._state.withScrollPosition(e);if(this._setState(r,!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,r){let s=this._state;s.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(s,r)))}},hu=class{constructor(e,r,s){this.scrollLeft=e,this.scrollTop=r,this.isDone=s}};function hf(e,r){let s=r-e;return function(r){return e+s*(1-Math.pow(1-r,3))}}var hp=class e{constructor(e,r,s,i){this.from=e,this.to=r,this.duration=i,this.startTime=s,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,r,s){if(Math.abs(e-r)>2.5*s){var i,n;let o,a;return e<r?(o=e+.75*s,a=r-.75*s):(o=e-.75*s,a=r+.75*s),i=hf(e,o),n=hf(a,r),function(e){return e<.33?i(e/.33):n((e-.33)/(1-.33))}}return hf(e,r)}dispose(){null!==this.animationFrameDisposable&&(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 r=(e-this.startTime)/this.duration;return r<1?new hu(this.scrollLeft(r),this.scrollTop(r),!1):new hu(this.to.scrollLeft,this.to.scrollTop,!0)}combine(r,s,i){return e.start(r,s,i)}static start(r,s,i){return i+=10,new e(r,s,Date.now()-10,i)}},hm=class extends cE{constructor(e,r,s){super(),this._visibility=e,this._visibleClassName=r,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new dU)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return 2!==this._visibility&&(3===this._visibility||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(){this._isNeeded?this._shouldBeVisible?this._reveal():this._hide(!0):this._hide(!1)}_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":"")))}},hg=class extends hl{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 hm(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new ho),this._shouldRender=!0,this.domNode=hn(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(d8(this.domNode.domNode,hr.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let r=this._register(new hc(e));this.domNode.domNode.appendChild(r.bgDomNode),this.domNode.domNode.appendChild(r.domNode)}_createSlider(e,r,s,i){this.slider=hn(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(r),"number"==typeof s&&this.slider.setWidth(s),"number"==typeof i&&this.slider.setHeight(i),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(d8(this.slider.domNode,hr.POINTER_DOWN,e=>{0===e.button&&(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 r=this.domNode.domNode.getClientRects()[0].top,s=r+this._scrollbarState.getSliderPosition(),i=r+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),n=this._sliderPointerPosition(e);s<=n&&n<=i?0===e.button&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let r,s;if(e.target===this.domNode.domNode&&"number"==typeof e.offsetX&&"number"==typeof e.offsetY)r=e.offsetX,s=e.offsetY;else{var i;let n,o,a=(n=(i=this.domNode.domNode).getBoundingClientRect(),o=dG(i),{left:n.left+o.scrollX,top:n.top+o.scrollY,width:n.width,height:n.height});r=e.pageX-a.left,s=e.pageY-a.top}let n=this._pointerDownRelativePosition(r,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(n):this._scrollbarState.getDesiredScrollPositionFromOffset(n)),0===e.button&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let r=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),i=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{let n=Math.abs(this._sliderOrthogonalPointerPosition(e)-s);if(df&&n>140)return void this._setDesiredScrollPositionNow(i.getScrollPosition());let o=this._sliderPointerPosition(e)-r;this._setDesiredScrollPositionNow(i.getDesiredScrollPositionFromDelta(o))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let r={};this.writeScrollPosition(r,e),this._scrollable.setScrollPositionNow(r)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},hv=class e{constructor(e,r,s,i,n,o){this._scrollbarSize=Math.round(r),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(e),this._visibleSize=i,this._scrollSize=n,this._scrollPosition=o,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 r=Math.round(e);return this._visibleSize!==r&&(this._visibleSize=r,this._refreshComputedValues(),!0)}setScrollSize(e){let r=Math.round(e);return this._scrollSize!==r&&(this._scrollSize=r,this._refreshComputedValues(),!0)}setScrollPosition(e){let r=Math.round(e);return this._scrollPosition!==r&&(this._scrollPosition=r,this._refreshComputedValues(),!0)}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,r,s,i,n){let o=Math.max(0,s-e),a=Math.max(0,o-2*r),l=i>0&&i>s;if(!l)return{computedAvailableSize:Math.round(o),computedIsNeeded:l,computedSliderSize:Math.round(a),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(s*a/i))),d=(a-c)/(i-s);return{computedAvailableSize:Math.round(o),computedIsNeeded:l,computedSliderSize:Math.round(c),computedSliderRatio:d,computedSliderPosition:Math.round(n*d)}}_refreshComputedValues(){let r=e._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=r.computedAvailableSize,this._computedIsNeeded=r.computedIsNeeded,this._computedSliderSize=r.computedSliderSize,this._computedSliderRatio=r.computedSliderRatio,this._computedSliderPosition=r.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){return this._computedIsNeeded?Math.round((e-this._arrowSize-this._computedSliderSize/2)/this._computedSliderRatio):0}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let r=e-this._arrowSize,s=this._scrollPosition;return r<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(e){return this._computedIsNeeded?Math.round((this._computedSliderPosition+e)/this._computedSliderRatio):0}},hx=class extends hg{constructor(e,r,s){let i=e.getScrollDimensions();if(super({lazyRender:r.lazyRender,host:s,scrollbarState:new hv(r.horizontalHasArrows?r.arrowSize:0,2===r.horizontal?0:r.horizontalScrollbarSize,2===r.vertical?0:r.verticalScrollbarSize,i.width,i.scrollWidth,e.getCurrentScrollPosition().scrollLeft),visibility:r.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:r.scrollByPage}),r.horizontalHasArrows)throw Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((r.horizontalScrollbarSize-r.horizontalSliderSize)/2),0,void 0,r.horizontalSliderSize)}_updateSlider(e,r){this.slider.setWidth(e),this.slider.setLeft(r)}_renderDomNode(e,r){this.domNode.setWidth(e),this.domNode.setHeight(r),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,r){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,r){e.scrollLeft=r}updateOptions(e){this.updateScrollbarSize(2===e.horizontal?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(2===e.vertical?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},h_=class extends hg{constructor(e,r,s){let i=e.getScrollDimensions();if(super({lazyRender:r.lazyRender,host:s,scrollbarState:new hv(r.verticalHasArrows?r.arrowSize:0,2===r.vertical?0:r.verticalScrollbarSize,0,i.height,i.scrollHeight,e.getCurrentScrollPosition().scrollTop),visibility:r.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:r.scrollByPage}),r.verticalHasArrows)throw Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((r.verticalScrollbarSize-r.verticalSliderSize)/2),r.verticalSliderSize,void 0)}_updateSlider(e,r){this.slider.setHeight(e),this.slider.setTop(r)}_renderDomNode(e,r){this.domNode.setWidth(r),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,r){return r}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,r){e.scrollTop=r}updateOptions(e){this.updateScrollbarSize(2===e.vertical?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},hy=class{constructor(e,r,s){this.timestamp=e,this.deltaX=r,this.deltaY=s,this.score=0}},hb=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(-1===this._front&&-1===this._rear)return!1;let e=1,r=0,s=1,i=this._rear;for(;;){let n=i===this._front?e:Math.pow(2,-s);if(e-=n,r+=this._memory[i].score*n,i===this._front)break;i=(this._capacity+i-1)%this._capacity,s++}return r<=.5}acceptStandardWheelEvent(e){if(c7){var r;let s=(r=dG(e.browserEvent),c3.INSTANCE.getZoomFactor(r));this.accept(Date.now(),e.deltaX*s,e.deltaY*s)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,r,s){let i=null,n=new hy(e,r,s);-1===this._front&&-1===this._rear?(this._memory[0]=n,this._front=0,this._rear=0):(i=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]=n),n.score=this._computeScore(n,i)}_computeScore(e,r){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let s=.5;if(this._isAlmostInt(e.deltaX)&&this._isAlmostInt(e.deltaY)||(s+=.25),r){let i=Math.abs(e.deltaX),n=Math.abs(e.deltaY),o=Math.abs(r.deltaX),a=Math.abs(r.deltaY),l=Math.max(Math.min(i,o),1),c=Math.max(Math.min(n,a),1),d=Math.max(n,a);Math.max(i,o)%l==0&&d%c==0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(e){return .01>Math.abs(Math.round(e)-e)}};hb.INSTANCE=new hb;var hw=class extends hl{constructor(e,r,s){super(),this._onScroll=this._register(new c2),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new c2),this.onWillScroll=this._onWillScroll.event,this._options=function(e){let r={lazyRender:"u">typeof e.lazyRender&&e.lazyRender,className:"u">typeof e.className?e.className:"",useShadows:!("u">typeof e.useShadows)||e.useShadows,handleMouseWheel:!("u">typeof e.handleMouseWheel)||e.handleMouseWheel,flipAxes:"u">typeof e.flipAxes&&e.flipAxes,consumeMouseWheelIfScrollbarIsNeeded:"u">typeof e.consumeMouseWheelIfScrollbarIsNeeded&&e.consumeMouseWheelIfScrollbarIsNeeded,alwaysConsumeMouseWheel:"u">typeof e.alwaysConsumeMouseWheel&&e.alwaysConsumeMouseWheel,scrollYToX:"u">typeof e.scrollYToX&&e.scrollYToX,mouseWheelScrollSensitivity:"u">typeof e.mouseWheelScrollSensitivity?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:"u">typeof e.fastScrollSensitivity?e.fastScrollSensitivity:5,scrollPredominantAxis:!("u">typeof e.scrollPredominantAxis)||e.scrollPredominantAxis,mouseWheelSmoothScroll:!("u">typeof e.mouseWheelSmoothScroll)||e.mouseWheelSmoothScroll,arrowSize:"u">typeof e.arrowSize?e.arrowSize:11,listenOnDomNode:"u">typeof e.listenOnDomNode?e.listenOnDomNode:null,horizontal:"u">typeof e.horizontal?e.horizontal:1,horizontalScrollbarSize:"u">typeof e.horizontalScrollbarSize?e.horizontalScrollbarSize:10,horizontalSliderSize:"u">typeof e.horizontalSliderSize?e.horizontalSliderSize:0,horizontalHasArrows:"u">typeof e.horizontalHasArrows&&e.horizontalHasArrows,vertical:"u">typeof e.vertical?e.vertical:1,verticalScrollbarSize:"u">typeof e.verticalScrollbarSize?e.verticalScrollbarSize:10,verticalHasArrows:"u">typeof e.verticalHasArrows&&e.verticalHasArrows,verticalSliderSize:"u">typeof e.verticalSliderSize?e.verticalSliderSize:0,scrollByPage:"u">typeof e.scrollByPage&&e.scrollByPage};return r.horizontalSliderSize="u">typeof e.horizontalSliderSize?e.horizontalSliderSize:r.horizontalScrollbarSize,r.verticalSliderSize="u">typeof e.verticalSliderSize?e.verticalSliderSize:r.verticalScrollbarSize,dp&&(r.className+=" mac"),r}(r),this._scrollable=s,this._register(this._scrollable.onScroll(e=>{this._onWillScroll.fire(e),this._onDidScroll(e),this._onScroll.fire(e)}));let i={onMouseWheel:e=>this._onMouseWheel(e),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new h_(this._scrollable,this._options,i)),this._horizontalScrollbar=this._register(new hx(this._scrollable,this._options,i)),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=hn(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=hn(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=hn(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 dU),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=cC(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,dp&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){"u">typeof e.handleMouseWheel&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),"u">typeof e.mouseWheelScrollSensitivity&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),"u">typeof e.fastScrollSensitivity&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),"u">typeof e.scrollPredominantAxis&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),"u">typeof e.horizontal&&(this._options.horizontal=e.horizontal),"u">typeof e.vertical&&(this._options.vertical=e.vertical),"u">typeof e.horizontalScrollbarSize&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),"u">typeof e.verticalScrollbarSize&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),"u">typeof e.scrollByPage&&(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 dW(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=cC(this._mouseWheelToDispose),e)){let e=e=>{this._onMouseWheel(new dW(e))};this._mouseWheelToDispose.push(d8(this._listenOnDomNode,hr.MOUSE_WHEEL,e,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let r=hb.INSTANCE;r.acceptStandardWheelEvent(e);let s=!1;if(e.deltaY||e.deltaX){let i=e.deltaY*this._options.mouseWheelScrollSensitivity,n=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&n+i===0?n=i=0:Math.abs(i)>=Math.abs(n)?n=0:i=0),this._options.flipAxes&&([i,n]=[n,i]);let o=!dp&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||o)&&!n&&(n=i,i=0),e.browserEvent&&e.browserEvent.altKey&&(n*=this._options.fastScrollSensitivity,i*=this._options.fastScrollSensitivity);let a=this._scrollable.getFutureScrollPosition(),l={};if(i){let e=50*i,r=a.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(l,r)}if(n){let e=50*n,r=a.scrollLeft-(e<0?Math.floor(e):Math.ceil(e));this._horizontalScrollbar.writeScrollPosition(l,r)}l=this._scrollable.validateScrollPosition(l),(a.scrollLeft!==l.scrollLeft||a.scrollTop!==l.scrollTop)&&(this._options.mouseWheelSmoothScroll&&r.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(l):this._scrollable.setScrollPositionNow(l),s=!0)}let i=s;!i&&this._options.alwaysConsumeMouseWheel&&(i=!0),!i&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(i=!0),i&&(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(),r=e.scrollTop>0,s=e.scrollLeft>0,i=s?" left":"",n=r?" top":"";this._leftShadowDomNode.setClassName(`shadow${i}`),this._topShadowDomNode.setClassName(`shadow${n}`),this._topLeftShadowDomNode.setClassName(`shadow${s||r?" top-left-corner":""}${n}${i}`)}}_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(),500)}},hS=class extends hw{constructor(e,r,s){super(e,r,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}},hC=class extends cE{constructor(e,r,s,i,n,o,a,l){super(),this._bufferService=s,this._optionsService=a,this._renderService=l,this._onRequestScrollLines=this._register(new c2),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new hh({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>hA(i.window,e)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new hS(r,{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(n.onProtocolChange(e=>{this._scrollableElement.updateOptions({handleMouseWheel:!(16&e)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(cX.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(ck(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=i.mainDocument.createElement("style"),r.appendChild(this._styleElement),this._register(ck(()=>this._styleElement.remove())),this._register(cX.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
16
+ `)})),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 r=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:r.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,r){r&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!r,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){void 0!==e&&(this._latestYDisp=e),void 0===this._queuedAnimationFrame&&(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 r=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),s=r-this._bufferService.buffer.ydisp;0!==s&&(this._latestYDisp=r,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};hC=lW([l$(2,l4),l$(3,ca),l$(4,l6),l$(5,cu),l$(6,ct),l$(7,cc)],hC);var hk=class extends cE{constructor(e,r,s,i,n){super(),this._screenElement=e,this._bufferService=r,this._coreBrowserService=s,this._decorationService=i,this._renderService=n,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(ck(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){void 0===this._animationFrame&&(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 r=this._coreBrowserService.mainDocument.createElement("div");r.classList.add("xterm-decoration"),r.classList.toggle("xterm-decoration-top-layer",e?.options?.layer==="top"),r.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,r.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,r.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,r.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=e.options.x??0;return s&&s>this._bufferService.cols&&(r.style.display="none"),this._refreshXPosition(e,r),r}_refreshStyle(e){let r=e.marker.line-this._bufferService.buffers.active.ydisp;if(r<0||r>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let s=this._decorationElements.get(e);s||(s=this._createElement(e),e.element=s,this._decorationElements.set(e,s),this._container.appendChild(s),e.onDispose(()=>{this._decorationElements.delete(e),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${r*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(s)}}_refreshXPosition(e,r=e.element){if(!r)return;let s=e.options.x??0;"right"===(e.options.anchor||"left")?r.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":r.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};hk=lW([l$(1,l4),l$(2,ca),l$(3,ci),l$(4,cc)],hk);var hj=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 r of this._zones)if(r.color===e.options.overviewRulerOptions.color&&r.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(r,e.marker.line))return;if(this._lineAdjacentToZone(r,e.marker.line,e.options.overviewRulerOptions.position))return void this._addLineToZone(r,e.marker.line)}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,r){return r>=e.startBufferLine&&r<=e.endBufferLine}_lineAdjacentToZone(e,r,s){return r>=e.startBufferLine-this._linePadding[s||"full"]&&r<=e.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(e,r){e.startBufferLine=Math.min(e.startBufferLine,r),e.endBufferLine=Math.max(e.endBufferLine,r)}},hN={full:0,left:0,center:0,right:0},hE={full:0,left:0,center:0,right:0},hR={full:0,left:0,center:0,right:0},hM=class extends cE{constructor(e,r,s,i,n,o,a,l){super(),this._viewportElement=e,this._screenElement=r,this._bufferService=s,this._decorationService=i,this._renderService=n,this._optionsService=o,this._themeService=a,this._coreBrowserService=l,this._colorZoneStore=new hj,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(ck(()=>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),r=Math.ceil((this._canvas.width-1)/3);hE.full=this._canvas.width,hE.left=e,hE.center=r,hE.right=e,this._refreshDrawHeightConstants(),hR.full=1,hR.left=1,hR.center=1+hE.left,hR.right=1+hE.left+hE.center}_refreshDrawHeightConstants(){hN.full=Math.round(2*this._coreBrowserService.dpr);let e=Math.round(Math.max(Math.min(this._canvas.height/this._bufferService.buffer.lines.length,12),6)*this._coreBrowserService.dpr);hN.left=e,hN.center=e,hN.right=e}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*hN.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*hN.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*hN.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*hN.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(){for(let e of(this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear(),this._decorationService.decorations))this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let r of e)"full"!==r.position&&this._renderColorZone(r);for(let r of e)"full"===r.position&&this._renderColorZone(r);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(hR[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-hN[e.position||"full"]/2),hE[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+hN[e.position||"full"]))}_queueRefresh(e,r){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=r||this._shouldUpdateAnchor,void 0===this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};hM=lW([l$(2,l4),l$(3,ci),l$(4,cc),l$(5,ct),l$(6,cu),l$(7,ca)],hM),(m=hI||={}).NUL="\0",m.SOH="\x01",m.STX="\x02",m.ETX="\x03",m.EOT="\x04",m.ENQ="\x05",m.ACK="\x06",m.BEL="\x07",m.BS="\b",m.HT=" ",m.LF=`
17
+ `,m.VT="\v",m.FF="\f",m.CR="\r",m.SO="\x0e",m.SI="\x0f",m.DLE="\x10",m.DC1="\x11",m.DC2="\x12",m.DC3="\x13",m.DC4="\x14",m.NAK="\x15",m.SYN="\x16",m.ETB="\x17",m.CAN="\x18",m.EM="\x19",m.SUB="\x1a",m.ESC="\x1b",m.FS="\x1c",m.GS="\x1d",m.RS="\x1e",m.US="\x1f",m.SP=" ",m.DEL="",(g=hO||={}).PAD="€",g.HOP="",g.BPH="‚",g.NBH="ƒ",g.IND="„",g.NEL="…",g.SSA="†",g.ESA="‡",g.HTS="ˆ",g.HTJ="‰",g.VTS="Š",g.PLD="‹",g.PLU="Œ",g.RI="",g.SS2="Ž",g.SS3="",g.DCS="",g.PU1="‘",g.PU2="’",g.STS="“",g.CCH="”",g.MW="•",g.SPA="–",g.EPA="—",g.SOS="˜",g.SGCI="™",g.SCI="š",g.CSI="›",g.ST="œ",g.OSC="",g.PM="ž",g.APC="Ÿ",(hz||={}).ST=`${hI.ESC}\\`;var hD=class{constructor(e,r,s,i,n,o){this._textarea=e,this._compositionView=r,this._bufferService=s,this._optionsService=i,this._coreService=n,this._renderService=o,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(20===e.keyCode||229===e.keyCode||16===e.keyCode||17===e.keyCode||18===e.keyCode)return!1;this._finalizeComposition(!1)}return 229!==e.keyCode||(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){let r;this._isSendingComposition=!1,e.start+=this._dataAlreadySent.length,(r=this._isComposing?this._textarea.value.substring(e.start,this._compositionPosition.start):this._textarea.value.substring(e.start)).length>0&&this._coreService.triggerDataEvent(r,!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 r=this._textarea.value,s=r.replace(e,"");this._dataAlreadySent=s,r.length>e.length?this._coreService.triggerDataEvent(s,!0):r.length<e.length?this._coreService.triggerDataEvent(`${hI.DEL}`,!0):r.length===e.length&&r!==e&&this._coreService.triggerDataEvent(r,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),r=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,i=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=i+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=r+"px",this._compositionView.style.lineHeight=r+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let n=this._compositionView.getBoundingClientRect();this._textarea.style.left=i+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(n.width,1)+"px",this._textarea.style.height=Math.max(n.height,1)+"px",this._textarea.style.lineHeight=n.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};hD=lW([l$(2,l4),l$(3,ct),l$(4,l8),l$(5,cc)],hD);var hT,hP,hL,hA,hB,hI,hO,hz,hF,hW=0,h$=0,hH=0,hU=0,hK={css:"#00000000",rgba:0};(fy=hF||={}).toCss=function(e,r,s,i){return void 0!==i?`#${hQ(e)}${hQ(r)}${hQ(s)}${hQ(i)}`:`#${hQ(e)}${hQ(r)}${hQ(s)}`},fy.toRgba=function(e,r,s,i=255){return(e<<24|r<<16|s<<8|i)>>>0},fy.toColor=function(e,r,s,i){return{css:fy.toCss(e,r,s,i),rgba:fy.toRgba(e,r,s,i)}};var hq=fb||={};function hV(e,r){return hU=Math.round(255*r),[hW,h$,hH]=fC.toChannels(e.rgba),{css:hF.toCss(hW,h$,hH,hU),rgba:hF.toRgba(hW,h$,hH,hU)}}hq.blend=function(e,r){if(1==(hU=(255&r.rgba)/255))return{css:r.css,rgba:r.rgba};let s=r.rgba>>24&255,i=r.rgba>>16&255,n=r.rgba>>8&255,o=e.rgba>>24&255,a=e.rgba>>16&255,l=e.rgba>>8&255;return hW=o+Math.round((s-o)*hU),h$=a+Math.round((i-a)*hU),hH=l+Math.round((n-l)*hU),{css:hF.toCss(hW,h$,hH),rgba:hF.toRgba(hW,h$,hH)}},hq.isOpaque=function(e){return(255&e.rgba)==255},hq.ensureContrastRatio=function(e,r,s){let i=fC.ensureContrastRatio(e.rgba,r.rgba,s);if(i)return hF.toColor(i>>24&255,i>>16&255,i>>8&255)},hq.opaque=function(e){let r=(255|e.rgba)>>>0;return[hW,h$,hH]=fC.toChannels(r),{css:hF.toCss(hW,h$,hH),rgba:r}},hq.opacity=hV,hq.multiplyOpacity=function(e,r){return hU=255&e.rgba,hV(e,hU*r/255)},hq.toColorRGB=function(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]},(e=>{let r,s;try{let e=document.createElement("canvas");e.width=1,e.height=1;let i=e.getContext("2d",{willReadFrequently:!0});i&&((r=i).globalCompositeOperation="copy",s=r.createLinearGradient(0,0,1,1))}catch{}e.toColor=function(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return hW=parseInt(e.slice(1,2).repeat(2),16),h$=parseInt(e.slice(2,3).repeat(2),16),hH=parseInt(e.slice(3,4).repeat(2),16),hF.toColor(hW,h$,hH);case 5:return hW=parseInt(e.slice(1,2).repeat(2),16),h$=parseInt(e.slice(2,3).repeat(2),16),hH=parseInt(e.slice(3,4).repeat(2),16),hU=parseInt(e.slice(4,5).repeat(2),16),hF.toColor(hW,h$,hH,hU);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 i=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(i)return hW=parseInt(i[1]),h$=parseInt(i[2]),hH=parseInt(i[3]),hU=Math.round((void 0===i[5]?1:parseFloat(i[5]))*255),hF.toColor(hW,h$,hH,hU);if(!r||!s||(r.fillStyle=s,r.fillStyle=e,"string"!=typeof r.fillStyle)||(r.fillRect(0,0,1,1),[hW,h$,hH,hU]=r.getImageData(0,0,1,1).data,255!==hU))throw Error("css.toColor: Unsupported css format");return{rgba:hF.toRgba(hW,h$,hH,hU),css:e}}})(fw||={});var hY=fS||={};function hX(e,r,s){let i=e/255,n=r/255,o=s/255;return .2126*(i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4))+.7152*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))+.0722*(o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4))}hY.relativeLuminance=function(e){return hX(e>>16&255,e>>8&255,255&e)},hY.relativeLuminance2=hX;var hG=fC||={};function hJ(e,r,s){let i=e>>24&255,n=e>>16&255,o=e>>8&255,a=r>>24&255,l=r>>16&255,c=r>>8&255,d=h0(fS.relativeLuminance2(a,l,c),fS.relativeLuminance2(i,n,o));for(;d<s&&(a>0||l>0||c>0);)a-=Math.max(0,Math.ceil(.1*a)),l-=Math.max(0,Math.ceil(.1*l)),c-=Math.max(0,Math.ceil(.1*c)),d=h0(fS.relativeLuminance2(a,l,c),fS.relativeLuminance2(i,n,o));return(a<<24|l<<16|c<<8|255)>>>0}function hZ(e,r,s){let i=e>>24&255,n=e>>16&255,o=e>>8&255,a=r>>24&255,l=r>>16&255,c=r>>8&255,d=h0(fS.relativeLuminance2(a,l,c),fS.relativeLuminance2(i,n,o));for(;d<s&&(a<255||l<255||c<255);)a=Math.min(255,a+Math.ceil((255-a)*.1)),l=Math.min(255,l+Math.ceil((255-l)*.1)),c=Math.min(255,c+Math.ceil((255-c)*.1)),d=h0(fS.relativeLuminance2(a,l,c),fS.relativeLuminance2(i,n,o));return(a<<24|l<<16|c<<8|255)>>>0}function hQ(e){let r=e.toString(16);return r.length<2?"0"+r:r}function h0(e,r){return e<r?(r+.05)/(e+.05):(e+.05)/(r+.05)}hG.blend=function(e,r){if(1==(hU=(255&r)/255))return r;let s=e>>24&255,i=e>>16&255,n=e>>8&255;return hW=s+Math.round(((r>>24&255)-s)*hU),h$=i+Math.round(((r>>16&255)-i)*hU),hH=n+Math.round(((r>>8&255)-n)*hU),hF.toRgba(hW,h$,hH)},hG.ensureContrastRatio=function(e,r,s){let i=fS.relativeLuminance(e>>8),n=fS.relativeLuminance(r>>8);if(h0(i,n)<s){if(n<i){let n=hJ(e,r,s),o=h0(i,fS.relativeLuminance(n>>8));if(o<s){let a=hZ(e,r,s);return o>h0(i,fS.relativeLuminance(a>>8))?n:a}return n}let o=hZ(e,r,s),a=h0(i,fS.relativeLuminance(o>>8));if(a<s){let n=hJ(e,r,s);return a>h0(i,fS.relativeLuminance(n>>8))?o:n}return o}},hG.reduceLuminance=hJ,hG.increaseLuminance=hZ,hG.toChannels=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]};var h1=class extends lZ{constructor(e,r,s){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=r,this._width=s}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()]}},h2=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new l0}register(e){let r={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(r),r.id}deregister(e){for(let r=0;r<this._characterJoiners.length;r++)if(this._characterJoiners[r].id===e)return this._characterJoiners.splice(r,1),!0;return!1}getJoinedCharacters(e){if(0===this._characterJoiners.length)return[];let r=this._bufferService.buffer.lines.get(e);if(!r||0===r.length)return[];let s=[],i=r.translateToString(!0),n=0,o=0,a=0,l=r.getFg(0),c=r.getBg(0);for(let e=0;e<r.getTrimmedLength();e++)if(r.loadCell(e,this._workCell),0!==this._workCell.getWidth()){if(this._workCell.fg!==l||this._workCell.bg!==c){if(e-n>1){let e=this._getJoinedRanges(i,a,o,r,n);for(let r=0;r<e.length;r++)s.push(e[r])}n=e,a=o,l=this._workCell.fg,c=this._workCell.bg}o+=this._workCell.getChars().length||1}if(this._bufferService.cols-n>1){let e=this._getJoinedRanges(i,a,o,r,n);for(let r=0;r<e.length;r++)s.push(e[r])}return s}_getJoinedRanges(e,r,s,i,n){let o=e.substring(r,s),a=[];try{a=this._characterJoiners[0].handler(o)}catch(e){console.error(e)}for(let e=1;e<this._characterJoiners.length;e++)try{let r=this._characterJoiners[e].handler(o);for(let e=0;e<r.length;e++)h2._mergeRanges(a,r[e])}catch(e){console.error(e)}return this._stringRangesToCellRanges(a,i,n),a}_stringRangesToCellRanges(e,r,s){let i=0,n=!1,o=0,a=e[0];if(a){for(let l=s;l<this._bufferService.cols;l++){let s=r.getWidth(l),c=r.getString(l).length||1;if(0!==s){if(!n&&a[0]<=o&&(a[0]=l,n=!0),a[1]<=o){if(a[1]=l,!(a=e[++i]))break;a[0]<=o?(a[0]=l,n=!0):n=!1}o+=c}}a&&(a[1]=this._bufferService.cols)}}static _mergeRanges(e,r){let s=!1;for(let i=0;i<e.length;i++){let n=e[i];if(s){if(r[1]<=n[0])return e[i-1][1]=r[1],e;if(r[1]<=n[1])return e[i-1][1]=Math.max(r[1],n[1]),e.splice(i,1),e;e.splice(i,1),i--}else{if(r[1]<=n[0])return e.splice(i,0,r),e;if(r[1]<=n[1])return n[0]=Math.min(r[0],n[0]),e;r[0]<n[1]&&(n[0]=Math.min(r[0],n[0]),s=!0);continue}}return s?e[e.length-1][1]=r[1]:e.push(r),e}};function h5(){return{width:0,height:0}}h2=lW([l$(0,l4)],h2);var h3=class{constructor(e,r,s,i,n,o,a){this._document=e,this._characterJoinerService=r,this._optionsService=s,this._coreBrowserService=i,this._coreService=n,this._decorationService=o,this._themeService=a,this._workCell=new l0,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,r,s){this._selectionStart=e,this._selectionEnd=r,this._columnSelectMode=s}createRow(e,r,s,i,n,o,a,l,c,d,h){let u=[],f=this._characterJoinerService.getJoinedCharacters(r),p=this._themeService.colors,m=e.getNoBgTrimmedLength();s&&m<o+1&&(m=o+1);let g,v=0,x="",_=0,y=0,b=0,w=0,S=!1,C=0,k=!1,j=0,N=0,E=[],R=-1!==d&&-1!==h;for(let M=0;M<m;M++){let m;e.loadCell(M,this._workCell);let D=this._workCell.getWidth();if(0===D)continue;let T=!1,P=M>=N,L=M,A=this._workCell;if(f.length>0&&M===f[0][0]&&P){let i=f.shift(),n=this._isCellInSelection(i[0],r);for(_=i[0]+1;_<i[1];_++)P&&=n===this._isCellInSelection(_,r);(P&&=!s||o<i[0]||o>=i[1])?(T=!0,A=new h1(this._workCell,e.translateToString(!0,i[0],i[1]),i[1]-i[0]),L=i[1]-1,D=A.getWidth()):N=i[1]}let B=this._isCellInSelection(M,r),I=s&&M===o,O=R&&M>=d&&M<=h,z=!1;this._decorationService.forEachDecorationAtCell(M,r,void 0,e=>{z=!0});let F=A.getChars()||" ";if(" "===F&&(A.isUnderline()||A.isOverline())&&(F=" "),j=D*l-c.get(F,A.isBold(),A.isItalic()),g)if(v&&(B&&k||!B&&!k&&A.bg===y)&&(B&&k&&p.selectionForeground||A.fg===b)&&A.extended.ext===w&&O===S&&j===C&&!I&&!T&&!z&&P){A.isInvisible()?x+=" ":x+=F,v++;continue}else v&&(g.textContent=x),g=this._document.createElement("span"),v=0,x="";else g=this._document.createElement("span");if(y=A.bg,b=A.fg,w=A.extended.ext,S=O,C=j,k=B,T&&o>=M&&o<=L&&(o=M),!this._coreService.isCursorHidden&&I&&this._coreService.isCursorInitialized){if(E.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&E.push("xterm-cursor-blink"),E.push("bar"===i?"xterm-cursor-bar":"underline"===i?"xterm-cursor-underline":"xterm-cursor-block");else if(n)switch(n){case"outline":E.push("xterm-cursor-outline");break;case"block":E.push("xterm-cursor-block");break;case"bar":E.push("xterm-cursor-bar");break;case"underline":E.push("xterm-cursor-underline")}}if(A.isBold()&&E.push("xterm-bold"),A.isItalic()&&E.push("xterm-italic"),A.isDim()&&E.push("xterm-dim"),x=A.isInvisible()?" ":A.getChars()||" ",A.isUnderline()&&(E.push(`xterm-underline-${A.extended.underlineStyle}`)," "===x&&(x=" "),!A.isUnderlineColorDefault()))if(A.isUnderlineColorRGB())g.style.textDecorationColor=`rgb(${lZ.toColorRGB(A.getUnderlineColor()).join(",")})`;else{let e=A.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&A.isBold()&&e<8&&(e+=8),g.style.textDecorationColor=p.ansi[e].css}A.isOverline()&&(E.push("xterm-overline")," "===x&&(x=" ")),A.isStrikethrough()&&E.push("xterm-strikethrough"),O&&(g.style.textDecoration="underline");let W=A.getFgColor(),$=A.getFgColorMode(),H=A.getBgColor(),U=A.getBgColorMode(),K=!!A.isInverse();if(K){let e=W;W=H,H=e;let r=$;$=U,U=r}let q,V,Y=!1;switch(this._decorationService.forEachDecorationAtCell(M,r,void 0,e=>{"top"!==e.options.layer&&Y||(e.backgroundColorRGB&&(U=0x3000000,H=e.backgroundColorRGB.rgba>>8&0xffffff,q=e.backgroundColorRGB),e.foregroundColorRGB&&($=0x3000000,W=e.foregroundColorRGB.rgba>>8&0xffffff,V=e.foregroundColorRGB),Y="top"===e.options.layer)}),!Y&&B&&(H=(q=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque).rgba>>8&0xffffff,U=0x3000000,Y=!0,p.selectionForeground&&($=0x3000000,W=p.selectionForeground.rgba>>8&0xffffff,V=p.selectionForeground)),Y&&E.push("xterm-decoration-top"),U){case 0x1000000:case 0x2000000:m=p.ansi[H],E.push(`xterm-bg-${H}`);break;case 0x3000000:m=hF.toColor(H>>16,H>>8&255,255&H),this._addStyle(g,`background-color:#${h4((H>>>0).toString(16),"0",6)}`);break;default:K?(m=p.foreground,E.push("xterm-bg-257")):m=p.background}switch(q||A.isDim()&&(q=fb.multiplyOpacity(m,.5)),$){case 0x1000000:case 0x2000000:A.isBold()&&W<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(W+=8),this._applyMinimumContrast(g,m,p.ansi[W],A,q,void 0)||E.push(`xterm-fg-${W}`);break;case 0x3000000:let X=hF.toColor(W>>16&255,W>>8&255,255&W);this._applyMinimumContrast(g,m,X,A,q,V)||this._addStyle(g,`color:#${h4(W.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(g,m,p.foreground,A,q,V)||K&&E.push("xterm-fg-257")}E.length&&(g.className=E.join(" "),E.length=0),I||T||z||!P?g.textContent=x:v++,j!==this.defaultSpacing&&(g.style.letterSpacing=`${j}px`),u.push(g),M=L}return g&&v&&(g.textContent=x),u}_applyMinimumContrast(e,r,s,i,n,o){var a,l,c;if(1===this._optionsService.rawOptions.minimumContrastRatio||57508<=(l=a=i.getCode())&&l<=57558||9472<=(c=a)&&c<=9631)return!1;let d=this._getContrastCache(i),h;if(n||o||(h=d.getColor(r.rgba,s.rgba)),void 0===h){let e=this._optionsService.rawOptions.minimumContrastRatio/(i.isDim()?2:1);h=fb.ensureContrastRatio(n||r,o||s,e),d.setColor((n||r).rgba,(o||s).rgba,h??null)}return!!h&&(this._addStyle(e,`color:${h.css}`),!0)}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,r){e.setAttribute("style",`${e.getAttribute("style")||""}${r};`)}_isCellInSelection(e,r){let s=this._selectionStart,i=this._selectionEnd;return!!s&&!!i&&(this._columnSelectMode?s[0]<=i[0]?e>=s[0]&&r>=s[1]&&e<i[0]&&r<=i[1]:e<s[0]&&r>=s[1]&&e>=i[0]&&r<=i[1]:r>s[1]&&r<i[1]||s[1]===i[1]&&r===s[1]&&e>=s[0]&&e<i[0]||s[1]<i[1]&&r===i[1]&&e<i[0]||s[1]<i[1]&&r===s[1]&&e>=s[0])}};function h4(e,r,s){for(;e.length<s;)e=r+e;return e}h3=lW([l$(1,ch),l$(2,ct),l$(3,ca),l$(4,l8),l$(5,ci),l$(6,cu)],h3);var h6=class{constructor(e,r){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 s=e.createElement("span");s.classList.add("xterm-char-measure-element");let i=e.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontWeight="bold";let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontStyle="italic";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[s,i,n,o],this._container.appendChild(s),this._container.appendChild(i),this._container.appendChild(n),this._container.appendChild(o),r.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,r,s,i){e===this._font&&r===this._fontSize&&s===this._weight&&i===this._weightBold||(this._font=e,this._fontSize=r,this._weight=s,this._weightBold=i,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${i}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${i}`,this.clear())}get(e,r,s){let i=0;if(!r&&!s&&1===e.length&&(i=e.charCodeAt(0))<256){if(-9999!==this._flat[i])return this._flat[i];let r=this._measure(e,0);return r>0&&(this._flat[i]=r),r}let n=e;r&&(n+="B"),s&&(n+="I");let o=this._holey.get(n);if(void 0===o){let i=0;r&&(i|=1),s&&(i|=2),(o=this._measure(e,i))>0&&this._holey.set(n,o)}return o}_measure(e,r){let s=this._measureElements[r];return s.textContent=e.repeat(32),s.offsetWidth/32}},h8=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,r,s,i=!1){if(this.selectionStart=r,this.selectionEnd=s,!r||!s||r[0]===s[0]&&r[1]===s[1])return void this.clear();let n=e.buffers.active.ydisp,o=r[1]-n,a=s[1]-n,l=Math.max(o,0),c=Math.min(a,e.rows-1);l>=e.rows||c<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=i,this.viewportStartRow=o,this.viewportEndRow=a,this.viewportCappedStartRow=l,this.viewportCappedEndRow=c,this.startCol=r[0],this.endCol=s[0])}isCellSelected(e,r,s){return!!this.hasSelection&&(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?r>=this.startCol&&s>=this.viewportCappedStartRow&&r<this.endCol&&s<=this.viewportCappedEndRow:r<this.startCol&&s>=this.viewportCappedStartRow&&r>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&r>=this.startCol&&r<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&r<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&r>=this.startCol)}},h7="xterm-dom-renderer-owner-",h9="xterm-rows",ue="xterm-fg-",ut="xterm-bg-",ur="xterm-focus",us="xterm-selection",ui=1,un=class extends cE{constructor(e,r,s,i,n,o,a,l,c,d,h,u,f,p){super(),this._terminal=e,this._document=r,this._element=s,this._screenElement=i,this._viewportElement=n,this._helperContainer=o,this._linkifier2=a,this._charSizeService=c,this._optionsService=d,this._bufferService=h,this._coreService=u,this._coreBrowserService=f,this._themeService=p,this._terminalClass=ui++,this._rowElements=[],this._selectionRenderModel=new h8,this.onRequestRedraw=this._register(new c2).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(h9),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(us),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions={css:{canvas:h5(),cell:h5()},device:{canvas:h5(),cell:h5(),char:{width:0,height:0,left:0,top:0}}},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=l.createInstance(h3,document),this._element.classList.add(h7+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(ck(()=>{this._element.classList.remove(h7+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new h6(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;for(let r of(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,this._rowElements))r.style.width=`${this.dimensions.css.canvas.width}px`,r.style.height=`${this.dimensions.css.cell.height}px`,r.style.lineHeight=`${this.dimensions.css.cell.height}px`,r.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let r=`${this._terminalSelector} .${h9} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=r,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 r=`${this._terminalSelector} .${h9} { 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}`;r+=`${this._terminalSelector} .${h9} .xterm-dim { color: ${fb.multiplyOpacity(e.foreground,.5).css};}${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 s=`blink_underline_${this._terminalClass}`,i=`blink_bar_${this._terminalClass}`,n=`blink_block_${this._terminalClass}`;for(let[o,a]of(r+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}@keyframes ${i} { 50% { box-shadow: none; }}@keyframes ${n} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}${this._terminalSelector} .${h9}.${ur} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${h9}.${ur} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${h9}.${ur} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${h9} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${h9} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${h9} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${h9} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${h9} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}${this._terminalSelector} .${us} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${us} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${us} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`,e.ansi.entries()))r+=`${this._terminalSelector} .${ue}${o} { color: ${a.css}; }${this._terminalSelector} .${ue}${o}.xterm-dim { color: ${fb.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${ut}${o} { background-color: ${a.css}; }`;r+=`${this._terminalSelector} .${ue}257 { color: ${fb.opaque(e.background).css}; }${this._terminalSelector} .${ue}257.xterm-dim { color: ${fb.multiplyOpacity(fb.opaque(e.background),.5).css}; }${this._terminalSelector} .${ut}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=r}_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,r){for(let e=this._rowElements.length;e<=r;e++){let e=this._document.createElement("div");this._rowContainer.appendChild(e),this._rowElements.push(e)}for(;this._rowElements.length>r;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,r){this._refreshRowElements(e,r),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(ur),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(ur),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,r,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,r,s),this.renderRows(0,this._bufferService.rows-1),!e||!r||(this._selectionRenderModel.update(this._terminal,e,r,s),!this._selectionRenderModel.hasSelection))return;let i=this._selectionRenderModel.viewportStartRow,n=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(s){let s=e[0]>r[0];l.appendChild(this._createSelectionElement(o,s?r[0]:e[0],s?e[0]:r[0],a-o+1))}else{let s=i===o?e[0]:0,c=o===n?r[0]:this._bufferService.cols;if(l.appendChild(this._createSelectionElement(o,s,c)),l.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,a-o-1)),o!==a){let e=n===a?r[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(a,0,e))}}this._selectionContainer.appendChild(l)}_createSelectionElement(e,r,s,i=1){let n=this._document.createElement("div"),o=r*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(s-r);return o+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-o),n.style.height=`${i*this.dimensions.css.cell.height}px`,n.style.top=`${e*this.dimensions.css.cell.height}px`,n.style.left=`${o}px`,n.style.width=`${a}px`,n}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,r){let s=this._bufferService.buffer,i=s.ybase+s.y,n=Math.min(s.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=r;c++){let e=c+s.ydisp,r=this._rowElements[c],d=s.lines.get(e);if(!r||!d)break;r.replaceChildren(...this._rowFactory.createRow(d,e,e===i,a,l,n,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${h7}${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,r,s,i,n,o){s<0&&(e=0),i<0&&(r=0);let a=this._bufferService.rows-1;s=Math.max(Math.min(s,a),0),i=Math.max(Math.min(i,a),0),n=Math.min(n,this._bufferService.cols);let l=this._bufferService.buffer,c=l.ybase+l.y,d=Math.min(l.x,n-1),h=this._optionsService.rawOptions.cursorBlink,u=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let a=s;a<=i;++a){let p=a+l.ydisp,m=this._rowElements[a],g=l.lines.get(p);if(!m||!g)break;m.replaceChildren(...this._rowFactory.createRow(g,p,p===c,u,f,d,h,this.dimensions.css.cell.width,this._widthCache,o?a===s?e:0:-1,o?(a===i?r:n)-1:-1))}}};un=lW([l$(7,l9),l$(8,co),l$(9,ct),l$(10,l4),l$(11,l8),l$(12,ca),l$(13,cu)],un);var uo=class extends cE{constructor(e,r,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new c2),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new uc(this._optionsService))}catch{this._measureStrategy=this._register(new ul(e,r,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())}};uo=lW([l$(2,ct)],uo);var ua=class extends cE{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,r){void 0!==e&&e>0&&void 0!==r&&r>0&&(this._result.width=e,this._result.height=r)}},ul=class extends ua{constructor(e,r,s){super(),this._document=e,this._parentElement=r,this._optionsService=s,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}},uc=class extends ua{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let r=this._ctx.measureText("W");if(!("width"in r&&"fontBoundingBoxAscent"in r&&"fontBoundingBoxDescent"in r))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}},ud=class extends cE{constructor(e,r,s){super(),this._textarea=e,this._window=r,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new uh(this._window)),this._onDprChange=this._register(new c2),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new c2),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(cX.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(d8(this._textarea,"focus",()=>this._isFocused=!0)),this._register(d8(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 void 0===this._cachedIsFocused&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},uh=class extends cE{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new cR),this._onDprChange=this._register(new c2),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(ck(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=d8(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)}},uu=class extends cE{constructor(){super(),this.linkProviders=[],this._register(ck(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let r=this.linkProviders.indexOf(e);-1!==r&&this.linkProviders.splice(r,1)}}}};function uf(e,r,s){let i=s.getBoundingClientRect(),n=e.getComputedStyle(s),o=parseInt(n.getPropertyValue("padding-left")),a=parseInt(n.getPropertyValue("padding-top"));return[r.clientX-i.left-o,r.clientY-i.top-a]}var up=class{constructor(e,r){this._renderService=e,this._charSizeService=r}getCoords(e,r,s,i,n){return function(e,r,s,i,n,o,a,l,c){if(!o)return;let d=uf(e,r,s);return d[0]=Math.ceil((d[0]+(c?a/2:0))/a),d[1]=Math.ceil(d[1]/l),d[0]=Math.min(Math.max(d[0],1),i+ +!!c),d[1]=Math.min(Math.max(d[1],1),n),d}(window,e,r,s,i,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,n)}getMouseReportCoords(e,r){let s=uf(window,e,r);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};up=lW([l$(0,cc),l$(1,co)],up);var um=class{constructor(e,r){this._renderCallback=e,this._coreBrowserService=r,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,r,s){this._rowCount=s,e=void 0!==e?e:0,r=void 0!==r?r:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,e):e,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,r):r,this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,void 0===this._rowStart||void 0===this._rowEnd||void 0===this._rowCount)return void this._runRefreshCallbacks();let e=Math.max(this._rowStart,0),r=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,r),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},ug={},uv={getSafariVersion:()=>uk,isChromeOS:()=>uD,isFirefox:()=>uw,isIpad:()=>uN,isIphone:()=>uE,isLegacyEdge:()=>uS,isLinux:()=>uM,isMac:()=>uj,isNode:()=>u_,isSafari:()=>uC,isWindows:()=>uR};for(var ux in uv)lz(ug,ux,{get:uv[ux],enumerable:!0});var u_="u">typeof lO.default&&"title"in lO.default,uy=u_?"node":navigator.userAgent,ub=u_?"node":navigator.platform,uw=uy.includes("Firefox"),uS=uy.includes("Edge"),uC=/^((?!chrome|android).)*safari/i.test(uy);function uk(){if(!uC)return 0;let e=uy.match(/Version\/(\d+)/);return null===e||e.length<2?0:parseInt(e[1])}var uj=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(ub),uN="iPad"===ub,uE="iPhone"===ub,uR=["Windows","Win16","Win32","WinCE"].includes(ub),uM=ub.indexOf("Linux")>=0,uD=/\bCrOS\b/.test(uy),uT=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),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let r=0,s=0,i=e.timeRemaining(),n=0;for(;this._i<this._tasks.length;){if(r=performance.now(),this._tasks[this._i]()||this._i++,1.5*(s=Math.max(r=Math.max(1,performance.now()-r),s))>(n=e.timeRemaining())){i-r<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-r))}ms`),this._start();return}i=n}this.clear()}},uP=class extends uT{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let r=performance.now()+e;return{timeRemaining:()=>Math.max(0,r-performance.now())}}},uL=class extends uT{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},uA=!u_&&"requestIdleCallback"in window?uL:uP,uB=class{constructor(){this._queue=new uA}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},uI=class extends cE{constructor(e,r,s,i,n,o,a,l,c){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=i,this._coreService=n,this._coreBrowserService=l,this._renderer=this._register(new cR),this._pausedResizeTask=new uB,this._observerDisposable=this._register(new cR),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 c2),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new c2),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new c2),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new c2),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new um((e,r)=>this._renderRows(e,r),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new uO(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(ck(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(a.onResize(()=>this._fullRefresh())),this._register(a.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(a.cols,a.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(a.buffer.y,a.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,r),this._register(this._coreBrowserService.onWindowChange(e=>this._registerIntersectionObserver(e,r)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,r){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(e=>this._handleIntersectionChange(e[e.length-1]),{threshold:0});s.observe(r),this._observerDisposable.value=ck(()=>s.disconnect())}}_handleIntersectionChange(e){this._isPaused=void 0===e.isIntersecting?0===e.intersectionRatio:!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,r,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput)return void this._syncOutputHandler.bufferRows(e,r);let i=this._syncOutputHandler.flush();i&&(e=Math.min(e,i.start),r=Math.max(r,i.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,r,this._rowCount)}_renderRows(e,r){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput)return void this._syncOutputHandler.bufferRows(e,r);e=Math.min(e,this._rowCount-1),r=Math.min(r,this._rowCount-1),this._renderer.value.renderRows(e,r),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:r}),this._onRender.fire({start:e,end:r}),this._isNextRenderRedrawOnly=!0}}resize(e,r){this._rowCount=r,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,r){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,r)):this._renderer.value.handleResize(e,r),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,r,s){this._selectionState.start=e,this._selectionState.end=r,this._selectionState.columnSelectMode=s,this._renderer.value?.handleSelectionChanged(e,r,s)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};uI=lW([l$(2,ct),l$(3,co),l$(4,l8),l$(5,ci),l$(6,l4),l$(7,ca),l$(8,cu)],uI);var uO=class{constructor(e,r,s){this._coreBrowserService=e,this._coreService=r,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,r){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,r)):(this._start=e,this._end=r,this._isBuffering=!0),void 0===this._timeout&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(void 0!==this._timeout&&(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(){void 0!==this._timeout&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function uz(e,r,s,i){return uH(Math.abs(e-uF(e,s)-(r-uF(r,s)))-function(e,r,s){let i=0,n=e-uF(e,s),o=r-uF(r,s);for(let a=0;a<Math.abs(n-o);a++){let o="A"===function(e,r){return e>r?"A":"B"}(e,r)?-1:1;s.buffer.lines.get(n+o*a)?.isWrapped&&i++}return i}(e,r,s),u$(e>r?"A":"B",i))}function uF(e,r){let s=0,i=r.buffer.lines.get(e),n=i?.isWrapped;for(;n&&e>=0&&e<r.rows;)s++,i=r.buffer.lines.get(--e),n=i?.isWrapped;return s}function uW(e,r,s,i,n,o){let a=e,l=r,c="";for(;(a!==s||l!==i)&&l>=0&&l<o.buffer.lines.length;)a+=n?1:-1,n&&a>o.cols-1?(c+=o.buffer.translateBufferLineToString(l,!1,e,a),a=0,e=0,l++):!n&&a<0&&(c+=o.buffer.translateBufferLineToString(l,!1,0,e+1),e=a=o.cols-1,l--);return c+o.buffer.translateBufferLineToString(l,!1,e,a)}function u$(e,r){return hI.ESC+(r?"O":"[")+e}function uH(e,r){e=Math.floor(e);let s="";for(let i=0;i<e;i++)s+=r;return s}var uU=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.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,r=this.selectionEnd;return!!e&&!!r&&(e[1]>r[1]||e[1]===r[1]&&e[0]>r[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 uK(e,r){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 r*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var uq=RegExp(" ","g"),uV=class extends cE{constructor(e,r,s,i,n,o,a,l,c){super(),this._element=e,this._screenElement=r,this._linkifier=s,this._bufferService=i,this._coreService=n,this._mouseService=o,this._optionsService=a,this._renderService=l,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new l0,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new c2),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new c2),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new c2),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new c2),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 uU(this._bufferService),this._activeSelectionMode=0,this._register(ck(()=>{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,r=this._model.finalSelectionEnd;return!!e&&!!r&&(e[0]!==r[0]||e[1]!==r[1])}get selectionText(){let e=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;if(!e||!r)return"";let s=this._bufferService.buffer,i=[];if(3===this._activeSelectionMode){if(e[0]===r[0])return"";let n=e[0]<r[0]?e[0]:r[0],o=e[0]<r[0]?r[0]:e[0];for(let a=e[1];a<=r[1];a++){let e=s.translateBufferLineToString(a,!0,n,o);i.push(e)}}else{let n=e[1]===r[1]?r[0]:void 0;i.push(s.translateBufferLineToString(e[1],!0,e[0],n));for(let n=e[1]+1;n<=r[1]-1;n++){let e=s.lines.get(n),r=s.translateBufferLineToString(n,!0);e?.isWrapped?i[i.length-1]+=r:i.push(r)}if(e[1]!==r[1]){let e=s.lines.get(r[1]),n=s.translateBufferLineToString(r[1],!0,0,r[0]);e&&e.isWrapped?i[i.length-1]+=n:i.push(n)}}return i.map(e=>e.replace(uq," ")).join(uR?`\r
18
+ `:`
19
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),uM&&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:3===this._activeSelectionMode})}_isClickInSelection(e){let r=this._getMouseBufferCoords(e),s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!!s&&!!i&&!!r&&this._areCoordsInSelection(r,s,i)}isCellInSelection(e,r){let s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!!s&&!!i&&this._areCoordsInSelection([e,r],s,i)}_areCoordsInSelection(e,r,s){return e[1]>r[1]&&e[1]<s[1]||r[1]===s[1]&&e[1]===r[1]&&e[0]>=r[0]&&e[0]<s[0]||r[1]<s[1]&&e[1]===s[1]&&e[0]<s[0]||r[1]<s[1]&&e[1]===r[1]&&e[0]>=r[0]}_selectWordAtCursor(e,r){let s=this._linkifier.currentLink?.link?.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=uK(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let i=this._getMouseBufferCoords(e);return!!i&&(this._selectWordAt(i,r),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,r){this._model.clearSelection(),e=Math.max(e,0),r=Math.min(r,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,r],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let r=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(r)return r[0]--,r[1]--,r[1]+=this._bufferService.buffer.ydisp,r}_getMouseEventScrollAmount(e){let r=uf(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return r>=0&&r<=s?0:(r>s&&(r-=s),(r=Math.min(Math.max(r,-50),50)/50)/Math.abs(r)+Math.round(14*r))}shouldForceSelection(e){return uj?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(2===e.button&&this.hasSelection)&&0===e.button){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):1===e.detail?this._handleSingleClick(e):2===e.detail?this._handleDoubleClick(e):3===e.detail&&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(),50)}_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=3*!!this.shouldColumnSelect(e),this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let r=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);r&&r.length!==this._model.selectionStart[0]&&0===r.hasWidth(this._model.selectionStart[0])&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let r=this._getMouseBufferCoords(e);r&&(this._activeSelectionMode=2,this._selectLineAt(r[1]))}shouldColumnSelect(e){return e.altKey&&!(uj&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let r=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd)return void this.refresh(!0);2===this._activeSelectionMode?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:1===this._activeSelectionMode&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),3!==this._activeSelectionMode&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let e=s.lines.get(this._model.selectionEnd[1]);e&&0===e.hasWidth(this._model.selectionEnd[0])&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}r&&r[0]===this._model.selectionEnd[0]&&r[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?(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let r=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&r<500&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let r=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(r&&void 0!==r[0]&&void 0!==r[1]){let e=function(e,r,s,i){var n,o,a,l,c,d,h,u,f,p,m,g,v,x,_,y,b,w;let S,C=s.buffer.x,k=s.buffer.y;if(!s.buffer.hasScrollback){let b,w,S;return n=C,a=0,(0===uz(o=k,r,l=s,c=i).length?"":uH(uW(n,o,n,o-uF(o,l),!1,l).length,u$("D",c)))+uz(k,r,s,i)+(d=C,h=k,u=e,b=uz(h,f=r,p=s,m=i).length>0?f-uF(f,p):h,S=(g=d,v=h,w=uz(x=u,_=f,y=p,m).length>0?_-uF(_,y):v,g<x&&w<=_||g>=x&&w<_?"C":"D"),uH(uW(d,b,u,f,"C"===S,p).length,u$(S,m)))}if(k===r)return S=C>e?"D":"C",uH(Math.abs(C-e),u$(S,i));S=k>r?"D":"C";let j=Math.abs(k-r);return uH((b=k>r?e:C,s.cols-b+(j-1)*s.cols+1+(w=0,(k>r?C:e)-1)),u$(S,i))}(r[0]-1,r[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,r=this._model.finalSelectionEnd,s=!!e&&!!r&&(e[0]!==r[0]||e[1]!==r[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(e,r,s);return}!e||!r||this._oldSelectionStart&&this._oldSelectionEnd&&e[0]===this._oldSelectionStart[0]&&e[1]===this._oldSelectionStart[1]&&r[0]===this._oldSelectionEnd[0]&&r[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(e,r,s)}_fireOnSelectionChange(e,r,s){this._oldSelectionStart=e,this._oldSelectionEnd=r,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,r){let s=r;for(let i=0;r>=i;i++){let n=e.loadCell(i,this._workCell).getChars().length;0===this._workCell.getWidth()?s--:n>1&&r!==i&&(s+=n-1)}return s}setSelection(e,r,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,r],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,r,s=!0,i=!0){if(e[0]>=this._bufferService.cols)return;let n=this._bufferService.buffer,o=n.lines.get(e[1]);if(!o)return;let a=n.translateBufferLineToString(e[1],!1),l=this._convertViewportColToCharacterIndex(o,e[0]),c=l,d=e[0]-l,h=0,u=0,f=0,p=0;if(" "===a.charAt(l)){for(;l>0&&" "===a.charAt(l-1);)l--;for(;c<a.length&&" "===a.charAt(c+1);)c++}else{let r=e[0],s=e[0];0===o.getWidth(r)&&(h++,r--),2===o.getWidth(s)&&(u++,s++);let i=o.getString(s).length;for(i>1&&(p+=i-1,c+=i-1);r>0&&l>0&&!this._isCharWordSeparator(o.loadCell(r-1,this._workCell));){o.loadCell(r-1,this._workCell);let e=this._workCell.getChars().length;0===this._workCell.getWidth()?(h++,r--):e>1&&(f+=e-1,l-=e-1),l--,r--}for(;s<o.length&&c+1<a.length&&!this._isCharWordSeparator(o.loadCell(s+1,this._workCell));){o.loadCell(s+1,this._workCell);let e=this._workCell.getChars().length;2===this._workCell.getWidth()?(u++,s++):e>1&&(p+=e-1,c+=e-1),c++,s++}}c++;let m=l+d-h+f,g=Math.min(this._bufferService.cols,c-l+h+u-f-p);if(!(!r&&""===a.slice(l,c).trim())){if(s&&0===m&&32!==o.getCodePoint(0)){let r=n.lines.get(e[1]-1);if(r&&o.isWrapped&&32!==r.getCodePoint(this._bufferService.cols-1)){let r=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(r){let e=this._bufferService.cols-r.start;m-=e,g+=e}}}if(i&&m+g===this._bufferService.cols&&32!==o.getCodePoint(this._bufferService.cols-1)){let r=n.lines.get(e[1]+1);if(r?.isWrapped&&32!==r.getCodePoint(0)){let r=this._getWordAt([0,e[1]+1],!1,!1,!0);r&&(g+=r.length)}}return{start:m,length:g}}}_selectWordAt(e,r){let s=this._getWordAt(e,r);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let r=this._getWordAt(e,!0);if(r){let s=e[1];for(;r.start<0;)r.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;r.start+r.length>this._bufferService.cols;)r.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?r.start:r.start+r.length,s]}}_isCharWordSeparator(e){return 0!==e.getWidth()&&this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let r=this._bufferService.buffer.getWrappedRangeForLine(e),s={start:{x:0,y:r.first},end:{x:this._bufferService.cols-1,y:r.last}};this._model.selectionStart=[0,r.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=uK(s,this._bufferService.cols)}};uV=lW([l$(3,l4),l$(4,l8),l$(5,cl),l$(6,ct),l$(7,cc),l$(8,ca)],uV);var uY=class{constructor(){this._data={}}set(e,r,s){this._data[e]||(this._data[e]={}),this._data[e][r]=s}get(e,r){return this._data[e]?this._data[e][r]:void 0}clear(){this._data={}}},uX=class{constructor(){this._color=new uY,this._css=new uY}setCss(e,r,s){this._css.set(e,r,s)}getCss(e,r){return this._css.get(e,r)}setColor(e,r,s){this._color.set(e,r,s)}getColor(e,r){return this._color.get(e,r)}clear(){this._color.clear(),this._css.clear()}},uG=Object.freeze((()=>{let e=[fw.toColor("#2e3436"),fw.toColor("#cc0000"),fw.toColor("#4e9a06"),fw.toColor("#c4a000"),fw.toColor("#3465a4"),fw.toColor("#75507b"),fw.toColor("#06989a"),fw.toColor("#d3d7cf"),fw.toColor("#555753"),fw.toColor("#ef2929"),fw.toColor("#8ae234"),fw.toColor("#fce94f"),fw.toColor("#729fcf"),fw.toColor("#ad7fa8"),fw.toColor("#34e2e2"),fw.toColor("#eeeeec")],r=[0,95,135,175,215,255];for(let s=0;s<216;s++){let i=r[s/36%6|0],n=r[s/6%6|0],o=r[s%6];e.push({css:hF.toCss(i,n,o),rgba:hF.toRgba(i,n,o)})}for(let r=0;r<24;r++){let s=8+10*r;e.push({css:hF.toCss(s,s,s),rgba:hF.toRgba(s,s,s)})}return e})()),uJ=fw.toColor("#ffffff"),uZ=fw.toColor("#000000"),uQ=fw.toColor("#ffffff"),u0={css:"rgba(255, 255, 255, 0.3)",rgba:0xffffff4d},u1=class extends cE{constructor(e){super(),this._optionsService=e,this._contrastCache=new uX,this._halfContrastCache=new uX,this._onChangeColors=this._register(new c2),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:uJ,background:uZ,cursor:uQ,cursorAccent:uZ,selectionForeground:void 0,selectionBackgroundTransparent:u0,selectionBackgroundOpaque:fb.blend(uZ,u0),selectionInactiveBackgroundTransparent:u0,selectionInactiveBackgroundOpaque:fb.blend(uZ,u0),scrollbarSliderBackground:fb.opacity(uJ,.2),scrollbarSliderHoverBackground:fb.opacity(uJ,.4),scrollbarSliderActiveBackground:fb.opacity(uJ,.5),overviewRulerBorder:uJ,ansi:uG.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 r=this._colors;if(r.foreground=u2(e.foreground,uJ),r.background=u2(e.background,uZ),r.cursor=fb.blend(r.background,u2(e.cursor,uQ)),r.cursorAccent=fb.blend(r.background,u2(e.cursorAccent,uZ)),r.selectionBackgroundTransparent=u2(e.selectionBackground,u0),r.selectionBackgroundOpaque=fb.blend(r.background,r.selectionBackgroundTransparent),r.selectionInactiveBackgroundTransparent=u2(e.selectionInactiveBackground,r.selectionBackgroundTransparent),r.selectionInactiveBackgroundOpaque=fb.blend(r.background,r.selectionInactiveBackgroundTransparent),r.selectionForeground=e.selectionForeground?u2(e.selectionForeground,hK):void 0,r.selectionForeground===hK&&(r.selectionForeground=void 0),fb.isOpaque(r.selectionBackgroundTransparent)&&(r.selectionBackgroundTransparent=fb.opacity(r.selectionBackgroundTransparent,.3)),fb.isOpaque(r.selectionInactiveBackgroundTransparent)&&(r.selectionInactiveBackgroundTransparent=fb.opacity(r.selectionInactiveBackgroundTransparent,.3)),r.scrollbarSliderBackground=u2(e.scrollbarSliderBackground,fb.opacity(r.foreground,.2)),r.scrollbarSliderHoverBackground=u2(e.scrollbarSliderHoverBackground,fb.opacity(r.foreground,.4)),r.scrollbarSliderActiveBackground=u2(e.scrollbarSliderActiveBackground,fb.opacity(r.foreground,.5)),r.overviewRulerBorder=u2(e.overviewRulerBorder,uJ),r.ansi=uG.slice(),r.ansi[0]=u2(e.black,uG[0]),r.ansi[1]=u2(e.red,uG[1]),r.ansi[2]=u2(e.green,uG[2]),r.ansi[3]=u2(e.yellow,uG[3]),r.ansi[4]=u2(e.blue,uG[4]),r.ansi[5]=u2(e.magenta,uG[5]),r.ansi[6]=u2(e.cyan,uG[6]),r.ansi[7]=u2(e.white,uG[7]),r.ansi[8]=u2(e.brightBlack,uG[8]),r.ansi[9]=u2(e.brightRed,uG[9]),r.ansi[10]=u2(e.brightGreen,uG[10]),r.ansi[11]=u2(e.brightYellow,uG[11]),r.ansi[12]=u2(e.brightBlue,uG[12]),r.ansi[13]=u2(e.brightMagenta,uG[13]),r.ansi[14]=u2(e.brightCyan,uG[14]),r.ansi[15]=u2(e.brightWhite,uG[15]),e.extendedAnsi){let s=Math.min(r.ansi.length-16,e.extendedAnsi.length);for(let i=0;i<s;i++)r.ansi[i+16]=u2(e.extendedAnsi[i],uG[i+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(void 0===e){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()}}};function u2(e,r){if(void 0!==e)try{return fw.toColor(e)}catch{}return r}u1=lW([l$(0,ct)],u1);var u5=class{constructor(...e){for(let[r,s]of(this._entries=new Map,e))this.set(r,s)}set(e,r){let s=this._entries.get(e);return this._entries.set(e,r),s}forEach(e){for(let[r,s]of this._entries.entries())e(r,s)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},u3=class{constructor(){this._services=new u5,this._services.set(l9,this)}setService(e,r){this._services.set(e,r)}getService(e){return this._services.get(e)}createInstance(e,...r){let s=(e[l2]||[]).sort((e,r)=>e.index-r.index),i=[];for(let r of s){let s=this._services.get(r.id);if(!s)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${r.id._id}.`);i.push(s)}let n=s.length>0?s[0].index:r.length;if(r.length!==n)throw Error(`[createInstance] First service dependency of ${e.name} at position ${n+1} conflicts with ${r.length} static arguments`);return new e(...r,...i)}},u4={trace:0,debug:1,info:2,warn:3,error:4,off:5},u6=class extends cE{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=u4[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let r=0;r<e.length;r++)"function"==typeof e[r]&&(e[r]=e[r]())}_log(e,r,s){this._evalLazyOptionalParams(s),e.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+r,...s)}trace(e,...r){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,r)}debug(e,...r){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,r)}info(e,...r){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,r)}warn(e,...r){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,r)}error(e,...r){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,r)}};u6=lW([l$(0,ct)],u6);var u8=class extends cE{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new c2),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new c2),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new c2),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 r=Array(e);for(let s=0;s<Math.min(e,this.length);s++)r[s]=this._array[this._getCyclicIndex(s)];this._array=r,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let r=this._length;r<e;r++)this._array[r]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,r){this._array[this._getCyclicIndex(e)]=r}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,r,...s){if(r){for(let s=e;s<this._length-r;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+r)];this._length-=r,this.onDeleteEmitter.fire({index:e,amount:r})}for(let r=this._length-1;r>=e;r--)this._array[this._getCyclicIndex(r+s.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;r<s.length;r++)this._array[this._getCyclicIndex(e+r)]=s[r];if(s.length&&this.onInsertEmitter.fire({index:e,amount:s.length}),this._length+s.length>this._maxLength){let e=this._length+s.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,r,s){if(!(r<=0)){if(e<0||e>=this._length)throw Error("start argument out of range");if(e+s<0)throw Error("Cannot shift elements in list beyond index 0");if(s>0){for(let i=r-1;i>=0;i--)this.set(e+i+s,this.get(e+i));let i=e+r+s-this._length;if(i>0)for(this._length+=i;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i=0;i<r;i++)this.set(e+i+s,this.get(e+i))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},u7=Object.freeze(new lZ),u9=0,fe=class e{constructor(e,r,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*e);let i=r||l0.fromCharData([0,"",1,0]);for(let r=0;r<e;++r)this.setCell(r,i);this.length=e}get(e){let r=this._data[3*e+0],s=2097151&r;return[this._data[3*e+1],2097152&r?this._combined[e]:s?lY(s):"",r>>22,2097152&r?this._combined[e].charCodeAt(this._combined[e].length-1):s]}set(e,r){this._data[3*e+1]=r[0],r[1].length>1?(this._combined[e]=r[1],this._data[3*e+0]=2097152|e|r[2]<<22):this._data[3*e+0]=r[1].charCodeAt(0)|r[2]<<22}getWidth(e){return this._data[3*e+0]>>22}hasWidth(e){return 0xc00000&this._data[3*e+0]}getFg(e){return this._data[3*e+1]}getBg(e){return this._data[3*e+2]}hasContent(e){return 4194303&this._data[3*e+0]}getCodePoint(e){let r=this._data[3*e+0];return 2097152&r?this._combined[e].charCodeAt(this._combined[e].length-1):2097151&r}isCombined(e){return 2097152&this._data[3*e+0]}getString(e){let r=this._data[3*e+0];return 2097152&r?this._combined[e]:2097151&r?lY(2097151&r):""}isProtected(e){return 0x20000000&this._data[3*e+2]}loadCell(e,r){return u9=3*e,r.content=this._data[u9+0],r.fg=this._data[u9+1],r.bg=this._data[u9+2],2097152&r.content&&(r.combinedData=this._combined[e]),0x10000000&r.bg&&(r.extended=this._extendedAttrs[e]),r}setCell(e,r){2097152&r.content&&(this._combined[e]=r.combinedData),0x10000000&r.bg&&(this._extendedAttrs[e]=r.extended),this._data[3*e+0]=r.content,this._data[3*e+1]=r.fg,this._data[3*e+2]=r.bg}setCellFromCodepoint(e,r,s,i){0x10000000&i.bg&&(this._extendedAttrs[e]=i.extended),this._data[3*e+0]=r|s<<22,this._data[3*e+1]=i.fg,this._data[3*e+2]=i.bg}addCodepointToCell(e,r,s){let i=this._data[3*e+0];2097152&i?this._combined[e]+=lY(r):2097151&i?(this._combined[e]=lY(2097151&i)+lY(r),i&=-2097152,i|=2097152):i=4194304|r,s&&(i&=-0xc00001,i|=s<<22),this._data[3*e+0]=i}insertCells(e,r,s){if((e%=this.length)&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,s),r<this.length-e){let i=new l0;for(let s=this.length-e-r-1;s>=0;--s)this.setCell(e+r+s,this.loadCell(e+s,i));for(let i=0;i<r;++i)this.setCell(e+i,s)}else for(let r=e;r<this.length;++r)this.setCell(r,s);2===this.getWidth(this.length-1)&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(e,r,s){if(e%=this.length,r<this.length-e){let i=new l0;for(let s=0;s<this.length-e-r;++s)this.setCell(e+s,this.loadCell(e+r+s,i));for(let e=this.length-r;e<this.length;++e)this.setCell(e,s)}else for(let r=e;r<this.length;++r)this.setCell(r,s);e&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,s),0!==this.getWidth(e)||this.hasContent(e)||this.setCellFromCodepoint(e,0,1,s)}replaceCells(e,r,s,i=!1){if(i){for(e&&2===this.getWidth(e-1)&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,s),r<this.length&&2===this.getWidth(r-1)&&!this.isProtected(r)&&this.setCellFromCodepoint(r,0,1,s);e<r&&e<this.length;)this.isProtected(e)||this.setCell(e,s),e++;return}for(e&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,s),r<this.length&&2===this.getWidth(r-1)&&this.setCellFromCodepoint(r,0,1,s);e<r&&e<this.length;)this.setCell(e++,s)}resize(e,r){if(e===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;let s=3*e;if(e>this.length){if(this._data.buffer.byteLength>=4*s)this._data=new Uint32Array(this._data.buffer,0,s);else{let e=new Uint32Array(s);e.set(this._data),this._data=e}for(let s=this.length;s<e;++s)this.setCell(s,r)}else{this._data=this._data.subarray(0,s);let r=Object.keys(this._combined);for(let s=0;s<r.length;s++){let i=parseInt(r[s],10);i>=e&&delete this._combined[i]}let i=Object.keys(this._extendedAttrs);for(let r=0;r<i.length;r++){let s=parseInt(i[r],10);s>=e&&delete this._extendedAttrs[s]}}return this.length=e,4*s*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,r=!1){if(r){for(let r=0;r<this.length;++r)this.isProtected(r)||this.setCell(r,e);return}this._combined={},this._extendedAttrs={};for(let r=0;r<this.length;++r)this.setCell(r,e)}copyFrom(e){for(let r in this.length!==e.length?this._data=new Uint32Array(e._data):this._data.set(e._data),this.length=e.length,this._combined={},e._combined)this._combined[r]=e._combined[r];for(let r in this._extendedAttrs={},e._extendedAttrs)this._extendedAttrs[r]=e._extendedAttrs[r];this.isWrapped=e.isWrapped}clone(){let r=new e(0);for(let e in r._data=new Uint32Array(this._data),r.length=this.length,this._combined)r._combined[e]=this._combined[e];for(let e in this._extendedAttrs)r._extendedAttrs[e]=this._extendedAttrs[e];return r.isWrapped=this.isWrapped,r}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(4194303&this._data[3*e+0])return e+(this._data[3*e+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(4194303&this._data[3*e+0]||0x3000000&this._data[3*e+2])return e+(this._data[3*e+0]>>22);return 0}copyCellsFrom(e,r,s,i,n){let o=e._data;if(n)for(let n=i-1;n>=0;n--){for(let e=0;e<3;e++)this._data[(s+n)*3+e]=o[(r+n)*3+e];0x10000000&o[(r+n)*3+2]&&(this._extendedAttrs[s+n]=e._extendedAttrs[r+n])}else for(let n=0;n<i;n++){for(let e=0;e<3;e++)this._data[(s+n)*3+e]=o[(r+n)*3+e];0x10000000&o[(r+n)*3+2]&&(this._extendedAttrs[s+n]=e._extendedAttrs[r+n])}let a=Object.keys(e._combined);for(let i=0;i<a.length;i++){let n=parseInt(a[i],10);n>=r&&(this._combined[n-r+s]=e._combined[n])}}translateToString(e,r,s,i){r=r??0,s=s??this.length,e&&(s=Math.min(s,this.getTrimmedLength())),i&&(i.length=0);let n="";for(;r<s;){let e=this._data[3*r+0],s=2097151&e,o=2097152&e?this._combined[r]:s?lY(s):" ";if(n+=o,i)for(let e=0;e<o.length;++e)i.push(r);r+=e>>22||1}return i&&i.push(r),n}};function ft(e,r,s){if(r===e.length-1)return e[r].getTrimmedLength();let i=!e[r].hasContent(s-1)&&1===e[r].getWidth(s-1),n=2===e[r+1].getWidth(0);return i&&n?s-1:s}var fr=class e{constructor(r){this.line=r,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new c2),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),cC(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};fr._nextId=1;var fs={},fi=fs.B;fs[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:"≥","{":"π","|":"≠","}":"£","~":"·"},fs.A={"#":"£"},fs.B=void 0,fs[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},fs.C=fs[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},fs.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},fs.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},fs.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},fs.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},fs.E=fs[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},fs.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},fs.H=fs[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},fs["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var fn=class{constructor(e,r,s){this._hasScrollback=e,this._optionsService=r,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=u7.clone(),this.savedCharset=fi,this.markers=[],this._nullCell=l0.fromCharData([0,"",1,0]),this._whitespaceCell=l0.fromCharData([0," ",1,32]),this._isClearing=!1,this._memoryCleanupQueue=new uA,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new u8(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 lQ),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 lQ),this._whitespaceCell}getBlankLine(e,r){return new fe(this._bufferService.cols,this.getNullCell(e),r)}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 r=e+this._optionsService.rawOptions.scrollback;return r>0xffffffff?0xffffffff:r}fillViewportRows(e){if(0===this.lines.length){void 0===e&&(e=u7);let r=this._rows;for(;r--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new u8(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,r){let s=this.getNullCell(u7),i=0,n=this._getCorrectBufferLength(r);if(n>this.lines.maxLength&&(this.lines.maxLength=n),this.lines.length>0){if(this._cols<e)for(let r=0;r<this.lines.length;r++)i+=+this.lines.get(r).resize(e,s);let o=0;if(this._rows<r)for(let i=this._rows;i<r;i++)this.lines.length<r+this.ybase&&(this._optionsService.rawOptions.windowsMode||void 0!==this._optionsService.rawOptions.windowsPty.backend||void 0!==this._optionsService.rawOptions.windowsPty.buildNumber?this.lines.push(new fe(e,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new fe(e,s)));else for(let e=this._rows;e>r;e--)this.lines.length>r+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(n<this.lines.maxLength){let e=this.lines.length-n;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=n}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,r-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=r-1,this._isReflowEnabled&&(this._reflow(e,r),this._cols>e))for(let r=0;r<this.lines.length;r++)i+=+this.lines.get(r).resize(e,s);this._cols=e,this._rows=r,this._memoryCleanupQueue.clear(),i>.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 r=0;for(;this._memoryCleanupPosition<this.lines.length;)if((r+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory())>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&"conpty"===e.backend&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,r){this._cols!==e&&(e>this._cols?this._reflowLarger(e,r):this._reflowSmaller(e,r))}_reflowLarger(e,r){let s=this._optionsService.rawOptions.reflowCursorLine,i=function(e,r,s,i,n,o){let a=[];for(let l=0;l<e.length-1;l++){let c=l,d=e.get(++c);if(!d.isWrapped)continue;let h=[e.get(l)];for(;c<e.length&&d.isWrapped;)h.push(d),d=e.get(++c);if(!o&&i>=l&&i<c){l+=h.length-1;continue}let u=0,f=ft(h,0,r),p=1,m=0;for(;p<h.length;){let e=ft(h,p,r),i=Math.min(e-m,s-f);h[u].copyCellsFrom(h[p],m,f,i,!1),(f+=i)===s&&(u++,f=0),(m+=i)===e&&(p++,m=0),0===f&&0!==u&&2===h[u-1].getWidth(s-1)&&(h[u].copyCellsFrom(h[u-1],s-1,f++,1,!1),h[u-1].setCell(s-1,n))}h[u].replaceCells(f,s,n);let g=0;for(let e=h.length-1;e>0&&(e>u||0===h[e].getTrimmedLength());e--)g++;g>0&&(a.push(l+h.length-g),a.push(g)),l+=h.length-1}return a}(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(u7),s);if(i.length>0){let s=function(e,r){let s=[],i=0,n=r[0],o=0;for(let a=0;a<e.length;a++)if(n===a){let s=r[++i];e.onDeleteEmitter.fire({index:a-o,amount:s}),a+=s-1,o+=s,n=r[++i]}else s.push(a);return{layout:s,countRemoved:o}}(this.lines,i);(function(e,r){let s=[];for(let i=0;i<r.length;i++)s.push(e.get(r[i]));for(let r=0;r<s.length;r++)e.set(r,s[r]);e.length=r.length})(this.lines,s.layout),this._reflowLargerAdjustViewport(e,r,s.countRemoved)}}_reflowLargerAdjustViewport(e,r,s){let i=this.getNullCell(u7),n=s;for(;n-- >0;)0===this.ybase?(this.y>0&&this.y--,this.lines.length<r&&this.lines.push(new fe(e,i))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(e,r){let s=this._optionsService.rawOptions.reflowCursorLine,i=this.getNullCell(u7),n=[],o=0;for(let a=this.lines.length-1;a>=0;a--){let l=this.lines.get(a);if(!l||!l.isWrapped&&l.getTrimmedLength()<=e)continue;let c=[l];for(;l.isWrapped&&a>0;)l=this.lines.get(--a),c.unshift(l);if(!s){let e=this.ybase+this.y;if(e>=a&&e<a+c.length)continue}let d=c[c.length-1].getTrimmedLength(),h=function(e,r,s){let i=[],n=e.map((s,i)=>ft(e,i,r)).reduce((e,r)=>e+r),o=0,a=0,l=0;for(;l<n;){if(n-l<s){i.push(n-l);break}o+=s;let c=ft(e,a,r);o>c&&(o-=c,a++);let d=2===e[a].getWidth(o-1);d&&o--;let h=d?s-1:s;i.push(h),l+=h}return i}(c,this._cols,e),u=h.length-c.length,f;f=0===this.ybase&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+u):Math.max(0,this.lines.length-this.lines.maxLength+u);let p=[];for(let e=0;e<u;e++){let e=this.getBlankLine(u7,!0);p.push(e)}p.length>0&&(n.push({start:a+c.length+o,newLines:p}),o+=p.length),c.push(...p);let m=h.length-1,g=h[m];0===g&&(g=h[--m]);let v=c.length-u-1,x=d;for(;v>=0;){let e=Math.min(x,g);if(void 0===c[m])break;c[m].copyCellsFrom(c[v],x-e,g-e,e,!0),0==(g-=e)&&(g=h[--m]),0==(x-=e)&&(x=ft(c,Math.max(--v,0),this._cols))}for(let r=0;r<c.length;r++)h[r]<e&&c[r].setCell(h[r],i);let _=u-f;for(;_-- >0;)0===this.ybase?this.y<r-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+o)-r&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+u,this.ybase+r-1)}if(n.length>0){let e=[],r=[];for(let e=0;e<this.lines.length;e++)r.push(this.lines.get(e));let s=this.lines.length,i=s-1,a=0,l=n[0];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let c=0;for(let d=Math.min(this.lines.maxLength-1,s+o-1);d>=0;d--)if(l&&l.start>i+c){for(let e=l.newLines.length-1;e>=0;e--)this.lines.set(d--,l.newLines[e]);d++,e.push({index:i+1,amount:l.newLines.length}),c+=l.newLines.length,l=n[++a]}else this.lines.set(d,r[i--]);let d=0;for(let r=e.length-1;r>=0;r--)e[r].index+=d,this.lines.onInsertEmitter.fire(e[r]),d+=e[r].amount;let h=Math.max(0,s+o-this.lines.maxLength);h>0&&this.lines.onTrimEmitter.fire(h)}}translateBufferLineToString(e,r,s=0,i){let n=this.lines.get(e);return n?n.translateToString(r,s,i):""}getWrappedRangeForLine(e){let r=e,s=e;for(;r>0&&this.lines.get(r).isWrapped;)r--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:r,last:s}}setupTabStops(e){for(null!=e?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(null==e&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(null==e&&(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 r=0;r<this.markers.length;r++)this.markers[r].line===e&&(this.markers[r].dispose(),this.markers.splice(r--,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 r=new fr(e);return this.markers.push(r),r.register(this.lines.onTrim(e=>{r.line-=e,r.line<0&&r.dispose()})),r.register(this.lines.onInsert(e=>{r.line>=e.index&&(r.line+=e.amount)})),r.register(this.lines.onDelete(e=>{r.line>=e.index&&r.line<e.index+e.amount&&r.dispose(),r.line>e.index&&(r.line-=e.amount)})),r.register(r.onDispose(()=>this._removeMarker(r))),r}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},fo=class extends cE{constructor(e,r){super(),this._optionsService=e,this._bufferService=r,this._onBufferActivate=this._register(new c2),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 fn(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new fn(!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,r){this._normal.resize(e,r),this._alt.resize(e,r),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},fa=class extends cE{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new c2),this.onResize=this._onResize.event,this._onScroll=this._register(new c2),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,2),this.rows=Math.max(e.rawOptions.rows||0,1),this.buffers=this._register(new fo(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,r){let s=this.cols!==e,i=this.rows!==r;this.cols=e,this.rows=r,this.buffers.resize(e,r),this._onResize.fire({cols:e,rows:r,colsChanged:s,rowsChanged:i})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,r=!1){let s=this.buffer,i;(i=this._cachedBlankLine)&&i.length===this.cols&&i.getFg(0)===e.fg&&i.getBg(0)===e.bg||(i=s.getBlankLine(e,r),this._cachedBlankLine=i),i.isWrapped=r;let n=s.ybase+s.scrollTop,o=s.ybase+s.scrollBottom;if(0===s.scrollTop){let e=s.lines.isFull;o===s.lines.length-1?e?s.lines.recycle().copyFrom(i):s.lines.push(i.clone()):s.lines.splice(o+1,0,i.clone()),e?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let e=o-n+1;s.lines.shiftElements(n+1,e-1,-1),s.lines.set(o,i.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(e,r){let s=this.buffer;if(e<0){if(0===s.ydisp)return;this.isUserScrolling=!0}else e+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let i=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+e,s.ybase),0),i!==s.ydisp&&(r||this._onScroll.fire(s.ydisp))}};fa=lW([l$(0,ct)],fa);var fl={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:uj,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},fc=["normal","bold","100","200","300","400","500","600","700","800","900"],fd=class extends cE{constructor(e){super(),this._onOptionChange=this._register(new c2),this.onOptionChange=this._onOptionChange.event;let r={...fl};for(let s in e)if(s in r)try{let i=e[s];r[s]=this._sanitizeAndValidateOption(s,i)}catch(e){console.error(e)}this.rawOptions=r,this.options={...r},this._setupOptions(),this._register(ck(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,r){return this.onOptionChange(s=>{s===e&&r(this.rawOptions[e])})}onMultipleOptionChange(e,r){return this.onOptionChange(s=>{-1!==e.indexOf(s)&&r()})}_setupOptions(){let e=e=>{if(!(e in fl))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},r=(e,r)=>{if(!(e in fl))throw Error(`No option with key "${e}"`);r=this._sanitizeAndValidateOption(e,r),this.rawOptions[e]!==r&&(this.rawOptions[e]=r,this._onOptionChange.fire(e))};for(let s in this.rawOptions){let i={get:e.bind(this,s),set:r.bind(this,s)};Object.defineProperty(this.options,s,i)}}_sanitizeAndValidateOption(e,r){switch(e){case"cursorStyle":var s;if(r||(r=fl[e]),"block"!==(s=r)&&"underline"!==s&&"bar"!==s)throw Error(`"${r}" is not a valid value for ${e}`);break;case"wordSeparator":r||(r=fl[e]);break;case"fontWeight":case"fontWeightBold":if("number"==typeof r&&1<=r&&r<=1e3)break;r=fc.includes(r)?r:fl[e];break;case"cursorWidth":r=Math.floor(r);case"lineHeight":case"tabStopWidth":if(r<1)throw Error(`${e} cannot be less than 1, value: ${r}`);break;case"minimumContrastRatio":r=Math.max(1,Math.min(21,Math.round(10*r)/10));break;case"scrollback":if((r=Math.min(r,0xffffffff))<0)throw Error(`${e} cannot be less than 0, value: ${r}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(r<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${r}`);break;case"rows":case"cols":if(!r&&0!==r)throw Error(`${e} must be numeric, value: ${r}`);break;case"windowsPty":r=r??{}}return r}};function fh(e,r=5){if("object"!=typeof e)return e;let s=Array.isArray(e)?[]:{};for(let i in e)s[i]=r<=1?e[i]:e[i]&&fh(e[i],r-1);return s}var fu=Object.freeze({insertMode:!1}),ff=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),fp=class extends cE{constructor(e,r,s){super(),this._bufferService=e,this._logService=r,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new c2),this.onData=this._onData.event,this._onUserInput=this._register(new c2),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new c2),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new c2),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=fh(fu),this.decPrivateModes=fh(ff)}reset(){this.modes=fh(fu),this.decPrivateModes=fh(ff)}triggerDataEvent(e,r=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;r&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),r&&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))}};fp=lW([l$(0,l4),l$(1,ce),l$(2,ct)],fp);var fm={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>4!==e.button&&1===e.action&&(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>32!==e.action},DRAG:{events:23,restrict:e=>32!==e.action||3!==e.button},ANY:{events:31,restrict:e=>!0}};function fg(e,r){let s=16*!!e.ctrl|4*!!e.shift|8*!!e.alt;return 4===e.button?(s|=64,s|=e.action):(s|=3&e.button,4&e.button&&(s|=64),8&e.button&&(s|=128),32===e.action?s|=32:0!==e.action||r||(s|=3)),s}var fv=String.fromCharCode,fx={DEFAULT:e=>{let r=[fg(e,!1)+32,e.col+32,e.row+32];return r[0]>255||r[1]>255||r[2]>255?"":`\x1b[M${fv(r[0])}${fv(r[1])}${fv(r[2])}`},SGR:e=>{let r=0===e.action&&4!==e.button?"m":"M";return`\x1b[<${fg(e,!0)};${e.col};${e.row}${r}`},SGR_PIXELS:e=>{let r=0===e.action&&4!==e.button?"m":"M";return`\x1b[<${fg(e,!0)};${e.x};${e.y}${r}`}},f_=class extends cE{constructor(e,r,s){for(let i of(super(),this._bufferService=e,this._coreService=r,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new c2),this.onProtocolChange=this._onProtocolChange.event,Object.keys(fm)))this.addProtocol(i,fm[i]);for(let e of Object.keys(fx))this.addEncoding(e,fx[e]);this.reset()}addProtocol(e,r){this._protocols[e]=r}addEncoding(e,r){this._encodings[e]=r}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return 0!==this._protocols[this._activeProtocol].events}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,r,s){if(0===e.deltaY||e.shiftKey||void 0===r||void 0===s)return 0;let i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r/s+0,50>Math.abs(e.deltaY)&&(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,r){return r.altKey||r.ctrlKey||r.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||4===e.button&&32===e.action||3===e.button&&32!==e.action||4!==e.button&&(2===e.action||3===e.action)||(e.col++,e.row++,32===e.action&&this._lastEvent&&this._equalEvents(this._lastEvent,e,"SGR_PIXELS"===this._activeEncoding))||!this._protocols[this._activeProtocol].restrict(e))return!1;let r=this._encodings[this._activeEncoding](e);return r&&("DEFAULT"===this._activeEncoding?this._coreService.triggerBinaryEvent(r):this._coreService.triggerDataEvent(r,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(1&e),up:!!(2&e),drag:!!(4&e),move:!!(8&e),wheel:!!(16&e)}}_equalEvents(e,r,s){if(s){if(e.x!==r.x||e.y!==r.y)return!1}else if(e.col!==r.col||e.row!==r.row)return!1;return e.button===r.button&&e.action===r.action&&e.ctrl===r.ctrl&&e.alt===r.alt&&e.shift===r.shift}};f_=lW([l$(0,l4),l$(1,l8),l$(2,ct)],f_);var fy,fb,fw,fS,fC,fk,fj=[[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]],fN=[[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]],fE=class{constructor(){if(this.version="6",!fk){(fk=new Uint8Array(65536)).fill(1),fk[0]=0,fk.fill(0,1,32),fk.fill(0,127,160),fk.fill(2,4352,4448),fk[9001]=2,fk[9002]=2,fk.fill(2,11904,42192),fk[12351]=1,fk.fill(2,44032,55204),fk.fill(2,63744,64256),fk.fill(2,65040,65050),fk.fill(2,65072,65136),fk.fill(2,65280,65377),fk.fill(2,65504,65511);for(let e=0;e<fj.length;++e)fk.fill(0,fj[e][0],fj[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?fk[e]:!function(e,r){let s=0,i=r.length-1,n;if(e<r[0][0]||e>r[i][1])return!1;for(;i>=s;)if(e>r[n=s+i>>1][1])s=n+1;else{if(!(e<r[n][0]))return!0;i=n-1}return!1}(e,fN)?e>=131072&&e<=196605||e>=196608&&e<=262141?2:1:0}charProperties(e,r){let s=this.wcwidth(e),i=0===s&&0!==r;if(i){let e=fR.extractWidth(r);0===e?i=!1:e>s&&(s=e)}return fR.createPropertyValue(0,s,i)}},fR=class e{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new c2,this.onChange=this._onChange.event;let e=new fE;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(1&e)!=0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,r,s=!1){return(0xffffff&e)<<3|(3&r)<<1|!!s}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(r){let s=0,i=0,n=r.length;for(let o=0;o<n;++o){let a=r.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=n)return s+this.wcwidth(a);let e=r.charCodeAt(o);56320<=e&&e<=57343?a=(a-55296)*1024+e-56320+65536:s+=this.wcwidth(e)}let l=this.charProperties(a,i),c=e.extractWidth(l);e.extractShouldJoin(l)&&(c-=e.extractWidth(i)),s+=c,i=l}return s}charProperties(e,r){return this._activeProvider.charProperties(e,r)}},fM=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,r){this._charsets[e]=r,this.glevel===e&&(this.charset=r)}};function fD(e){let r=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);s&&r&&(s.isWrapped=0!==r[3]&&32!==r[3])}var fT=class e{constructor(e=32,r=32){if(this.maxLength=e,this.maxSubParamsLength=r,r>256)throw Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(r),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(r){let s=new e;if(!r.length)return s;for(let e=+!!Array.isArray(r[0]);e<r.length;++e){let i=r[e];if(Array.isArray(i))for(let e=0;e<i.length;++e)s.addSubParam(i[e]);else s.addParam(i)}return s}clone(){let r=new e(this.maxLength,this.maxSubParamsLength);return r.params.set(this.params),r.length=this.length,r._subParams.set(this._subParams),r._subParamsLength=this._subParamsLength,r._subParamsIdx.set(this._subParamsIdx),r._rejectDigits=this._rejectDigits,r._rejectSubDigits=this._rejectSubDigits,r._digitIsSub=this._digitIsSub,r}toArray(){let e=[];for(let r=0;r<this.length;++r){e.push(this.params[r]);let s=this._subParamsIdx[r]>>8,i=255&this._subParamsIdx[r];i-s>0&&e.push(Array.prototype.slice.call(this._subParams,s,i))}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>0x7fffffff?0x7fffffff: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>0x7fffffff?0x7fffffff:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(255&this._subParamsIdx[e])-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let r=this._subParamsIdx[e]>>8,s=255&this._subParamsIdx[e];return s-r>0?this._subParams.subarray(r,s):null}getSubParamsAll(){let e={};for(let r=0;r<this.length;++r){let s=this._subParamsIdx[r]>>8,i=255&this._subParamsIdx[r];i-s>0&&(e[r]=this._subParams.slice(s,i))}return e}addDigit(e){let r;if(this._rejectDigits||!(r=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,i=s[r-1];s[r-1]=~i?Math.min(10*i+e,0x7fffffff):e}},fP=[],fL=class{constructor(){this._state=0,this._active=fP,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,r){void 0===this._handlers[e]&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(r),{dispose:()=>{let e=s.indexOf(r);-1!==e&&s.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=fP}reset(){if(2===this._state)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=fP,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||fP,this._active.length)for(let e=this._active.length-1;e>=0;e--)this._active[e].start();else this._handlerFb(this._id,"START")}_put(e,r,s){if(this._active.length)for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,r,s);else this._handlerFb(this._id,"PUT",lX(e,r,s))}start(){this.reset(),this._state=1}put(e,r,s){if(3!==this._state){if(1===this._state)for(;r<s;){let s=e[r++];if(59===s){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}-1===this._id&&(this._id=0),this._id=10*this._id+s-48}2===this._state&&s-r>0&&this._put(e,r,s)}}end(e,r=!0){if(0!==this._state){if(3!==this._state)if(1===this._state&&this._start(),this._active.length){let s=!1,i=this._active.length-1,n=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=r,n=this._stack.fallThrough,this._stack.paused=!1),!n&&!1===s){for(;i>=0&&!0!==(s=this._active[i].end(e));i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if((s=this._active[i].end(!1))instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}else this._handlerFb(this._id,"END",e);this._active=fP,this._id=-1,this._state=0}}},fA=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,r,s){this._hitLimit||(this._data+=lX(e,r,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let r=!1;if(this._hitLimit)r=!1;else if(e&&(r=this._handler(this._data))instanceof Promise)return r.then(e=>(this._data="",this._hitLimit=!1,e));return this._data="",this._hitLimit=!1,r}},fB=[],fI=class{constructor(){this._handlers=Object.create(null),this._active=fB,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=fB}registerHandler(e,r){void 0===this._handlers[e]&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(r),{dispose:()=>{let e=s.indexOf(r);-1!==e&&s.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=fB,this._ident=0}hook(e,r){if(this.reset(),this._ident=e,this._active=this._handlers[e]||fB,this._active.length)for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(r);else this._handlerFb(this._ident,"HOOK",r)}put(e,r,s){if(this._active.length)for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,r,s);else this._handlerFb(this._ident,"PUT",lX(e,r,s))}unhook(e,r=!0){if(this._active.length){let s=!1,i=this._active.length-1,n=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=r,n=this._stack.fallThrough,this._stack.paused=!1),!n&&!1===s){for(;i>=0&&!0!==(s=this._active[i].unhook(e));i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if((s=this._active[i].unhook(!1))instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}else this._handlerFb(this._ident,"UNHOOK",e);this._active=fB,this._ident=0}},fO=new fT;fO.addParam(0);var fz=class{constructor(e){this._handler=e,this._data="",this._params=fO,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():fO,this._data="",this._hitLimit=!1}put(e,r,s){this._hitLimit||(this._data+=lX(e,r,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let r=!1;if(this._hitLimit)r=!1;else if(e&&(r=this._handler(this._data,this._params))instanceof Promise)return r.then(e=>(this._params=fO,this._data="",this._hitLimit=!1,e));return this._params=fO,this._data="",this._hitLimit=!1,r}},fF=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,r){this.table.fill(e<<4|r)}add(e,r,s,i){this.table[r<<8|e]=s<<4|i}addMany(e,r,s,i){for(let n=0;n<e.length;n++)this.table[r<<8|e[n]]=s<<4|i}},fW=function(){let e=new fF(4095),r=Array.apply(null,Array(256)).map((e,r)=>r),s=(e,s)=>r.slice(e,s),i=s(32,127),n=s(0,24);n.push(25),n.push.apply(n,s(28,32));let o=s(0,14),a;for(a in e.setDefault(1,0),e.addMany(i,0,2,0),o)e.addMany([24,26,153,154],a,3,0),e.addMany(s(128,144),a,3,0),e.addMany(s(144,152),a,3,0),e.add(156,a,0,0),e.add(27,a,11,1),e.add(157,a,4,8),e.addMany([152,158,159],a,0,7),e.add(155,a,11,3),e.add(144,a,11,9);return e.addMany(n,0,3,0),e.addMany(n,1,3,1),e.add(127,1,0,1),e.addMany(n,8,0,8),e.addMany(n,3,3,3),e.add(127,3,0,3),e.addMany(n,4,3,4),e.add(127,4,0,4),e.addMany(n,6,3,6),e.addMany(n,5,3,5),e.add(127,5,0,5),e.addMany(n,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(i,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(s(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(i,7,0,7),e.addMany(n,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(s(64,127),3,7,0),e.addMany(s(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(s(48,60),4,8,4),e.addMany(s(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(s(32,64),6,0,6),e.add(127,6,0,6),e.addMany(s(64,127),6,0,0),e.addMany(s(32,48),3,9,5),e.addMany(s(32,48),5,9,5),e.addMany(s(48,64),5,0,6),e.addMany(s(64,127),5,7,0),e.addMany(s(32,48),4,9,5),e.addMany(s(32,48),1,9,2),e.addMany(s(32,48),2,9,2),e.addMany(s(48,127),2,10,0),e.addMany(s(48,80),1,10,0),e.addMany(s(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(s(96,127),1,10,0),e.add(80,1,11,9),e.addMany(n,9,0,9),e.add(127,9,0,9),e.addMany(s(28,32),9,0,9),e.addMany(s(32,48),9,9,12),e.addMany(s(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(n,11,0,11),e.addMany(s(32,128),11,0,11),e.addMany(s(28,32),11,0,11),e.addMany(n,10,0,10),e.add(127,10,0,10),e.addMany(s(28,32),10,0,10),e.addMany(s(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(s(32,48),10,9,12),e.addMany(n,12,0,12),e.add(127,12,0,12),e.addMany(s(28,32),12,0,12),e.addMany(s(32,48),12,9,12),e.addMany(s(48,64),12,0,11),e.addMany(s(64,127),12,12,13),e.addMany(s(64,127),10,12,13),e.addMany(s(64,127),9,12,13),e.addMany(n,13,13,13),e.addMany(i,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(160,0,2,0),e.add(160,8,5,8),e.add(160,6,0,6),e.add(160,11,0,11),e.add(160,13,13,13),e}(),f$=class extends cE{constructor(e=fW){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 fT,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,r,s)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,r)=>{},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(ck(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new fL),this._dcsParser=this._register(new fI),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,r=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw Error("only one byte as prefix supported");if((s=e.prefix.charCodeAt(0))&&60>s||s>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 r=0;r<e.intermediates.length;++r){let i=e.intermediates.charCodeAt(r);if(32>i||i>47)throw Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=i}}if(1!==e.final.length)throw Error("final must be a single byte");let i=e.final.charCodeAt(0);if(r[0]>i||i>r[1])throw Error(`final must be in range ${r[0]} .. ${r[1]}`);return s<<=8,s|=i}identToString(e){let r=[];for(;e;)r.push(String.fromCharCode(255&e)),e>>=8;return r.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,r){let s=this._identifier(e,[48,126]);void 0===this._escHandlers[s]&&(this._escHandlers[s]=[]);let i=this._escHandlers[s];return i.push(r),{dispose:()=>{let e=i.indexOf(r);-1!==e&&i.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,r){this._executeHandlers[e.charCodeAt(0)]=r}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,r){let s=this._identifier(e);void 0===this._csiHandlers[s]&&(this._csiHandlers[s]=[]);let i=this._csiHandlers[s];return i.push(r),{dispose:()=>{let e=i.indexOf(r);-1!==e&&i.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,r){return this._dcsParser.registerHandler(this._identifier(e),r)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,r){return this._oscParser.registerHandler(e,r)}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,0!==this._parseStack.state&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,r,s,i,n){this._parseStack.state=e,this._parseStack.handlers=r,this._parseStack.handlerPos=s,this._parseStack.transition=i,this._parseStack.chunkPos=n}parse(e,r,s){let i=0,n=0,o=0,a;if(this._parseStack.state)if(2===this._parseStack.state)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(void 0===s||1===this._parseStack.state)throw this._parseStack.state=1,Error("improper continuation due to previous async handler, giving up parsing");let r=this._parseStack.handlers,n=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(!1===s&&n>-1){for(;n>=0&&!0!==(a=r[n](this._params));n--)if(a instanceof Promise)return this._parseStack.handlerPos=n,a}this._parseStack.handlers=[];break;case 4:if(!1===s&&n>-1){for(;n>=0&&!0!==(a=r[n]());n--)if(a instanceof Promise)return this._parseStack.handlerPos=n,a}this._parseStack.handlers=[];break;case 6:if(i=e[this._parseStack.chunkPos],a=this._dcsParser.unhook(24!==i&&26!==i,s))return a;27===i&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(i=e[this._parseStack.chunkPos],a=this._oscParser.end(24!==i&&26!==i,s))return a;27===i&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let s=o;s<r;++s){switch(i=e[s],(n=this._transitions.table[this.currentState<<8|(i<160?i:160)])>>4){case 2:for(let n=s+1;;++n)if(n>=r||(i=e[n])<32||i>126&&i<160||++n>=r||(i=e[n])<32||i>126&&i<160||++n>=r||(i=e[n])<32||i>126&&i<160||++n>=r||(i=e[n])<32||i>126&&i<160){this._printHandler(e,s,n),s=n-1;break}break;case 3:this._executeHandlers[i]?this._executeHandlers[i]():this._executeHandlerFb(i),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:s,code:i,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let o=this._csiHandlers[this._collect<<8|i],l=o?o.length-1:-1;for(;l>=0&&!0!==(a=o[l](this._params));l--)if(a instanceof Promise)return this._preserveStack(3,o,l,n,s),a;l<0&&this._csiHandlerFb(this._collect<<8|i,this._params),this.precedingJoinState=0;break;case 8:do switch(i){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(i-48)}while(++s<r&&(i=e[s])>47&&i<60)s--;break;case 9:this._collect<<=8,this._collect|=i;break;case 10:let c=this._escHandlers[this._collect<<8|i],d=c?c.length-1:-1;for(;d>=0&&!0!==(a=c[d]());d--)if(a instanceof Promise)return this._preserveStack(4,c,d,n,s),a;d<0&&this._escHandlerFb(this._collect<<8|i),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|i,this._params);break;case 13:for(let n=s+1;;++n)if(n>=r||24===(i=e[n])||26===i||27===i||i>127&&i<160){this._dcsParser.put(e,s,n),s=n-1;break}break;case 14:if(a=this._dcsParser.unhook(24!==i&&26!==i))return this._preserveStack(6,[],0,n,s),a;27===i&&(n|=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 n=s+1;;n++)if(n>=r||(i=e[n])<32||i>127&&i<160){this._oscParser.put(e,s,n),s=n-1;break}break;case 6:if(a=this._oscParser.end(24!==i&&26!==i))return this._preserveStack(5,[],0,n,s),a;27===i&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&n}}},fH=/^([\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})$/,fU=/^[\da-f]+$/;function fK(e){if(!e)return;let r=e.toLowerCase();if(0===r.indexOf("rgb:")){r=r.slice(4);let e=fH.exec(r);if(e){let r=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/r*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/r*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/r*255)]}}else if(0===r.indexOf("#")&&(r=r.slice(1),fU.exec(r)&&[3,6,9,12].includes(r.length))){let e=r.length/3,s=[0,0,0];for(let i=0;i<3;++i){let n=parseInt(r.slice(e*i,e*i+e),16);s[i]=1===e?n<<4:2===e?n:3===e?n>>4:n>>8}return s}}function fq(e,r){let s=e.toString(16),i=s.length<2?"0"+s:s;switch(r){case 4:return s[0];case 8:return i;case 12:return(i+i).slice(0,3);default:return i+i}}var fV={"(":0,")":1,"*":2,"+":3,"-":1,".":2};function fY(e,r){if(e>24)return r.setWinLines||!1;switch(e){case 1:return!!r.restoreWin;case 2:return!!r.minimizeWin;case 3:return!!r.setWinPosition;case 4:return!!r.setWinSizePixels;case 5:return!!r.raiseWin;case 6:return!!r.lowerWin;case 7:return!!r.refreshWin;case 8:return!!r.setWinSizeChars;case 9:return!!r.maximizeWin;case 10:return!!r.fullscreenWin;case 11:return!!r.getWinState;case 13:return!!r.getWinPosition;case 14:return!!r.getWinSizePixels;case 15:return!!r.getScreenSizePixels;case 16:return!!r.getCellSizePixels;case 18:return!!r.getWinSizeChars;case 19:return!!r.getScreenSizeChars;case 20:return!!r.getIconTitle;case 21:return!!r.getWinTitle;case 22:return!!r.pushTitle;case 23:return!!r.popTitle;case 24:return!!r.setWinLines}return!1}var fX=0,fG=class extends cE{constructor(e,r,s,i,n,o,a,l,c=new f$){for(let d in super(),this._bufferService=e,this._charsetService=r,this._coreService=s,this._logService=i,this._optionsService=n,this._oscLinkService=o,this._coreMouseService=a,this._unicodeService=l,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new lG,this._utf8Decoder=new lJ,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=u7.clone(),this._eraseAttrDataInternal=u7.clone(),this._onRequestBell=this._register(new c2),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new c2),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new c2),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new c2),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new c2),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new c2),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new c2),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new c2),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new c2),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new c2),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new c2),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new c2),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new c2),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 fJ(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,r)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(e),params:r.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,r,s)=>{this._logService.debug("Unknown OSC code: ",{identifier:e,action:r,data:s})}),this._parser.setDcsHandlerFallback((e,r,s)=>{"HOOK"===r&&(s=s.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(e),action:r,payload:s})}),this._parser.setPrintHandler((e,r,s)=>this.print(e,r,s)),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(hI.BEL,()=>this.bell()),this._parser.setExecuteHandler(hI.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(hI.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(hI.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(hI.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(hI.BS,()=>this.backspace()),this._parser.setExecuteHandler(hI.HT,()=>this.tab()),this._parser.setExecuteHandler(hI.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(hI.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(hO.IND,()=>this.index()),this._parser.setExecuteHandler(hO.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(hO.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new fA(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new fA(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new fA(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new fA(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new fA(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new fA(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new fA(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new fA(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new fA(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new fA(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new fA(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new fA(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()),fs)this._parser.registerEscHandler({intermediates:"(",final:d},()=>this.selectCharset("("+d)),this._parser.registerEscHandler({intermediates:")",final:d},()=>this.selectCharset(")"+d)),this._parser.registerEscHandler({intermediates:"*",final:d},()=>this.selectCharset("*"+d)),this._parser.registerEscHandler({intermediates:"+",final:d},()=>this.selectCharset("+"+d)),this._parser.registerEscHandler({intermediates:"-",final:d},()=>this.selectCharset("-"+d)),this._parser.registerEscHandler({intermediates:".",final:d},()=>this.selectCharset("."+d)),this._parser.registerEscHandler({intermediates:"/",final:d},()=>this.selectCharset("/"+d));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 fz((e,r)=>this.requestStatusString(e,r)))}getAttrData(){return this._curAttrData}_preserveStack(e,r,s,i){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=r,this._parseStack.decodedLength=s,this._parseStack.position=i}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,r)=>setTimeout(()=>r("#SLOW_TIMEOUT"),5e3))]).catch(e=>{if("#SLOW_TIMEOUT"!==e)throw e;console.warn("async parser handler taking longer than 5000 ms")})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,r){let s,i=this._activeBuffer.x,n=this._activeBuffer.y,o=0,a=this._parseStack.paused;if(a){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,r))return this._logSlowResolvingAsync(s),s;i=this._parseStack.cursorStartX,n=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>131072&&(o=this._parseStack.position+131072)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${"string"==typeof e?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join("")}"`}`),0===this._logService.logLevel&&this._logService.trace("parsing data (codes)","string"==typeof e?e.split("").map(e=>e.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<131072&&(this._parseBuffer=new Uint32Array(Math.min(e.length,131072))),a||this._dirtyRowTracker.clearRange(),e.length>131072)for(let r=o;r<e.length;r+=131072){let o=r+131072<e.length?r+131072:e.length,a="string"==typeof e?this._stringDecoder.decode(e.substring(r,o),this._parseBuffer):this._utf8Decoder.decode(e.subarray(r,o),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,a))return this._preserveStack(i,n,a,r),this._logSlowResolvingAsync(s),s}else if(!a){let r="string"==typeof e?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,r))return this._preserveStack(i,n,r,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==i||this._activeBuffer.y!==n)&&this._onCursorMove.fire();let l=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(l,this._bufferService.rows-1)})}print(e,r,s){let i,n,o=this._charsetService.charset,a=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,d=this._coreService.modes.insertMode,h=this._curAttrData,u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-r>0&&2===u.getWidth(this._activeBuffer.x-1)&&u.setCellFromCodepoint(this._activeBuffer.x-1,0,1,h);let f=this._parser.precedingJoinState;for(let p=r;p<s;++p){if((i=e[p])<127&&o){let e=o[String.fromCharCode(i)];e&&(i=e.charCodeAt(0))}let r=this._unicodeService.charProperties(i,f);n=fR.extractWidth(r);let s=fR.extractShouldJoin(r),m=s?fR.extractWidth(f):0;if(f=r,a&&this._onA11yChar.fire(lY(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+n-m>l){if(c){let e=u,r=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),u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m>0&&u instanceof fe&&u.copyCellsFrom(e,r,0,m,!1);r<l;)e.setCellFromCodepoint(r++,0,1,h)}else if(this._activeBuffer.x=l-1,2===n)continue}if(s&&this._activeBuffer.x){let e=u.getWidth(this._activeBuffer.x-1)?1:2;u.addCodepointToCell(this._activeBuffer.x-e,i,n);for(let e=n-m;--e>=0;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,h);continue}if(d&&(u.insertCells(this._activeBuffer.x,n-m,this._activeBuffer.getNullCell(h)),2===u.getWidth(l-1)&&u.setCellFromCodepoint(l-1,0,1,h)),u.setCellFromCodepoint(this._activeBuffer.x++,i,n,h),n>0)for(;--n;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,h)}this._parser.precedingJoinState=f,this._activeBuffer.x<l&&s-r>0&&0===u.getWidth(this._activeBuffer.x)&&!u.hasContent(this._activeBuffer.x)&&u.setCellFromCodepoint(this._activeBuffer.x,0,1,h),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,r){return"t"!==e.final||e.prefix||e.intermediates?this._parser.registerCsiHandler(e,r):this._parser.registerCsiHandler(e,e=>!fY(e.params[0],this._optionsService.rawOptions.windowOptions)||r(e))}registerDcsHandler(e,r){return this._parser.registerDcsHandler(e,new fz(r))}registerEscHandler(e,r){return this._parser.registerEscHandler(e,r)}registerOscHandler(e,r){return this._parser.registerOscHandler(e,new fA(r))}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(0===this._activeBuffer.x&&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,r){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+r):(this._activeBuffer.x=e,this._activeBuffer.y=r),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,r){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+r)}cursorUp(e){let r=this._activeBuffer.y-this._activeBuffer.scrollTop;return r>=0?this._moveCursor(0,-Math.min(r,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let r=this._activeBuffer.scrollBottom-this._activeBuffer.y;return r>=0?this._moveCursor(0,Math.min(r,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 r=e.params[0];return 0===r?delete this._activeBuffer.tabs[this._activeBuffer.x]:3===r&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let r=e.params[0]||1;for(;r--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let r=e.params[0]||1;for(;r--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let r=e.params[0];return 1===r&&(this._curAttrData.bg|=0x20000000),(2===r||0===r)&&(this._curAttrData.bg&=-0x20000001),!0}_eraseInBufferLine(e,r,s,i=!1,n=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(r,s,this._activeBuffer.getNullCell(this._eraseAttrData()),n),i&&(o.isWrapped=!1)}_resetBufferLine(e,r=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),r),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),s.isWrapped=!1)}eraseInDisplay(e,r=!1){let s;switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x,r);s<this._bufferService.rows;s++)this._resetBufferLine(s,r);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,r),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,r);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+s)?.getTrimmedLength(););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,r);this._dirtyRowTracker.markDirty(0)}break;case 3:let i=this._activeBuffer.lines.length-this._bufferService.rows;i>0&&(this._activeBuffer.lines.trimStart(i),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-i,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-i,0),this._onScroll.fire(0))}return!0}eraseInLine(e,r=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x,r);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,r);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,r)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let r=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,n=this._bufferService.rows-1+this._activeBuffer.ybase-i+1;for(;r--;)this._activeBuffer.lines.splice(n-1,1),this._activeBuffer.lines.splice(s,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 r=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i;for(i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-i;r--;)this._activeBuffer.lines.splice(s,1),this._activeBuffer.lines.splice(i,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 r=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return r&&(r.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 r=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return r&&(r.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let r=e.params[0]||1;for(;r--;)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 r=e.params[0]||1;for(;r--;)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(u7));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 r=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s.deleteCells(0,r,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 r=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s.insertCells(0,r,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 r=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s.insertCells(this._activeBuffer.x,r,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 r=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s.deleteCells(this._activeBuffer.x,r,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return r&&(r.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 r=this._parser.precedingJoinState;if(!r)return!0;let s=e.params[0]||1,i=fR.extractWidth(r),n=this._activeBuffer.x-i,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(n),a=new Uint32Array(o.length*s),l=0;for(let e=0;e<o.length;){let r=o.codePointAt(e)||0;a[l++]=r,e+=r>65535?2:1}let c=l;for(let e=1;e<s;++e)a.copyWithin(c,0,l),c+=l;return this.print(a,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(hI.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(hI.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(hI.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(hI.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(hI.ESC+"[>83;40003;0c")),!0}_is(e){return 0===(this._optionsService.rawOptions.termName+"").indexOf(e)}setMode(e){for(let r=0;r<e.length;r++)switch(e.params[r]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(e){for(let r=0;r<e.length;r++)switch(e.params[r]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,fi),this._charsetService.setgCharset(1,fi),this._charsetService.setgCharset(2,fi),this._charsetService.setgCharset(3,fi);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}return!0}resetMode(e){for(let r=0;r<e.length;r++)switch(e.params[r]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(e){for(let r=0;r<e.length;r++)switch(e.params[r]){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:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),1049===e.params[r]&&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)}return!0}requestMode(e,r){let s,i,n,o;(i=s||={})[i.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",i[i.SET=1]="SET",i[i.RESET=2]="RESET",i[i.PERMANENTLY_SET=3]="PERMANENTLY_SET",i[i.PERMANENTLY_RESET=4]="PERMANENTLY_RESET";let a=this._coreService.decPrivateModes,{activeProtocol:l,activeEncoding:c}=this._coreMouseService,d=this._coreService,{buffers:h,cols:u}=this._bufferService,{active:f,alt:p}=h,m=this._optionsService.rawOptions,g=e=>e?1:2,v=e.params[0];return n=v,o=r?2===v?4:4===v?g(d.modes.insertMode):12===v?3:20===v?g(m.convertEol):0:1===v?g(a.applicationCursorKeys):3===v?m.windowOptions.setWinLines?80===u?2:+(132===u):0:6===v?g(a.origin):7===v?g(a.wraparound):8===v?3:9===v?g("X10"===l):12===v?g(m.cursorBlink):25===v?g(!d.isCursorHidden):45===v?g(a.reverseWraparound):66===v?g(a.applicationKeypad):67===v?4:1e3===v?g("VT200"===l):1002===v?g("DRAG"===l):1003===v?g("ANY"===l):1004===v?g(a.sendFocus):1005===v?4:1006===v?g("SGR"===c):1015===v?4:1016===v?g("SGR_PIXELS"===c):1048===v?1:47===v||1047===v||1049===v?g(f===p):2004===v?g(a.bracketedPasteMode):2026===v?g(a.synchronizedOutput):0,d.triggerDataEvent(`${hI.ESC}[${r?"":"?"}${n};${o}$y`),!0}_updateAttrColor(e,r,s,i,n){return 2===r?(e|=0x3000000,e&=-0x1000000,e|=lZ.fromColorRGB([s,i,n])):5===r&&(e&=-0x3000100,e|=0x2000000|255&s),e}_extractColor(e,r,s){let i=[0,0,-1,0,0,0],n=0,o=0;do{if(i[o+n]=e.params[r+o],e.hasSubParams(r+o)){let s=e.getSubParams(r+o),a=0;do 5===i[1]&&(n=1),i[o+a+1+n]=s[a];while(++a<s.length&&a+o+1+n<i.length)break}if(5===i[1]&&o+n>=2||2===i[1]&&o+n>=5)break;i[1]&&(n=1)}while(++o+r<e.length&&o+n<i.length)for(let e=2;e<i.length;++e)-1===i[e]&&(i[e]=0);switch(i[0]){case 38:s.fg=this._updateAttrColor(s.fg,i[1],i[3],i[4],i[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,i[1],i[3],i[4],i[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,i[1],i[3],i[4],i[5])}return o}_processUnderline(e,r){r.extended=r.extended.clone(),(!~e||e>5)&&(e=1),r.extended.underlineStyle=e,r.fg|=0x10000000,0===e&&(r.fg&=-0x10000001),r.updateExtended()}_processSGR0(e){e.fg=u7.fg,e.bg=u7.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-0x4000000,e.updateExtended()}charAttributes(e){if(1===e.length&&0===e.params[0])return this._processSGR0(this._curAttrData),!0;let r=e.length,s,i=this._curAttrData;for(let n=0;n<r;n++)(s=e.params[n])>=30&&s<=37?(i.fg&=-0x3000100,i.fg|=0x1000000|s-30):s>=40&&s<=47?(i.bg&=-0x3000100,i.bg|=0x1000000|s-40):s>=90&&s<=97?(i.fg&=-0x3000100,i.fg|=0x1000000|s-90|8):s>=100&&s<=107?(i.bg&=-0x3000100,i.bg|=0x1000000|s-100|8):0===s?this._processSGR0(i):1===s?i.fg|=0x8000000:3===s?i.bg|=0x4000000:4===s?(i.fg|=0x10000000,this._processUnderline(e.hasSubParams(n)?e.getSubParams(n)[0]:1,i)):5===s?i.fg|=0x20000000:7===s?i.fg|=0x4000000:8===s?i.fg|=0x40000000:9===s?i.fg|=0x80000000:2===s?i.bg|=0x8000000:21===s?this._processUnderline(2,i):22===s?(i.fg&=-0x8000001,i.bg&=-0x8000001):23===s?i.bg&=-0x4000001:24===s?(i.fg&=-0x10000001,this._processUnderline(0,i)):25===s?i.fg&=-0x20000001:27===s?i.fg&=-0x4000001:28===s?i.fg&=-0x40000001:29===s?i.fg&=0x7fffffff:39===s?(i.fg&=-0x4000000,i.fg|=0xffffff&u7.fg):49===s?(i.bg&=-0x4000000,i.bg|=0xffffff&u7.bg):38===s||48===s||58===s?n+=this._extractColor(e,n,i):53===s?i.bg|=0x40000000:55===s?i.bg&=-0x40000001:59===s?(i.extended=i.extended.clone(),i.extended.underlineColor=-1,i.updateExtended()):100===s?(i.fg&=-0x4000000,i.fg|=0xffffff&u7.fg,i.bg&=-0x4000000,i.bg|=0xffffff&u7.bg):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${hI.ESC}[0n`);break;case 6:let r=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${hI.ESC}[${r};${s}R`)}return!0}deviceStatusPrivate(e){if(6===e.params[0]){let e=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${hI.ESC}[?${e};${r}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=u7.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 r=0===e.length?1:e.params[0];if(0===r)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(r){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"}this._coreService.decPrivateModes.cursorBlink=r%2==1}return!0}setScrollRegion(e){let r=e.params[0]||1,s;return(e.length<2||(s=e.params[1])>this._bufferService.rows||0===s)&&(s=this._bufferService.rows),s>r&&(this._activeBuffer.scrollTop=r-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(e){if(!fY(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let r=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:2!==r&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${hI.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(0===r||2===r)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),(0===r||1===r)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:(0===r||2===r)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(0===r||1===r)&&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 r=[],s=e.split(";");for(;s.length>1;){let e=s.shift(),i=s.shift();if(/^\d+$/.exec(e)){let s=parseInt(e);if(fZ(s))if("?"===i)r.push({type:0,index:s});else{let e=fK(i);e&&r.push({type:1,index:s,color:e})}}}return r.length&&this._onColor.fire(r),!0}setHyperlink(e){let r=e.indexOf(";");if(-1===r)return!0;let s=e.slice(0,r).trim(),i=e.slice(r+1);return i?this._createHyperlink(s,i):!s.trim()&&this._finishHyperlink()}_createHyperlink(e,r){this._getCurrentLinkId()&&this._finishHyperlink();let s=e.split(":"),i,n=s.findIndex(e=>e.startsWith("id="));return -1!==n&&(i=s[n].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:i,uri:r}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,r){let s=e.split(";");for(let e=0;e<s.length&&!(r>=this._specialColors.length);++e,++r)if("?"===s[e])this._onColor.fire([{type:0,index:this._specialColors[r]}]);else{let i=fK(s[e]);i&&this._onColor.fire([{type:1,index:this._specialColors[r],color:i}])}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 r=[],s=e.split(";");for(let e=0;e<s.length;++e)if(/^\d+$/.exec(s[e])){let i=parseInt(s[e]);fZ(i)&&r.push({type:2,index:i})}return r.length&&this._onColor.fire(r),!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,fi),!0}selectCharset(e){return 2!==e.length?this.selectDefaultCharset():"/"===e[0]||this._charsetService.setgCharset(fV[e[0]],fs[e[1]]||fi),!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=u7.clone(),this._eraseAttrDataInternal=u7.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-0x4000000,this._eraseAttrDataInternal.bg|=0x3ffffff&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new l0;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let r=0;r<this._bufferService.rows;++r){let s=this._activeBuffer.ybase+this._activeBuffer.y+r,i=this._activeBuffer.lines.get(s);i&&(i.fill(e),i.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,r){let s=e=>(this._coreService.triggerDataEvent(`${hI.ESC}${e}${hI.ESC}\\`),!0),i=this._bufferService.buffer,n=this._optionsService.rawOptions;return s('"q'===e?`P1$r${+!!this._curAttrData.isProtected()}"q`:'"p'===e?'P1$r61;1"p':"r"===e?`P1$r${i.scrollTop+1};${i.scrollBottom+1}r`:"m"===e?"P1$r0m":" q"===e?`P1$r${({block:2,underline:4,bar:6})[n.cursorStyle]-!!n.cursorBlink} q`:"P0$r")}markRangeDirty(e,r){this._dirtyRowTracker.markRangeDirty(e,r)}},fJ=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,r){e>r&&(fX=e,e=r,r=fX),e<this.start&&(this.start=e),r>this.end&&(this.end=r)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function fZ(e){return 0<=e&&e<256}fJ=lW([l$(0,l4)],fJ);var fQ=class extends cE{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 c2),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,r){let s;if(void 0!==r&&this._syncCalls>r){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,!this._isSyncWriting){for(this._isSyncWriting=!0;s=this._writeBuffer.shift();){this._action(s);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=0x7fffffff,this._isSyncWriting=!1,this._syncCalls=0}}write(e,r){if(this._pendingData>5e7)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(r),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(r)}_innerWrite(e=0,r=!0){let s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],i=this._action(e,r);if(i){let e=e=>performance.now()-s>=12?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(s,e);i.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-s>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(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()}},f0=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let r=this._bufferService.buffer;if(void 0===e.id){let s=r.addMarker(r.ybase+r.y),i={data:e,id:this._nextId++,lines:[s]};return s.onDispose(()=>this._removeMarkerFromLink(i,s)),this._dataByLinkId.set(i.id,i),i.id}let s=this._getEntryIdKey(e),i=this._entriesWithId.get(s);if(i)return this.addLineToLink(i.id,r.ybase+r.y),i.id;let n=r.addMarker(r.ybase+r.y),o={id:this._nextId++,key:this._getEntryIdKey(e),data:e,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(o,n)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,r){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(e=>e.line!==r)){let e=this._bufferService.buffer.addMarker(r);s.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(s,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,r){let s=e.lines.indexOf(r);-1!==s&&(e.lines.splice(s,1),0===e.lines.length&&(void 0!==e.data.id&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};f0=lW([l$(0,l4)],f0);var f1=!1,f2=class extends cE{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new cR),this._onBinary=this._register(new c2),this.onBinary=this._onBinary.event,this._onData=this._register(new c2),this.onData=this._onData.event,this._onLineFeed=this._register(new c2),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new c2),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new c2),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new c2),this._instantiationService=new u3,this.optionsService=this._register(new fd(e)),this._instantiationService.setService(ct,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(fa)),this._instantiationService.setService(l4,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(u6)),this._instantiationService.setService(ce,this._logService),this.coreService=this._register(this._instantiationService.createInstance(fp)),this._instantiationService.setService(l8,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(f_)),this._instantiationService.setService(l6,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(fR)),this._instantiationService.setService(cs,this.unicodeService),this._charsetService=this._instantiationService.createInstance(fM),this._instantiationService.setService(l7,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(f0),this._instantiationService.setService(cr,this._oscLinkService),this._inputHandler=this._register(new fG(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(cX.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(cX.forward(this._bufferService.onResize,this._onResize)),this._register(cX.forward(this.coreService.onData,this._onData)),this._register(cX.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 fQ((e,r)=>this._inputHandler.parse(e,r))),this._register(cX.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new c2),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 r in e)this.optionsService.options[r]=e[r]}write(e,r){this._writeBuffer.write(e,r)}writeSync(e,r){this._logService.logLevel<=3&&!f1&&(this._logService.warn("writeSync is unreliable and will be removed soon."),f1=!0),this._writeBuffer.writeSync(e,r)}input(e,r=!0){this.coreService.triggerDataEvent(e,r)}resize(e,r){isNaN(e)||isNaN(r)||(e=Math.max(e,2),r=Math.max(r,1),this._bufferService.resize(e,r))}scroll(e,r=!1){this._bufferService.scroll(e,r)}scrollLines(e,r){this._bufferService.scrollLines(e,r)}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 r=e-this._bufferService.buffer.ydisp;0!==r&&this.scrollLines(r)}registerEscHandler(e,r){return this._inputHandler.registerEscHandler(e,r)}registerDcsHandler(e,r){return this._inputHandler.registerDcsHandler(e,r)}registerCsiHandler(e,r){return this._inputHandler.registerCsiHandler(e,r)}registerOscHandler(e,r){return this._inputHandler.registerOscHandler(e,r)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,r=this.optionsService.rawOptions.windowsPty;r&&void 0!==r.buildNumber&&void 0!==r.buildNumber?e="conpty"===r.backend&&r.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(fD.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(fD(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ck(()=>{for(let r of e)r.dispose()})}}},f5={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:["'",'"']},f3=0,f4=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new uA,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new uA,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(),0===this._insertedValues.length&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((e,r)=>this._getKey(e)-this._getKey(r)),r=0,s=0,i=Array(this._array.length+this._insertedValues.length);for(let n=0;n<i.length;n++)s>=this._array.length||this._getKey(e[r])<=this._getKey(this._array[s])?(i[n]=e[r],r++):i[n]=this._array[s++];this._array=i,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),0===this._array.length)return!1;let r=this._getKey(e);if(void 0===r||-1===(f3=this._search(r))||this._getKey(this._array[f3])!==r)return!1;do if(this._array[f3]===e)return 0===this._deletedIndices.length&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(f3),!0;while(++f3<this._array.length&&this._getKey(this._array[f3])===r)return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((e,r)=>e-r),r=0,s=Array(this._array.length-e.length),i=0;for(let n=0;n<this._array.length;n++)e[r]===n?r++:s[i++]=this._array[n];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),0!==this._array.length&&!((f3=this._search(e))<0||f3>=this._array.length)&&this._getKey(this._array[f3])===e)do yield this._array[f3];while(++f3<this._array.length&&this._getKey(this._array[f3])===e)}forEachByKey(e,r){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),0!==this._array.length&&!((f3=this._search(e))<0||f3>=this._array.length)&&this._getKey(this._array[f3])===e)do r(this._array[f3]);while(++f3<this._array.length&&this._getKey(this._array[f3])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let r=0,s=this._array.length-1;for(;s>=r;){let i=r+s>>1,n=this._getKey(this._array[i]);if(n>e)s=i-1;else if(n<e)r=i+1;else{for(;i>0&&this._getKey(this._array[i-1])===e;)i--;return i}}return r}},f6=0,f8=0,f7=class extends cE{constructor(){super(),this._decorations=new f4(e=>e?.marker.line),this._onDecorationRegistered=this._register(new c2),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new c2),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(ck(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let r=new f9(e);if(r){let e=r.marker.onDispose(()=>r.dispose()),s=r.onDispose(()=>{s.dispose(),r&&(this._decorations.delete(r)&&this._onDecorationRemoved.fire(r),e.dispose())});this._decorations.insert(r),this._onDecorationRegistered.fire(r)}return r}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,r,s){let i=0,n=0;for(let o of this._decorations.getKeyIterator(r))n=(i=o.options.x??0)+(o.options.width??1),e>=i&&e<n&&(!s||(o.options.layer??"bottom")===s)&&(yield o)}forEachDecorationAtCell(e,r,s,i){this._decorations.forEachByKey(r,r=>{f8=(f6=r.options.x??0)+(r.options.width??1),e>=f6&&e<f8&&(!s||(r.options.layer??"bottom")===s)&&i(r)})}},f9=class extends cN{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new c2),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new c2),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 null===this._cachedBg&&(this.options.backgroundColor?this._cachedBg=fw.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return null===this._cachedFg&&(this.options.foregroundColor?this._cachedFg=fw.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},pe=class{constructor(e,r=1e3){this._renderCallback=e,this._debounceThresholdMS=r,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,r,s){this._rowCount=s,e=void 0!==e?e:0,r=void 0!==r?r:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,e):e,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,r):r;let i=performance.now();if(i-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=i,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=i-this._lastRefreshMs,r=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},r)}}_innerRefresh(){if(void 0===this._rowStart||void 0===this._rowEnd||void 0===this._rowCount)return;let e=Math.max(this._rowStart,0),r=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,r)}},pt=class extends cE{constructor(e,r,s,i){super(),this._terminal=e,this._coreBrowserService=s,this._renderService=i,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let n=this._coreBrowserService.mainDocument;this._accessibilityContainer=n.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=n.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=n.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new pe(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(`
20
+ `))),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(d8(n,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(ck(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let r=0;r<e;r++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
21
+ `&&(this._liveRegionLineCount++,21===this._liveRegionLineCount&&(this._liveRegion.textContent+=lU)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,r){this._liveRegionDebouncer.refresh(e,r,this._terminal.rows)}_renderRows(e,r){let s=this._terminal.buffer,i=s.lines.length.toString();for(let n=e;n<=r;n++){let e=s.lines.get(s.ydisp+n),r=[],o=e?.translateToString(!0,void 0,void 0,r)||"",a=(s.ydisp+n+1).toString(),l=this._rowElements[n];l&&(0===o.length?(l.textContent=" ",this._rowColumns.set(l,[0,1])):(l.textContent=o,this._rowColumns.set(l,r)),l.setAttribute("aria-posinset",a),l.setAttribute("aria-setsize",i),this._alignRowWidth(l))}this._announceCharacters()}_announceCharacters(){0!==this._charsToAnnounce.length&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,r){let s,i,n=e.target,o=this._rowElements[0===r?1:this._rowElements.length-2];if(n.getAttribute("aria-posinset")!==(0===r?"1":`${this._terminal.buffer.lines.length}`)&&e.relatedTarget===o){if(0===r?(s=n,i=this._rowElements.pop(),this._rowContainer.removeChild(i)):(s=this._rowElements.shift(),i=n,this._rowContainer.removeChild(s)),s.removeEventListener("focus",this._topBoundaryFocusListener),i.removeEventListener("focus",this._bottomBoundaryFocusListener),0===r){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(0===r?-1:1),this._rowElements[0===r?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}}_handleSelectionChange(){if(0===this._rowElements.length)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)return void console.error("anchorNode and/or focusNode are null");let r={node:e.anchorNode,offset:e.anchorOffset},s={node:e.focusNode,offset:e.focusOffset};if((r.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||r.node===s.node&&r.offset>s.offset)&&([r,s]=[s,r]),r.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(r={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(r.node))return;let i=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(i)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:i,offset:i.textContent?.length??0}),!this._rowContainer.contains(s.node))return;let n=({node:e,offset:r})=>{let s=e instanceof Text?e.parentNode:e,i=parseInt(s?.getAttribute("aria-posinset"),10)-1;if(isNaN(i))return console.warn("row is invalid. Race condition?"),null;let n=this._rowColumns.get(s);if(!n)return console.warn("columns is null. Race condition?"),null;let o=r<n.length?n[r]:n.slice(-1)[0]+1;return o>=this._terminal.cols&&(++i,o=0),{row:i,column:o}},o=n(r),a=n(s);if(!(!o||!a)){if(o.row>a.row||o.row===a.row&&o.column>=a.column)throw Error("invalid range");this._terminal.select(o.column,o.row,(a.row-o.row)*this._terminal.cols-o.column+a.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 r=e.getBoundingClientRect().width,s=this._rowColumns.get(e)?.slice(-1)?.[0];if(!s)return;let i=s*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${i/r})`}};pt=lW([l$(1,l9),l$(2,ca),l$(3,cc)],pt);var pr=class extends cE{constructor(e,r,s,i,n){super(),this._element=e,this._mouseService=r,this._renderService=s,this._bufferService=i,this._linkProviderService=n,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new c2),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new c2),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(ck(()=>{cC(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(d8(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(d8(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(d8(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(d8(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let r=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!r)return;this._isMouseOut=!1;let s=e.composedPath();for(let e=0;e<s.length;e++){let r=s[e];if(r.classList.contains("xterm"))break;if(r.classList.contains("xterm-hover"))return}this._lastBufferCell&&r.x===this._lastBufferCell.x&&r.y===this._lastBufferCell.y||(this._handleHover(r),this._lastBufferCell=r)}_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,r){this._activeProviderReplies&&r||(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let s=!1;for(let[i,n]of this._linkProviderService.linkProviders.entries())r?this._activeProviderReplies?.get(i)&&(s=this._checkLinkProviderResult(i,e,s)):n.provideLinks(e.y,r=>{if(this._isMouseOut)return;let n=r?.map(e=>({link:e}));this._activeProviderReplies?.set(i,n),s=this._checkLinkProviderResult(i,e,s),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,r){let s=new Set;for(let i=0;i<r.size;i++){let n=r.get(i);if(n)for(let r=0;r<n.length;r++){let i=n[r],o=i.link.range.start.y<e?0:i.link.range.start.x,a=i.link.range.end.y>e?this._bufferService.cols:i.link.range.end.x;for(let e=o;e<=a;e++){if(s.has(e)){n.splice(r--,1);break}s.add(e)}}}}_checkLinkProviderResult(e,r,s){if(!this._activeProviderReplies)return s;let i=this._activeProviderReplies.get(e),n=!1;for(let r=0;r<e;r++)(!this._activeProviderReplies.has(r)||this._activeProviderReplies.get(r))&&(n=!0);if(!n&&i){let e=i.find(e=>this._linkAtPosition(e.link,r));e&&(s=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let e=0;e<this._activeProviderReplies.size;e++){let i=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,r));if(i){s=!0,this._handleNewLink(i);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){var r,s;if(!this._currentLink)return;let i=this._positionFromMouseEvent(e,this._element,this._mouseService);i&&this._mouseDownLink&&(r=this._mouseDownLink.link,s=this._currentLink.link,r.text===s.text&&r.range.start.x===s.range.start.x&&r.range.start.y===s.range.start.y&&r.range.end.x===s.range.end.x&&r.range.end.y===s.range.end.y)&&this._linkAtPosition(this._currentLink.link,i)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,r){this._currentLink&&this._lastMouseEvent&&(!e||!r||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=r)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,cC(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let r=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);r&&this._linkAtPosition(e.link,r)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:void 0===e.link.decorations||e.link.decorations.underline,pointerCursor:void 0===e.link.decorations||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:r=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==r&&(this._currentLink.state.decorations.underline=r,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,r))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let r=0===e.start?0:e.start+1+this._bufferService.buffer.ydisp,s=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=r&&this._currentLink.link.range.end.y<=s&&(this._clearCurrentLink(r,s),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,r,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(r,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),r.hover&&r.hover(s,r.text)}_fireUnderlineEvent(e,r){let s=e.range,i=this._bufferService.buffer.ydisp,n=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-i-1,s.end.x,s.end.y-i-1,void 0);(r?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(n)}_linkLeave(e,r,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(r,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),r.leave&&r.leave(s,r.text)}_linkAtPosition(e,r){let s=e.range.start.y*this._bufferService.cols+e.range.start.x,i=e.range.end.y*this._bufferService.cols+e.range.end.x,n=r.y*this._bufferService.cols+r.x;return s<=n&&n<=i}_positionFromMouseEvent(e,r,s){let i=s.getCoords(e,r,this._bufferService.cols,this._bufferService.rows);if(i)return{x:i[0],y:i[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,r,s,i,n){return{x1:e,y1:r,x2:s,y2:i,cols:this._bufferService.cols,fg:n}}};pr=lW([l$(1,cl),l$(2,cc),l$(3,l4),l$(4,cf)],pr);var ps=class extends f2{constructor(e={}){super(e),this._linkifier=this._register(new cR),this.browser=ug,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new cR),this._onCursorMove=this._register(new c2),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new c2),this.onKey=this._onKey.event,this._onRender=this._register(new c2),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new c2),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new c2),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new c2),this.onBell=this._onBell.event,this._onFocus=this._register(new c2),this._onBlur=this._register(new c2),this._onA11yCharEmitter=this._register(new c2),this._onA11yTabEmitter=this._register(new c2),this._onWillOpen=this._register(new c2),this._setup(),this._decorationService=this._instantiationService.createInstance(f7),this._instantiationService.setService(ci,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(uu),this._instantiationService.setService(cf,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(cn)),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(cX.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(cX.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(cX.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(cX.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(ck(()=>{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 r of e){let e,s="";switch(r.index){case 256:e="foreground",s="10";break;case 257:e="background",s="11";break;case 258:e="cursor",s="12";break;default:e="ansi",s="4;"+r.index}switch(r.type){case 0:let i=fb.toColorRGB("ansi"===e?this._themeService.colors.ansi[r.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${hI.ESC}]${s};${function(e,r=16){let[s,i,n]=e;return`rgb:${fq(s,r)}/${fq(i,r)}/${fq(n,r)}`}(i)}${hz.ST}`);break;case 1:if("ansi"===e)this._themeService.modifyColors(e=>e.ansi[r.index]=hF.toColor(...r.color));else{let s=e;this._themeService.modifyColors(e=>e[s]=hF.toColor(...r.color))}break;case 2:this._themeService.restoreColor(r.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(pt,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(hI.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(hI.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,r=this.buffer.lines.get(e);if(!r)return;let s=Math.min(this.buffer.x,this.cols-1),i=this._renderService.dimensions.css.cell.height,n=r.getWidth(s),o=this._renderService.dimensions.css.cell.width*n,a=this.buffer.y*this._renderService.dimensions.css.cell.height,l=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=a+"px",this.textarea.style.width=o+"px",this.textarea.style.height=i+"px",this.textarea.style.lineHeight=i+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(d8(this.element,"copy",e=>{var r;this.hasSelection()&&(r=this._selectionService,e.clipboardData&&e.clipboardData.setData("text/plain",r.selectionText),e.preventDefault())}));let e=e=>{var r,s,i;return r=this.textarea,s=this.coreService,i=this.optionsService,void(e.stopPropagation(),e.clipboardData&&lK(e.clipboardData.getData("text/plain"),r,s,i))};this._register(d8(this.textarea,"paste",e)),this._register(d8(this.element,"paste",e)),uw?this._register(d8(this.element,"mousedown",e=>{2===e.button&&lV(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(d8(this.element,"contextmenu",e=>{lV(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),uM&&this._register(d8(this.element,"auxclick",e=>{1===e.button&&lq(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(d8(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(d8(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(d8(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(d8(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(d8(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(d8(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(d8(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 r=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),r.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(d8(this.screenElement,"mousemove",e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),r.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",lH),uD||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",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(ud,this.textarea,e.ownerDocument.defaultView??window,this._document??"u">typeof window?window.document:null)),this._instantiationService.setService(ca,this._coreBrowserService),this._register(d8(this.textarea,"focus",e=>this._handleTextAreaFocus(e))),this._register(d8(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(uo,this._document,this._helperContainer),this._instantiationService.setService(co,this._charSizeService),this._themeService=this._instantiationService.createInstance(u1),this._instantiationService.setService(cu,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(h2),this._instantiationService.setService(ch,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(uI,this.rows,this.screenElement)),this._instantiationService.setService(cc,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(hD,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(up),this._instantiationService.setService(cl,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(pr,this.screenElement));this.element.appendChild(r);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(hC,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(uV,this.element,this.screenElement,i)),this._instantiationService.setService(cd,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(cX.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(hk,this.screenElement)),this._register(d8(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(pt,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(hM,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(hM,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(un,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,r=this.element;function s(r){let s,i,n=e._mouseService.getMouseReportCoords(r,e.screenElement);if(!n)return!1;switch(r.overrideType||r.type){case"mousemove":i=32,void 0===r.buttons?(s=3,void 0!==r.button&&(s=r.button<3?r.button:3)):s=1&r.buttons?0:4&r.buttons?1:2&r.buttons?2:3;break;case"mouseup":i=0,s=r.button<3?r.button:3;break;case"mousedown":i=1,s=r.button<3?r.button:3;break;case"wheel":if(e._customWheelEventHandler&&!1===e._customWheelEventHandler(r))return!1;let o=r.deltaY;if(0===o||0===e.coreMouseService.consumeWheelEvent(r,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr))return!1;i=o<0?0:1,s=4;break;default:return!1}return void 0!==i&&void 0!==s&&!(s>4)&&e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:s,action:i,ctrl:r.ctrlKey,alt:r.altKey,shift:r.shiftKey})}let i={mouseup:null,wheel:null,mousedrag:null,mousemove:null},n=e=>(s(e),e.buttons||(this._document.removeEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.removeEventListener("mousemove",i.mousedrag)),this.cancel(e)),o=e=>(s(e),this.cancel(e,!0)),a=e=>{e.buttons&&s(e)},l=e=>{e.buttons||s(e)};this._register(this.coreMouseService.onProtocolChange(e=>{e?("debug"===this.optionsService.rawOptions.logLevel&&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()),8&e?i.mousemove||(r.addEventListener("mousemove",l),i.mousemove=l):(r.removeEventListener("mousemove",i.mousemove),i.mousemove=null),16&e?i.wheel||(r.addEventListener("wheel",o,{passive:!1}),i.wheel=o):(r.removeEventListener("wheel",i.wheel),i.wheel=null),2&e?i.mouseup||(i.mouseup=n):(this._document.removeEventListener("mouseup",i.mouseup),i.mouseup=null),4&e?i.mousedrag||(i.mousedrag=a):(this._document.removeEventListener("mousemove",i.mousedrag),i.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(d8(r,"mousedown",e=>{if(e.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(e)))return s(e),i.mouseup&&this._document.addEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.addEventListener("mousemove",i.mousedrag),this.cancel(e)})),this._register(d8(r,"wheel",r=>{if(!i.wheel){if(this._customWheelEventHandler&&!1===this._customWheelEventHandler(r))return!1;if(!this.buffer.hasScrollback){if(0===r.deltaY)return!1;if(0===e.coreMouseService.consumeWheelEvent(r,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr))return this.cancel(r,!0);let s=hI.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(r.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(s,!0),this.cancel(r,!0)}}},{passive:!1}))}refresh(e,r){this._renderService?.refreshRows(e,r)}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,r){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,r),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 r=e-this._bufferService.buffer.ydisp;0!==r&&this.scrollLines(r)}paste(e){lK(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 r=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),r}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}select(e,r,s){this._selectionService.setSelection(e,r,s)}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,r){this._selectionService?.selectLines(e,r)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;let r=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!r&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;r||"Dead"!==e.key&&"AltGraph"!==e.key||(this._unprocessedDeadKey=!0);let s=function(e,r,s,i){let n={type:0,cancel:!1,key:void 0},o=!!e.shiftKey|2*!!e.altKey|4*!!e.ctrlKey|8*!!e.metaKey;switch(e.keyCode){case 0:"UIKeyInputUpArrow"===e.key?r?n.key=hI.ESC+"OA":n.key=hI.ESC+"[A":"UIKeyInputLeftArrow"===e.key?r?n.key=hI.ESC+"OD":n.key=hI.ESC+"[D":"UIKeyInputRightArrow"===e.key?r?n.key=hI.ESC+"OC":n.key=hI.ESC+"[C":"UIKeyInputDownArrow"===e.key&&(r?n.key=hI.ESC+"OB":n.key=hI.ESC+"[B");break;case 8:n.key=e.ctrlKey?"\b":hI.DEL,e.altKey&&(n.key=hI.ESC+n.key);break;case 9:if(e.shiftKey){n.key=hI.ESC+"[Z";break}n.key=hI.HT,n.cancel=!0;break;case 13:n.key=e.altKey?hI.ESC+hI.CR:hI.CR,n.cancel=!0;break;case 27:n.key=hI.ESC,e.altKey&&(n.key=hI.ESC+hI.ESC),n.cancel=!0;break;case 37:if(e.metaKey)break;o?n.key=hI.ESC+"[1;"+(o+1)+"D":r?n.key=hI.ESC+"OD":n.key=hI.ESC+"[D";break;case 39:if(e.metaKey)break;o?n.key=hI.ESC+"[1;"+(o+1)+"C":r?n.key=hI.ESC+"OC":n.key=hI.ESC+"[C";break;case 38:if(e.metaKey)break;o?n.key=hI.ESC+"[1;"+(o+1)+"A":r?n.key=hI.ESC+"OA":n.key=hI.ESC+"[A";break;case 40:if(e.metaKey)break;o?n.key=hI.ESC+"[1;"+(o+1)+"B":r?n.key=hI.ESC+"OB":n.key=hI.ESC+"[B";break;case 45:e.shiftKey||e.ctrlKey||(n.key=hI.ESC+"[2~");break;case 46:o?n.key=hI.ESC+"[3;"+(o+1)+"~":n.key=hI.ESC+"[3~";break;case 36:o?n.key=hI.ESC+"[1;"+(o+1)+"H":r?n.key=hI.ESC+"OH":n.key=hI.ESC+"[H";break;case 35:o?n.key=hI.ESC+"[1;"+(o+1)+"F":r?n.key=hI.ESC+"OF":n.key=hI.ESC+"[F";break;case 33:e.shiftKey?n.type=2:e.ctrlKey?n.key=hI.ESC+"[5;"+(o+1)+"~":n.key=hI.ESC+"[5~";break;case 34:e.shiftKey?n.type=3:e.ctrlKey?n.key=hI.ESC+"[6;"+(o+1)+"~":n.key=hI.ESC+"[6~";break;case 112:o?n.key=hI.ESC+"[1;"+(o+1)+"P":n.key=hI.ESC+"OP";break;case 113:o?n.key=hI.ESC+"[1;"+(o+1)+"Q":n.key=hI.ESC+"OQ";break;case 114:o?n.key=hI.ESC+"[1;"+(o+1)+"R":n.key=hI.ESC+"OR";break;case 115:o?n.key=hI.ESC+"[1;"+(o+1)+"S":n.key=hI.ESC+"OS";break;case 116:o?n.key=hI.ESC+"[15;"+(o+1)+"~":n.key=hI.ESC+"[15~";break;case 117:o?n.key=hI.ESC+"[17;"+(o+1)+"~":n.key=hI.ESC+"[17~";break;case 118:o?n.key=hI.ESC+"[18;"+(o+1)+"~":n.key=hI.ESC+"[18~";break;case 119:o?n.key=hI.ESC+"[19;"+(o+1)+"~":n.key=hI.ESC+"[19~";break;case 120:o?n.key=hI.ESC+"[20;"+(o+1)+"~":n.key=hI.ESC+"[20~";break;case 121:o?n.key=hI.ESC+"[21;"+(o+1)+"~":n.key=hI.ESC+"[21~";break;case 122:o?n.key=hI.ESC+"[23;"+(o+1)+"~":n.key=hI.ESC+"[23~";break;case 123:o?n.key=hI.ESC+"[24;"+(o+1)+"~":n.key=hI.ESC+"[24~";break;default:if(!e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)if((!s||i)&&e.altKey&&!e.metaKey){let r=f5[e.keyCode]?.[+!!e.shiftKey];if(r)n.key=hI.ESC+r;else if(e.keyCode>=65&&e.keyCode<=90){let r=String.fromCharCode(e.ctrlKey?e.keyCode-64:e.keyCode+32);e.shiftKey&&(r=r.toUpperCase()),n.key=hI.ESC+r}else if(32===e.keyCode)n.key=hI.ESC+(e.ctrlKey?hI.NUL:" ");else if("Dead"===e.key&&e.code.startsWith("Key")){let r=e.code.slice(3,4);e.shiftKey||(r=r.toLowerCase()),n.key=hI.ESC+r,n.cancel=!0}}else!s||e.altKey||e.ctrlKey||e.shiftKey||!e.metaKey?!e.key||e.ctrlKey||e.altKey||e.metaKey||!(e.keyCode>=48)||1!==e.key.length?e.key&&e.ctrlKey&&("_"===e.key&&(n.key=hI.US),"@"===e.key&&(n.key=hI.NUL)):n.key=e.key:65===e.keyCode&&(n.type=1);else e.keyCode>=65&&e.keyCode<=90?n.key=String.fromCharCode(e.keyCode-64):32===e.keyCode?n.key=hI.NUL:e.keyCode>=51&&e.keyCode<=55?n.key=String.fromCharCode(e.keyCode-51+27):56===e.keyCode?n.key=hI.DEL:219===e.keyCode?n.key=hI.ESC:220===e.keyCode?n.key=hI.FS:221===e.keyCode&&(n.key=hI.GS)}return n}(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),3===s.type||2===s.type){let r=this.rows-1;return this.scrollLines(2===s.type?-r:r),this.cancel(e,!0)}return 1===s.type&&this.selectAll(),!!(this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&1===e.key.length&&e.key.charCodeAt(0)>=65&&90>=e.key.charCodeAt(0))||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):((s.key===hI.ETX||s.key===hI.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)?this.cancel(e,!0):void(this._keyDownHandled=!0))}_isThirdLevelShift(e,r){let s=e.isMac&&!this.options.macOptionIsMeta&&r.altKey&&!r.ctrlKey&&!r.metaKey||e.isWindows&&r.altKey&&r.ctrlKey&&!r.metaKey||e.isWindows&&r.getModifierState("AltGraph");return"keypress"===r.type?s:s&&(!r.keyCode||r.keyCode>47)}_keyUp(e){var r;this._keyDownSeen=!1,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e)||(16===(r=e).keyCode||17===r.keyCode||18===r.keyCode||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let r;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;if(this.cancel(e),e.charCode)r=e.charCode;else if(null===e.which||void 0===e.which)r=e.keyCode;else{if(0===e.which||0===e.charCode)return!1;r=e.which}return!!r&&(!e.altKey&&!e.ctrlKey&&!e.metaKey||!!this._isThirdLevelShift(this.browser,e))&&(r=String.fromCharCode(r),this._onKey.fire({key:r,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(r,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&"insertText"===e.inputType&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let r=e.data;return this.coreService.triggerDataEvent(r,!0),this.cancel(e),!0}return!1}resize(e,r){if(e===this.cols&&r===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,r)}_afterResize(e,r){this._charSizeService?.measure()}clear(){if(0!==this.buffer.ybase||0!==this.buffer.y){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(u7));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(hI.ESC+"[I"):this.coreService.triggerDataEvent(hI.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let r=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${hI.ESC}[4;${s};${r}t`);break;case 1:let i=this._renderService.dimensions.css.cell.width.toFixed(0),n=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${hI.ESC}[6;${n};${i}t`)}}cancel(e,r){if(!(!this.options.cancelEvents&&!r))return e.preventDefault(),e.stopPropagation(),!1}},pi=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,r){let s={instance:r,dispose:r.dispose,isDisposed:!1};this._addons.push(s),r.dispose=()=>this._wrappedAddonDispose(s),r.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let r=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===e){r=s;break}if(-1===r)throw Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(r,1)}},pn=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,r){if(!(e<0||e>=this._line.length))return r?(this._line.loadCell(e,r),r):this._line.loadCell(e,new l0)}translateToString(e,r,s){return this._line.translateToString(e,r,s)}},po=class{constructor(e,r){this._buffer=e,this.type=r}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 r=this._buffer.lines.get(e);if(r)return new pn(r)}getNullCell(){return new l0}},pa=class extends cE{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new c2),this.onBufferChange=this._onBufferChange.event,this._normal=new po(this._core.buffers.normal,"normal"),this._alternate=new po(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)}},pl=class{constructor(e){this._core=e}registerCsiHandler(e,r){return this._core.registerCsiHandler(e,e=>r(e.toArray()))}addCsiHandler(e,r){return this.registerCsiHandler(e,r)}registerDcsHandler(e,r){return this._core.registerDcsHandler(e,(e,s)=>r(e,s.toArray()))}addDcsHandler(e,r){return this.registerDcsHandler(e,r)}registerEscHandler(e,r){return this._core.registerEscHandler(e,r)}addEscHandler(e,r){return this.registerEscHandler(e,r)}registerOscHandler(e,r){return this._core.registerOscHandler(e,r)}addOscHandler(e,r){return this.registerOscHandler(e,r)}},pc=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}},pd=["cols","rows"],ph=0,pu=class extends cE{constructor(e){super(),this._core=this._register(new ps(e)),this._addonManager=this._register(new pi),this._publicOptions={...this._core.options};let r=e=>this._core.options[e],s=(e,r)=>{this._checkReadonlyOptions(e),this._core.options[e]=r};for(let e in this._core.options){let i={get:r.bind(this,e),set:s.bind(this,e)};Object.defineProperty(this._publicOptions,e,i)}}_checkReadonlyOptions(e){if(pd.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||(this._parser=new pl(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new pc(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._buffer=this._register(new pa(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,r="none";switch(this._core.coreMouseService.activeProtocol){case"X10":r="x10";break;case"VT200":r="vt200";break;case"DRAG":r="drag";break;case"ANY":r="any"}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:r,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 r in e)this._publicOptions[r]=e[r]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,r=!0){this._core.input(e,r)}resize(e,r){this._verifyIntegers(e,r),this._core.resize(e,r)}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,r,s){this._verifyIntegers(e,r,s),this._core.select(e,r,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,r){this._verifyIntegers(e,r),this._core.selectLines(e,r)}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,r){this._core.write(e,r)}writeln(e,r){this._core.write(e),this._core.write(`\r
22
+ `,r)}paste(e){this._core.paste(e)}refresh(e,r){this._verifyIntegers(e,r),this._core.refresh(e,r)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return lH},set promptLabel(t){lH=t},get tooMuchOutput(){return lU},set tooMuchOutput(t){lU=t}}}_verifyIntegers(...e){for(ph of e)if(ph===1/0||isNaN(ph)||ph%1!=0)throw Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(ph of e)if(ph&&(ph===1/0||isNaN(ph)||ph%1!=0||ph<0))throw Error("This API only accepts positive integers")}},pf=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let r=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(r._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(0===e.css.cell.width||0===e.css.cell.height)return;let r=0===this._terminal.options.scrollback?0:this._terminal.options.overviewRuler?.width||14,s=window.getComputedStyle(this._terminal.element.parentElement),i=parseInt(s.getPropertyValue("height")),n=Math.max(0,parseInt(s.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),a={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},l=a.top+a.bottom;return{cols:Math.max(2,Math.floor((n-(a.right+a.left)-r)/e.css.cell.width)),rows:Math.max(1,Math.floor((i-l)/e.css.cell.height))}}},pp=class{constructor(e,r,s,i={}){this._terminal=e,this._regex=r,this._handler=s,this._options=i}provideLinks(e,r){let s=pm.computeLink(e,this._regex,this._terminal,this._handler);r(this._addCallbacks(s))}_addCallbacks(e){return e.map(e=>(e.leave=this._options.leave,e.hover=(r,s)=>{if(this._options.hover){let{range:i}=e;this._options.hover(r,s,i)}},e))}},pm=class e{static computeLink(r,s,i,n){let o=RegExp(s.source,(s.flags||"")+"g"),[a,l]=e._getWindowedLineStrings(r-1,i),c=a.join(""),d,h=[];for(;d=o.exec(c);){let r=d[0];if(!function(e){try{let r=new URL(e),s=r.password&&r.username?`${r.protocol}//${r.username}:${r.password}@${r.host}`:r.username?`${r.protocol}//${r.username}@${r.host}`:`${r.protocol}//${r.host}`;return e.toLocaleLowerCase().startsWith(s.toLocaleLowerCase())}catch{return!1}}(r))continue;let[s,o]=e._mapStrIdx(i,l,0,d.index),[a,c]=e._mapStrIdx(i,s,o,r.length);if(-1===s||-1===o||-1===a||-1===c)continue;let u={start:{x:o+1,y:s+1},end:{x:c,y:a+1}};h.push({range:u,text:r,activate:n})}return h}static _getWindowedLineStrings(e,r){let s,i=e,n=e,o=0,a="",l=[];if(s=r.buffer.active.getLine(e)){let e=s.translateToString(!0);if(s.isWrapped&&" "!==e[0]){for(o=0;(s=r.buffer.active.getLine(--i))&&o<2048&&(o+=(a=s.translateToString(!0)).length,l.push(a),!(!s.isWrapped||-1!==a.indexOf(" "))););l.reverse()}for(l.push(e),o=0;(s=r.buffer.active.getLine(++n))&&s.isWrapped&&o<2048&&(o+=(a=s.translateToString(!0)).length,l.push(a),-1===a.indexOf(" ")););}return[l,i]}static _mapStrIdx(e,r,s,i){let n=e.buffer.active,o=n.getNullCell(),a=s;for(;i;){let e=n.getLine(r);if(!e)return[-1,-1];for(let s=a;s<e.length;++s){e.getCell(s,o);let a=o.getChars();if(o.getWidth()&&(i-=a.length||1,s===e.length-1&&""===a)){let e=n.getLine(r+1);e&&e.isWrapped&&(e.getCell(0,o),2===o.getWidth()&&(i+=1))}if(i<0)return[r,s]}r++,a=0}return[r,a]}},pg=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function pv(e,r){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=r}else console.warn("Opening link blocked as opener could not be cleared")}var px=class{constructor(e=pv,r={}){this._handler=e,this._options=r}activate(e){this._terminal=e;let r=this._options,s=r.urlRegex||pg;this._linkProvider=this._terminal.registerLinkProvider(new pp(this._terminal,s,this._handler,r))}dispose(){this._linkProvider?.dispose()}},p_=e.i(754219);let py=/\x1B(?:\][^\x07]*(?:\x07|\x1B\\)|[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g;function pb({logs:e,isPty:r,className:s,onInput:i,onResize:n,muteInput:o}){let a=(0,W.useRef)(null),l=(0,W.useRef)(null),c=(0,W.useRef)(null),d=(0,W.useRef)(0),h=(0,W.useRef)(o);h.current!==o&&console.log(`[ExecutorOutput] muteInput changed: ${h.current} → ${o}`),h.current=o;let{settings:u}=(0,oX.useTerminalSettings)(),f=(0,W.useRef)(u),[p,m]=(0,W.useState)(!1),g=(0,W.useRef)(0),v=(0,W.useRef)(e);v.current=e;let x=async()=>{if(!p){g.current=v.current.length,m(!0);return}let e=v.current,r=Math.min(g.current,e.length),s=e.slice(r).map(e=>"stdout"===e.type||"stderr"===e.type||"pty"===e.type?e.data:"").join("");m(!1);let i=s.replace(py,"");if(!i)return void p_.toast.info("Capture stopped — no output to copy");try{await navigator.clipboard.writeText(i),p_.toast.success("Copied captured output to clipboard")}catch{p_.toast.error("Failed to copy to clipboard")}};return(0,W.useEffect)(()=>{if(!a.current||l.current)return;let e=f.current,s=new pu({cursorBlink:r,cursorStyle:r?"block":"underline",disableStdin:!r,convertEol:!0,fontSize:e.fontSize,fontFamily:e.fontFamily,scrollback:e.scrollback,theme:{background:"#09090b",foreground:"#fafafa",cursor:r?"#fafafa":"#09090b",cursorAccent:"#09090b",selectionBackground:"#3f3f46",black:"#09090b",red:"#f87171",green:"#4ade80",yellow:"#facc15",blue:"#60a5fa",magenta:"#c084fc",cyan:"#22d3ee",white:"#fafafa",brightBlack:"#71717a",brightRed:"#fca5a5",brightGreen:"#86efac",brightYellow:"#fde047",brightBlue:"#93c5fd",brightMagenta:"#d8b4fe",brightCyan:"#67e8f9",brightWhite:"#ffffff"},allowProposedApi:!0}),o=new pf,u=new px;return s.loadAddon(o),s.loadAddon(u),s.open(a.current),setTimeout(()=>{try{o.fit(),r&&n?.(s.cols,s.rows)}catch{}},0),l.current=s,c.current=o,r&&i&&s.onData(e=>{(32>e.charCodeAt(0)||e.startsWith("\x1b"))&&console.log(`[ExecutorOutput onData] terminal response detected, muteInput=${h.current}, data=${JSON.stringify(e)}`),h.current||i(e)}),r&&n&&s.onResize(({cols:e,rows:r})=>{n(e,r)}),()=>{s.dispose(),l.current=null,c.current=null,d.current=0}},[r,i,n]),(0,W.useEffect)(()=>{if(!l.current)return;e.length<d.current&&(l.current.reset(),d.current=0);let r=e.length-d.current;r>0&&console.log(`[ExecutorOutput] writing ${r} logs (${d.current}→${e.length}), muteInput=${h.current}`);for(let r=d.current;r<e.length;r++){let s=e[r];"pty"===s.type?l.current.write(s.data):("stdout"===s.type||"stderr"===s.type)&&l.current.write(s.data)}d.current=e.length},[e]),(0,W.useEffect)(()=>{let e=l.current;if(e){e.options.fontSize=u.fontSize,e.options.fontFamily=u.fontFamily,e.options.scrollback=u.scrollback;try{c.current?.fit()}catch{}}},[u.fontSize,u.fontFamily,u.scrollback]),(0,W.useEffect)(()=>{if(!a.current||!c.current)return;let e=new ResizeObserver(()=>{try{c.current?.fit()}catch{}});return e.observe(a.current),()=>{e.disconnect()}},[]),(0,F.jsxs)("div",{className:(0,ey.cn)("relative h-[300px] rounded-md border bg-zinc-950 overflow-hidden",s),children:[(0,F.jsx)("div",{ref:a,className:"h-full w-full"}),(0,F.jsx)("button",{type:"button",onClick:x,title:p?"Stop capture & copy to clipboard":"Start capturing output","aria-label":p?"Stop capture and copy":"Start capturing output",className:(0,ey.cn)("absolute top-2 right-3 z-10 flex h-6 w-6 items-center justify-center rounded","bg-zinc-900/70 backdrop-blur-sm border border-zinc-700/60","text-zinc-400 hover:text-zinc-100 hover:border-zinc-500 transition-colors",p&&"text-red-400 border-red-500/70 hover:text-red-300"),children:p?(0,F.jsx)(lA,{className:"h-3 w-3 fill-current"}):(0,F.jsx)(nV,{className:"h-3 w-3"})})]})}let pw=(0,ew.default)("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]),pS=[{name:"Dev Server",command:"pnpm dev",executor_type:"command",pty:!0,description:"Start the development server with hot reload"},{name:"Build",command:"pnpm build",executor_type:"command",pty:!0,description:"Build the project for production"},{name:"Lint",command:"pnpm lint",executor_type:"command",pty:!0,description:"Run the linter to check code quality"},{name:"Type Check",command:"npx tsc --noEmit",executor_type:"command",pty:!0,description:"Run TypeScript type checking without emitting files"},{name:"Test",command:"pnpm test",executor_type:"command",pty:!0,description:"Run the test suite"},{name:"Rebase on and merge into main",command:"Our goal is to sync the current local branch with the local branch/worktree `main`. The two branches may have diverged.\n\nPlease do the following in order. Only proceed to the next step if the previous step succeeds:\n\n1. Rebase the current local branch onto the local branch `main`, and resolve any conflicts if needed.\n2. If, after the rebase, `main` does not yet contain the current branch's commits, switch to the `main` branch/worktree and merge the current branch into `main` using `git merge`. Do not use `git branch -f`.\n3. If the current branch is already fully contained in `main`, and `main` has newer commits, update the current branch so it includes the latest commits from `main`.\n4. Push both the current local branch and the local branch `main` to the remote.",executor_type:"prompt",pty:!1,description:"Rebase current branch onto main, merge into main, and push both branches"},{name:"Reset to main",command:"git reset --hard main",executor_type:"command",pty:!0,description:"Hard reset the current branch to match main"},{name:"Push to remote",command:"git push --force-with-lease",executor_type:"command",pty:!0,description:"Force push to remote with lease safety check"},{name:"Git commit",command:"Inspect the modified and untracked and deleted files in the current repository, generate an appropriate commit message, and commit all relevant files.\n\nCommit message rules:\n- Use Conventional Commits format (feat:, fix:, chore:, refactor:, docs:, test:, ci:, build:, perf:, style:, etc.)\n- Choose the type that best matches the main purpose of the changes\n- Make the message specific to the actual changes\n- Keep it within 50 characters if possible\n- Use lowercase\n- Do not end with a period\n- Do not wrap the message in quotes, backticks, or markdown\n\nCommit requirements:\n- Include all relevant modified and untracked files\n- Do not include unrelated files\n- If there are no meaningful changes to commit, do not create a commit\n\nWhen finished, output only the final commit message.",executor_type:"prompt",pty:!1,description:"Inspect changes, generate a conventional commit message, and commit"},{name:"Tag and push",command:"Find the latest SemVer tag in the repository, increase the patch number by 1, create the new tag from the current commit, and push it to origin.",executor_type:"prompt",pty:!1,description:"Bump the patch version tag and push it to origin"}];function pC({open:e,onOpenChange:r,executor:s,onSubmit:i}){let[n,o]=(0,W.useState)(s?.name??""),[a,l]=(0,W.useState)(s?.executor_type??"command"),[c,d]=(0,W.useState)(s?.prompt_provider??"claude"),[h,u]=(0,W.useState)(s?.command??""),[f,p]=(0,W.useState)(s?.cwd??""),[m,g]=(0,W.useState)(s?.pty??!0),[v,x]=(0,W.useState)(!1),[_,y]=(0,W.useState)(!1),[b,w]=(0,W.useState)(null),[S,C]=(0,W.useState)(null),[k,j]=(0,W.useState)(""),N=!!s;(0,W.useEffect)(()=>{e&&(y(!1),w(null),C(null),j(""),s&&(o(s.name),l(s.executor_type??"command"),d(s.prompt_provider??"claude"),u(s.command),p(s.cwd??""),g(s.pty)))},[e]);let E=async e=>{if(e.preventDefault(),n.trim()&&h.trim()){x(!0);try{await i({name:n.trim(),command:h.trim(),executor_type:a,prompt_provider:"prompt"===a?c:null,cwd:f.trim()||void 0,pty:"prompt"===a||m}),r(!1),N||(o(""),l("command"),d("claude"),u(""),p(""),g(!0))}finally{x(!1)}}};return(0,F.jsx)(t8,{open:e,onOpenChange:r,children:(0,F.jsxs)(re,{children:[(0,F.jsx)(rt,{children:(0,F.jsxs)("div",{className:"flex items-center justify-between pr-6",children:[(0,F.jsx)(rs,{children:_?"Select Preset":N?"Edit Executor":"Add Executor"}),!N&&!_&&(0,F.jsx)("button",{type:"button",className:"text-sm text-muted-foreground hover:text-foreground transition-colors",onClick:()=>y(!0),children:"Select from presets"})]})}),(0,F.jsxs)("div",{className:"h-[420px] flex flex-col",children:[!_&&(0,F.jsxs)("form",{onSubmit:E,className:"space-y-4 flex-1 flex flex-col",children:[(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Name"}),(0,F.jsx)(rn,{placeholder:"e.g., Dev Server",value:n,onChange:e=>o(e.target.value),required:!0})]}),(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Type"}),(0,F.jsxs)("div",{className:"flex rounded-md border border-input overflow-hidden",children:[(0,F.jsx)("button",{type:"button",className:(0,ey.cn)("flex-1 px-3 py-1.5 text-sm font-medium transition-colors","command"===a?"bg-primary text-primary-foreground":"bg-background text-muted-foreground hover:bg-muted"),onClick:()=>l("command"),children:"Command"}),(0,F.jsx)("button",{type:"button",className:(0,ey.cn)("flex-1 px-3 py-1.5 text-sm font-medium transition-colors border-l border-input","prompt"===a?"bg-primary text-primary-foreground":"bg-background text-muted-foreground hover:bg-muted"),onClick:()=>l("prompt"),children:"Prompt"})]})]}),"prompt"===a&&(0,F.jsxs)("div",{className:"flex gap-3",children:[(0,F.jsxs)("div",{className:"w-[140px] shrink-0 space-y-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Provider"}),(0,F.jsxs)(a4,{value:c,onValueChange:e=>d(e),children:[(0,F.jsx)(a8,{className:"w-full",children:(0,F.jsx)(a6,{})}),(0,F.jsxs)(a7,{children:[(0,F.jsx)(a9,{value:"claude",children:"Claude"}),(0,F.jsx)(a9,{value:"codex",children:"Codex"})]})]})]}),(0,F.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,F.jsxs)("label",{className:"text-sm font-medium",children:["Working Directory"," ",(0,F.jsx)("span",{className:"text-muted-foreground",children:"(optional)"})]}),(0,F.jsx)(rn,{placeholder:"Relative to worktree root",value:f,onChange:e=>p(e.target.value)})]})]}),(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"prompt"===a?"Prompt":"Command"}),"prompt"===a?(0,F.jsx)("textarea",{className:"flex min-h-[90px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 resize-y",placeholder:"e.g., Review the code and suggest improvements",value:h,onChange:e=>u(e.target.value),required:!0}):(0,F.jsx)(rn,{placeholder:"e.g., npm run dev",value:h,onChange:e=>u(e.target.value),required:!0})]}),"command"===a&&(0,F.jsxs)("div",{className:"space-y-2",children:[(0,F.jsxs)("label",{className:"text-sm font-medium",children:["Working Directory"," ",(0,F.jsx)("span",{className:"text-muted-foreground",children:"(optional)"})]}),(0,F.jsx)(rn,{placeholder:"Relative to worktree root (leave empty for root)",value:f,onChange:e=>p(e.target.value)})]}),"command"===a&&(0,F.jsxs)("div",{className:"flex items-center justify-between",children:[(0,F.jsxs)("div",{className:"space-y-0.5",children:[(0,F.jsx)("label",{className:"text-sm font-medium",children:"Terminal Mode (PTY)"}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground",children:"Enable for interactive commands like top, vim, htop"})]}),(0,F.jsx)("button",{type:"button",role:"switch","aria-checked":m,onClick:()=>g(!m),className:(0,ey.cn)("relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",m?"bg-primary":"bg-input"),children:(0,F.jsx)("span",{className:(0,ey.cn)("pointer-events-none inline-block h-5 w-5 transform rounded-full bg-background shadow-lg ring-0 transition-transform",m?"translate-x-5":"translate-x-0")})})]}),(0,F.jsx)("div",{className:"flex-1"}),(0,F.jsxs)(rr,{children:[(0,F.jsx)($.Button,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),(0,F.jsx)($.Button,{type:"submit",disabled:v||!n.trim()||!h.trim(),children:v?"Saving...":N?"Save":"Add"})]})]}),_&&(0,F.jsxs)("div",{className:"space-y-4 flex-1 flex flex-col min-h-0",children:[(0,F.jsx)(rn,{placeholder:"Search presets...",value:k,onChange:e=>j(e.target.value),autoFocus:!0}),(0,F.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0 space-y-1",children:pS.filter(e=>{if(!k.trim())return!0;let r=k.toLowerCase();return e.name.toLowerCase().includes(r)||e.command.toLowerCase().includes(r)||(e.description?.toLowerCase().includes(r)??!1)}).map(e=>{let r=b?.command===e.command,s=S===e.command;return(0,F.jsxs)("div",{className:"rounded-md overflow-hidden",children:[(0,F.jsxs)("button",{type:"button",className:(0,ey.cn)("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors",r?"bg-primary/10 text-primary":"hover:bg-muted"),onClick:()=>w(e),children:["command"===e.executor_type?(0,F.jsx)(n5.Terminal,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):(0,F.jsx)(pw,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,F.jsx)("span",{className:"font-medium flex-1 text-left",children:e.name}),(0,F.jsx)("button",{type:"button",className:"shrink-0 p-0.5 rounded hover:bg-muted-foreground/10 transition-colors",onClick:r=>{r.stopPropagation(),C(s?null:e.command)},children:s?(0,F.jsx)(r7,{className:"h-4 w-4 text-muted-foreground"}):(0,F.jsx)(nq,{className:"h-4 w-4 text-muted-foreground"})})]}),s&&(0,F.jsxs)("div",{className:(0,ey.cn)("px-3 pb-2 pt-1 text-xs text-muted-foreground space-y-1 border-t border-border/50",r?"bg-primary/5":"bg-muted/50"),children:[e.description&&(0,F.jsx)("p",{children:e.description}),(0,F.jsx)("pre",{className:"whitespace-pre-wrap break-all bg-muted/50 rounded px-2 py-1 font-mono",children:e.command}),(0,F.jsxs)("div",{className:"flex gap-3",children:[(0,F.jsxs)("span",{children:["Type: ",(0,F.jsx)("span",{className:"font-medium text-foreground/70",children:e.executor_type})]}),(0,F.jsxs)("span",{children:["PTY: ",(0,F.jsx)("span",{className:"font-medium text-foreground/70",children:e.pty?"on":"off"})]})]})]})]},e.command)})}),(0,F.jsxs)(rr,{children:[(0,F.jsx)($.Button,{type:"button",variant:"outline",onClick:()=>{y(!1),w(null),C(null)},children:"Cancel"}),(0,F.jsx)($.Button,{type:"button",disabled:!b,onClick:()=>{b&&(o(b.name),u(b.command),l(b.executor_type),g(b.pty),y(!1),w(null),C(null))},children:"Select"})]})]})]})]})})}function pk(e,r){let[s,i]=(0,W.useState)([]),[n,o]=(0,W.useState)("closed"),[a,l]=(0,W.useState)(null),[c,d]=(0,W.useState)(!1),[h,u]=(0,W.useState)(!0),f=(0,W.useRef)(null),p=(0,W.useRef)(null),m=(0,W.useRef)(0),g=(0,W.useRef)(null),v=(0,W.useRef)(!1),x=(0,W.useCallback)(()=>{i([]),l(null),d(!1)},[]),_=(0,W.useCallback)(e=>{f.current?.readyState===WebSocket.OPEN&&f.current.send(JSON.stringify({type:"input",data:e}))},[]),y=(0,W.useCallback)((e,r)=>{f.current?.readyState===WebSocket.OPEN?f.current.send(JSON.stringify({type:"resize",cols:e,rows:r})):p.current={cols:e,rows:r}},[]);return(0,W.useEffect)(()=>{if(!e)return;i([]),l(null),d(!1),v.current=!1,m.current=0;let r=!1;return!function s(){if(r||v.current)return;o("connecting");let n=(0,rg.getWebSocketUrl)(`/api/executor-processes/${e}/logs`);console.log(`[useExecutorLogs] Connecting to WebSocket: ${n}`);let a=new WebSocket(n);f.current=a,a.onopen=()=>{if(!r&&(console.log("[useExecutorLogs] WebSocket connected"),o("connected"),i([]),m.current=0,p.current)){let{cols:e,rows:r}=p.current;a.send(JSON.stringify({type:"resize",cols:e,rows:r})),p.current=null}},a.onmessage=e=>{if(!r)try{let r=JSON.parse(e.data);"init"===r.type?(d(r.isPty),u(!0),console.log("[useExecutorLogs] init received, setReplayingHistory(true)")):"history_end"===r.type?(u(!1),console.log("[useExecutorLogs] history_end received, setReplayingHistory(false)")):"finished"===r.type?(v.current=!0,l(r.exitCode),o("closed")):"error"===r.type?o("error"):i(e=>[...e,r])}catch(e){console.error("Failed to parse WebSocket message:",e)}},a.onerror=e=>{r||console.error("[useExecutorLogs] WebSocket error:",e)},a.onclose=i=>{if(console.log("[useExecutorLogs] WebSocket closed:",i.code,i.reason),f.current=null,v.current||r||!e?.startsWith("remote-"))return void o("closed");if(m.current<8){let e=m.current,i=Math.min(15e3,1e3*Math.pow(2,e)),n=i*Math.random()*.25,a=i+n;console.log(`[useExecutorLogs] Scheduling reconnect in ${Math.round(a)}ms (attempt ${e+1}/8)`),o("connecting"),m.current=e+1,g.current=setTimeout(()=>{g.current=null,r||s()},a)}else console.log("[useExecutorLogs] Max reconnect attempts reached"),o("error")}}(),()=>{r=!0,g.current&&(clearTimeout(g.current),g.current=null),f.current&&(f.current.close(),f.current=null)}},[e,r]),{logs:s,status:n,exitCode:a,isPty:c,replayingHistory:h,clearLogs:x,sendInput:_,sendResize:y}}let pj="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement;function pN(e){let r=Object.prototype.toString.call(e);return"[object Window]"===r||"[object global]"===r}function pE(e){return"nodeType"in e}function pR(e){var r,s;return e?pN(e)?e:pE(e)&&null!=(r=null==(s=e.ownerDocument)?void 0:s.defaultView)?r:window:window}function pM(e){let{Document:r}=pR(e);return e instanceof r}function pD(e){return!pN(e)&&e instanceof pR(e).HTMLElement}function pT(e){return e instanceof pR(e).SVGElement}function pP(e){return e?pN(e)?e.document:pE(e)?pM(e)?e:pD(e)||pT(e)?e.ownerDocument:document:document:document}let pL=pj?W.useLayoutEffect:W.useEffect;function pA(e){let r=(0,W.useRef)(e);return pL(()=>{r.current=e}),(0,W.useCallback)(function(){for(var e=arguments.length,s=Array(e),i=0;i<e;i++)s[i]=arguments[i];return null==r.current?void 0:r.current(...s)},[])}function pB(e,r){void 0===r&&(r=[e]);let s=(0,W.useRef)(e);return pL(()=>{s.current!==e&&(s.current=e)},r),s}function pI(e,r){let s=(0,W.useRef)();return(0,W.useMemo)(()=>{let r=e(s.current);return s.current=r,r},[...r])}function pO(e){let r=pA(e),s=(0,W.useRef)(null),i=(0,W.useCallback)(e=>{e!==s.current&&(null==r||r(e,s.current)),s.current=e},[]);return[s,i]}function pz(e){let r=(0,W.useRef)();return(0,W.useEffect)(()=>{r.current=e},[e]),r.current}let pF={};function pW(e,r){return(0,W.useMemo)(()=>{if(r)return r;let s=null==pF[e]?0:pF[e]+1;return pF[e]=s,e+"-"+s},[e,r])}function p$(e){return function(r){for(var s=arguments.length,i=Array(s>1?s-1:0),n=1;n<s;n++)i[n-1]=arguments[n];return i.reduce((r,s)=>{for(let[i,n]of Object.entries(s)){let s=r[i];null!=s&&(r[i]=s+e*n)}return r},{...r})}}let pH=p$(1),pU=p$(-1);function pK(e){if(!e)return!1;let{KeyboardEvent:r}=pR(e.target);return r&&e instanceof r}function pq(e){if(function(e){if(!e)return!1;let{TouchEvent:r}=pR(e.target);return r&&e instanceof r}(e)){if(e.touches&&e.touches.length){let{clientX:r,clientY:s}=e.touches[0];return{x:r,y:s}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:r,clientY:s}=e.changedTouches[0];return{x:r,y:s}}}return"clientX"in e&&"clientY"in e?{x:e.clientX,y:e.clientY}:null}let pV=Object.freeze({Translate:{toString(e){if(!e)return;let{x:r,y:s}=e;return"translate3d("+(r?Math.round(r):0)+"px, "+(s?Math.round(s):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;let{scaleX:r,scaleY:s}=e;return"scaleX("+r+") scaleY("+s+")"}},Transform:{toString(e){if(e)return[pV.Translate.toString(e),pV.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:r,duration:s,easing:i}=e;return r+" "+s+"ms "+i}}}),pY="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]",pX={display:"none"};function pG(e){let{id:r,value:s}=e;return W.default.createElement("div",{id:r,style:pX},s)}function pJ(e){let{id:r,announcement:s,ariaLiveType:i="assertive"}=e;return W.default.createElement("div",{id:r,style:{position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"},role:"status","aria-live":i,"aria-atomic":!0},s)}let pZ=(0,W.createContext)(null),pQ={draggable:"\n To pick up a draggable item, press the space bar.\n While dragging, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n "},p0={onDragStart(e){let{active:r}=e;return"Picked up draggable item "+r.id+"."},onDragOver(e){let{active:r,over:s}=e;return s?"Draggable item "+r.id+" was moved over droppable area "+s.id+".":"Draggable item "+r.id+" is no longer over a droppable area."},onDragEnd(e){let{active:r,over:s}=e;return s?"Draggable item "+r.id+" was dropped over droppable area "+s.id:"Draggable item "+r.id+" was dropped."},onDragCancel(e){let{active:r}=e;return"Dragging was cancelled. Draggable item "+r.id+" was dropped."}};function p1(e){var r;let s,{announcements:i=p0,container:n,hiddenTextDescribedById:o,screenReaderInstructions:a=pQ}=e,{announce:l,announcement:c}=function(){let[e,r]=(0,W.useState)("");return{announce:(0,W.useCallback)(e=>{null!=e&&r(e)},[]),announcement:e}}(),d=pW("DndLiveRegion"),[h,u]=(0,W.useState)(!1);if((0,W.useEffect)(()=>{u(!0)},[]),r=(0,W.useMemo)(()=>({onDragStart(e){let{active:r}=e;l(i.onDragStart({active:r}))},onDragMove(e){let{active:r,over:s}=e;i.onDragMove&&l(i.onDragMove({active:r,over:s}))},onDragOver(e){let{active:r,over:s}=e;l(i.onDragOver({active:r,over:s}))},onDragEnd(e){let{active:r,over:s}=e;l(i.onDragEnd({active:r,over:s}))},onDragCancel(e){let{active:r,over:s}=e;l(i.onDragCancel({active:r,over:s}))}}),[l,i]),s=(0,W.useContext)(pZ),(0,W.useEffect)(()=>{if(!s)throw Error("useDndMonitor must be used within a children of <DndContext>");return s(r)},[r,s]),!h)return null;let f=W.default.createElement(W.default.Fragment,null,W.default.createElement(pG,{id:o,value:a.draggable}),W.default.createElement(pJ,{id:d,announcement:c}));return n?(0,ee.createPortal)(f,n):f}function p2(){}function p5(e,r){return(0,W.useMemo)(()=>({sensor:e,options:null!=r?r:{}}),[e,r])}(_=E||(E={})).DragStart="dragStart",_.DragMove="dragMove",_.DragEnd="dragEnd",_.DragCancel="dragCancel",_.DragOver="dragOver",_.RegisterDroppable="registerDroppable",_.SetDroppableDisabled="setDroppableDisabled",_.UnregisterDroppable="unregisterDroppable";let p3=Object.freeze({x:0,y:0});function p4(e,r){return Math.sqrt(Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2))}function p6(e,r){let{data:{value:s}}=e,{data:{value:i}}=r;return s-i}function p8(e,r){let{data:{value:s}}=e,{data:{value:i}}=r;return i-s}function p7(e){let{left:r,top:s,height:i,width:n}=e;return[{x:r,y:s},{x:r+n,y:s},{x:r,y:s+i},{x:r+n,y:s+i}]}function p9(e,r){if(!e||0===e.length)return null;let[s]=e;return r?s[r]:s}function me(e,r,s){return void 0===r&&(r=e.left),void 0===s&&(s=e.top),{x:r+.5*e.width,y:s+.5*e.height}}let mt=e=>{let{collisionRect:r,droppableRects:s,droppableContainers:i}=e,n=[];for(let e of i){let{id:i}=e,o=s.get(i);if(o){let s=function(e,r){let s=Math.max(r.top,e.top),i=Math.max(r.left,e.left),n=Math.min(r.left+r.width,e.left+e.width),o=Math.min(r.top+r.height,e.top+e.height);if(i<n&&s<o){let a=r.width*r.height,l=e.width*e.height,c=(n-i)*(o-s);return Number((c/(a+l-c)).toFixed(4))}return 0}(o,r);s>0&&n.push({id:i,data:{droppableContainer:e,value:s}})}}return n.sort(p8)};function mr(e,r){return e&&r?{x:e.left-r.left,y:e.top-r.top}:p3}let ms=function(e){for(var r=arguments.length,s=Array(r>1?r-1:0),i=1;i<r;i++)s[i-1]=arguments[i];return s.reduce((e,r)=>({...e,top:e.top+ +r.y,bottom:e.bottom+ +r.y,left:e.left+ +r.x,right:e.right+ +r.x}),{...e})},mi={ignoreTransform:!1};function mn(e,r){void 0===r&&(r=mi);let s=e.getBoundingClientRect();if(r.ignoreTransform){let{transform:r,transformOrigin:i}=pR(e).getComputedStyle(e);r&&(s=function(e,r,s){let i=function(e){if(e.startsWith("matrix3d(")){let r=e.slice(9,-1).split(/, /);return{x:+r[12],y:+r[13],scaleX:+r[0],scaleY:+r[5]}}if(e.startsWith("matrix(")){let r=e.slice(7,-1).split(/, /);return{x:+r[4],y:+r[5],scaleX:+r[0],scaleY:+r[3]}}return null}(r);if(!i)return e;let{scaleX:n,scaleY:o,x:a,y:l}=i,c=e.left-a-(1-n)*parseFloat(s),d=e.top-l-(1-o)*parseFloat(s.slice(s.indexOf(" ")+1)),h=n?e.width/n:e.width,u=o?e.height/o:e.height;return{width:h,height:u,top:d,right:c+h,bottom:d+u,left:c}}(s,r,i))}let{top:i,left:n,width:o,height:a,bottom:l,right:c}=s;return{top:i,left:n,width:o,height:a,bottom:l,right:c}}function mo(e){return mn(e,{ignoreTransform:!0})}function ma(e,r){let s=[];return e?function i(n){var o,a;let l;if(null!=r&&s.length>=r||!n)return s;if(pM(n)&&null!=n.scrollingElement&&!s.includes(n.scrollingElement))return s.push(n.scrollingElement),s;if(!pD(n)||pT(n)||s.includes(n))return s;let c=pR(e).getComputedStyle(n);return(n!==e&&(void 0===(o=c)&&(o=pR(n).getComputedStyle(n)),l=/(auto|scroll|overlay)/,["overflow","overflowX","overflowY"].some(e=>{let r=o[e];return"string"==typeof r&&l.test(r)}))&&s.push(n),void 0===(a=c)&&(a=pR(n).getComputedStyle(n)),"fixed"===a.position)?s:i(n.parentNode)}(e):s}function ml(e){let[r]=ma(e,1);return null!=r?r:null}function mc(e){return pj&&e?pN(e)?e:pE(e)?pM(e)||e===pP(e).scrollingElement?window:pD(e)?e:null:null:null}function md(e){return pN(e)?e.scrollX:e.scrollLeft}function mh(e){return pN(e)?e.scrollY:e.scrollTop}function mu(e){return{x:md(e),y:mh(e)}}function mf(e){return!!pj&&!!e&&e===document.scrollingElement}function mp(e){let r={x:0,y:0},s=mf(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},i={x:e.scrollWidth-s.width,y:e.scrollHeight-s.height},n=e.scrollTop<=r.y,o=e.scrollLeft<=r.x;return{isTop:n,isLeft:o,isBottom:e.scrollTop>=i.y,isRight:e.scrollLeft>=i.x,maxScroll:i,minScroll:r}}(y=R||(R={}))[y.Forward=1]="Forward",y[y.Backward=-1]="Backward";let mm={x:.2,y:.2};function mg(e){return e.reduce((e,r)=>pH(e,mu(r)),p3)}let mv=[["x",["left","right"],function(e){return e.reduce((e,r)=>e+md(r),0)}],["y",["top","bottom"],function(e){return e.reduce((e,r)=>e+mh(r),0)}]];class mx{constructor(e,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const s=ma(r),i=mg(s);for(const[r,n,o]of(this.rect={...e},this.width=e.width,this.height=e.height,mv))for(const e of n)Object.defineProperty(this,e,{get:()=>{let n=o(s),a=i[r]-n;return this.rect[e]+a},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class m_{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>{var r;return null==(r=this.target)?void 0:r.removeEventListener(...e)})},this.target=e}add(e,r,s){var i;null==(i=this.target)||i.addEventListener(e,r,s),this.listeners.push([e,r,s])}}function my(e,r){let s=Math.abs(e.x),i=Math.abs(e.y);return"number"==typeof r?Math.sqrt(s**2+i**2)>r:"x"in r&&"y"in r?s>r.x&&i>r.y:"x"in r?s>r.x:"y"in r&&i>r.y}function mb(e){e.preventDefault()}function mw(e){e.stopPropagation()}(b=M||(M={})).Click="click",b.DragStart="dragstart",b.Keydown="keydown",b.ContextMenu="contextmenu",b.Resize="resize",b.SelectionChange="selectionchange",b.VisibilityChange="visibilitychange",(w=D||(D={})).Space="Space",w.Down="ArrowDown",w.Right="ArrowRight",w.Left="ArrowLeft",w.Up="ArrowUp",w.Esc="Escape",w.Enter="Enter",w.Tab="Tab";let mS={start:[D.Space,D.Enter],cancel:[D.Esc],end:[D.Space,D.Enter,D.Tab]},mC=(e,r)=>{let{currentCoordinates:s}=r;switch(e.code){case D.Right:return{...s,x:s.x+25};case D.Left:return{...s,x:s.x-25};case D.Down:return{...s,y:s.y+25};case D.Up:return{...s,y:s.y-25}}};class mk{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:r}}=e;this.props=e,this.listeners=new m_(pP(r)),this.windowListeners=new m_(pR(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(M.Resize,this.handleCancel),this.windowListeners.add(M.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(M.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:r}=this.props,s=e.node.current;s&&function(e,r){if(void 0===r&&(r=mn),!e)return;let{top:s,left:i,bottom:n,right:o}=r(e);ml(e)&&(n<=0||o<=0||s>=window.innerHeight||i>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}(s),r(p3)}handleKeyDown(e){if(pK(e)){let{active:r,context:s,options:i}=this.props,{keyboardCodes:n=mS,coordinateGetter:o=mC,scrollBehavior:a="smooth"}=i,{code:l}=e;if(n.end.includes(l))return void this.handleEnd(e);if(n.cancel.includes(l))return void this.handleCancel(e);let{collisionRect:c}=s.current,d=c?{x:c.left,y:c.top}:p3;this.referenceCoordinates||(this.referenceCoordinates=d);let h=o(e,{active:r,context:s.current,currentCoordinates:d});if(h){let r=pU(h,d),i={x:0,y:0},{scrollableAncestors:n}=s.current;for(let s of n){let n=e.code,{isTop:o,isRight:l,isLeft:c,isBottom:d,maxScroll:u,minScroll:f}=mp(s),p=function(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:r}=window;return{top:0,left:0,right:e,bottom:r,width:e,height:r}}let{top:r,left:s,right:i,bottom:n}=e.getBoundingClientRect();return{top:r,left:s,right:i,bottom:n,width:e.clientWidth,height:e.clientHeight}}(s),m={x:Math.min(n===D.Right?p.right-p.width/2:p.right,Math.max(n===D.Right?p.left:p.left+p.width/2,h.x)),y:Math.min(n===D.Down?p.bottom-p.height/2:p.bottom,Math.max(n===D.Down?p.top:p.top+p.height/2,h.y))},g=n===D.Right&&!l||n===D.Left&&!c,v=n===D.Down&&!d||n===D.Up&&!o;if(g&&m.x!==h.x){let e=s.scrollLeft+r.x,o=n===D.Right&&e<=u.x||n===D.Left&&e>=f.x;if(o&&!r.y)return void s.scrollTo({left:e,behavior:a});o?i.x=s.scrollLeft-e:i.x=n===D.Right?s.scrollLeft-u.x:s.scrollLeft-f.x,i.x&&s.scrollBy({left:-i.x,behavior:a});break}if(v&&m.y!==h.y){let e=s.scrollTop+r.y,o=n===D.Down&&e<=u.y||n===D.Up&&e>=f.y;if(o&&!r.x)return void s.scrollTo({top:e,behavior:a});o?i.y=s.scrollTop-e:i.y=n===D.Down?s.scrollTop-u.y:s.scrollTop-f.y,i.y&&s.scrollBy({top:-i.y,behavior:a});break}}this.handleMove(e,pH(pU(h,this.referenceCoordinates),i))}}}handleMove(e,r){let{onMove:s}=this.props;e.preventDefault(),s(r)}handleEnd(e){let{onEnd:r}=this.props;e.preventDefault(),this.detach(),r()}handleCancel(e){let{onCancel:r}=this.props;e.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}function mj(e){return!!(e&&"distance"in e)}function mN(e){return!!(e&&"delay"in e)}mk.activators=[{eventName:"onKeyDown",handler:(e,r,s)=>{let{keyboardCodes:i=mS,onActivation:n}=r,{active:o}=s,{code:a}=e.nativeEvent;if(i.start.includes(a)){let r=o.activatorNode.current;return(!r||e.target===r)&&(e.preventDefault(),null==n||n({event:e.nativeEvent}),!0)}return!1}}];class mE{constructor(e,r,s){var i;void 0===s&&(s=function(e){let{EventTarget:r}=pR(e);return e instanceof r?e:pP(e)}(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=r;const{event:n}=e,{target:o}=n;this.props=e,this.events=r,this.document=pP(o),this.documentListeners=new m_(this.document),this.listeners=new m_(s),this.windowListeners=new m_(pR(o)),this.initialCoordinates=null!=(i=pq(n))?i:p3,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:r,bypassActivationConstraint:s}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(M.Resize,this.handleCancel),this.windowListeners.add(M.DragStart,mb),this.windowListeners.add(M.VisibilityChange,this.handleCancel),this.windowListeners.add(M.ContextMenu,mb),this.documentListeners.add(M.Keydown,this.handleKeydown),r){if(null!=s&&s({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(mN(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(mj(r))return void this.handlePending(r)}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),null!==this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,r){let{active:s,onPending:i}=this.props;i(s,e,this.initialCoordinates,r)}handleStart(){let{initialCoordinates:e}=this,{onStart:r}=this.props;e&&(this.activated=!0,this.documentListeners.add(M.Click,mw,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(M.SelectionChange,this.removeTextSelection),r(e))}handleMove(e){var r;let{activated:s,initialCoordinates:i,props:n}=this,{onMove:o,options:{activationConstraint:a}}=n;if(!i)return;let l=null!=(r=pq(e))?r:p3,c=pU(i,l);if(!s&&a){if(mj(a)){if(null!=a.tolerance&&my(c,a.tolerance))return this.handleCancel();if(my(c,a.distance))return this.handleStart()}return mN(a)&&my(c,a.tolerance)?this.handleCancel():void this.handlePending(a,c)}e.cancelable&&e.preventDefault(),o(l)}handleEnd(){let{onAbort:e,onEnd:r}=this.props;this.detach(),this.activated||e(this.props.active),r()}handleCancel(){let{onAbort:e,onCancel:r}=this.props;this.detach(),this.activated||e(this.props.active),r()}handleKeydown(e){e.code===D.Esc&&this.handleCancel()}removeTextSelection(){var e;null==(e=this.document.getSelection())||e.removeAllRanges()}}let mR={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class mM extends mE{constructor(e){const{event:r}=e;super(e,mR,pP(r.target))}}mM.activators=[{eventName:"onPointerDown",handler:(e,r)=>{let{nativeEvent:s}=e,{onActivation:i}=r;return!!s.isPrimary&&0===s.button&&(null==i||i({event:s}),!0)}}];(S=T||(T={}))[S.RightClick=2]="RightClick";(C=P||(P={}))[C.Pointer=0]="Pointer",C[C.DraggableRect=1]="DraggableRect",(k=L||(L={}))[k.TreeOrder=0]="TreeOrder",k[k.ReversedTreeOrder=1]="ReversedTreeOrder";let mD={x:{[R.Backward]:!1,[R.Forward]:!1},y:{[R.Backward]:!1,[R.Forward]:!1}};(j=A||(A={}))[j.Always=0]="Always",j[j.BeforeDragging=1]="BeforeDragging",j[j.WhileDragging=2]="WhileDragging",(B||(B={})).Optimized="optimized";let mT=new Map;function mP(e,r){return pI(s=>e?s||("function"==typeof r?r(e):e):null,[r,e])}function mL(e){let{callback:r,disabled:s}=e,i=pA(r),n=(0,W.useMemo)(()=>{if(s||"undefined"==typeof window||void 0===window.ResizeObserver)return;let{ResizeObserver:e}=window;return new e(i)},[s]);return(0,W.useEffect)(()=>()=>null==n?void 0:n.disconnect(),[n]),n}function mA(e){return new mx(mn(e),e)}function mB(e,r,s){void 0===r&&(r=mA);let[i,n]=(0,W.useState)(null);function o(){n(i=>{if(!e)return null;if(!1===e.isConnected){var n;return null!=(n=null!=i?i:s)?n:null}let o=r(e);return JSON.stringify(i)===JSON.stringify(o)?i:o})}let a=function(e){let{callback:r,disabled:s}=e,i=pA(r),n=(0,W.useMemo)(()=>{if(s||"undefined"==typeof window||void 0===window.MutationObserver)return;let{MutationObserver:e}=window;return new e(i)},[i,s]);return(0,W.useEffect)(()=>()=>null==n?void 0:n.disconnect(),[n]),n}({callback(r){if(e)for(let s of r){let{type:r,target:i}=s;if("childList"===r&&i instanceof HTMLElement&&i.contains(e)){o();break}}}}),l=mL({callback:o});return pL(()=>{o(),e?(null==l||l.observe(e),null==a||a.observe(document.body,{childList:!0,subtree:!0})):(null==l||l.disconnect(),null==a||a.disconnect())},[e]),i}let mI=[];function mO(e,r){void 0===r&&(r=[]);let s=(0,W.useRef)(null);return(0,W.useEffect)(()=>{s.current=null},r),(0,W.useEffect)(()=>{let r=e!==p3;r&&!s.current&&(s.current=e),!r&&s.current&&(s.current=null)},[e]),s.current?pU(e,s.current):p3}function mz(e){return(0,W.useMemo)(()=>{let r,s;return e?(r=e.innerWidth,{top:0,left:0,right:r,bottom:s=e.innerHeight,width:r,height:s}):null},[e])}let mF=[],mW=[{sensor:mM,options:{}},{sensor:mk,options:{}}],m$={current:{}},mH={draggable:{measure:mo},droppable:{measure:mo,strategy:A.WhileDragging,frequency:B.Optimized},dragOverlay:{measure:mn}};class mU extends Map{get(e){var r;return null!=e&&null!=(r=super.get(e))?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:r}=e;return!r})}getNodeFor(e){var r,s;return null!=(r=null==(s=this.get(e))?void 0:s.node.current)?r:void 0}}let mK={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new mU,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:p2},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:mH,measureDroppableContainers:p2,windowRect:null,measuringScheduled:!1},mq={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:p2,draggableNodes:new Map,over:null,measureDroppableContainers:p2},mV=(0,W.createContext)(mq),mY=(0,W.createContext)(mK);function mX(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new mU}}}function mG(e,r){switch(r.type){case E.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:r.initialCoordinates,active:r.active}};case E.DragMove:if(null==e.draggable.active)return e;return{...e,draggable:{...e.draggable,translate:{x:r.coordinates.x-e.draggable.initialCoordinates.x,y:r.coordinates.y-e.draggable.initialCoordinates.y}}};case E.DragEnd:case E.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case E.RegisterDroppable:{let{element:s}=r,{id:i}=s,n=new mU(e.droppable.containers);return n.set(i,s),{...e,droppable:{...e.droppable,containers:n}}}case E.SetDroppableDisabled:{let{id:s,key:i,disabled:n}=r,o=e.droppable.containers.get(s);if(!o||i!==o.key)return e;let a=new mU(e.droppable.containers);return a.set(s,{...o,disabled:n}),{...e,droppable:{...e.droppable,containers:a}}}case E.UnregisterDroppable:{let{id:s,key:i}=r,n=e.droppable.containers.get(s);if(!n||i!==n.key)return e;let o=new mU(e.droppable.containers);return o.delete(s),{...e,droppable:{...e.droppable,containers:o}}}default:return e}}function mJ(e){let{disabled:r}=e,{active:s,activatorEvent:i,draggableNodes:n}=(0,W.useContext)(mV),o=pz(i),a=pz(null==s?void 0:s.id);return(0,W.useEffect)(()=>{if(!r&&!i&&o&&null!=a){if(!pK(o)||document.activeElement===o.target)return;let e=n.get(a);if(!e)return;let{activatorNode:r,node:s}=e;(r.current||s.current)&&requestAnimationFrame(()=>{for(let e of[r.current,s.current]){if(!e)continue;let r=e.matches(pY)?e:e.querySelector(pY);if(r){r.focus();break}}})}},[i,r,n,a,o]),null}let mZ=(0,W.createContext)({...p3,scaleX:1,scaleY:1});(N=I||(I={}))[N.Uninitialized=0]="Uninitialized",N[N.Initializing=1]="Initializing",N[N.Initialized=2]="Initialized";let mQ=(0,W.memo)(function(e){var r,s,i,n,o,a,l,c;let d,h,u,f,p,m,g,v,{id:x,accessibility:_,autoScroll:y=!0,children:b,sensors:w=mW,collisionDetection:S=mt,measuring:C,modifiers:k,...j}=e,[N,M]=(0,W.useReducer)(mG,void 0,mX),[D,T]=function(){let[e]=(0,W.useState)(()=>new Set),r=(0,W.useCallback)(r=>(e.add(r),()=>e.delete(r)),[e]);return[(0,W.useCallback)(r=>{let{type:s,event:i}=r;e.forEach(e=>{var r;return null==(r=e[s])?void 0:r.call(e,i)})},[e]),r]}(),[B,O]=(0,W.useState)(I.Uninitialized),z=B===I.Initialized,{draggable:{active:F,nodes:$,translate:H},droppable:{containers:U}}=N,K=null!=F?$.get(F):null,q=(0,W.useRef)({initial:null,translated:null}),V=(0,W.useMemo)(()=>{var e;return null!=F?{id:F,data:null!=(e=null==K?void 0:K.data)?e:m$,rect:q}:null},[F,K]),Y=(0,W.useRef)(null),[X,G]=(0,W.useState)(null),[J,Z]=(0,W.useState)(null),Q=pB(j,Object.values(j)),et=pW("DndDescribedBy",x),er=(0,W.useMemo)(()=>U.getEnabled(),[U]),es=(0,W.useMemo)(()=>({draggable:{...mH.draggable,...null==C?void 0:C.draggable},droppable:{...mH.droppable,...null==C?void 0:C.droppable},dragOverlay:{...mH.dragOverlay,...null==C?void 0:C.dragOverlay}}),[null==C?void 0:C.draggable,null==C?void 0:C.droppable,null==C?void 0:C.dragOverlay]),{droppableRects:ei,measureDroppableContainers:en,measuringScheduled:eo}=function(e,r){let{dragging:s,dependencies:i,config:n}=r,[o,a]=(0,W.useState)(null),{frequency:l,measure:c,strategy:d}=n,h=(0,W.useRef)(e),u=function(){switch(d){case A.Always:return!1;case A.BeforeDragging:return s;default:return!s}}(),f=pB(u),p=(0,W.useCallback)(function(e){void 0===e&&(e=[]),f.current||a(r=>null===r?e:r.concat(e.filter(e=>!r.includes(e))))},[f]),m=(0,W.useRef)(null),g=pI(r=>{if(u&&!s)return mT;if(!r||r===mT||h.current!==e||null!=o){let r=new Map;for(let s of e){if(!s)continue;if(o&&o.length>0&&!o.includes(s.id)&&s.rect.current){r.set(s.id,s.rect.current);continue}let e=s.node.current,i=e?new mx(c(e),e):null;s.rect.current=i,i&&r.set(s.id,i)}return r}return r},[e,o,s,u,c]);return(0,W.useEffect)(()=>{h.current=e},[e]),(0,W.useEffect)(()=>{u||p()},[s,u]),(0,W.useEffect)(()=>{o&&o.length>0&&a(null)},[JSON.stringify(o)]),(0,W.useEffect)(()=>{u||"number"!=typeof l||null!==m.current||(m.current=setTimeout(()=>{p(),m.current=null},l))},[l,u,p,...i]),{droppableRects:g,measureDroppableContainers:p,measuringScheduled:null!=o}}(er,{dragging:z,dependencies:[H.x,H.y],config:es.droppable}),ea=pI(e=>{var r;return null==F?null:null!=(r=null!=p?p:e)?r:null},[p=(f=null!=F?$.get(F):void 0)?f.node.current:null,F]),el=(0,W.useMemo)(()=>J?pq(J):null,[J]),ec=(d=(null==X?void 0:X.autoScrollEnabled)===!1,h="object"==typeof y?!1===y.enabled:!1===y,u=z&&!d&&!h,"object"==typeof y?{...y,enabled:u}:{enabled:u}),ed=mP(ea,es.draggable.measure);!function(e){let{activeNode:r,measure:s,initialRect:i,config:n=!0}=e,o=(0,W.useRef)(!1),{x:a,y:l}="boolean"==typeof n?{x:n,y:n}:n;pL(()=>{if(!a&&!l||!r){o.current=!1;return}if(o.current||!i)return;let e=null==r?void 0:r.node.current;if(!e||!1===e.isConnected)return;let n=mr(s(e),i);if(a||(n.x=0),l||(n.y=0),o.current=!0,Math.abs(n.x)>0||Math.abs(n.y)>0){let r=ml(e);r&&r.scrollBy({top:n.y,left:n.x})}},[r,a,l,i,s])}({activeNode:null!=F?$.get(F):null,config:ec.layoutShiftCompensation,initialRect:ed,measure:es.draggable.measure});let eh=mB(ea,es.draggable.measure,ed),eu=mB(ea?ea.parentElement:null),ef=(0,W.useRef)({activatorEvent:null,active:null,activeNode:ea,collisionRect:null,collisions:null,droppableRects:ei,draggableNodes:$,draggingNode:null,draggingNodeRect:null,droppableContainers:U,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ep=U.getNodeFor(null==(r=ef.current.over)?void 0:r.id),em=function(e){let{measure:r}=e,[s,i]=(0,W.useState)(null),n=mL({callback:(0,W.useCallback)(e=>{for(let{target:s}of e)if(pD(s)){i(e=>{let i=r(s);return e?{...e,width:i.width,height:i.height}:i});break}},[r])}),[o,a]=pO((0,W.useCallback)(e=>{let s=function(e){if(!e)return null;if(e.children.length>1)return e;let r=e.children[0];return pD(r)?r:e}(e);null==n||n.disconnect(),s&&(null==n||n.observe(s)),i(s?r(s):null)},[r,n]));return(0,W.useMemo)(()=>({nodeRef:o,rect:s,setRef:a}),[s,o,a])}({measure:es.dragOverlay.measure}),eg=null!=(s=em.nodeRef.current)?s:ea,ev=z?null!=(i=em.rect)?i:eh:null,ex=!!(em.nodeRef.current&&em.rect),e_=(m=mP(o=ex?null:eh),mr(o,m)),ey=mz(eg?pR(eg):null),eb=(a=z?null!=ep?ep:ea:null,g=(0,W.useRef)(a),v=pI(e=>a?e&&e!==mI&&a&&g.current&&a.parentNode===g.current.parentNode?e:ma(a):mI,[a]),(0,W.useEffect)(()=>{g.current=a},[a]),v),ew=function(e,r){void 0===r&&(r=mn);let[s]=e,i=mz(s?pR(s):null),[n,o]=(0,W.useState)(mF);function a(){o(()=>e.length?e.map(e=>mf(e)?i:new mx(r(e),e)):mF)}let l=mL({callback:a});return pL(()=>{null==l||l.disconnect(),a(),e.forEach(e=>null==l?void 0:l.observe(e))},[e]),n}(eb),eS=function(e,r){let{transform:s,...i}=r;return null!=e&&e.length?e.reduce((e,r)=>r({transform:e,...i}),s):s}(k,{transform:{x:H.x-e_.x,y:H.y-e_.y,scaleX:1,scaleY:1},activatorEvent:J,active:V,activeNodeRect:eh,containerNodeRect:eu,draggingNodeRect:ev,over:ef.current.over,overlayNodeRect:em.rect,scrollableAncestors:eb,scrollableAncestorRects:ew,windowRect:ey}),eC=el?pH(el,H):null,ek=function(e){let[r,s]=(0,W.useState)(null),i=(0,W.useRef)(e),n=(0,W.useCallback)(e=>{let r=mc(e.target);r&&s(e=>e?(e.set(r,mu(r)),new Map(e)):null)},[]);return(0,W.useEffect)(()=>{let r=i.current;if(e!==r){o(r);let a=e.map(e=>{let r=mc(e);return r?(r.addEventListener("scroll",n,{passive:!0}),[r,mu(r)]):null}).filter(e=>null!=e);s(a.length?new Map(a):null),i.current=e}return()=>{o(e),o(r)};function o(e){e.forEach(e=>{let r=mc(e);null==r||r.removeEventListener("scroll",n)})}},[n,e]),(0,W.useMemo)(()=>e.length?r?Array.from(r.values()).reduce((e,r)=>pH(e,r),p3):mg(e):p3,[e,r])}(eb),ej=mO(ek),eN=mO(ek,[eh]),eE=pH(eS,ej),eR=ev?ms(ev,eS):null,eM=V&&eR?S({active:V,collisionRect:eR,droppableRects:ei,droppableContainers:er,pointerCoordinates:eC}):null,eD=p9(eM,"id"),[eT,eP]=(0,W.useState)(null),eL=(l=ex?eS:pH(eS,eN),c=null!=(n=null==eT?void 0:eT.rect)?n:null,{...l,scaleX:c&&eh?c.width/eh.width:1,scaleY:c&&eh?c.height/eh.height:1}),eA=(0,W.useRef)(null),eB=(0,W.useCallback)((e,r)=>{let{sensor:s,options:i}=r;if(null==Y.current)return;let n=$.get(Y.current);if(!n)return;let o=e.nativeEvent,a=new s({active:Y.current,activeNode:n,event:o,options:i,context:ef,onAbort(e){if(!$.get(e))return;let{onDragAbort:r}=Q.current,s={id:e};null==r||r(s),D({type:"onDragAbort",event:s})},onPending(e,r,s,i){if(!$.get(e))return;let{onDragPending:n}=Q.current,o={id:e,constraint:r,initialCoordinates:s,offset:i};null==n||n(o),D({type:"onDragPending",event:o})},onStart(e){let r=Y.current;if(null==r)return;let s=$.get(r);if(!s)return;let{onDragStart:i}=Q.current,n={activatorEvent:o,active:{id:r,data:s.data,rect:q}};(0,ee.unstable_batchedUpdates)(()=>{null==i||i(n),O(I.Initializing),M({type:E.DragStart,initialCoordinates:e,active:r}),D({type:"onDragStart",event:n}),G(eA.current),Z(o)})},onMove(e){M({type:E.DragMove,coordinates:e})},onEnd:l(E.DragEnd),onCancel:l(E.DragCancel)});function l(e){return async function(){let{active:r,collisions:s,over:i,scrollAdjustedTranslate:n}=ef.current,a=null;if(r&&n){let{cancelDrop:l}=Q.current;a={activatorEvent:o,active:r,collisions:s,delta:n,over:i},e===E.DragEnd&&"function"==typeof l&&await Promise.resolve(l(a))&&(e=E.DragCancel)}Y.current=null,(0,ee.unstable_batchedUpdates)(()=>{M({type:e}),O(I.Uninitialized),eP(null),G(null),Z(null),eA.current=null;let r=e===E.DragEnd?"onDragEnd":"onDragCancel";if(a){let e=Q.current[r];null==e||e(a),D({type:r,event:a})}})}}eA.current=a},[$]),eI=(0,W.useCallback)((e,r)=>(s,i)=>{let n=s.nativeEvent,o=$.get(i);null!==Y.current||!o||n.dndKit||n.defaultPrevented||!0===e(s,r.options,{active:o})&&(n.dndKit={capturedBy:r.sensor},Y.current=i,eB(s,r))},[$,eB]),eO=(0,W.useMemo)(()=>w.reduce((e,r)=>{let{sensor:s}=r;return[...e,...s.activators.map(e=>({eventName:e.eventName,handler:eI(e.handler,r)}))]},[]),[w,eI]);(0,W.useEffect)(()=>{if(!pj)return;let e=w.map(e=>{let{sensor:r}=e;return null==r.setup?void 0:r.setup()});return()=>{for(let r of e)null==r||r()}},w.map(e=>{let{sensor:r}=e;return r})),pL(()=>{eh&&B===I.Initializing&&O(I.Initialized)},[eh,B]),(0,W.useEffect)(()=>{let{onDragMove:e}=Q.current,{active:r,activatorEvent:s,collisions:i,over:n}=ef.current;if(!r||!s)return;let o={active:r,activatorEvent:s,collisions:i,delta:{x:eE.x,y:eE.y},over:n};(0,ee.unstable_batchedUpdates)(()=>{null==e||e(o),D({type:"onDragMove",event:o})})},[eE.x,eE.y]),(0,W.useEffect)(()=>{let{active:e,activatorEvent:r,collisions:s,droppableContainers:i,scrollAdjustedTranslate:n}=ef.current;if(!e||null==Y.current||!r||!n)return;let{onDragOver:o}=Q.current,a=i.get(eD),l=a&&a.rect.current?{id:a.id,rect:a.rect.current,data:a.data,disabled:a.disabled}:null,c={active:e,activatorEvent:r,collisions:s,delta:{x:n.x,y:n.y},over:l};(0,ee.unstable_batchedUpdates)(()=>{eP(l),null==o||o(c),D({type:"onDragOver",event:c})})},[eD]),pL(()=>{ef.current={activatorEvent:J,active:V,activeNode:ea,collisionRect:eR,collisions:eM,droppableRects:ei,draggableNodes:$,draggingNode:eg,draggingNodeRect:ev,droppableContainers:U,over:eT,scrollableAncestors:eb,scrollAdjustedTranslate:eE},q.current={initial:ev,translated:eR}},[V,ea,eM,eR,$,eg,ev,ei,U,eT,eb,eE]),function(e){let r,{acceleration:s,activator:i=P.Pointer,canScroll:n,draggingRect:o,enabled:a,interval:l=5,order:c=L.TreeOrder,pointerCoordinates:d,scrollableAncestors:h,scrollableAncestorRects:u,delta:f,threshold:p}=e,m=function(e){let{delta:r,disabled:s}=e,i=pz(r);return pI(e=>{if(s||!i||!e)return mD;let n={x:Math.sign(r.x-i.x),y:Math.sign(r.y-i.y)};return{x:{[R.Backward]:e.x[R.Backward]||-1===n.x,[R.Forward]:e.x[R.Forward]||1===n.x},y:{[R.Backward]:e.y[R.Backward]||-1===n.y,[R.Forward]:e.y[R.Forward]||1===n.y}}},[s,r,i])}({delta:f,disabled:!a}),[g,v]=(r=(0,W.useRef)(null),[(0,W.useCallback)((e,s)=>{r.current=setInterval(e,s)},[]),(0,W.useCallback)(()=>{null!==r.current&&(clearInterval(r.current),r.current=null)},[])]),x=(0,W.useRef)({x:0,y:0}),_=(0,W.useRef)({x:0,y:0}),y=(0,W.useMemo)(()=>{switch(i){case P.Pointer:return d?{top:d.y,bottom:d.y,left:d.x,right:d.x}:null;case P.DraggableRect:return o}},[i,o,d]),b=(0,W.useRef)(null),w=(0,W.useCallback)(()=>{let e=b.current;if(!e)return;let r=x.current.x*_.current.x,s=x.current.y*_.current.y;e.scrollBy(r,s)},[]),S=(0,W.useMemo)(()=>c===L.TreeOrder?[...h].reverse():h,[c,h]);(0,W.useEffect)(()=>{if(!a||!h.length||!y)return void v();for(let e of S){if((null==n?void 0:n(e))===!1)continue;let r=u[h.indexOf(e)];if(!r)continue;let{direction:i,speed:o}=function(e,r,s,i,n){let{top:o,left:a,right:l,bottom:c}=s;void 0===i&&(i=10),void 0===n&&(n=mm);let{isTop:d,isBottom:h,isLeft:u,isRight:f}=mp(e),p={x:0,y:0},m={x:0,y:0},g={height:r.height*n.y,width:r.width*n.x};return!d&&o<=r.top+g.height?(p.y=R.Backward,m.y=i*Math.abs((r.top+g.height-o)/g.height)):!h&&c>=r.bottom-g.height&&(p.y=R.Forward,m.y=i*Math.abs((r.bottom-g.height-c)/g.height)),!f&&l>=r.right-g.width?(p.x=R.Forward,m.x=i*Math.abs((r.right-g.width-l)/g.width)):!u&&a<=r.left+g.width&&(p.x=R.Backward,m.x=i*Math.abs((r.left+g.width-a)/g.width)),{direction:p,speed:m}}(e,r,y,s,p);for(let e of["x","y"])m[e][i[e]]||(o[e]=0,i[e]=0);if(o.x>0||o.y>0){v(),b.current=e,g(w,l),x.current=o,_.current=i;return}}x.current={x:0,y:0},_.current={x:0,y:0},v()},[s,w,n,v,a,l,JSON.stringify(y),JSON.stringify(m),g,h,S,u,JSON.stringify(p)])}({...ec,delta:H,draggingRect:eR,pointerCoordinates:eC,scrollableAncestors:eb,scrollableAncestorRects:ew});let ez=(0,W.useMemo)(()=>({active:V,activeNode:ea,activeNodeRect:eh,activatorEvent:J,collisions:eM,containerNodeRect:eu,dragOverlay:em,draggableNodes:$,droppableContainers:U,droppableRects:ei,over:eT,measureDroppableContainers:en,scrollableAncestors:eb,scrollableAncestorRects:ew,measuringConfiguration:es,measuringScheduled:eo,windowRect:ey}),[V,ea,eh,J,eM,eu,em,$,U,ei,eT,en,eb,ew,es,eo,ey]),eF=(0,W.useMemo)(()=>({activatorEvent:J,activators:eO,active:V,activeNodeRect:eh,ariaDescribedById:{draggable:et},dispatch:M,draggableNodes:$,over:eT,measureDroppableContainers:en}),[J,eO,V,eh,M,et,$,eT,en]);return W.default.createElement(pZ.Provider,{value:T},W.default.createElement(mV.Provider,{value:eF},W.default.createElement(mY.Provider,{value:ez},W.default.createElement(mZ.Provider,{value:eL},b)),W.default.createElement(mJ,{disabled:(null==_?void 0:_.restoreFocus)===!1})),W.default.createElement(p1,{..._,hiddenTextDescribedById:et}))}),m0=(0,W.createContext)(null),m1="button",m2={timeout:25},m5={position:"fixed",touchAction:"none"},m3=e=>pK(e)?"transform 250ms ease":void 0;function m4(e,r,s){let i=e.slice();return i.splice(s<0?i.length+s:s,0,i.splice(r,1)[0]),i}function m6(e){return null!==e&&e>=0}(e,r)=>{let{as:s,activatorEvent:i,adjustScale:n,children:o,className:a,rect:l,style:c,transform:d,transition:h=m3}=e;if(!l)return null;let u=n?d:{...d,scaleX:1,scaleY:1},f={...m5,width:l.width,height:l.height,top:l.top,left:l.left,transform:pV.Transform.toString(u),transformOrigin:n&&i?function(e,r){let s=pq(e);if(!s)return"0 0";let i={x:(s.x-r.left)/r.width*100,y:(s.y-r.top)/r.height*100};return i.x+"% "+i.y+"%"}(i,l):void 0,transition:"function"==typeof h?h(i):h,...c};return W.default.createElement(s,{className:a,style:f,ref:r},o)},v={styles:{active:{opacity:"0"}}};let m8=e=>{let{rects:r,activeIndex:s,overIndex:i,index:n}=e,o=m4(r,i,s),a=r[n],l=o[n];return l&&a?{x:l.left-a.left,y:l.top-a.top,scaleX:l.width/a.width,scaleY:l.height/a.height}:null},m7={scaleX:1,scaleY:1},m9=e=>{var r,s,i,n;let o,a,l,{activeIndex:c,activeNodeRect:d,index:h,rects:u,overIndex:f}=e,p=null!=(r=u[c])?r:d;if(!p)return null;if(h===c){let e=u[f];return e?{x:0,y:c<f?e.top+e.height-(p.top+p.height):e.top-p.top,...m7}:null}let m=(s=u,i=h,n=c,o=s[i],a=s[i-1],l=s[i+1],o?n<i?a?o.top-(a.top+a.height):l?l.top-(o.top+o.height):0:l?l.top-(o.top+o.height):a?o.top-(a.top+a.height):0:0);return h>c&&h<=f?{x:0,y:-p.height-m,...m7}:h<c&&h>=f?{x:0,y:p.height+m,...m7}:{x:0,y:0,...m7}},ge="Sortable",gt=W.default.createContext({activeIndex:-1,containerId:ge,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:m8,disabled:{draggable:!1,droppable:!1}});function gr(e){let{children:r,id:s,items:i,strategy:n=m8,disabled:o=!1}=e,{active:a,dragOverlay:l,droppableRects:c,over:d,measureDroppableContainers:h}=(0,W.useContext)(mY),u=pW(ge,s),f=null!==l.rect,p=(0,W.useMemo)(()=>i.map(e=>"object"==typeof e&&"id"in e?e.id:e),[i]),m=null!=a,g=a?p.indexOf(a.id):-1,v=d?p.indexOf(d.id):-1,x=(0,W.useRef)(p),_=!function(e,r){if(e===r)return!0;if(e.length!==r.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!==r[s])return!1;return!0}(p,x.current),y=-1!==v&&-1===g||_,b="boolean"==typeof o?{draggable:o,droppable:o}:o;pL(()=>{_&&m&&h(p)},[_,p,m,h]),(0,W.useEffect)(()=>{x.current=p},[p]);let w=(0,W.useMemo)(()=>({activeIndex:g,containerId:u,disabled:b,disableTransforms:y,items:p,overIndex:v,useDragOverlay:f,sortedRects:p.reduce((e,r,s)=>{let i=c.get(r);return i&&(e[s]=i),e},Array(p.length)),strategy:n}),[g,u,b.draggable,b.droppable,y,p,v,c,f,n]);return W.default.createElement(gt.Provider,{value:w},r)}let gs=e=>{let{id:r,items:s,activeIndex:i,overIndex:n}=e;return m4(s,i,n).indexOf(r)},gi=e=>{let{containerId:r,isSorting:s,wasDragging:i,index:n,items:o,newIndex:a,previousItems:l,previousContainerId:c,transition:d}=e;return!!d&&!!i&&(l===o||n!==a)&&(!!s||a!==n&&r===c)},gn={duration:200,easing:"ease"},go="transform",ga=pV.Transition.toString({property:go,duration:0,easing:"linear"}),gl={roleDescription:"sortable"};function gc(e){if(!e)return!1;let r=e.data.current;return!!r&&"sortable"in r&&"object"==typeof r.sortable&&"containerId"in r.sortable&&"items"in r.sortable&&"index"in r.sortable}let gd=[D.Down,D.Right,D.Up,D.Left],gh=(e,r)=>{let{context:{active:s,collisionRect:i,droppableRects:n,droppableContainers:o,over:a,scrollableAncestors:l}}=r;if(gd.includes(e.code)){if(e.preventDefault(),!s||!i)return;let r=[];o.getEnabled().forEach(s=>{if(!s||null!=s&&s.disabled)return;let o=n.get(s.id);if(o)switch(e.code){case D.Down:i.top<o.top&&r.push(s);break;case D.Up:i.top>o.top&&r.push(s);break;case D.Left:i.left>o.left&&r.push(s);break;case D.Right:i.left<o.left&&r.push(s)}});let h=(e=>{let{collisionRect:r,droppableRects:s,droppableContainers:i}=e,n=p7(r),o=[];for(let e of i){let{id:r}=e,i=s.get(r);if(i){let s=p7(i),a=Number((n.reduce((e,r,i)=>e+p4(s[i],r),0)/4).toFixed(4));o.push({id:r,data:{droppableContainer:e,value:a}})}}return o.sort(p6)})({active:s,collisionRect:i,droppableRects:n,droppableContainers:r,pointerCoordinates:null}),u=p9(h,"id");if(u===(null==a?void 0:a.id)&&h.length>1&&(u=h[1].id),null!=u){let e=o.get(s.id),r=o.get(u),a=r?n.get(r.id):null,h=null==r?void 0:r.node.current;if(h&&a&&e&&r){var c,d;let s=ma(h).some((e,r)=>l[r]!==e),n=gu(e,r),o=(c=e,d=r,!!gc(c)&&!!gc(d)&&!!gu(c,d)&&c.data.current.sortable.index<d.data.current.sortable.index),u=s||!n?{x:0,y:0}:{x:o?i.width-a.width:0,y:o?i.height-a.height:0},f={x:a.left,y:a.top};return u.x&&u.y?f:pU(f,u)}}}};function gu(e,r){return!!gc(e)&&!!gc(r)&&e.data.current.sortable.containerId===r.data.current.sortable.containerId}function gf({executor:e,executorMode:r,isOpen:s,onOpenChange:i,onStart:n,onStop:o,onUpdate:a,onDelete:l,onProcessFinished:c}){let[d,h]=(0,W.useState)(!1),[u,f]=(0,W.useState)(e.currentProcessId),p=(0,W.useRef)(!1),m=(0,W.useRef)(e.currentProcessId),{attributes:g,listeners:v,setNodeRef:x,transform:_,transition:y,isDragging:b}=function(e){var r,s,i,n;let{animateLayoutChanges:o=gi,attributes:a,disabled:l,data:c,getNewIndex:d=gs,id:h,strategy:u,resizeObserverConfig:f,transition:p=gn}=e,{items:m,containerId:g,activeIndex:v,disabled:x,disableTransforms:_,sortedRects:y,overIndex:b,useDragOverlay:w,strategy:S}=(0,W.useContext)(gt),C=(r=l,s=x,"boolean"==typeof r?{draggable:r,droppable:!1}:{draggable:null!=(i=null==r?void 0:r.draggable)?i:s.draggable,droppable:null!=(n=null==r?void 0:r.droppable)?n:s.droppable}),k=m.indexOf(h),j=(0,W.useMemo)(()=>({sortable:{containerId:g,index:k,items:m},...c}),[g,c,k,m]),N=(0,W.useMemo)(()=>m.slice(m.indexOf(h)),[m,h]),{rect:R,node:M,isOver:D,setNodeRef:T}=function(e){let{data:r,disabled:s=!1,id:i,resizeObserverConfig:n}=e,o=pW("Droppable"),{active:a,dispatch:l,over:c,measureDroppableContainers:d}=(0,W.useContext)(mV),h=(0,W.useRef)({disabled:s}),u=(0,W.useRef)(!1),f=(0,W.useRef)(null),p=(0,W.useRef)(null),{disabled:m,updateMeasurementsFor:g,timeout:v}={...m2,...n},x=pB(null!=g?g:i),_=mL({callback:(0,W.useCallback)(()=>{if(!u.current){u.current=!0;return}null!=p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{d(Array.isArray(x.current)?x.current:[x.current]),p.current=null},v)},[v]),disabled:m||!a}),[y,b]=pO((0,W.useCallback)((e,r)=>{_&&(r&&(_.unobserve(r),u.current=!1),e&&_.observe(e))},[_])),w=pB(r);return(0,W.useEffect)(()=>{_&&y.current&&(_.disconnect(),u.current=!1,_.observe(y.current))},[y,_]),(0,W.useEffect)(()=>(l({type:E.RegisterDroppable,element:{id:i,key:o,disabled:s,node:y,rect:f,data:w}}),()=>l({type:E.UnregisterDroppable,key:o,id:i})),[i]),(0,W.useEffect)(()=>{s!==h.current.disabled&&(l({type:E.SetDroppableDisabled,id:i,key:o,disabled:s}),h.current.disabled=s)},[i,o,s,l]),{active:a,rect:f,isOver:(null==c?void 0:c.id)===i,node:y,over:c,setNodeRef:b}}({id:h,data:j,disabled:C.droppable,resizeObserverConfig:{updateMeasurementsFor:N,...f}}),{active:P,activatorEvent:L,activeNodeRect:A,attributes:B,setNodeRef:I,listeners:O,isDragging:z,over:F,setActivatorNodeRef:$,transform:H}=function(e){let{id:r,data:s,disabled:i=!1,attributes:n}=e,o=pW("Draggable"),{activators:a,activatorEvent:l,active:c,activeNodeRect:d,ariaDescribedById:h,draggableNodes:u,over:f}=(0,W.useContext)(mV),{role:p=m1,roleDescription:m="draggable",tabIndex:g=0}=null!=n?n:{},v=(null==c?void 0:c.id)===r,x=(0,W.useContext)(v?mZ:m0),[_,y]=pO(),[b,w]=pO(),S=(0,W.useMemo)(()=>a.reduce((e,s)=>{let{eventName:i,handler:n}=s;return e[i]=e=>{n(e,r)},e},{}),[a,r]),C=pB(s);return pL(()=>(u.set(r,{id:r,key:o,node:_,activatorNode:b,data:C}),()=>{let e=u.get(r);e&&e.key===o&&u.delete(r)}),[u,r]),{active:c,activatorEvent:l,activeNodeRect:d,attributes:(0,W.useMemo)(()=>({role:p,tabIndex:g,"aria-disabled":i,"aria-pressed":!!v&&p===m1||void 0,"aria-roledescription":m,"aria-describedby":h.draggable}),[i,p,g,v,m,h.draggable]),isDragging:v,listeners:i?void 0:S,node:_,over:f,setNodeRef:y,setActivatorNodeRef:w,transform:x}}({id:h,data:j,attributes:{...gl,...a},disabled:C.draggable}),U=function(){for(var e=arguments.length,r=Array(e),s=0;s<e;s++)r[s]=arguments[s];return(0,W.useMemo)(()=>e=>{r.forEach(r=>r(e))},r)}(T,I),K=!!P,q=K&&!_&&m6(v)&&m6(b),V=!w&&z,Y=V&&q?H:null,X=q?null!=Y?Y:(null!=u?u:S)({rects:y,activeNodeRect:A,activeIndex:v,overIndex:b,index:k}):null,G=m6(v)&&m6(b)?d({id:h,items:m,activeIndex:v,overIndex:b}):k,J=null==P?void 0:P.id,Z=(0,W.useRef)({activeId:J,items:m,newIndex:G,containerId:g}),Q=m!==Z.current.items,ee=o({active:P,containerId:g,isDragging:z,isSorting:K,id:h,index:k,items:m,newIndex:Z.current.newIndex,previousItems:Z.current.items,previousContainerId:Z.current.containerId,transition:p,wasDragging:null!=Z.current.activeId}),et=function(e){let{disabled:r,index:s,node:i,rect:n}=e,[o,a]=(0,W.useState)(null),l=(0,W.useRef)(s);return pL(()=>{if(!r&&s!==l.current&&i.current){let e=n.current;if(e){let r=mn(i.current,{ignoreTransform:!0}),s={x:e.left-r.left,y:e.top-r.top,scaleX:e.width/r.width,scaleY:e.height/r.height};(s.x||s.y)&&a(s)}}s!==l.current&&(l.current=s)},[r,s,i,n]),(0,W.useEffect)(()=>{o&&a(null)},[o]),o}({disabled:!ee,index:k,node:M,rect:R});return(0,W.useEffect)(()=>{K&&Z.current.newIndex!==G&&(Z.current.newIndex=G),g!==Z.current.containerId&&(Z.current.containerId=g),m!==Z.current.items&&(Z.current.items=m)},[K,G,g,m]),(0,W.useEffect)(()=>{if(J===Z.current.activeId)return;if(null!=J&&null==Z.current.activeId){Z.current.activeId=J;return}let e=setTimeout(()=>{Z.current.activeId=J},50);return()=>clearTimeout(e)},[J]),{active:P,activeIndex:v,attributes:B,data:j,rect:R,index:k,newIndex:G,items:m,isOver:D,isSorting:K,isDragging:z,listeners:O,node:M,overIndex:b,over:F,setNodeRef:U,setActivatorNodeRef:$,setDroppableNodeRef:T,setDraggableNodeRef:I,transform:null!=et?et:X,transition:et||Q&&Z.current.newIndex===k?ga:(!V||pK(L))&&p&&(K||ee)?pV.Transition.toString({...p,property:go}):void 0}}({id:e.id}),w={transform:pV.Translate.toString(_),transition:y,zIndex:b?50:void 0,position:b?"relative":void 0,opacity:b?1:void 0},{logs:S,status:C,exitCode:k,isPty:j,replayingHistory:N,sendInput:R,sendResize:M}=pk(u,r);(0,W.useEffect)(()=>{let r=m.current;m.current=e.currentProcessId,e.currentProcessId&&e.currentProcessId!==r&&(f(e.currentProcessId),p.current=!1,i(!0))},[e.currentProcessId,i]),(0,W.useEffect)(()=>{"closed"!==C||null===k||p.current||(p.current=!0,c(u))},[C,k,u,c]);let D=async()=>{console.log(`[ExecutorItem] Starting executor ${e.id}`),p.current=!1;let r=await n();console.log(`[ExecutorItem] Got processId: ${r}`),r&&(f(r),i(!0))},T=async()=>{await o(u||void 0)},P=e.isRunning;return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(lw,{open:s,onOpenChange:i,children:(0,F.jsxs)("div",{ref:x,style:w,className:(0,ey.cn)("border rounded-lg",b&&"shadow-lg bg-background"),children:[(0,F.jsx)(lS,{asChild:!0,children:(0,F.jsxs)("div",{className:"flex items-center justify-between p-3 cursor-pointer hover:bg-muted/50",children:[(0,F.jsxs)("div",{className:"flex items-center gap-2",children:[(0,F.jsx)("button",{type:"button",className:"cursor-grab touch-none text-muted-foreground hover:text-foreground",...g,...v,onClick:e=>e.stopPropagation(),children:(0,F.jsx)(lI,{className:"h-4 w-4"})}),s?(0,F.jsx)(r7,{className:"h-4 w-4"}):(0,F.jsx)(nq,{className:"h-4 w-4"}),(0,F.jsx)("span",{className:"font-medium",children:e.name}),(0,F.jsx)(lL,{variant:P?"default":"secondary",className:(0,ey.cn)(P&&"bg-green-600 hover:bg-green-600"),children:P?"Running":null!==k?0===k?"Completed":"Failed":"Stopped"})]}),(0,F.jsxs)("div",{className:"flex items-center gap-2",onClick:e=>e.stopPropagation(),children:[P?(0,F.jsxs)($.Button,{size:"sm",variant:"destructive",onClick:T,children:[(0,F.jsx)(lA,{className:"h-3 w-3 mr-1"}),"Stop"]}):(0,F.jsxs)($.Button,{size:"sm",onClick:D,children:[(0,F.jsx)(rd,{className:"h-3 w-3 mr-1"}),"Start"]}),(0,F.jsxs)(nY,{children:[(0,F.jsx)(nX,{asChild:!0,children:(0,F.jsx)($.Button,{size:"icon",variant:"ghost",className:"h-8 w-8",children:(0,F.jsx)(lB,{className:"h-4 w-4"})})}),(0,F.jsxs)(nG,{align:"end",children:[(0,F.jsxs)(nJ,{onClick:()=>h(!0),children:[(0,F.jsx)(rp,{className:"h-4 w-4 mr-2"}),"Edit"]}),(0,F.jsxs)(nJ,{onClick:l,className:"text-destructive",children:[(0,F.jsx)(ra,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]})]})}),(0,F.jsx)(lC,{children:(0,F.jsxs)("div",{className:"px-3 pb-3",children:[(0,F.jsx)("div",{className:"text-xs text-muted-foreground mb-2 font-mono",children:"prompt"===e.executor_type?`${e.prompt_provider??"claude"} → ${e.command}`:`$ ${e.command}`}),(0,F.jsx)(pb,{logs:S,isPty:j,onInput:R,onResize:M,muteInput:N})]})})]})}),(0,F.jsx)(pC,{open:d,onOpenChange:h,executor:e,onSubmit:async e=>{await a(e)}})]})}let gp=e=>{let{droppableContainers:r,pointerCoordinates:s}=e;if(!s)return(e=>{let{collisionRect:r,droppableRects:s,droppableContainers:i}=e,n=me(r,r.left,r.top),o=[];for(let e of i){let{id:r}=e,i=s.get(r);if(i){let s=p4(me(i),n);o.push({id:r,data:{droppableContainer:e,value:s}})}}return o.sort(p6)})(e);let i=[];for(let e of r){let r=e.rect.current;if(!r)continue;let n=r.top,o=r.top+52;s.x>=r.left&&s.x<=r.right&&s.y>=n&&s.y<=o&&i.push({id:e.id,data:{droppableContainer:e}})}if(i.length>0)return i;let n=null;for(let e of r){let r=e.rect.current;if(!r)continue;let i=r.top+26,o=r.left+r.width/2,a=Math.sqrt(Math.pow(s.x-o,2)+Math.pow(s.y-i,2));(!n||a<n.distance)&&(n={id:e.id,distance:a,data:{droppableContainer:e}})}return n?[{id:n.id,data:n.data}]:[]};function gm({projectId:e,selectedBranch:r,project:s,onExecutorModeChange:i}){let[n,o]=(0,W.useState)(!1),[a,l]=(0,W.useState)(new Set),{remotes:c}=r8(s?.id??void 0),d=[];for(let e of(s?.path&&d.push({id:"local",label:"Local",icon:n4.Monitor}),c))d.push({id:e.remote_server_id,label:e.server_name,icon:n6});let{activeGroup:h,loading:u,createGroup:f}=function(e,r){let[s,i]=(0,W.useState)([]),[n,o]=(0,W.useState)(null),[a,l]=(0,W.useState)(!0),c=r??"",d=(0,W.useCallback)(async()=>{if(!e){i([]),o(null),l(!1);return}try{let[r,s]=await Promise.all([rg.api.getExecutorGroups(e),rg.api.getExecutorGroupByBranch(e,c)]);i(r),o(s)}catch(e){console.error("Failed to fetch executor groups:",e)}finally{l(!1)}},[e,c]);(0,W.useEffect)(()=>{l(!0),d()},[d]);let h=(0,W.useCallback)(async r=>{if(!e)return null;try{let s=await rg.api.createExecutorGroup(e,{name:r,branch:c});return i(e=>[...e,s]),o(s),s}catch(e){return console.error("Failed to create executor group:",e),null}},[e,c]);return{groups:s,activeGroup:n,loading:a,createGroup:h,updateGroup:(0,W.useCallback)(async(e,r)=>{try{let s=await rg.api.updateExecutorGroup(e,r);return i(r=>r.map(r=>r.id===e?s:r)),o(r=>r?.id===e?s:r),s}catch(e){return console.error("Failed to update executor group:",e),null}},[]),deleteGroup:(0,W.useCallback)(async e=>{try{await rg.api.deleteExecutorGroup(e),i(r=>r.filter(r=>r.id!==e)),o(r=>r?.id===e?null:r)}catch(e){console.error("Failed to delete executor group:",e)}},[]),refetch:d}}(e,r),{executors:p,loading:m,createExecutor:g,updateExecutor:v,deleteExecutor:x,startExecutor:_,stopExecutor:y,markProcessFinished:b,reorderExecutors:w}=function(e,r,s){let[i,n]=(0,W.useState)([]),[o,a]=(0,W.useState)(new Map),[l,c]=(0,W.useState)(new Map),[d,h]=(0,W.useState)(!0),u=(0,W.useCallback)(async()=>{if(!e||!r){n([]),h(!1);return}try{let s=await rg.api.getExecutors(e,r);n(s)}catch(e){console.error("Failed to fetch executors:",e)}finally{h(!1)}},[e,r]),f=(0,W.useCallback)(async()=>{try{let e=await rg.api.getRunningProcesses();console.log(`[useExecutors] fetchRunningProcesses: ${e.length} running`,e.map(e=>`${e.executor_id}/${e.id}/${e.target??"local"}`));let{runningProcesses:r,lastStartedProcess:s}=function(e){let r=new Map,s=new Map;for(let i of e){let e={processId:i.id,target:i.target??"local"},n=r.get(i.executor_id);n?n.push(e):r.set(i.executor_id,[e]),s.set(i.executor_id,e)}return{runningProcesses:r,lastStartedProcess:s}}(e);a(r),c(e=>{let i=function(e,r){let s=new Map;for(let[i,n]of e)r.get(i)?.some(e=>e.processId===n.processId&&e.target===n.target)&&s.set(i,n);return s}(e,r);for(let[e,r]of s)i.set(e,r);return i})}catch(e){console.error("Failed to fetch running processes:",e)}},[]);(0,W.useEffect)(()=>{u(),f()},[u,f]),(0,W.useEffect)(()=>{let e=()=>{"visible"===document.visibilityState&&f()};return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[f]);let p=(0,W.useRef)(new Set);(0,W.useEffect)(()=>{p.current=new Set(i.map(e=>e.id))},[i]),(0,W.useEffect)(()=>{let r,s;if(!e)return;let i=new EventSource((s=(r=(0,rg.getAuthToken)())?`?token=${encodeURIComponent(r)}`:"",`${"localhost"===window.location.hostname&&"3000"===window.location.port?"http://localhost:5173":""}/api/events${s}`));return i.onmessage=r=>{try{let s=JSON.parse(r.data);if(("executor:started"===s.type||"executor:stopped"===s.type)&&console.log(`[useExecutors] SSE received: ${s.type} executor=${s.executorId} process=${s.processId} target=${s.target??"local"} project=${s.projectId}`),s.projectId!==e){("executor:started"===s.type||"executor:stopped"===s.type)&&console.log(`[useExecutors] SSE filtered: projectId mismatch (event=${s.projectId}, hook=${e})`);return}if(!p.current.has(s.executorId)){("executor:started"===s.type||"executor:stopped"===s.type)&&console.log(`[useExecutors] SSE filtered: executorId ${s.executorId} not in current group (known: ${Array.from(p.current).join(",")})`);return}"executor:started"===s.type?(console.log("[useExecutors] Processing executor:started, adding to runningProcesses"),a(e=>{let r=e.get(s.executorId)??[];if(r.some(e=>e.processId===s.processId))return e;let i=new Map(e);return i.set(s.executorId,[...r,{processId:s.processId,target:s.target??"local"}]),i}),c(e=>{let r=new Map(e);return r.set(s.executorId,{processId:s.processId,target:s.target??"local"}),r})):"executor:stopped"===s.type&&(console.log("[useExecutors] Processing executor:stopped, removing from runningProcesses"),a(e=>{let r=e.get(s.executorId);if(!r)return e;let i=r.filter(e=>e.processId!==s.processId),n=new Map(e);return 0===i.length?n.delete(s.executorId):n.set(s.executorId,i),n}),c(e=>{let r=e.get(s.executorId);if(!r||r.processId!==s.processId)return e;let i=new Map(e);return i.delete(s.executorId),i}))}catch{}},()=>{i.close()}},[e]);let m=(0,W.useCallback)(async s=>{if(!e||!r)return null;try{let i=await rg.api.createExecutor(e,{...s,group_id:r});return n(e=>[...e,i]),i}catch(e){return console.error("Failed to create executor:",e),null}},[e,r]),g=(0,W.useCallback)(async(e,r)=>{try{let s=await rg.api.updateExecutor(e,r);return n(r=>r.map(r=>r.id===e?s:r)),s}catch(e){return console.error("Failed to update executor:",e),null}},[]),v=(0,W.useCallback)(async e=>{try{await rg.api.deleteExecutor(e),n(r=>r.filter(r=>r.id!==e))}catch(e){console.error("Failed to delete executor:",e)}},[]),x=(0,W.useCallback)(async(e,r)=>{try{let i=await rg.api.startExecutor(e,r,s),n=s??"local";return a(r=>{let s=r.get(e)??[],o=new Map(r);return o.set(e,[...s,{processId:i,target:n}]),o}),c(r=>{let s=new Map(r);return s.set(e,{processId:i,target:n}),s}),i}catch(e){return console.error("Failed to start executor:",e),null}},[s]),_=(0,W.useCallback)(async(e,r)=>{let i=o.get(e),n=i?.find(e=>e.target===(s??"local")),l=r||n?.processId;if(l){try{await rg.api.stopProcess(l)}catch(e){console.error("Failed to stop executor:",e)}a(r=>{let s=r.get(e);if(!s)return r;let i=s.filter(e=>e.processId!==l),n=new Map(r);return 0===i.length?n.delete(e):n.set(e,i),n}),c(r=>{let s=r.get(e);if(!s||s.processId!==l)return r;let i=new Map(r);return i.delete(e),i})}},[o,s]),y=(0,W.useCallback)((e,r)=>{a(s=>{let i=s.get(e);if(!i)return s;if(r){let n=i.filter(e=>e.processId!==r);if(n.length===i.length)return s;let o=new Map(s);return 0===n.length?o.delete(e):o.set(e,n),o}let n=new Map(s);return n.delete(e),n}),c(s=>{if(!r){if(!s.has(e))return s;let r=new Map(s);return r.delete(e),r}let i=s.get(e);if(!i||i.processId!==r)return s;let n=new Map(s);return n.delete(e),n})},[]),b=(0,W.useCallback)(async s=>{if(e&&r){n(s.map(e=>i.find(r=>r.id===e)).filter(e=>void 0!==e));try{await rg.api.reorderExecutors(e,s,r)}catch(e){console.error("Failed to reorder executors:",e),n(i)}}},[e,r,i]);return{executors:i.map(e=>{let r=o.get(e.id),i=s??"local",n=r?.find(e=>e.target===i),a=l.get(e.id),c=a?.target===i?a:void 0;return{...e,currentProcessId:n?.processId??c?.processId??null,isRunning:!!n}}),loading:d,createExecutor:m,updateExecutor:g,deleteExecutor:v,startExecutor:x,stopExecutor:_,markProcessFinished:y,reorderExecutors:b,refetch:u}}(e,h?.id,s?.executor_mode),S=function(){for(var e=arguments.length,r=Array(e),s=0;s<e;s++)r[s]=arguments[s];return(0,W.useMemo)(()=>[...r].filter(e=>null!=e),[...r])}(p5(mM,{activationConstraint:{distance:8}}),p5(mk,{coordinateGetter:gh}));return e?(0,F.jsxs)("div",{className:"h-full flex flex-col",children:[(0,F.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border/60 h-10",children:[(0,F.jsxs)("div",{className:"flex items-center gap-2",children:[(0,F.jsxs)("h2",{className:"text-xs font-semibold flex items-center gap-2 text-foreground",children:[(0,F.jsx)(n5.Terminal,{className:"h-3.5 w-3.5"}),h?h.name:"Executors"]}),d.length>1&&i&&(0,F.jsx)(n1,{targets:d,activeTarget:s?.executor_mode??"local",onTargetChange:i})]}),h&&(0,F.jsxs)($.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>o(!0),children:[(0,F.jsx)(eS,{className:"h-3 w-3 mr-1"}),"Add"]})]}),(0,F.jsx)(oT,{className:"flex-1 overflow-hidden",children:(0,F.jsx)("div",{className:"p-4 space-y-3",children:u||m?(0,F.jsx)("div",{className:"text-center text-muted-foreground py-8",children:"Loading executors..."}):h?0===p.length?(0,F.jsxs)("div",{className:"text-center text-muted-foreground py-8",children:[(0,F.jsx)("p",{children:"No executors configured"}),(0,F.jsx)("p",{className:"text-sm mt-1",children:'Add an executor to run commands like "npm run dev"'})]}):(0,F.jsx)(mQ,{sensors:S,collisionDetection:gp,onDragEnd:e=>{let{active:r,over:s}=e;if(s&&r.id!==s.id){let e=p.findIndex(e=>e.id===r.id),i=p.findIndex(e=>e.id===s.id),n=[...p],[o]=n.splice(e,1);n.splice(i,0,o),w(n.map(e=>e.id))}},children:(0,F.jsx)(gr,{items:p.map(e=>e.id),strategy:m9,children:p.map(e=>(0,F.jsx)(gf,{executor:e,executorMode:s?.executor_mode??"local",isOpen:a.has(e.id),onOpenChange:r=>l(s=>{let i=new Set(s);return r?i.add(e.id):i.delete(e.id),i}),onStart:()=>_(e.id,r),onStop:r=>y(e.id,r||e.currentProcessId||void 0),onUpdate:r=>v(e.id,r),onDelete:()=>x(e.id),onProcessFinished:r=>b(e.id,r)},`${e.id}-${s?.executor_mode??"local"}`))})}):(0,F.jsxs)("div",{className:"text-center text-muted-foreground py-8",children:[(0,F.jsx)("p",{children:"No executor group for this branch"}),(0,F.jsx)("p",{className:"text-sm mt-1 mb-4",children:"Create a group to start adding executors"}),(0,F.jsxs)($.Button,{size:"sm",onClick:()=>f(r?`Executors (${r})`:"Default"),children:[(0,F.jsx)(lc,{className:"h-4 w-4 mr-1"}),"Create Group"]})]})})}),(0,F.jsx)(pC,{open:n,onOpenChange:o,onSubmit:async e=>{await g(e)}})]}):(0,F.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,F.jsxs)("div",{className:"text-center",children:[(0,F.jsx)("div",{className:"mx-auto w-10 h-10 rounded-xl bg-muted flex items-center justify-center mb-3",children:(0,F.jsx)(n5.Terminal,{className:"h-5 w-5 text-muted-foreground/50"})}),(0,F.jsx)("p",{className:"text-sm",children:"Select a project to manage executors"})]})})}let gg=(0,ew.default)("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),gv=(0,ew.default)("git-merge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]),gx=(0,ew.default)("chevrons-up-down",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]);function g_({line:e}){let r="add"===e.type?"+":"delete"===e.type?"-":" ";return(0,F.jsxs)("div",{className:(0,ey.cn)("flex font-mono text-sm","add"===e.type&&"bg-green-500/30","delete"===e.type&&"bg-red-500/30"),children:[(0,F.jsx)("span",{className:"w-12 flex-shrink-0 text-right pr-2 text-muted-foreground select-none border-r border-border",children:e.oldLineNo??""}),(0,F.jsx)("span",{className:"w-12 flex-shrink-0 text-right pr-2 text-muted-foreground select-none border-r border-border",children:e.newLineNo??""}),(0,F.jsx)("span",{className:"w-6 flex-shrink-0 text-center select-none",children:r}),(0,F.jsx)("span",{className:"whitespace-pre-wrap break-all pr-4 flex-1 min-w-0",children:e.content})]})}let gy={modified:"bg-yellow-500/20 text-yellow-500",added:"bg-green-500/20 text-green-500",deleted:"bg-red-500/20 text-red-500",renamed:"bg-blue-500/20 text-blue-500"},gb={modified:"Modified",added:"Added",deleted:"Deleted",renamed:"Renamed"};function gw({file:e,defaultOpen:r=!0}){let[s,i]=(0,W.useState)(r);return(0,F.jsxs)(lw,{open:s,onOpenChange:i,className:"border rounded-lg overflow-hidden",children:[(0,F.jsxs)(lS,{className:"flex items-center gap-2 px-4 py-2 bg-muted border-b w-full cursor-pointer hover:bg-muted/80 transition-colors",children:[s?(0,F.jsx)(r7,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):(0,F.jsx)(nq,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,F.jsx)("span",{className:"font-mono text-sm flex-1 min-w-0 truncate text-left",children:e.oldPath&&"renamed"===e.status?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)("span",{className:"text-muted-foreground",children:e.oldPath}),(0,F.jsx)("span",{className:"mx-2",children:"→"}),e.path]}):e.path}),(0,F.jsx)(lL,{variant:"secondary",className:gy[e.status],children:gb[e.status]})]}),(0,F.jsx)(lC,{children:(0,F.jsx)("div",{children:e.hunks.map((e,r)=>(0,F.jsxs)("div",{children:[(0,F.jsxs)("div",{className:"px-4 py-1 bg-muted/50 text-muted-foreground text-sm font-mono sticky top-0",children:["@@ -",e.oldStart,",",e.oldLines," +",e.newStart,",",e.newLines," @@"]}),e.lines.map((e,r)=>(0,F.jsx)(g_,{line:e},r))]},r))})})]})}let gS=(0,ew.default)("git-commit-horizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]),gC="__head__";function gk({commits:e,selectedCommit:r,onSelectCommit:s,loading:i,disabled:n}){return(0,F.jsxs)(a4,{value:r??gC,onValueChange:e=>{s(e===gC?null:e)},disabled:n||i,children:[(0,F.jsxs)(a8,{size:"sm",className:"w-[200px]",children:[(0,F.jsx)(gS,{className:"h-3.5 w-3.5 shrink-0"}),(0,F.jsx)(a6,{placeholder:"Select commit..."})]}),(0,F.jsxs)(a7,{children:[(0,F.jsx)(a9,{value:gC,children:"HEAD (uncommitted)"}),e.map(e=>(0,F.jsxs)(a9,{value:e.hash,children:[(0,F.jsx)("span",{className:"font-mono text-xs",children:e.shortHash})," ",(0,F.jsx)("span",{className:"truncate",children:e.message.length>40?e.message.slice(0,40)+"...":e.message})]},e.hash))]})]})}function gj({projectId:e,selectedBranch:r,onMergeRequest:s,project:i}){let[n,o]=(0,W.useState)(null),{remotes:a}=r8(i?.id??void 0),l=[];for(let e of(i?.path&&l.push({id:"local",label:"Local",icon:n4.Monitor}),a))l.push({id:e.remote_server_id,label:e.server_name,icon:n6});let c=i?.path?"local":a.length>0?a[0].remote_server_id:"local",[d,h]=(0,W.useState)(c),[u,f]=(0,W.useState)(!0),[p,m]=(0,W.useState)(0),g="local"===d?i?.path?"local":void 0:"remote",{diff:v,loading:x,error:_,refresh:y}=function(e,r,s,i){let[n,o]=(0,W.useState)(null),[a,l]=(0,W.useState)(!1),[c,d]=(0,W.useState)(null),h=(0,W.useCallback)(async()=>{if(!e)return void o(null);l(!0),d(null);try{let n=await rg.api.getDiff(e,r,s,i);o(n)}catch(e){d(e instanceof Error?e.message:"Failed to load diff"),o(null)}finally{l(!1)}},[e,r,s,i]);return{diff:n,loading:a,error:c,refresh:h}}(e,r,n,g),{commits:b,loading:w,refetch:S}=function(e,r,s,i){let[n,o]=(0,W.useState)([]),[a,l]=(0,W.useState)(!1);return{commits:n,loading:a,refetch:(0,W.useCallback)(async()=>{if(!e)return void o([]);l(!0);try{let n=await rg.api.getCommits(e,r,s,i);o(n)}catch{o([])}finally{l(!1)}},[e,r,s,i])}}(e,r,void 0,g);if((0,W.useEffect)(()=>{y()},[y]),(0,W.useEffect)(()=>{S()},[S]),(0,W.useEffect)(()=>{o(null)},[r]),(0,W.useEffect)(()=>{h(c)},[e,c]),!e)return(0,F.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,F.jsxs)("div",{className:"text-center",children:[(0,F.jsx)("div",{className:"mx-auto w-10 h-10 rounded-xl bg-muted flex items-center justify-center mb-3",children:(0,F.jsx)(la,{className:"h-5 w-5 text-muted-foreground/50"})}),(0,F.jsx)("p",{className:"text-sm",children:"Select a project to view changes"})]})});let C=v?.files.length??0;return(0,F.jsxs)("div",{className:"h-full flex flex-col",children:[(0,F.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border/60 h-10",children:[(0,F.jsx)("div",{className:"flex items-center gap-4",children:C>0&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)("span",{className:"text-xs text-muted-foreground",children:[C," file",1!==C?"s":""," changed"]}),(0,F.jsxs)($.Button,{size:"sm",variant:"ghost",onClick:()=>{f(e=>!e),m(e=>e+1)},title:u?"Collapse all":"Expand all",children:[(0,F.jsx)(gx,{className:"h-4 w-4 mr-1"}),u?"Collapse all":"Expand all"]})]})}),(0,F.jsxs)("div",{className:"flex items-center gap-2",children:[l.length>1&&(0,F.jsx)(n1,{targets:l,activeTarget:d,onTargetChange:h,disabled:x}),(0,F.jsx)("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Commit:"}),(0,F.jsx)(gk,{commits:b,selectedCommit:n,onSelectCommit:o,loading:w,disabled:x}),(0,F.jsxs)($.Button,{size:"sm",variant:"outline",onClick:s,disabled:x||0===C,children:[(0,F.jsx)(gv,{className:"h-4 w-4 mr-1"}),"Merge"]}),(0,F.jsxs)($.Button,{size:"sm",variant:"outline",onClick:y,disabled:x,children:[(0,F.jsx)(gg,{className:`h-4 w-4 mr-1 ${x?"animate-spin":""}`}),"Refresh"]})]})]}),(0,F.jsx)(oT,{className:"flex-1 overflow-hidden",children:(0,F.jsx)("div",{className:"p-4 space-y-4",children:x&&!v?(0,F.jsx)("div",{className:"text-center text-muted-foreground py-8",children:"Loading changes..."}):_?(0,F.jsx)("div",{className:"text-center text-red-400 py-8",children:_}):0===C?(0,F.jsx)("div",{className:"text-center text-muted-foreground py-8",children:(0,F.jsx)("p",{children:n?"No changes in this commit":"No uncommitted changes"})}):v?.files.map((e,r)=>(0,F.jsx)(gw,{file:e,defaultOpen:u},`${r}-${p}`))})})]})}function gN({terminalId:e,onExit:r}){let{logs:s,sendInput:i,sendResize:n,exitCode:o,replayingHistory:a}=pk(e);return(0,W.useEffect)(()=>{null!==o&&r(e)},[o,r,e]),(0,F.jsx)(pb,{logs:s,isPty:!0,className:"h-full rounded-none border-0",onInput:i,onResize:n,muteInput:a})}function gE({projectId:e,selectedBranch:r,project:s}){let{terminals:i,activeTerminalId:n,createTerminal:o,closeTerminal:a,setActiveTerminal:l,removeTerminal:c}=function(e,r){let[s,i]=(0,W.useState)([]),[n,o]=(0,W.useState)(null);(0,W.useEffect)(()=>{if(!e){i([]),o(null);return}rg.api.getTerminals(e,r).then(e=>{i(e),o(e.length>0?e[0].id:null)})},[e,r]);let a=(0,W.useCallback)(async(s,n)=>{if(e)try{let a=await rg.api.createTerminal(e,r,s,n);i(e=>[...e,a]),o(a.id)}catch(e){console.error("[useTerminals] Failed to create terminal:",e)}},[e,r]),l=(0,W.useCallback)(async e=>{await rg.api.closeTerminal(e),i(r=>{let s=r.filter(r=>r.id!==e);return o(r=>r===e?s.length>0?s[s.length-1].id:null:r),s})},[]);return{terminals:s,activeTerminalId:n,createTerminal:a,closeTerminal:l,setActiveTerminal:(0,W.useCallback)(e=>{o(e)},[]),removeTerminal:(0,W.useCallback)(e=>{i(r=>{let s=r.filter(r=>r.id!==e);return o(r=>r===e?s.length>0?s[s.length-1].id:null:r),s})},[])}}(e,r),{remotes:d}=r8(s?.id??void 0),[h,u]=(0,W.useState)(!1),f=(0,W.useRef)(null),p=!!s?.path,m=d.length>0,g=p&&m||d.length>1,v=!p&&m||g&&s?.executor_mode!=="local"?"remote":"local",x=(0,W.useCallback)(()=>{o(v)},[o,v]),_=(0,W.useCallback)((e,r)=>{u(!1),o(e,r)},[o]);(0,W.useEffect)(()=>{if(h)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e);function e(e){f.current&&!f.current.contains(e.target)&&u(!1)}},[h]);let y=(0,W.useCallback)(e=>{c(e)},[c]);return e?(0,F.jsxs)("div",{className:"h-full flex flex-col",children:[(0,F.jsxs)("div",{className:"flex items-center h-10 border-b border-border/60 px-2 gap-1 shrink-0 bg-muted/20",children:[(0,F.jsx)("div",{className:"flex-1 min-w-0 flex items-center gap-1 overflow-hidden",children:i.map(e=>{let r="remote"===e.location||e.id.startsWith("remote-"),s=g?r?n6:n4.Monitor:n5.Terminal,i=n===e.id;return(0,F.jsxs)("button",{onClick:()=>l(e.id),title:e.name,className:(0,ey.cn)("group flex items-center gap-1.5 px-2 py-1 rounded-md text-xs transition-all duration-150 border flex-1 min-w-0 basis-0 max-w-[180px]",i?"bg-background text-foreground border-border shadow-sm":"text-muted-foreground hover:text-foreground bg-muted/40 hover:bg-background/60 border-border/30 hover:border-border/60"),children:[(0,F.jsx)(s,{className:"h-3 w-3 shrink-0"}),(0,F.jsx)("span",{className:"truncate flex-1 text-left",children:e.name}),(0,F.jsx)("span",{role:"button",onClick:r=>{r.stopPropagation(),a(e.id)},className:(0,ey.cn)("shrink-0 rounded-sm p-0.5 hover:bg-destructive/10 hover:text-destructive",i?"opacity-80 hover:opacity-100":"opacity-0 group-hover:opacity-80 hover:!opacity-100"),children:(0,F.jsx)(t6,{className:"h-3 w-3"})})]},e.id)})}),(0,F.jsxs)("div",{className:"relative shrink-0",ref:f,children:[(0,F.jsx)($.Button,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:g?()=>u(e=>!e):x,children:(0,F.jsx)(eS,{className:"h-3.5 w-3.5"})}),g&&h&&(0,F.jsxs)("div",{className:"absolute right-0 top-full mt-1 z-50 min-w-[160px] rounded-md border bg-popover p-1 shadow-md",children:[p&&(0,F.jsxs)("button",{className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground transition-colors",onClick:()=>_("local"),children:[(0,F.jsx)(n4.Monitor,{className:"h-3.5 w-3.5"}),"Local Terminal"]}),d.map(e=>(0,F.jsxs)("button",{className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground transition-colors",onClick:()=>_("remote",e.remote_server_id),children:[(0,F.jsx)(n6,{className:"h-3.5 w-3.5"}),e.server_name," Terminal"]},e.remote_server_id))]})]})]}),(0,F.jsx)("div",{className:"flex-1 overflow-hidden bg-zinc-950",children:n?(0,F.jsx)(gN,{terminalId:n,onExit:y},n):(0,F.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,F.jsx)(n5.Terminal,{className:"h-10 w-10 text-muted-foreground/70"})})})]}):(0,F.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,F.jsxs)("div",{className:"text-center",children:[(0,F.jsx)("div",{className:"mx-auto w-10 h-10 rounded-xl bg-muted flex items-center justify-center mb-3",children:(0,F.jsx)(n5.Terminal,{className:"h-5 w-5 text-muted-foreground/50"})}),(0,F.jsx)("p",{className:"text-sm",children:"Select a project to use the terminal"})]})})}let gR=(0,ew.default)("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);var[gM,gD]=K("Tooltip",[iv]),gT=iv(),gP="TooltipProvider",gL="tooltip.open",[gA,gB]=gM(gP),gI=e=>{let{__scopeTooltip:r,delayDuration:s=700,skipDelayDuration:i=300,disableHoverableContent:n=!1,children:o}=e,a=W.useRef(!0),l=W.useRef(!1),c=W.useRef(0);return W.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,F.jsx)(gA,{scope:r,isOpenDelayedRef:a,delayDuration:s,onOpen:W.useCallback(()=>{window.clearTimeout(c.current),a.current=!1},[]),onClose:W.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.current=!0,i)},[i]),isPointerInTransitRef:l,onPointerInTransitChange:W.useCallback(e=>{l.current=e},[]),disableHoverableContent:n,children:o})};gI.displayName=gP;var gO="Tooltip",[gz,gF]=gM(gO),gW=e=>{let{__scopeTooltip:r,children:s,open:i,defaultOpen:n,onOpenChange:o,disableHoverableContent:a,delayDuration:l}=e,c=gB(gO,e.__scopeTooltip),d=gT(r),[h,u]=W.useState(null),f=ej(),p=W.useRef(0),m=a??c.disableHoverableContent,g=l??c.delayDuration,v=W.useRef(!1),[x,_]=X({prop:i,defaultProp:n??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(gL))):c.onClose(),o?.(e)},caller:gO}),y=W.useMemo(()=>x?v.current?"delayed-open":"instant-open":"closed",[x]),b=W.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v.current=!1,_(!0)},[_]),w=W.useCallback(()=>{window.clearTimeout(p.current),p.current=0,_(!1)},[_]),S=W.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{v.current=!0,_(!0),p.current=0},g)},[g,_]);return W.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),(0,F.jsx)(iy,{...d,children:(0,F.jsx)(gz,{scope:r,contentId:f,open:x,stateAttribute:y,trigger:h,onTriggerChange:u,onTriggerEnter:W.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:W.useCallback(()=>{m?w():(window.clearTimeout(p.current),p.current=0)},[w,m]),onOpen:b,onClose:w,disableHoverableContent:m,children:s})})};gW.displayName=gO;var g$="TooltipTrigger",gH=W.forwardRef((e,r)=>{let{__scopeTooltip:s,...i}=e,n=gF(g$,s),o=gB(g$,s),a=gT(s),l=W.useRef(null),c=(0,U.useComposedRefs)(r,l,n.onTriggerChange),d=W.useRef(!1),h=W.useRef(!1),u=W.useCallback(()=>d.current=!1,[]);return W.useEffect(()=>()=>document.removeEventListener("pointerup",u),[u]),(0,F.jsx)(iw,{asChild:!0,...a,children:(0,F.jsx)(er.button,{"aria-describedby":n.open?n.contentId:void 0,"data-state":n.stateAttribute,...i,ref:c,onPointerMove:q(e.onPointerMove,e=>{"touch"!==e.pointerType&&(h.current||o.isPointerInTransitRef.current||(n.onTriggerEnter(),h.current=!0))}),onPointerLeave:q(e.onPointerLeave,()=>{n.onTriggerLeave(),h.current=!1}),onPointerDown:q(e.onPointerDown,()=>{n.open&&n.onClose(),d.current=!0,document.addEventListener("pointerup",u,{once:!0})}),onFocus:q(e.onFocus,()=>{d.current||n.onOpen()}),onBlur:q(e.onBlur,n.onClose),onClick:q(e.onClick,n.onClose)})})});gH.displayName=g$;var gU="TooltipPortal",[gK,gq]=gM(gU,{forceMount:void 0}),gV=e=>{let{__scopeTooltip:r,forceMount:s,children:i,container:n}=e,o=gF(gU,r);return(0,F.jsx)(gK,{scope:r,forceMount:s,children:(0,F.jsx)(Z,{present:s||o.open,children:(0,F.jsx)(e$,{asChild:!0,container:n,children:i})})})};gV.displayName=gU;var gY="TooltipContent",gX=W.forwardRef((e,r)=>{let s=gq(gY,e.__scopeTooltip),{forceMount:i=s.forceMount,side:n="top",...o}=e,a=gF(gY,e.__scopeTooltip);return(0,F.jsx)(Z,{present:i||a.open,children:a.disableHoverableContent?(0,F.jsx)(g0,{side:n,...o,ref:r}):(0,F.jsx)(gG,{side:n,...o,ref:r})})}),gG=W.forwardRef((e,r)=>{let s=gF(gY,e.__scopeTooltip),i=gB(gY,e.__scopeTooltip),n=W.useRef(null),o=(0,U.useComposedRefs)(r,n),[a,l]=W.useState(null),{trigger:c,onClose:d}=s,h=n.current,{onPointerInTransitChange:u}=i,f=W.useCallback(()=>{l(null),u(!1)},[u]),p=W.useCallback((e,r)=>{let s,i=e.currentTarget,n={x:e.clientX,y:e.clientY},o=function(e,r){let s=Math.abs(r.top-e.y),i=Math.abs(r.bottom-e.y),n=Math.abs(r.right-e.x),o=Math.abs(r.left-e.x);switch(Math.min(s,i,n,o)){case o:return"left";case n:return"right";case s:return"top";case i:return"bottom";default:throw Error("unreachable")}}(n,i.getBoundingClientRect());l(((s=[...function(e,r,s=5){let i=[];switch(r){case"top":i.push({x:e.x-s,y:e.y+s},{x:e.x+s,y:e.y+s});break;case"bottom":i.push({x:e.x-s,y:e.y-s},{x:e.x+s,y:e.y-s});break;case"left":i.push({x:e.x+s,y:e.y-s},{x:e.x+s,y:e.y+s});break;case"right":i.push({x:e.x-s,y:e.y-s},{x:e.x-s,y:e.y+s})}return i}(n,o),...function(e){let{top:r,right:s,bottom:i,left:n}=e;return[{x:n,y:r},{x:s,y:r},{x:s,y:i},{x:n,y:i}]}(r.getBoundingClientRect())].slice()).sort((e,r)=>e.x<r.x?-1:e.x>r.x?1:e.y<r.y?-1:1*!!(e.y>r.y)),function(e){if(e.length<=1)return e.slice();let r=[];for(let s=0;s<e.length;s++){let i=e[s];for(;r.length>=2;){let e=r[r.length-1],s=r[r.length-2];if((e.x-s.x)*(i.y-s.y)>=(e.y-s.y)*(i.x-s.x))r.pop();else break}r.push(i)}r.pop();let s=[];for(let r=e.length-1;r>=0;r--){let i=e[r];for(;s.length>=2;){let e=s[s.length-1],r=s[s.length-2];if((e.x-r.x)*(i.y-r.y)>=(e.y-r.y)*(i.x-r.x))s.pop();else break}s.push(i)}return(s.pop(),1===r.length&&1===s.length&&r[0].x===s[0].x&&r[0].y===s[0].y)?r:r.concat(s)}(s))),u(!0)},[u]);return W.useEffect(()=>()=>f(),[f]),W.useEffect(()=>{if(c&&h){let e=e=>p(e,h),r=e=>p(e,c);return c.addEventListener("pointerleave",e),h.addEventListener("pointerleave",r),()=>{c.removeEventListener("pointerleave",e),h.removeEventListener("pointerleave",r)}}},[c,h,p,f]),W.useEffect(()=>{if(a){let e=e=>{let r=e.target,s={x:e.clientX,y:e.clientY},i=c?.contains(r)||h?.contains(r),n=!function(e,r){let{x:s,y:i}=e,n=!1;for(let e=0,o=r.length-1;e<r.length;o=e++){let a=r[e],l=r[o],c=a.x,d=a.y,h=l.x,u=l.y;d>i!=u>i&&s<(h-c)*(i-d)/(u-d)+c&&(n=!n)}return n}(s,a);i?f():n&&(f(),d())};return document.addEventListener("pointermove",e),()=>document.removeEventListener("pointermove",e)}},[c,h,a,d,f]),(0,F.jsx)(g0,{...e,ref:o})}),[gJ,gZ]=gM(gO,{isInside:!1}),gQ=(0,et.createSlottable)("TooltipContent"),g0=W.forwardRef((e,r)=>{let{__scopeTooltip:s,children:i,"aria-label":n,onEscapeKeyDown:o,onPointerDownOutside:a,...l}=e,c=gF(gY,s),d=gT(s),{onClose:h}=c;return W.useEffect(()=>(document.addEventListener(gL,h),()=>document.removeEventListener(gL,h)),[h]),W.useEffect(()=>{if(c.trigger){let e=e=>{let r=e.target;r?.contains(c.trigger)&&h()};return window.addEventListener("scroll",e,{capture:!0}),()=>window.removeEventListener("scroll",e,{capture:!0})}},[c.trigger,h]),(0,F.jsx)(eM,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:a,onFocusOutside:e=>e.preventDefault(),onDismiss:h,children:(0,F.jsxs)(ij,{"data-state":c.stateAttribute,...d,...l,ref:r,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[(0,F.jsx)(gQ,{children:i}),(0,F.jsx)(gJ,{scope:s,isInside:!0,children:(0,F.jsx)(ai,{id:c.contentId,role:"tooltip",children:n||i})})]})})});gX.displayName=gY;var g1="TooltipArrow",g2=W.forwardRef((e,r)=>{let{__scopeTooltip:s,...i}=e,n=gT(s);return gZ(g1,s).isInside?null:(0,F.jsx)(iR,{...n,...i,ref:r})});g2.displayName=g1,e.s(["Arrow",()=>g2,"Content",()=>gX,"Portal",()=>gV,"Provider",()=>gI,"Root",()=>gW,"Tooltip",()=>gW,"TooltipArrow",()=>g2,"TooltipContent",()=>gX,"TooltipPortal",()=>gV,"TooltipProvider",()=>gI,"TooltipTrigger",()=>gH,"Trigger",()=>gH,"createTooltipScope",()=>gD],517964);var g5=e.i(517964),g5=g5;function g3({delayDuration:e=0,...r}){return(0,F.jsx)(g5.Provider,{"data-slot":"tooltip-provider",delayDuration:e,...r})}function g4({...e}){return(0,F.jsx)(g5.Root,{"data-slot":"tooltip",...e})}function g6({...e}){return(0,F.jsx)(g5.Trigger,{"data-slot":"tooltip-trigger",...e})}function g8({className:e,sideOffset:r=0,children:s,...i}){return(0,F.jsx)(g5.Portal,{children:(0,F.jsxs)(g5.Content,{"data-slot":"tooltip-content",sideOffset:r,className:(0,ey.cn)("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 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 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...i,children:[s,(0,F.jsx)(g5.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}let g7=(0,W.createContext)(null),g9=({className:e,children:r,defaultUrl:s="",onUrlChange:i,...n})=>{let[o,a]=(0,W.useState)(s),[l,c]=(0,W.useState)(!1);return(0,F.jsx)(g7.Provider,{value:{url:o,setUrl:e=>{a(e),i?.(e)},consoleOpen:l,setConsoleOpen:c},children:(0,F.jsx)("div",{className:(0,ey.cn)("flex size-full flex-col bg-card",e),...n,children:r})})},ve=({className:e,children:r,...s})=>(0,F.jsx)("div",{className:(0,ey.cn)("flex items-center gap-1 border-b p-2 h-14",e),...s,children:r}),vt=({onClick:e,disabled:r,tooltip:s,children:i,...n})=>(0,F.jsx)(g3,{children:(0,F.jsxs)(g4,{children:[(0,F.jsx)(g6,{asChild:!0,children:(0,F.jsx)($.Button,{className:"h-8 w-8 p-0 hover:text-foreground",disabled:r,onClick:e,size:"sm",variant:"ghost",...n,children:i})}),(0,F.jsx)(g8,{children:(0,F.jsx)("p",{children:s})})]})}),vr=({value:e,onChange:r,onKeyDown:s,...i})=>{let{url:n,setUrl:o}=(()=>{let e=(0,W.useContext)(g7);if(!e)throw Error("WebPreview components must be used within a WebPreview");return e})(),[a,l]=(0,W.useState)(n);return(0,W.useEffect)(()=>{l(n)},[n]),(0,F.jsx)(rn,{className:"h-8 flex-1 text-sm",onChange:r??(e=>{l(e.target.value),r?.(e)}),onKeyDown:e=>{"Enter"===e.key&&o(e.target.value),s?.(e)},placeholder:"Enter URL...",value:e??a,...i})};var vs=e.i(254824);function vi({projectId:e}){let r=(0,W.useRef)(null),s=(0,W.useRef)(null),{addFrame:i,updateFrameUrl:n,refreshFrame:o,hasFrame:a,claimFrame:l,getFrameUrl:c}=(0,vs.useBrowserFrames)(),d=e?c(e):void 0;(0,W.useEffect)(()=>{if(e&&d&&r.current){let i=setTimeout(()=>{r.current&&(s.current?.(),s.current=l(e,r.current))},50);return()=>{clearTimeout(i),s.current?.(),s.current=null}}return()=>{s.current?.(),s.current=null}},[e,d,l]);let h=(0,W.useCallback)(()=>{e&&o(e)},[e,o]),u=(0,W.useCallback)(()=>{d&&window.open(d,"_blank")},[d]),f=(0,W.useCallback)(r=>{e&&(a(e)?n(e,r):i(e,r))},[e,a,n,i]);return(0,F.jsx)("div",{className:"h-full flex flex-col",children:(0,F.jsxs)(g9,{defaultUrl:d??"",onUrlChange:f,className:"h-full",children:[(0,F.jsxs)(ve,{className:"h-10 p-1.5 gap-0.5",children:[(0,F.jsx)(vt,{tooltip:"Refresh",onClick:h,disabled:!d,children:(0,F.jsx)(gg,{className:"h-3.5 w-3.5"})}),(0,F.jsx)(vt,{tooltip:"Open in browser",onClick:u,disabled:!d,children:(0,F.jsx)(gR,{className:"h-3.5 w-3.5"})}),(0,F.jsx)(vr,{className:"h-7 text-xs"})]}),d?(0,F.jsx)("div",{ref:r,className:"flex-1 bg-white"}):(0,F.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:(0,F.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,F.jsx)(rx,{className:"h-8 w-8 opacity-40"}),(0,F.jsx)("p",{className:"text-sm",children:"Enter a URL above to preview"})]})})]})})}function vn({projectId:e,selectedBranch:r,onMergeRequest:s,project:i,onExecutorModeChange:n,agentSlot:o}){let[a,l]=function(e,r){let s=`vibedeckx:activeTab:${e??"none"}:${r??"main"}`,[i,n]=(0,W.useState)(()=>localStorage.getItem(s)??"agent");return(0,W.useEffect)(()=>{n(localStorage.getItem(s)??"agent")},[s]),[i,(0,W.useCallback)(e=>{n(e),localStorage.setItem(s,e)},[s])]}(e,r);return(0,F.jsxs)("div",{className:"h-full flex flex-col",children:[(0,F.jsx)("div",{className:"flex items-center px-3 gap-4 border-b border-border/60",children:[{id:"agent",icon:n3,label:"Agent"},{id:"executors",icon:n5.Terminal,label:"Executors"},{id:"diff",icon:la,label:"Diff"},{id:"terminal",icon:ll,label:"Terminal"},{id:"preview",icon:rx,label:"Preview"}].map(({id:e,icon:r,label:s})=>(0,F.jsxs)("button",{onClick:()=>l(e),className:(0,ey.cn)("flex items-center gap-0.5 py-2.5 text-xs font-medium border-b-2 transition-colors",a===e?"text-foreground border-foreground":"text-muted-foreground border-transparent hover:text-foreground/70"),children:[(0,F.jsx)(r,{className:"h-3.5 w-3.5"}),s]},e))}),(0,F.jsx)("div",{className:(0,ey.cn)("flex-1 overflow-hidden","agent"!==a&&"hidden"),children:o}),(0,F.jsx)("div",{className:(0,ey.cn)("flex-1 overflow-hidden","executors"!==a&&"hidden"),children:(0,F.jsx)(gm,{projectId:e,selectedBranch:r,project:i,onExecutorModeChange:n})}),(0,F.jsx)("div",{className:(0,ey.cn)("flex-1 overflow-hidden","diff"!==a&&"hidden"),children:(0,F.jsx)(gj,{projectId:e,selectedBranch:r,onMergeRequest:s,project:i})}),(0,F.jsx)("div",{className:(0,ey.cn)("flex-1 overflow-hidden","terminal"!==a&&"hidden"),children:(0,F.jsx)(gE,{projectId:e,selectedBranch:r,project:i})}),(0,F.jsx)("div",{className:(0,ey.cn)("flex-1 overflow-hidden","preview"!==a&&"hidden"),children:(0,F.jsx)(vi,{projectId:e,selectedBranch:r,project:i})})]})}var vo=Symbol.for("immer-nothing"),va=Symbol.for("immer-draftable"),vl=Symbol.for("immer-state");function vc(e){throw Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var vd=Object.getPrototypeOf;function vh(e){return!!e&&!!e[vl]}function vu(e){return!!e&&(vm(e)||Array.isArray(e)||!!e[va]||!!e.constructor?.[va]||vy(e)||vb(e))}var vf=Object.prototype.constructor.toString(),vp=new WeakMap;function vm(e){if(!e||"object"!=typeof e)return!1;let r=Object.getPrototypeOf(e);if(null===r||r===Object.prototype)return!0;let s=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;if(s===Object)return!0;if("function"!=typeof s)return!1;let i=vp.get(s);return void 0===i&&(i=Function.toString.call(s),vp.set(s,i)),i===vf}function vg(e,r,s=!0){0===vv(e)?(s?Reflect.ownKeys(e):Object.keys(e)).forEach(s=>{r(s,e[s],e)}):e.forEach((s,i)=>r(i,s,e))}function vv(e){let r=e[vl];return r?r.type_:Array.isArray(e)?1:vy(e)?2:3*!!vb(e)}function vx(e,r){return 2===vv(e)?e.has(r):Object.prototype.hasOwnProperty.call(e,r)}function v_(e,r,s){let i=vv(e);2===i?e.set(r,s):3===i?e.add(s):e[r]=s}function vy(e){return e instanceof Map}function vb(e){return e instanceof Set}function vw(e){return e.copy_||e.base_}function vS(e,r){if(vy(e))return new Map(e);if(vb(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let s=vm(e);if(!0!==r&&("class_only"!==r||s)){let r=vd(e);return null!==r&&s?{...e}:Object.assign(Object.create(r),e)}{let r=Object.getOwnPropertyDescriptors(e);delete r[vl];let s=Reflect.ownKeys(r);for(let i=0;i<s.length;i++){let n=s[i],o=r[n];!1===o.writable&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[n]={configurable:!0,writable:!0,enumerable:o.enumerable,value:e[n]})}return Object.create(vd(e),r)}}function vC(e,r=!1){return vj(e)||vh(e)||!vu(e)||(vv(e)>1&&Object.defineProperties(e,{set:vk,add:vk,clear:vk,delete:vk}),Object.freeze(e),r&&Object.values(e).forEach(e=>vC(e,!0))),e}var vk={value:function(){vc(2)}};function vj(e){return null===e||"object"!=typeof e||Object.isFrozen(e)}var vN={};function vE(e){let r=vN[e];return r||vc(0,e),r}function vR(e,r){r&&(vE("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=r)}function vM(e){vD(e),e.drafts_.forEach(vP),e.drafts_=null}function vD(e){e===O&&(O=e.parent_)}function vT(e){return O={drafts_:[],parent_:O,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function vP(e){let r=e[vl];0===r.type_||1===r.type_?r.revoke_():r.revoked_=!0}function vL(e,r){r.unfinalizedDrafts_=r.drafts_.length;let s=r.drafts_[0];return void 0!==e&&e!==s?(s[vl].modified_&&(vM(r),vc(4)),vu(e)&&(e=vA(r,e),r.parent_||vI(r,e)),r.patches_&&vE("Patches").generateReplacementPatches_(s[vl].base_,e,r.patches_,r.inversePatches_)):e=vA(r,s,[]),vM(r),r.patches_&&r.patchListener_(r.patches_,r.inversePatches_),e!==vo?e:void 0}function vA(e,r,s){if(vj(r))return r;let i=e.immer_.shouldUseStrictIteration(),n=r[vl];if(!n)return vg(r,(i,o)=>vB(e,n,r,i,o,s),i),r;if(n.scope_!==e)return r;if(!n.modified_)return vI(e,n.base_,!0),n.base_;if(!n.finalized_){n.finalized_=!0,n.scope_.unfinalizedDrafts_--;let r=n.copy_,o=r,a=!1;3===n.type_&&(o=new Set(r),r.clear(),a=!0),vg(o,(i,o)=>vB(e,n,r,i,o,s,a),i),vI(e,r,!1),s&&e.patches_&&vE("Patches").generatePatches_(n,s,e.patches_,e.inversePatches_)}return n.copy_}function vB(e,r,s,i,n,o,a){if(null==n||"object"!=typeof n&&!a)return;let l=vj(n);if(!l||a){if(vh(n)){let a=vA(e,n,o&&r&&3!==r.type_&&!vx(r.assigned_,i)?o.concat(i):void 0);if(v_(s,i,a),!vh(a))return;e.canAutoFreeze_=!1}else a&&s.add(n);if(vu(n)&&!l){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1||r&&r.base_&&r.base_[i]===n&&l)return;vA(e,n),(!r||!r.scope_.parent_)&&"symbol"!=typeof i&&(vy(s)?s.has(i):Object.prototype.propertyIsEnumerable.call(s,i))&&vI(e,n)}}}function vI(e,r,s=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&vC(r,s)}var vO={get(e,r){if(r===vl)return e;let s=vw(e);if(!vx(s,r)){var i;let n;return i=e,(n=vW(s,r))?"value"in n?n.value:n.get?.call(i.draft_):void 0}let n=s[r];return e.finalized_||!vu(n)?n:n===vF(e.base_,r)?(vH(e),e.copy_[r]=vU(n,e)):n},has:(e,r)=>r in vw(e),ownKeys:e=>Reflect.ownKeys(vw(e)),set(e,r,s){let i=vW(vw(e),r);if(i?.set)return i.set.call(e.draft_,s),!0;if(!e.modified_){let i=vF(vw(e),r),n=i?.[vl];if(n&&n.base_===s)return e.copy_[r]=s,e.assigned_[r]=!1,!0;if((s===i?0!==s||1/s==1/i:s!=s&&i!=i)&&(void 0!==s||vx(e.base_,r)))return!0;vH(e),v$(e)}return!!(e.copy_[r]===s&&(void 0!==s||r in e.copy_)||Number.isNaN(s)&&Number.isNaN(e.copy_[r]))||(e.copy_[r]=s,e.assigned_[r]=!0,!0)},deleteProperty:(e,r)=>(void 0!==vF(e.base_,r)||r in e.base_?(e.assigned_[r]=!1,vH(e),v$(e)):delete e.assigned_[r],e.copy_&&delete e.copy_[r],!0),getOwnPropertyDescriptor(e,r){let s=vw(e),i=Reflect.getOwnPropertyDescriptor(s,r);return i?{writable:!0,configurable:1!==e.type_||"length"!==r,enumerable:i.enumerable,value:s[r]}:i},defineProperty(){vc(11)},getPrototypeOf:e=>vd(e.base_),setPrototypeOf(){vc(12)}},vz={};function vF(e,r){let s=e[vl];return(s?vw(s):e)[r]}function vW(e,r){if(!(r in e))return;let s=vd(e);for(;s;){let e=Object.getOwnPropertyDescriptor(s,r);if(e)return e;s=vd(s)}}function v$(e){!e.modified_&&(e.modified_=!0,e.parent_&&v$(e.parent_))}function vH(e){e.copy_||(e.copy_=vS(e.base_,e.scope_.immer_.useStrictShallowCopy_))}function vU(e,r){let s=vy(e)?vE("MapSet").proxyMap_(e,r):vb(e)?vE("MapSet").proxySet_(e,r):function(e,r){let s=Array.isArray(e),i={type_:+!!s,scope_:r?r.scope_:O,modified_:!1,finalized_:!1,assigned_:{},parent_:r,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},n=i,o=vO;s&&(n=[i],o=vz);let{revoke:a,proxy:l}=Proxy.revocable(n,o);return i.draft_=l,i.revoke_=a,l}(e,r);return(r?r.scope_:O).drafts_.push(s),s}vg(vO,(e,r)=>{vz[e]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)}}),vz.deleteProperty=function(e,r){return vz.set.call(this,e,r,void 0)},vz.set=function(e,r,s){return vO.set.call(this,e[0],r,s,e[0])};var vK=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(e,r,s)=>{let i;if("function"==typeof e&&"function"!=typeof r){let s=r;r=e;let i=this;return function(e=s,...n){return i.produce(e,e=>r.call(this,e,...n))}}if("function"!=typeof r&&vc(6),void 0!==s&&"function"!=typeof s&&vc(7),vu(e)){let n=vT(this),o=vU(e,void 0),a=!0;try{i=r(o),a=!1}finally{a?vM(n):vD(n)}return vR(n,s),vL(i,n)}if(e&&"object"==typeof e)vc(1,e);else{if(void 0===(i=r(e))&&(i=e),i===vo&&(i=void 0),this.autoFreeze_&&vC(i,!0),s){let r=[],n=[];vE("Patches").generateReplacementPatches_(e,i,r,n),s(r,n)}return i}},this.produceWithPatches=(e,r)=>{let s,i;return"function"==typeof e?(r,...s)=>this.produceWithPatches(r,r=>e(r,...s)):[this.produce(e,r,(e,r)=>{s=e,i=r}),s,i]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),"boolean"==typeof e?.useStrictIteration&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){var r;vu(e)||vc(8),vh(e)&&(vh(r=e)||vc(10,r),e=function e(r){let s;if(!vu(r)||vj(r))return r;let i=r[vl],n=!0;if(i){if(!i.modified_)return i.base_;i.finalized_=!0,s=vS(r,i.scope_.immer_.useStrictShallowCopy_),n=i.scope_.immer_.shouldUseStrictIteration()}else s=vS(r,!0);return vg(s,(r,i)=>{v_(s,r,e(i))},n),i&&(i.finalized_=!1),s}(r));let s=vT(this),i=vU(e,void 0);return i[vl].isManual_=!0,vD(s),i}finishDraft(e,r){let s=e&&e[vl];s&&s.isManual_||vc(9);let{scope_:i}=s;return vR(i,r),vL(void 0,i)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,r){let s;for(s=r.length-1;s>=0;s--){let i=r[s];if(0===i.path.length&&"replace"===i.op){e=i.value;break}}s>-1&&(r=r.slice(s+1));let i=vE("Patches").applyPatches_;return vh(e)?i(e,r):this.produce(e,e=>i(e,r))}}().produce;function vq(){return"localhost"===window.location.hostname&&"3000"===window.location.port?"http://localhost:5173":""}function vV(e){let r={};e&&(r["Content-Type"]=e);let s=(0,rg.getAuthToken)();return s&&(r.Authorization=`Bearer ${s}`),r}async function vY(e,r,s,i){let n=await fetch(`${vq()}/api/projects/${e}/agent-sessions`,{method:"POST",headers:vV("application/json"),body:JSON.stringify({branch:r,permissionMode:s,agentType:i})});if(!n.ok)throw Error("Failed to create session");return n.json()}async function vX(e,r){let s=await fetch(`${vq()}/api/agent-sessions/${e}/message`,{method:"POST",headers:vV("application/json"),body:JSON.stringify({content:r})});if(!s.ok){let r="";try{let e=await s.json();if(e.errorCode){let s=[`${e.errorCode}`];e.attempts&&s.push(`${e.attempts} attempts`),e.totalDurationMs&&s.push(`${(e.totalDurationMs/1e3).toFixed(1)}s`),r=` (${s.join(", ")})`}else e.error&&(r=` — ${e.error}`)}catch{}throw console.error(`[AgentSession] /message failed: status=${s.status}, sessionId=${e}, detail=${r}`),Error(`Failed to send message [${s.status}]${r}`)}}async function vG(e,r){let s=await fetch(`${vq()}/api/agent-sessions/${e}/paste`,{method:"POST",headers:vV("application/json"),body:JSON.stringify({content:r})});if(!s.ok){let r="";try{let e=await s.json();if(e.errorCode){let s=[`${e.errorCode}`];e.attempts&&s.push(`${e.attempts} attempts`),e.totalDurationMs&&s.push(`${(e.totalDurationMs/1e3).toFixed(1)}s`),r=` (${s.join(", ")})`}else e.error&&(r=` — ${e.error}`)}catch{}throw console.error(`[AgentSession] /paste failed: status=${s.status}, sessionId=${e}, detail=${r}`),Error(`Failed to upload paste [${s.status}]${r}`)}return s.json()}async function vJ(e,r){if(!(await fetch(`${vq()}/api/agent-sessions/${e}/restart`,{method:"POST",headers:vV("application/json"),body:JSON.stringify({agentType:r})})).ok)throw Error("Failed to restart session")}async function vZ(e){if(!(await fetch(`${vq()}/api/agent-sessions/${e}/stop`,{method:"POST",headers:vV()})).ok)throw Error("Failed to stop session")}async function vQ(e,r){if(!(await fetch(`${vq()}/api/agent-sessions/${e}/switch-mode`,{method:"POST",headers:vV("application/json"),body:JSON.stringify({mode:r})})).ok)throw Error("Failed to switch mode")}async function v0(e,r){if(!(await fetch(`${vq()}/api/agent-sessions/${e}/accept-plan`,{method:"POST",headers:vV("application/json"),body:JSON.stringify({planContent:r})})).ok)throw Error("Failed to accept plan")}let v1=new Map;function v2(e,r,s){return`${e}:${r??""}:${s??"latest"}`}async function v5(e){let r=await fetch(`${vq()}/api/agent-sessions/${e}`,{headers:vV()});if(!r.ok)throw Error(`Session ${e} not found`);return r.json()}let v3=(0,ew.default)("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]),v4=(0,ew.default)("wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]]),v6=(0,ew.default)("brain",[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]]),v8=(0,ew.default)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),v7=(0,ew.default)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),v9=(0,ew.default)("circle-question-mark",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),xe=(0,ew.default)("file-check",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m9 15 2 2 4-4",key:"1grp1n"}]]),xt=(0,ew.default)("list-todo",[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]]),xr=(0,ew.default)("file-text",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]),xs=(0,ew.default)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),xi=(0,ew.default)("folder-search",[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]]),xn=(0,ew.default)("workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]),xo=(0,ew.default)("file-pen-line",[["path",{d:"m18.226 5.226-2.52-2.52A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-.351",key:"1k2beg"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}],["path",{d:"M8 18h1",key:"13wk12"}]]),xa=(0,ew.default)("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]]),xl=(0,ew.default)("file-plus-corner",[["path",{d:"M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35",key:"17jvcc"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M14 19h6",key:"bvotb8"}],["path",{d:"M17 16v6",key:"18yu1i"}]]),xc=(0,ew.default)("earth",[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),xd=(0,ew.default)("shield-alert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);var xh="horizontal",xu=["horizontal","vertical"],xf=W.forwardRef((e,r)=>{var s;let{decorative:i,orientation:n=xh,...o}=e,a=(s=n,xu.includes(s))?n:xh;return(0,F.jsx)(er.div,{"data-orientation":a,...i?{role:"none"}:{"aria-orientation":"vertical"===a?a:void 0,role:"separator"},...o,ref:r})});xf.displayName="Separator",e.s(["Root",()=>xf,"Separator",()=>xf],691102),e.i(691102),(0,lT.cva)("flex w-fit items-stretch [&>*]:focus-visible:z-10 [&>*]:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md has-[>[data-slot=button-group]]:gap-2",{variants:{orientation:{horizontal:"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}}),(0,ew.default)("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);var xp=e.i(94265);let xm=({className:e,from:r,...s})=>(0,F.jsx)("div",{className:(0,ey.cn)("group flex w-full max-w-[95%] flex-col gap-2","user"===r?"is-user ml-auto justify-end":"is-assistant",e),...s}),xg=({children:e,className:r,...s})=>(0,F.jsx)("div",{className:(0,ey.cn)("is-user:dark flex w-fit max-w-full min-w-0 flex-col gap-2 overflow-hidden text-sm","group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground","group-[.is-assistant]:text-foreground",r),...s,children:e}),xv=(0,W.memo)(({className:e,...r})=>(0,F.jsx)(xp.i,{className:(0,ey.cn)("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...r}),(e,r)=>e.children===r.children);xv.displayName="MessageResponse";function xx({input:e,messageIndex:r}){let{sendMessage:s,messages:i}=y4(),n=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&Array.isArray(r.questions)&&r.questions.length>0&&r.questions.every(e=>"string"==typeof e.question&&"string"==typeof e.header&&Array.isArray(e.options)))return r}catch{}return null}(e),o=i[r+1],a=o?.type==="user",l=a?o.content:"",c="string"==typeof l?l:l.filter(e=>"text"===e.type).map(e=>e.text).join("\n");if(!n){let r="string"==typeof e?e:JSON.stringify(e,null,2);return(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:r.length>500?r.substring(0,500)+"...":r})}return a?(0,F.jsx)(x_,{questions:n.questions,answeredText:c}):(0,F.jsx)(xy,{questions:n.questions,sendMessage:s})}function x_({questions:e,answeredText:r}){return(0,F.jsx)("div",{className:"space-y-3 mt-2",children:e.map((e,s)=>(0,F.jsxs)("div",{className:"rounded-lg border bg-muted/30 p-3",children:[(0,F.jsx)("div",{className:"flex items-center gap-2 mb-1.5",children:(0,F.jsx)(lL,{variant:"secondary",className:"text-[10px]",children:e.header})}),(0,F.jsx)("p",{className:"text-sm text-muted-foreground mb-2",children:e.question}),(0,F.jsxs)("div",{className:"flex items-center gap-2 text-sm text-green-600 dark:text-green-400",children:[(0,F.jsx)(oq,{className:"h-4 w-4"}),(0,F.jsx)("span",{className:"font-medium",children:r})]})]},s))})}function xy({questions:e,sendMessage:r}){let[s,i]=(0,W.useState)(new Map),[n,o]=(0,W.useState)(new Map),[a,l]=(0,W.useState)(new Set),[c,d]=(0,W.useState)(!1);async function h(){let i=[];for(let r=0;r<e.length;r++)if(a.has(r)){let e=n.get(r)?.trim();e&&i.push(e)}else{let e=s.get(r);e&&e.size>0&&i.push(Array.from(e).join(", "))}if(i.length>0){d(!0);try{await r(i.join("\n"))}finally{d(!1)}}}let u=e.some((e,r)=>{if(a.has(r))return!!n.get(r)?.trim();let i=s.get(r);return i&&i.size>0});return(0,F.jsxs)("div",{className:"space-y-4 mt-2",children:[e.map((e,r)=>{let c=s.get(r)||new Set,d=n.get(r)||"",h=a.has(r);return(0,F.jsxs)("div",{className:"rounded-lg border bg-card p-3",children:[(0,F.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[(0,F.jsx)(v9,{className:"h-3.5 w-3.5 text-violet-500"}),(0,F.jsx)(lL,{variant:"secondary",className:"text-[10px]",children:e.header})]}),(0,F.jsx)("p",{className:"text-sm font-medium mb-3",children:e.question}),(0,F.jsxs)("div",{className:"grid gap-2",children:[e.options.map(s=>{let n=c.has(s.label)&&!h;return(0,F.jsx)($.Button,{variant:n?"default":"outline",className:(0,ey.cn)("h-auto py-2 px-3 justify-start text-left whitespace-normal",n&&"ring-2 ring-primary/50"),onClick:()=>{var n,o;return n=s.label,o=e.multiSelect,void(i(e=>{let s=new Map(e),i=new Set(s.get(r)||[]);return o?i.has(n)?i.delete(n):i.add(n):i.has(n)?i.clear():(i.clear(),i.add(n)),s.set(r,i),s}),l(e=>{let s=new Set(e);return s.delete(r),s}))},children:(0,F.jsxs)("div",{children:[(0,F.jsx)("span",{className:"font-medium text-sm",children:s.label}),s.description&&(0,F.jsx)("span",{className:"block text-xs text-muted-foreground mt-0.5",children:s.description})]})},s.label)}),(0,F.jsx)("div",{className:"flex items-center gap-2 mt-1",children:(0,F.jsx)(rn,{placeholder:"Other...",value:d,onChange:e=>{var s;return s=e.target.value,void(o(e=>new Map(e).set(r,s)),s&&(i(e=>{let s=new Map(e);return s.set(r,new Set),s}),l(e=>new Set(e).add(r))))},className:"text-sm"})})]})]},r)}),(0,F.jsxs)($.Button,{onClick:h,disabled:!u||c,size:"sm",className:"active:scale-95 transition-transform",children:[c&&(0,F.jsx)(n2,{className:"h-3.5 w-3.5 animate-spin"}),c?"Submitting...":"Submit"]})]})}function xb(e){try{return JSON.parse(e)}catch{return null}}function xw({input:e,messageIndex:r}){let{messages:s,acceptPlan:i,permissionMode:n,agentType:o}=y4(),[a,l]=(0,W.useState)(!0),[c,d]=(0,W.useState)(!1),h=function(e,r,s){let i="string"==typeof e?xb(e):e;if(i&&"object"==typeof i&&"plan"in i){let e=i.plan;if(e)return e}if("claude-code"===s)for(let e=r.length-1;e>=0;e--){let s=r[e];if("tool_use"===s.type&&"Write"===s.tool){let e="string"==typeof s.input?xb(s.input):s.input;if(e&&"object"==typeof e&&e.file_path?.includes(".claude/plans/")&&e.content)return e.content}}return"Plan written to file"}(e,s,o),u=(0,W.useCallback)(async()=>{d(!0);try{await i(h)}catch{d(!1)}},[i,h]),f="edit"===n,p=!1,m="";for(let e=r+1;e<s.length;e++){let r=s[e];if(r?.type==="user"){p=!0;let e=r.content??"";m="string"==typeof e?e:e.filter(e=>"text"===e.type).map(e=>e.text).join("\n");break}}return(f&&!p&&(p=!0),f||p)?(0,F.jsxs)("div",{className:"space-y-2 mt-2",children:[f?(0,F.jsxs)(lL,{variant:"default",className:"bg-green-600 hover:bg-green-700 text-white",children:[(0,F.jsx)(oq,{className:"h-3 w-3 mr-1"}),"Plan Accepted"]}):(0,F.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,F.jsx)(pw,{className:"h-3.5 w-3.5"}),(0,F.jsxs)("span",{children:["Feedback sent: ",m.length>100?m.substring(0,100)+"...":m]})]}),(0,F.jsxs)("details",{open:!f,children:[(0,F.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"View Plan"}),(0,F.jsx)("div",{className:"mt-2 rounded-lg border p-3 bg-muted/30",children:(0,F.jsx)("div",{className:"text-sm prose prose-sm dark:prose-invert max-w-none break-words [&_pre]:overflow-x-auto [&_pre]:max-w-full [&_code]:break-all [&_p]:break-words",children:(0,F.jsx)(xv,{children:h})})})]})]}):(0,F.jsxs)("div",{className:"space-y-3 mt-2",children:[(0,F.jsxs)("div",{className:"rounded-lg border p-3 bg-card",children:[(0,F.jsxs)("button",{onClick:()=>l(!a),className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground mb-2 block",children:[a?"Collapse":"Expand"," Plan"]}),a&&(0,F.jsx)("div",{className:"text-sm prose prose-sm dark:prose-invert max-w-none break-words [&_pre]:overflow-x-auto [&_pre]:max-w-full [&_code]:break-all [&_p]:break-words max-h-96 overflow-y-auto",children:(0,F.jsx)(xv,{children:h})})]}),(0,F.jsxs)($.Button,{onClick:u,disabled:c,className:"bg-green-600 hover:bg-green-700 text-white",size:"sm",children:[c?(0,F.jsx)(n2,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):(0,F.jsx)(rd,{className:"h-3.5 w-3.5 mr-1.5"}),c?"Accepting Plan...":"Accept Plan & Start Editing"]})]})}function xS({requestId:e,command:r,cwd:s,messageIndex:i}){let{messages:n,sessionId:o}=y4(),[a,l]=(0,W.useState)(!1),[c,d]=(0,W.useState)(null),h=!1;for(let e=i+1;e<n.length;e++)if(n[e]?.type==="user"){h=!0;break}c&&(h=!0);let u=(0,W.useCallback)(async r=>{if(o){l(!0),d(r);try{await (0,rg.sendApprovalResponse)(o,e,r)}catch{d(null),l(!1)}}},[o,e]);return h?(0,F.jsxs)("div",{className:"space-y-2 mt-2",children:[(0,F.jsxs)("div",{className:"rounded-lg border bg-muted/30 p-3",children:[(0,F.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,F.jsx)(n5.Terminal,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,F.jsx)("span",{className:"text-xs text-muted-foreground",children:"Command"})]}),(0,F.jsx)("pre",{className:"text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:r||"(empty)"}),s&&(0,F.jsxs)("p",{className:"text-xs text-muted-foreground mt-1",children:["cwd: ",s]})]}),(0,F.jsxs)(lL,{variant:"default",className:"decline"===c?"bg-red-600 hover:bg-red-700 text-white":"bg-green-600 hover:bg-green-700 text-white",children:[(0,F.jsx)(oq,{className:"h-3 w-3 mr-1"}),"decline"===c?"Denied":"Allowed"]})]}):(0,F.jsxs)("div",{className:"space-y-2 mt-2",children:[(0,F.jsxs)("div",{className:"rounded-lg border bg-card p-3",children:[(0,F.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,F.jsx)(n5.Terminal,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,F.jsx)("span",{className:"text-xs text-muted-foreground",children:"Command"})]}),(0,F.jsx)("pre",{className:"text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:r||"(empty)"}),s&&(0,F.jsxs)("p",{className:"text-xs text-muted-foreground mt-1",children:["cwd: ",s]})]}),(0,F.jsxs)("div",{className:"flex gap-2",children:[(0,F.jsxs)($.Button,{onClick:()=>u("accept"),disabled:a,className:"bg-green-600 hover:bg-green-700 text-white",size:"sm",children:[a&&"accept"===c?(0,F.jsx)(n2,{className:"h-3.5 w-3.5 mr-1 animate-spin"}):(0,F.jsx)(oq,{className:"h-3.5 w-3.5 mr-1"}),"Allow"]}),(0,F.jsxs)($.Button,{onClick:()=>u("decline"),disabled:a,variant:"destructive",size:"sm",children:[a&&"decline"===c?(0,F.jsx)(n2,{className:"h-3.5 w-3.5 mr-1 animate-spin"}):(0,F.jsx)(oV,{className:"h-3.5 w-3.5 mr-1"}),"Deny"]})]})]})}function xC({requestId:e,changes:r,messageIndex:s}){let{messages:i,sessionId:n}=y4(),[o,a]=(0,W.useState)(!1),[l,c]=(0,W.useState)(null),d=!1;for(let e=s+1;e<i.length;e++)if(i[e]?.type==="user"){d=!0;break}l&&(d=!0);let h=(0,W.useCallback)(async r=>{if(n){a(!0),c(r);try{await (0,rg.sendApprovalResponse)(n,e,r)}catch{c(null),a(!1)}}},[n,e]),u=r??[],f=()=>(0,F.jsx)("div",{className:"rounded-lg border bg-muted/30 p-3 space-y-2",children:0===u.length?(0,F.jsx)("p",{className:"text-xs text-muted-foreground",children:"No file changes"}):u.map((e,r)=>(0,F.jsxs)("div",{children:[(0,F.jsxs)("div",{className:"flex items-center gap-2",children:[(0,F.jsx)(xr,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),(0,F.jsx)("code",{className:"text-xs break-all",children:e.path}),(0,F.jsx)(lL,{variant:"secondary",className:`text-[10px] ${function(e){switch(e){case"added":case"add":return"bg-green-500/10 text-green-600";case"deleted":case"delete":return"bg-red-500/10 text-red-600";default:return"bg-blue-500/10 text-blue-600"}}(e.kind)}`,children:function(e){switch(e){case"added":case"add":return"added";case"deleted":case"delete":return"deleted";default:return"modified"}}(e.kind)})]}),e.diff&&(0,F.jsxs)("details",{className:"mt-1",children:[(0,F.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"View diff"}),(0,F.jsx)("pre",{className:"mt-1 text-xs p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:e.diff.split("\n").map((e,r)=>{let s="";return e.startsWith("+")?s="bg-green-500/10 text-green-700 dark:text-green-400":e.startsWith("-")&&(s="bg-red-500/10 text-red-700 dark:text-red-400"),(0,F.jsx)("div",{className:s,children:e},r)})})]})]},r))});return d?(0,F.jsxs)("div",{className:"space-y-2 mt-2",children:[f(),(0,F.jsxs)(lL,{variant:"default",className:"decline"===l?"bg-red-600 hover:bg-red-700 text-white":"bg-green-600 hover:bg-green-700 text-white",children:[(0,F.jsx)(oq,{className:"h-3 w-3 mr-1"}),"decline"===l?"Denied":"Allowed"]})]}):(0,F.jsxs)("div",{className:"space-y-2 mt-2",children:[f(),(0,F.jsxs)("div",{className:"flex gap-2",children:[(0,F.jsxs)($.Button,{onClick:()=>h("accept"),disabled:o,className:"bg-green-600 hover:bg-green-700 text-white",size:"sm",children:[o&&"accept"===l?(0,F.jsx)(n2,{className:"h-3.5 w-3.5 mr-1 animate-spin"}):(0,F.jsx)(oq,{className:"h-3.5 w-3.5 mr-1"}),"Allow"]}),(0,F.jsxs)($.Button,{onClick:()=>h("decline"),disabled:o,variant:"destructive",size:"sm",children:[o&&"decline"===l?(0,F.jsx)(n2,{className:"h-3.5 w-3.5 mr-1 animate-spin"}):(0,F.jsx)(oV,{className:"h-3.5 w-3.5 mr-1"}),"Deny"]})]})]})}let xk=(0,ew.default)("circle-plus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);var xj=e.i(252512);let xN=(0,ew.default)("badge",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}]]);function xE({status:e,className:r}){switch(e){case"completed":return(0,F.jsx)(oq,{className:(0,ey.cn)("h-4 w-4 text-green-500",r)});case"in_progress":return(0,F.jsx)(n2,{className:(0,ey.cn)("h-4 w-4 text-cyan-500 animate-spin",r)});case"pending":default:return(0,F.jsx)(nV,{className:(0,ey.cn)("h-4 w-4 text-muted-foreground",r)});case"deleted":return(0,F.jsx)(oV,{className:(0,ey.cn)("h-4 w-4 text-red-400",r)})}}function xR(e,r){try{let s="string"==typeof e?JSON.parse(e):e;if(s&&"object"==typeof s&&r(s))return s}catch{}return null}function xM({input:e}){let r="string"==typeof e?e:JSON.stringify(e,null,2);return(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:r.length>500?r.substring(0,500)+"...":r})}function xD({input:e}){let r=xR(e,e=>Array.isArray(e.todos)&&e.todos.length>0);return r?(0,F.jsx)("div",{className:"mt-2 space-y-1",children:r.todos.map((e,r)=>(0,F.jsxs)("div",{className:"flex items-start gap-2 py-0.5",children:[(0,F.jsx)(xE,{status:e.status,className:"mt-0.5 flex-shrink-0"}),(0,F.jsxs)("div",{className:"min-w-0",children:[(0,F.jsx)("span",{className:(0,ey.cn)("text-sm break-words","completed"===e.status&&"line-through text-muted-foreground"),children:e.subject??e.content??"Untitled task"}),"in_progress"===e.status&&e.activeForm&&(0,F.jsx)("span",{className:"block text-xs italic text-cyan-500",children:e.activeForm})]})]},e.id??r))}):(0,F.jsx)(xM,{input:e})}function xT({input:e}){let r=xR(e,e=>"string"==typeof e.subject);return r?(0,F.jsxs)("div",{className:"mt-2 flex items-start gap-2",children:[(0,F.jsx)(xk,{className:"h-4 w-4 text-cyan-500 mt-0.5 flex-shrink-0"}),(0,F.jsxs)("div",{className:"min-w-0",children:[(0,F.jsx)("span",{className:"text-sm font-medium break-words",children:r.subject}),r.description&&(0,F.jsx)("span",{className:"block text-xs text-muted-foreground mt-0.5 break-words",children:r.description.length>200?r.description.substring(0,200)+"...":r.description})]})]}):(0,F.jsx)(xM,{input:e})}function xP({input:e}){let r=xR(e,e=>"string"==typeof e.taskId);return r?(0,F.jsxs)("div",{className:"mt-2 flex items-start gap-2 flex-wrap",children:[r.status?(0,F.jsx)(xE,{status:r.status,className:"mt-0.5 flex-shrink-0"}):(0,F.jsx)(xj.ArrowRight,{className:"h-4 w-4 text-cyan-500 mt-0.5 flex-shrink-0"}),(0,F.jsxs)("span",{className:"text-sm break-words",children:["Task #",r.taskId,r.status&&(0,F.jsxs)(F.Fragment,{children:[" ",(0,F.jsx)(xj.ArrowRight,{className:"inline h-3 w-3 text-muted-foreground mx-0.5"})," ",r.status]}),r.subject&&(0,F.jsxs)("span",{className:"text-muted-foreground",children:[" — ",r.subject]})]}),r.addBlockedBy&&r.addBlockedBy.length>0&&(0,F.jsx)("div",{className:"flex gap-1 mt-1 w-full pl-6",children:r.addBlockedBy.map(e=>(0,F.jsxs)(lL,{variant:"outline",className:"text-[10px]",children:[(0,F.jsx)(xN,{className:"h-2.5 w-2.5 mr-0.5"}),"blocked by #",e]},e))}),r.addBlocks&&r.addBlocks.length>0&&(0,F.jsx)("div",{className:"flex gap-1 mt-1 w-full pl-6",children:r.addBlocks.map(e=>(0,F.jsxs)(lL,{variant:"outline",className:"text-[10px]",children:[(0,F.jsx)(xN,{className:"h-2.5 w-2.5 mr-0.5"}),"blocks #",e]},e))})]}):(0,F.jsx)(xM,{input:e})}function xL(){return(0,F.jsxs)("div",{className:"mt-2 flex items-center gap-2 text-sm text-muted-foreground",children:[(0,F.jsx)(n2,{className:"h-4 w-4 animate-spin text-cyan-500"}),(0,F.jsx)("span",{children:"Listing tasks..."})]})}function xA({input:e}){let r=xR(e,e=>"string"==typeof e.taskId);return r?(0,F.jsxs)("div",{className:"mt-2 flex items-center gap-2 text-sm text-muted-foreground",children:[(0,F.jsx)(n2,{className:"h-4 w-4 animate-spin text-cyan-500"}),(0,F.jsxs)("span",{children:["Fetching task #",r.taskId,"..."]})]}):(0,F.jsx)(xM,{input:e})}function xB({output:e}){let r=function(e){try{let r=JSON.parse(e);if(Array.isArray(r))return r.filter(e=>e.id&&e.subject).map(e=>({id:String(e.id),subject:String(e.subject),status:e.status||"pending",owner:e.owner?String(e.owner):void 0,blockedBy:Array.isArray(e.blockedBy)?e.blockedBy.map(String):void 0}));let s=r.tasks??r.items??r.data;if(Array.isArray(s))return s.filter(e=>e.id&&e.subject).map(e=>({id:String(e.id),subject:String(e.subject),status:e.status||"pending",owner:e.owner?String(e.owner):void 0,blockedBy:Array.isArray(e.blockedBy)?e.blockedBy.map(String):void 0}))}catch{let r=e.trim().split("\n").filter(Boolean),s=[];for(let e of r){let r=e.match(/^#?(\d+)[\s.:\-]+\[?(completed|in_progress|pending|deleted)\]?\s+(.+)/i);r&&s.push({id:r[1],status:r[2].toLowerCase(),subject:r[3].trim()})}if(s.length>0)return s}return null}(e);return r?(0,F.jsx)("div",{className:"mt-1 space-y-1",children:r.map(e=>(0,F.jsxs)("div",{className:"flex items-start gap-2 py-0.5",children:[(0,F.jsx)(xE,{status:e.status,className:"mt-0.5 flex-shrink-0"}),(0,F.jsxs)("div",{className:"min-w-0 flex items-center gap-1.5 flex-wrap",children:[(0,F.jsxs)("span",{className:"text-xs text-muted-foreground",children:["#",e.id]}),(0,F.jsx)("span",{className:(0,ey.cn)("text-sm break-words","completed"===e.status&&"line-through text-muted-foreground"),children:e.subject}),e.blockedBy&&e.blockedBy.length>0&&(0,F.jsx)(lL,{variant:"outline",className:"text-[10px]",children:"blocked"})]})]},e.id))}):null}function xI({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.file_path)return r;return null}catch{return null}}(e);if(!r)return(0,F.jsx)("pre",{className:"text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:"string"==typeof e?e:JSON.stringify(e,null,2)});let{file_path:s,offset:i,limit:n}=r,o=s.split("/"),a=o.pop()||s,l=o.join("/"),c=null!=i||null!=n,d="";if(c){let e=i??1;d=null!=n?`Lines ${e}\u2013${e+n-1}`:`From line ${e}`}return(0,F.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,F.jsxs)("div",{className:"min-w-0",children:[(0,F.jsx)("span",{className:"text-sm font-medium break-all",children:a}),l&&(0,F.jsx)("p",{className:"text-xs text-muted-foreground truncate",title:s,children:l})]}),c&&(0,F.jsx)(lL,{variant:"outline",className:"text-xs shrink-0",children:d})]})}function xO({output:e}){let r=e.split("\n").length;return(0,F.jsxs)("details",{children:[(0,F.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["File contents (",r," ",1===r?"line":"lines",")"]}),(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function xz({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.file_path)return r;return null}catch{return null}}(e);if(!r)return(0,F.jsx)("pre",{className:"text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:"string"==typeof e?e:JSON.stringify(e,null,2)});let{file_path:s,content:i}=r,n=s.split("/"),o=n.pop()||s,a=n.join("/"),l=i.split("\n").length;return(0,F.jsxs)("div",{className:"space-y-1",children:[(0,F.jsxs)("div",{className:"min-w-0",children:[(0,F.jsx)("span",{className:"text-sm font-medium break-all",children:o}),a&&(0,F.jsx)("p",{className:"text-xs text-muted-foreground truncate",title:s,children:a})]}),(0,F.jsxs)("details",{children:[(0,F.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Content (",l," ",1===l?"line":"lines",")"]}),(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:i.length>1e3?i.substring(0,1e3)+"...":i})]})]})}function xF({output:e}){return e&&""!==e.trim()?(0,F.jsxs)("details",{children:[(0,F.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"Result"}),(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:e.length>1e3?e.substring(0,1e3)+"...":e})]}):(0,F.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"File written"})}function xW({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.command)return r;return null}catch{return null}}(e);if(!r)return(0,F.jsx)("pre",{className:"text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:"string"==typeof e?e:JSON.stringify(e,null,2)});let{command:s,description:i,timeout:n}=r;return(0,F.jsxs)("div",{className:"space-y-1",children:[i&&(0,F.jsx)("p",{className:"text-xs text-muted-foreground",children:i}),(0,F.jsxs)("div",{className:"flex items-start gap-2",children:[(0,F.jsxs)("pre",{className:"flex-1 min-w-0 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:[(0,F.jsx)("span",{className:"text-muted-foreground select-none",children:"$ "}),s]}),null!=n&&(0,F.jsx)(lL,{variant:"outline",className:"text-xs shrink-0 mt-1",children:function(e){if(e>=6e4){let r=e/6e4;return`${r%1==0?r:r.toFixed(1)}m`}return`${e/1e3}s`}(n)})]})]})}function x$({output:e}){if(!e||""===e.trim())return(0,F.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No output"});let r=e.split("\n").length;return(0,F.jsxs)("details",{children:[(0,F.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Output (",r," ",1===r?"line":"lines",")"]}),(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function xH({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.pattern)return r;return null}catch{return null}}(e);if(!r)return(0,F.jsx)("pre",{className:"text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:"string"==typeof e?e:JSON.stringify(e,null,2)});let s=[];return r.path&&s.push({label:r.path}),r.glob&&s.push({label:r.glob}),r.type&&s.push({label:`.${r.type}`}),r.output_mode&&"files_with_matches"!==r.output_mode&&s.push({label:r.output_mode}),null!=r.context&&s.push({label:`context: ${r.context}`}),null!=r["-C"]&&s.push({label:`context: ${r["-C"]}`}),null!=r["-B"]&&s.push({label:`before: ${r["-B"]}`}),null!=r["-A"]&&s.push({label:`after: ${r["-A"]}`}),r["-i"]&&s.push({label:"case-insensitive"}),r.multiline&&s.push({label:"multiline"}),null!=r.head_limit&&s.push({label:`limit: ${r.head_limit}`}),null!=r.offset&&s.push({label:`offset: ${r.offset}`}),(0,F.jsxs)("div",{className:"space-y-1",children:[(0,F.jsx)("div",{className:"flex items-start gap-2",children:(0,F.jsxs)("pre",{className:"flex-1 min-w-0 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:[(0,F.jsx)("span",{className:"text-muted-foreground select-none",children:"/ "}),r.pattern]})}),s.length>0&&(0,F.jsx)("div",{className:"flex items-center gap-1.5 flex-wrap",children:s.map((e,r)=>(0,F.jsx)(lL,{variant:"outline",className:"text-xs",children:e.label},r))})]})}function xU({output:e}){if(!e||""===e.trim())return(0,F.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No matches"});let r=e.split("\n").length;return(0,F.jsxs)("details",{children:[(0,F.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Results (",r," ",1===r?"line":"lines",")"]}),(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function xK({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.pattern)return r;return null}catch{return null}}(e);return r?(0,F.jsxs)("div",{className:"space-y-1",children:[(0,F.jsx)("div",{className:"flex items-start gap-2",children:(0,F.jsx)("pre",{className:"flex-1 min-w-0 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:r.pattern})}),r.path&&(0,F.jsx)("div",{className:"flex items-center gap-1.5 flex-wrap",children:(0,F.jsx)(lL,{variant:"outline",className:"text-xs",children:r.path})})]}):(0,F.jsx)("pre",{className:"text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:"string"==typeof e?e:JSON.stringify(e,null,2)})}function xq({output:e}){if(!e||""===e.trim())return(0,F.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No matches"});let r=e.trim().split("\n").length;return(0,F.jsxs)("details",{children:[(0,F.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:[r," ",1===r?"file":"files"," found"]}),(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}let xV={Explore:"Explore",Bash:"Bash",Plan:"Plan","general-purpose":"General","code-simplifier":"Simplify","superpowers:code-reviewer":"Review","memory-leak-detector":"Memory","directory-structure-validator":"Structure","tech-docs-finder":"Docs","claude-code-guide":"Guide","statusline-setup":"Status"};function xY({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.description&&"string"==typeof r.subagent_type)return r;return null}catch{return null}}(e);if(!r)return(0,F.jsx)("pre",{className:"text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:"string"==typeof e?e:JSON.stringify(e,null,2)});let{description:s,subagent_type:i,prompt:n,model:o,max_turns:a,resume:l,run_in_background:c}=r,d=[];return d.push({label:xV[i]||i}),o&&d.push({label:o}),null!=a&&d.push({label:`${a} turns`}),c&&d.push({label:"background"}),l&&d.push({label:"resume"}),(0,F.jsxs)("div",{className:"space-y-1",children:[(0,F.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,F.jsx)("span",{className:"text-sm",children:s}),d.map((e,r)=>(0,F.jsx)(lL,{variant:"outline",className:"text-xs shrink-0",children:e.label},r))]}),n&&(0,F.jsxs)("details",{children:[(0,F.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Prompt (",n.length>1e3?`${Math.round(n.length/1e3)}k chars`:`${n.length} chars`,")"]}),(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:n.length>1e3?n.substring(0,1e3)+"...":n})]})]})}function xX({output:e}){if(!e||""===e.trim())return(0,F.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No output"});let r=e.split("\n").length;return(0,F.jsxs)("details",{children:[(0,F.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Agent result (",r," ",1===r?"line":"lines",")"]}),(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function xG(e,r){return e.length>r?e.substring(0,r)+"...":e}function xJ({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.file_path&&"string"==typeof r.old_string&&"string"==typeof r.new_string)return r;return null}catch{return null}}(e);if(!r)return(0,F.jsx)("pre",{className:"text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:"string"==typeof e?e:JSON.stringify(e,null,2)});let{file_path:s,old_string:i,new_string:n,replace_all:o}=r,a=s.split("/"),l=a.pop()||s,c=a.join("/"),d=i.split("\n").length,h=n.split("\n").length;return(0,F.jsxs)("div",{className:"space-y-1",children:[(0,F.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,F.jsxs)("div",{className:"min-w-0",children:[(0,F.jsx)("span",{className:"text-sm font-medium break-all",children:l}),c&&(0,F.jsx)("p",{className:"text-xs text-muted-foreground truncate",title:s,children:c})]}),(0,F.jsx)(lL,{variant:"outline",className:"text-xs shrink-0",children:d===h?`${d} ${1===d?"line":"lines"}`:`${d}\u2192${h} lines`}),o&&(0,F.jsx)(lL,{variant:"outline",className:"text-xs shrink-0",children:"replace all"})]}),(0,F.jsxs)("details",{children:[(0,F.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"Diff"}),(0,F.jsxs)("div",{className:"mt-1 text-xs rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full",children:[(0,F.jsxs)("pre",{className:"bg-red-500/10 p-1.5 rounded-t whitespace-pre-wrap break-all",children:[(0,F.jsx)("span",{className:"text-red-500 select-none",children:"- "}),xG(i,500)]}),(0,F.jsxs)("pre",{className:"bg-green-500/10 p-1.5 rounded-b whitespace-pre-wrap break-all",children:[(0,F.jsx)("span",{className:"text-green-500 select-none",children:"+ "}),xG(n,500)]})]})]})]})}function xZ({output:e}){if(!e||""===e.trim())return(0,F.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No output"});if(e.length<=200)return(0,F.jsx)("p",{className:"text-xs text-muted-foreground",children:e});let r=e.split("\n").length;return(0,F.jsxs)("details",{children:[(0,F.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Result (",r," ",1===r?"line":"lines",")"]}),(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function xQ({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.url&&"string"==typeof r.prompt)return r;return null}catch{return null}}(e);if(!r)return(0,F.jsx)("pre",{className:"text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:"string"==typeof e?e:JSON.stringify(e,null,2)});let{display:s,href:i}=function(e){try{let r=new URL(e),s="/"===r.pathname?"":r.pathname,i=r.hostname+s;return{display:i.length>80?i.substring(0,77)+"...":i,href:e}}catch{return{display:e.length>80?e.substring(0,77)+"...":e,href:e}}}(r.url),n=r.prompt.length>150?r.prompt.substring(0,147)+"...":r.prompt;return(0,F.jsxs)("div",{className:"space-y-1",children:[(0,F.jsx)("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"block text-xs font-mono text-blue-500 hover:underline truncate",children:s}),(0,F.jsxs)("p",{className:"text-xs text-muted-foreground",children:['"',n,'"']})]})}function x0({output:e}){if(!e||""===e.trim())return(0,F.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No content fetched"});let r=e.split("\n").length;return(0,F.jsxs)("details",{children:[(0,F.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Response (",r," ",1===r?"line":"lines",")"]}),(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function x1({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.query)return r;return null}catch{return null}}(e);return r?(0,F.jsxs)("div",{className:"space-y-1.5",children:[(0,F.jsx)("p",{className:"text-xs font-mono bg-muted/50 px-2 py-1 rounded break-words",children:r.query}),r.allowed_domains&&r.allowed_domains.length>0&&(0,F.jsxs)("div",{className:"flex items-center gap-1 flex-wrap",children:[(0,F.jsx)("span",{className:"text-xs text-muted-foreground",children:"only:"}),r.allowed_domains.map(e=>(0,F.jsx)(lL,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:e},e))]}),r.blocked_domains&&r.blocked_domains.length>0&&(0,F.jsxs)("div",{className:"flex items-center gap-1 flex-wrap",children:[(0,F.jsx)("span",{className:"text-xs text-muted-foreground",children:"exclude:"}),r.blocked_domains.map(e=>(0,F.jsx)(lL,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:e},e))]})]}):(0,F.jsx)("pre",{className:"text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:"string"==typeof e?e:JSON.stringify(e,null,2)})}function x2({output:e}){if(!e||""===e.trim())return(0,F.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No search results"});let r=e.split("\n").length;return(0,F.jsxs)("details",{children:[(0,F.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Results (",r," ",1===r?"line":"lines",")"]}),(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function x5({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.skill)return r;return null}catch{return null}}(e);return r?(0,F.jsxs)("div",{className:"space-y-1",children:[(0,F.jsx)("p",{className:"text-xs font-mono text-pink-500",children:r.skill}),r.args&&(0,F.jsxs)("p",{className:"text-xs text-muted-foreground truncate",children:["args: ",r.args]})]}):(0,F.jsx)("pre",{className:"text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:"string"==typeof e?e:JSON.stringify(e,null,2)})}function x3({output:e}){if(!e||""===e.trim())return(0,F.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No output"});let r=e.split("\n").length;return(0,F.jsxs)("details",{children:[(0,F.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Loaded (",r," ",1===r?"line":"lines",")"]}),(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function x4({input:e}){let r=function(e){try{let r="string"==typeof e?JSON.parse(e):e;if(r&&"object"==typeof r&&"string"==typeof r.task_id)return r;return null}catch{return null}}(e);if(!r)return(0,F.jsx)("pre",{className:"text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:"string"==typeof e?e:JSON.stringify(e,null,2)});let{task_id:s,block:i,timeout:n}=r,o=[];return o.push({label:!1===i?"non-blocking":"blocking"}),null!=n&&o.push({label:`${Math.round(n/1e3)}s`}),(0,F.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,F.jsx)("code",{className:"text-sm bg-muted/50 px-1.5 py-0.5 rounded",children:s}),o.map((e,r)=>(0,F.jsx)(lL,{variant:"outline",className:"text-xs shrink-0",children:e.label},r))]})}function x6({output:e}){if(!e||""===e.trim())return(0,F.jsx)("p",{className:"text-xs text-muted-foreground italic",children:"No output"});let r=e.split("\n").length;return(0,F.jsxs)("details",{children:[(0,F.jsxs)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:["Task output (",r," ",1===r?"line":"lines",")"]}),(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:e.length>1e3?e.substring(0,1e3)+"...":e})]})}function x8({input:e}){let r="string"==typeof e?function(e){try{return JSON.parse(e)}catch{return null}}(e):e,s=r?.changes??[];return 0===s.length?(0,F.jsx)("p",{className:"text-xs text-muted-foreground",children:"No file changes"}):(0,F.jsx)("div",{className:"space-y-2 mt-1",children:s.map((e,r)=>(0,F.jsxs)("div",{children:[(0,F.jsxs)("div",{className:"flex items-center gap-2",children:[(0,F.jsx)(xr,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),(0,F.jsx)("code",{className:"text-xs break-all",children:e.path}),(0,F.jsx)(lL,{variant:"secondary",className:`text-[10px] ${function(e){switch(e){case"added":case"add":return"bg-green-500/10 text-green-600";case"deleted":case"delete":return"bg-red-500/10 text-red-600";default:return"bg-blue-500/10 text-blue-600"}}(e.kind)}`,children:function(e){switch(e){case"added":case"add":return"added";case"deleted":case"delete":return"deleted";default:return"modified"}}(e.kind)})]}),e.diff&&(0,F.jsxs)("details",{className:"mt-1",children:[(0,F.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"View diff"}),(0,F.jsx)("pre",{className:"mt-1 text-xs p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:e.diff.split("\n").map((e,r)=>{let s="";return e.startsWith("+")?s="bg-green-500/10 text-green-700 dark:text-green-400":e.startsWith("-")&&(s="bg-red-500/10 text-red-700 dark:text-red-400"),(0,F.jsx)("div",{className:s,children:e},r)})})]})]},r))})}function x7({output:e}){let r=e.toLowerCase(),s="text-muted-foreground";return r.includes("completed")||r.includes("success")?s="text-green-600 dark:text-green-400":r.includes("failed")||r.includes("error")?s="text-red-600 dark:text-red-400":(r.includes("declined")||r.includes("denied"))&&(s="text-amber-600 dark:text-amber-400"),(0,F.jsx)("p",{className:`text-xs ${s}`,children:e})}function x9({path:e,size:r}){let s;return(0,F.jsxs)("span",{className:"inline-flex items-center gap-1.5 rounded-md border border-border bg-muted/60 px-1.5 py-0.5 text-xs font-mono align-baseline",title:e,children:[(0,F.jsx)(xr,{className:"w-3 h-3 text-muted-foreground shrink-0"}),(0,F.jsx)("span",{className:"truncate max-w-[18ch]",children:(s=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\")))>=0?e.slice(s+1):e}),(0,F.jsx)("span",{className:"text-muted-foreground",children:function(e){if(e<1024)return`${e} B`;let r=e/1024;return r<10?`${r.toFixed(1)} KB`:r<1024?`${Math.round(r)} KB`:`${(r/1024).toFixed(1)} MB`}(r)})]})}let _e=/<vpaste path="([^"]+)" size="(\d+)" \/>/g;function _t({message:e,messageIndex:r}){let s=function(e,r){switch(e.type){case"user":return(0,F.jsx)(_i,{content:e.content});case"assistant":return(0,F.jsx)(_n,{content:e.content});case"tool_use":return(0,F.jsx)(_o,{tool:e.tool,input:e.input,messageIndex:r});case"tool_result":return(0,F.jsx)(_a,{tool:e.tool,output:e.output});case"thinking":return(0,F.jsx)(_l,{content:e.content});case"error":return(0,F.jsx)(_c,{message:e.message});case"system":return(0,F.jsx)(_d,{content:e.content});case"approval_request":return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-amber-500/10 flex items-center justify-center",children:(0,F.jsx)(xd,{className:"w-4 h-4 text-amber-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-amber-500 mb-1",children:"command"===e.requestType?"Command Approval":"File Change Approval"}),"command"===e.requestType?(0,F.jsx)(xS,{requestId:e.requestId,command:e.command,cwd:e.cwd,messageIndex:r}):(0,F.jsx)(xC,{requestId:e.requestId,changes:e.changes,messageIndex:r})]})]});default:return null}}(e,r);return s?(0,F.jsxs)("div",{className:"group relative",children:[s,(0,F.jsx)("span",{className:"pointer-events-none absolute right-0 top-3 text-xs tabular-nums text-muted-foreground opacity-0 transition-opacity duration-150 group-hover:opacity-100",children:function(e){let r=new Date(e),s=new Date,i=r.getFullYear()===s.getFullYear()&&r.getMonth()===s.getMonth()&&r.getDate()===s.getDate(),n=r.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});if(i)return n;let o=r.toLocaleDateString(void 0,{year:"numeric",month:"2-digit",day:"2-digit"});return`${o} ${n}`}(e.timestamp)})]}):null}let _r=[...Object.values(xp.f),function(){return e=>(function e(r){if(!Array.isArray(r.children))return;let s=[];for(let i of r.children)"text"===i.type&&"string"==typeof i.value&&/\r?\n/.test(i.value)?i.value.split(/\r?\n/).forEach((e,r)=>{r>0&&s.push({type:"break"}),e&&s.push({type:"text",value:e})}):(e(i),s.push(i));r.children=s})(e)}];function _s(e){let r=function(e){let r,s=[],i=0,n=RegExp(_e.source,"g");for(;null!==(r=n.exec(e));)r.index>i&&s.push({kind:"text",text:e.slice(i,r.index)}),s.push({kind:"chip",path:r[1],size:Number(r[2])}),i=r.index+r[0].length;return i<e.length&&s.push({kind:"text",text:e.slice(i)}),s}(e);return 1===r.length&&"text"===r[0].kind?(0,F.jsx)(xv,{remarkPlugins:_r,children:e??""}):(0,F.jsx)("div",{className:"text-sm text-foreground prose prose-sm dark:prose-invert max-w-none break-words [&_pre]:overflow-x-auto [&_pre]:max-w-full [&_code]:break-all [&_p]:break-words",children:r.map((e,r)=>"text"===e.kind?(0,F.jsx)(W.Fragment,{children:(0,F.jsx)(xv,{remarkPlugins:_r,children:e.text})},r):(0,F.jsx)(x9,{path:e.path,size:e.size},r))})}function _i({content:e}){return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-primary/10 flex items-center justify-center",children:(0,F.jsx)(v3,{className:"w-3.5 h-3.5 text-primary"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-foreground mb-1",children:"You"}),(0,F.jsx)("div",{className:"text-sm text-foreground prose prose-sm dark:prose-invert max-w-none break-words [&_pre]:overflow-x-auto [&_pre]:max-w-full [&_code]:break-all [&_p]:break-words",children:"string"==typeof e?_s(e):e.map((e,r)=>"text"===e.type?(0,F.jsx)(W.Fragment,{children:_s(e.text)},r):(0,F.jsx)("img",{src:`data:${e.mediaType};base64,${e.data}`,alt:"Attached image",className:"max-w-sm rounded-lg mt-2"},r))})]})]})}function _n({content:e}){let r="codex"===function(){try{return y4().agentType}catch{return"claude-code"}}();return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:`flex-shrink-0 w-7 h-7 rounded-lg ${r?"bg-green-500/10":"bg-violet-500/10"} flex items-center justify-center`,children:(0,F.jsx)(n3,{className:`w-3.5 h-3.5 ${r?"text-green-500":"text-violet-500"}`})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:`text-sm font-medium ${r?"text-green-500":"text-violet-500"} mb-1`,children:r?"Codex":"Claude"}),(0,F.jsx)("div",{className:"text-sm text-foreground prose prose-sm dark:prose-invert max-w-none break-words [&_pre]:overflow-x-auto [&_pre]:max-w-full [&_code]:break-all [&_p]:break-words",children:(0,F.jsx)(xv,{children:e??""})})]})]})}function _o({tool:e,input:r,messageIndex:s}){if("AskUserQuestion"===e)return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-violet-500/10 flex items-center justify-center",children:(0,F.jsx)(v9,{className:"w-4 h-4 text-violet-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-violet-500 mb-1",children:"Question"}),(0,F.jsx)(xx,{input:r,messageIndex:s})]})]});if("ExitPlanMode"===e)return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-green-500/10 flex items-center justify-center",children:(0,F.jsx)(xe,{className:"w-4 h-4 text-green-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-green-500 mb-1",children:"Plan Ready"}),(0,F.jsx)(xw,{input:r,messageIndex:s})]})]});let i={TodoWrite:{label:"Tasks",ui:(0,F.jsx)(xD,{input:r})},TaskCreate:{label:"Create Task",ui:(0,F.jsx)(xT,{input:r})},TaskUpdate:{label:"Update Task",ui:(0,F.jsx)(xP,{input:r})},TaskList:{label:"Task List",ui:(0,F.jsx)(xL,{})},TaskGet:{label:"Get Task",ui:(0,F.jsx)(xA,{input:r})}}[e];if(i)return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-cyan-500/10 flex items-center justify-center",children:(0,F.jsx)(xt,{className:"w-4 h-4 text-cyan-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-cyan-500 mb-1",children:i.label}),i.ui]})]});if("Read"===e)return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-sky-500/10 flex items-center justify-center",children:(0,F.jsx)(xr,{className:"w-4 h-4 text-sky-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-sky-500 mb-1",children:"Read File"}),(0,F.jsx)(xI,{input:r})]})]});if("Edit"===e)return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-sky-500/10 flex items-center justify-center",children:(0,F.jsx)(xo,{className:"w-4 h-4 text-sky-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-sky-500 mb-1",children:"Edit File"}),(0,F.jsx)(xJ,{input:r})]})]});if("Write"===e)return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-sky-500/10 flex items-center justify-center",children:(0,F.jsx)(xl,{className:"w-4 h-4 text-sky-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-sky-500 mb-1",children:"Write File"}),(0,F.jsx)(xz,{input:r})]})]});if("Bash"===e)return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-emerald-500/10 flex items-center justify-center",children:(0,F.jsx)(n5.Terminal,{className:"w-4 h-4 text-emerald-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-emerald-500 mb-1",children:"Run Command"}),(0,F.jsx)(xW,{input:r})]})]});if("Grep"===e)return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-orange-500/10 flex items-center justify-center",children:(0,F.jsx)(xs,{className:"w-4 h-4 text-orange-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-orange-500 mb-1",children:"Search"}),(0,F.jsx)(xH,{input:r})]})]});if("Glob"===e)return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-teal-500/10 flex items-center justify-center",children:(0,F.jsx)(xi,{className:"w-4 h-4 text-teal-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-teal-500 mb-1",children:"Glob"}),(0,F.jsx)(xK,{input:r})]})]});if("Task"===e||"Agent"===e)return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-purple-500/10 flex items-center justify-center",children:(0,F.jsx)(xn,{className:"w-4 h-4 text-purple-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-purple-500 mb-1",children:"Agent"}),(0,F.jsx)(xY,{input:r})]})]});if("TaskOutput"===e)return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-purple-500/10 flex items-center justify-center",children:(0,F.jsx)(xn,{className:"w-4 h-4 text-purple-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-purple-500 mb-1",children:"Task Output"}),(0,F.jsx)(x4,{input:r})]})]});if("WebFetch"===e)return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-blue-500/10 flex items-center justify-center",children:(0,F.jsx)(rx,{className:"w-4 h-4 text-blue-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-blue-500 mb-1",children:"Fetch Web Page"}),(0,F.jsx)(xQ,{input:r})]})]});if("WebSearch"===e)return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-indigo-500/10 flex items-center justify-center",children:(0,F.jsx)(xc,{className:"w-4 h-4 text-indigo-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-indigo-500 mb-1",children:"Web Search"}),(0,F.jsx)(x1,{input:r})]})]});if("Skill"===e)return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-pink-500/10 flex items-center justify-center",children:(0,F.jsx)(xa,{className:"w-4 h-4 text-pink-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-pink-500 mb-1",children:"Skill"}),(0,F.jsx)(x5,{input:r})]})]});if("FileChange"===e)return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-sky-500/10 flex items-center justify-center",children:(0,F.jsx)(xo,{className:"w-4 h-4 text-sky-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-sky-500 mb-1",children:"File Changes"}),(0,F.jsx)(x8,{input:r})]})]});let n="string"==typeof r?r:JSON.stringify(r,null,2);return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-amber-500/10 flex items-center justify-center",children:(0,F.jsx)(v4,{className:"w-4 h-4 text-amber-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsxs)("p",{className:"text-sm font-medium text-amber-500 mb-1 break-words",children:["Tool: ",e]}),(0,F.jsxs)("details",{open:!0,children:[(0,F.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"Input"}),(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-w-full whitespace-pre-wrap break-all",children:n.length>500?n.substring(0,500)+"...":n})]})]})]})}function _a({tool:e,output:r}){if(["TodoWrite","TaskCreate","TaskUpdate","TaskList","TaskGet"].includes(e)){let s="TaskList"===e?(0,F.jsx)(xB,{output:r}):null;return(0,F.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsxs)("p",{className:"text-xs text-muted-foreground mb-1",children:["Result (",e,")"]}),s||(0,F.jsxs)("details",{children:[(0,F.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"Output"}),(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:r.length>1e3?r.substring(0,1e3)+"...":r})]})]})})}if("Read"===e)return(0,F.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,F.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,F.jsx)(xO,{output:r})})});if("Edit"===e)return(0,F.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,F.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,F.jsx)(xZ,{output:r})})});if("Write"===e)return(0,F.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,F.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,F.jsx)(xF,{output:r})})});if("Bash"===e)return(0,F.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,F.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,F.jsx)(x$,{output:r})})});if("Grep"===e)return(0,F.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,F.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,F.jsx)(xU,{output:r})})});if("Glob"===e)return(0,F.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,F.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,F.jsx)(xq,{output:r})})});if("Task"===e||"Agent"===e)return(0,F.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,F.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,F.jsx)(xX,{output:r})})});if("TaskOutput"===e)return(0,F.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,F.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,F.jsx)(x6,{output:r})})});if("WebFetch"===e)return(0,F.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,F.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,F.jsx)(x0,{output:r})})});if("WebSearch"===e)return(0,F.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,F.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,F.jsx)(x2,{output:r})})});if("Skill"===e)return(0,F.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,F.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,F.jsx)(x3,{output:r})})});if("FileChange"===e)return(0,F.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,F.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,F.jsx)(x7,{output:r})})});let s=r.length>200;return(0,F.jsx)("div",{className:"flex gap-3 py-3 pl-11",children:(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsxs)("p",{className:"text-xs text-muted-foreground mb-1",children:["Result",e?` (${e})`:""]}),(0,F.jsxs)("details",{className:(0,ey.cn)(!s&&"open"),children:[(0,F.jsx)("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:"Output"}),(0,F.jsx)("pre",{className:"mt-1 text-xs bg-muted/50 p-2 rounded overflow-x-auto max-h-48 overflow-y-auto max-w-full whitespace-pre-wrap break-all",children:r.length>1e3?r.substring(0,1e3)+"...":r})]})]})})}function _l({content:e}){let r=e??"",s=r.trim().length>0,i=s?r.length>500?r.substring(0,500)+"...":r:"Reasoning unavailable — this model does not expose its thinking content.";return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-blue-500/10 flex items-center justify-center",children:(0,F.jsx)(v6,{className:"w-3.5 h-3.5 text-blue-500"})}),(0,F.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,F.jsxs)("details",{children:[(0,F.jsx)("summary",{className:"text-xs font-medium text-blue-500 cursor-pointer hover:underline",children:"Thinking..."}),(0,F.jsx)("div",{className:`mt-2 text-xs whitespace-pre-wrap break-words bg-blue-500/5 p-2 rounded-md overflow-hidden ${s?"text-muted-foreground":"text-muted-foreground/70 italic"}`,children:i})]})})]})}function _c({message:e}){return(0,F.jsxs)("div",{className:"flex gap-3 py-3",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-red-500/10 flex items-center justify-center",children:(0,F.jsx)(v8,{className:"w-3.5 h-3.5 text-red-500"})}),(0,F.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-red-500 mb-1",children:"Error"}),(0,F.jsx)("p",{className:"text-sm text-red-500/80 break-words",children:e})]})]})}function _d({content:e}){return(0,F.jsxs)("div",{className:"flex gap-3 py-2",children:[(0,F.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-lg bg-gray-500/10 flex items-center justify-center",children:(0,F.jsx)(v7,{className:"w-3.5 h-3.5 text-gray-500"})}),(0,F.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,F.jsx)("p",{className:"text-xs text-muted-foreground break-words",children:e??""})})]})}let _h=(0,ew.default)("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]),_u={damping:.7,stiffness:.05,mass:1.25},_f=1e3/60,_p=!1;function _m(e,r){let s=(0,W.useCallback)(r=>(s.current=r,e(r)),r);return s}globalThis.document?.addEventListener("mousedown",()=>{_p=!0}),globalThis.document?.addEventListener("mouseup",()=>{_p=!1}),globalThis.document?.addEventListener("click",()=>{_p=!1});let _g=new Map;function _v(...e){let r={..._u},s=!1;for(let i of e){if("instant"===i){s=!0;continue}"object"==typeof i&&(s=!1,r.damping=i.damping??r.damping,r.stiffness=i.stiffness??r.stiffness,r.mass=i.mass??r.mass)}let i=JSON.stringify(r);return _g.has(i)||_g.set(i,Object.freeze(r)),s?"instant":_g.get(i)}let _x=(0,W.createContext)(null),__="undefined"!=typeof window?W.useLayoutEffect:W.useEffect;function _y({instance:e,children:r,resize:s,initial:i,mass:n,damping:o,stiffness:a,targetScrollTop:l,contextRef:c,...d}){let h=(0,W.useRef)(null),u=((e={})=>{let[r,s]=(0,W.useState)(!1),[i,n]=(0,W.useState)(!1!==e.initial),[o,a]=(0,W.useState)(!1),l=(0,W.useRef)(null);l.current=e;let c=(0,W.useCallback)(()=>{if(!_p)return!1;let e=window.getSelection();if(!e||!e.rangeCount)return!1;let r=e.getRangeAt(0);return r.commonAncestorContainer.contains(v.current)||v.current?.contains(r.commonAncestorContainer)},[]),d=(0,W.useCallback)(e=>{u.isAtBottom=e,n(e)},[]),h=(0,W.useCallback)(e=>{u.escapedFromLock=e,s(e)},[]),u=(0,W.useMemo)(()=>{let s;return{escapedFromLock:r,isAtBottom:i,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return v.current?.scrollTop??0},set scrollTop(scrollTop){v.current&&(v.current.scrollTop=scrollTop,u.ignoreScrollToTop=v.current.scrollTop)},get targetScrollTop(){if(!v.current||!x.current)return 0;return v.current.scrollHeight-1-v.current.clientHeight},get calculatedTargetScrollTop(){if(!v.current||!x.current)return 0;let{targetScrollTop:r}=this;if(!e.targetScrollTop)return r;if(s?.targetScrollTop===r)return s.calculatedScrollTop;let i=Math.max(Math.min(e.targetScrollTop(r,{scrollElement:v.current,contentElement:x.current}),r),0);return s={targetScrollTop:r,calculatedScrollTop:i},requestAnimationFrame(()=>{s=void 0}),i},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=70}}},[]),f=(0,W.useCallback)((e={})=>{let r;"string"==typeof e&&(e={animation:e}),e.preserveScrollPosition||d(!0);let s=Date.now()+(Number(e.wait)||0),i=_v(l.current,e.animation),{ignoreEscapes:n=!1}=e,o=u.calculatedTargetScrollTop;e.duration instanceof Promise?e.duration.finally(()=>{r=Date.now()}):r=s+(e.duration??0);let a=async()=>{let e=new Promise(requestAnimationFrame).then(()=>{if(!u.isAtBottom)return u.animation=void 0,!1;let{scrollTop:d}=u,h=performance.now(),p=(h-(u.lastTick??h))/_f;if(u.animation||(u.animation={behavior:i,promise:e,ignoreEscapes:n}),u.animation.behavior===i&&(u.lastTick=h),c()||s>Date.now())return a();if(d<Math.min(o,u.calculatedTargetScrollTop)){if(u.animation?.behavior===i){if("instant"===i)return u.scrollTop=u.calculatedTargetScrollTop,a();u.velocity=(i.damping*u.velocity+i.stiffness*u.scrollDifference)/i.mass,u.accumulated+=u.velocity*p,u.scrollTop+=u.accumulated,u.scrollTop!==d&&(u.accumulated=0)}return a()}return r>Date.now()?(o=u.calculatedTargetScrollTop,a()):(u.animation=void 0,u.scrollTop<u.calculatedTargetScrollTop)?f({animation:_v(l.current,l.current.resize),ignoreEscapes:n,duration:Math.max(0,r-Date.now())||void 0}):u.isAtBottom});return e.then(e=>(requestAnimationFrame(()=>{u.animation||(u.lastTick=void 0,u.velocity=0)}),e))};return(!0!==e.wait&&(u.animation=void 0),u.animation?.behavior===i)?u.animation.promise:a()},[d,c,u]),p=(0,W.useCallback)(()=>{h(!0),d(!1)},[h,d]),m=(0,W.useCallback)(({target:e})=>{if(e!==v.current)return;let{scrollTop:r,ignoreScrollToTop:s}=u,{lastScrollTop:i=r}=u;u.lastScrollTop=r,u.ignoreScrollToTop=void 0,s&&s>r&&(i=s),a(u.isNearBottom),setTimeout(()=>{if(u.resizeDifference||r===s)return;if(c()){h(!0),d(!1);return}let e=r>i,n=r<i;if(u.animation?.ignoreEscapes){u.scrollTop=i;return}n&&(h(!0),d(!1)),e&&h(!1),!u.escapedFromLock&&u.isNearBottom&&d(!0)},1)},[h,d,c,u]),g=(0,W.useCallback)(({target:e,deltaY:r})=>{let s=e;for(;!["scroll","auto"].includes(getComputedStyle(s).overflow);){if(!s.parentElement)return;s=s.parentElement}s===v.current&&r<0&&v.current.scrollHeight>v.current.clientHeight&&!u.animation?.ignoreEscapes&&(h(!0),d(!1))},[h,d,u]),v=_m(e=>{v.current?.removeEventListener("scroll",m),v.current?.removeEventListener("wheel",g),e?.addEventListener("scroll",m,{passive:!0}),e?.addEventListener("wheel",g,{passive:!0})},[]),x=_m(e=>{let r;u.resizeObserver?.disconnect(),e&&(u.resizeObserver=new ResizeObserver(([e])=>{let{height:s}=e.contentRect,i=s-(r??s);if(u.resizeDifference=i,u.scrollTop>u.targetScrollTop&&(u.scrollTop=u.targetScrollTop),a(u.isNearBottom),i>=0){let e=_v(l.current,r?l.current.resize:l.current.initial);f({animation:e,wait:!0,preserveScrollPosition:!0,duration:"instant"===e?void 0:350})}else u.isNearBottom&&(h(!1),d(!0));r=s,requestAnimationFrame(()=>{setTimeout(()=>{u.resizeDifference===i&&(u.resizeDifference=0)},1)})}),u.resizeObserver?.observe(e))},[]);return{contentRef:x,scrollRef:v,scrollToBottom:f,stopScroll:p,isAtBottom:i||o,isNearBottom:o,escapedFromLock:r,state:u}})({mass:n,damping:o,stiffness:a,resize:s,initial:i,targetScrollTop:W.useCallback((e,r)=>{let s=y?.targetScrollTop??l;return s?.(e,r)??e},[l])}),{scrollRef:f,contentRef:p,scrollToBottom:m,stopScroll:g,isAtBottom:v,escapedFromLock:x,state:_}=e??u,y=(0,W.useMemo)(()=>({scrollToBottom:m,stopScroll:g,scrollRef:f,isAtBottom:v,escapedFromLock:x,contentRef:p,state:_,get targetScrollTop(){return h.current},set targetScrollTop(targetScrollTop){h.current=targetScrollTop}}),[m,v,p,f,g,x,_]);return(0,W.useImperativeHandle)(c,()=>y,[y]),__(()=>{f.current&&"visible"===getComputedStyle(f.current).overflow&&(f.current.style.overflow="auto")},[]),W.createElement(_x.Provider,{value:y},W.createElement("div",{...d},"function"==typeof r?r(y):r))}function _b(){let e=(0,W.useContext)(_x);if(!e)throw Error("use-stick-to-bottom component context must be used within a StickToBottom component");return e}(_y||(_y={})).Content=function({children:e,scrollClassName:r,...s}){let i=_b();return W.createElement("div",{ref:i.scrollRef,style:{height:"100%",width:"100%",scrollbarGutter:"stable both-edges"},className:r},W.createElement("div",{...s,ref:i.contentRef},"function"==typeof e?e(i):e))};let _w=({className:e,...r})=>(0,F.jsx)(_y,{className:(0,ey.cn)("relative flex-1 overflow-y-hidden",e),initial:"smooth",resize:"smooth",role:"log",...r}),_S=({className:e,...r})=>(0,F.jsx)(_y.Content,{className:(0,ey.cn)("flex flex-col gap-8 p-4",e),...r}),_C=({className:e,...r})=>{let{isAtBottom:s,scrollToBottom:i}=_b(),n=(0,W.useCallback)(()=>{i()},[i]);return!s&&(0,F.jsx)($.Button,{className:(0,ey.cn)("absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full",e),onClick:n,size:"icon",type:"button",variant:"outline",...r,children:(0,F.jsx)(_h,{className:"size-4"})})};var _k=/[\\\/_+.#"@\[\(\{&]/,_j=/[\\\/_+.#"@\[\(\{&]/g,_N=/[\s-]/,_E=/[\s-]/g;function _R(e){return e.toLowerCase().replace(_E," ")}var _M=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,r)=>{let s=lE(`Primitive.${r}`),i=W.forwardRef((e,i)=>{let{asChild:n,...o}=e;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,F.jsx)(n?s:r,{...o,ref:i})});return i.displayName=`Primitive.${r}`,{...e,[r]:i}},{}),_D='[cmdk-group=""]',_T='[cmdk-group-items=""]',_P='[cmdk-item=""]',_L=`${_P}:not([aria-disabled="true"])`,_A="cmdk-item-select",_B="data-value",_I=(e,r,s)=>{var i;return i=e,function e(r,s,i,n,o,a,l){if(a===s.length)return o===r.length?1:.99;var c=`${o},${a}`;if(void 0!==l[c])return l[c];for(var d,h,u,f,p=n.charAt(a),m=i.indexOf(p,o),g=0;m>=0;)(d=e(r,s,i,n,m+1,a+1,l))>g&&(m===o?d*=1:_k.test(r.charAt(m-1))?(d*=.8,(u=r.slice(o,m-1).match(_j))&&o>0&&(d*=Math.pow(.999,u.length))):_N.test(r.charAt(m-1))?(d*=.9,(f=r.slice(o,m-1).match(_E))&&o>0&&(d*=Math.pow(.999,f.length))):(d*=.17,o>0&&(d*=Math.pow(.999,m-o))),r.charAt(m)!==s.charAt(a)&&(d*=.9999)),(d<.1&&i.charAt(m-1)===n.charAt(a+1)||n.charAt(a+1)===n.charAt(a)&&i.charAt(m-1)!==n.charAt(a))&&.1*(h=e(r,s,i,n,m+1,a+2,l))>d&&(d=.1*h),d>g&&(g=d),m=i.indexOf(p,m+1);return l[c]=g,g}(i=s&&s.length>0?`${i+" "+s.join(" ")}`:i,r,_R(i),_R(r),0,0,{})},_O=W.createContext(void 0),_z=W.createContext(void 0),_F=W.createContext(void 0),_W=W.forwardRef((e,r)=>{let s=_G(()=>{var r,s;return{search:"",value:null!=(s=null!=(r=e.value)?r:e.defaultValue)?s:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),i=_G(()=>new Set),n=_G(()=>new Map),o=_G(()=>new Map),a=_G(()=>new Set),l=_Y(e),{label:c,children:d,value:h,onValueChange:u,filter:f,shouldFilter:p,loop:m,disablePointerSelection:g=!1,vimBindings:v=!0,...x}=e,_=ej(),y=ej(),b=ej(),w=W.useRef(null),S=_Q();_X(()=>{if(void 0!==h){let e=h.trim();s.current.value=e,C.emit()}},[h]),_X(()=>{S(6,M)},[]);let C=W.useMemo(()=>({subscribe:e=>(a.current.add(e),()=>a.current.delete(e)),snapshot:()=>s.current,setState:(e,r,i)=>{var n,o,a,c;if(!Object.is(s.current[e],r)){if(s.current[e]=r,"search"===e)R(),N(),S(1,E);else if("value"===e){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let e=document.getElementById(b);e?e.focus():null==(n=document.getElementById(_))||n.focus()}if(S(7,()=>{var e;s.current.selectedItemId=null==(e=D())?void 0:e.id,C.emit()}),i||S(5,M),(null==(o=l.current)?void 0:o.value)!==void 0){null==(c=(a=l.current).onValueChange)||c.call(a,null!=r?r:"");return}}C.emit()}},emit:()=>{a.current.forEach(e=>e())}}),[]),k=W.useMemo(()=>({value:(e,r,i)=>{var n;r!==(null==(n=o.current.get(e))?void 0:n.value)&&(o.current.set(e,{value:r,keywords:i}),s.current.filtered.items.set(e,j(r,i)),S(2,()=>{N(),C.emit()}))},item:(e,r)=>(i.current.add(e),r&&(n.current.has(r)?n.current.get(r).add(e):n.current.set(r,new Set([e]))),S(3,()=>{R(),N(),s.current.value||E(),C.emit()}),()=>{o.current.delete(e),i.current.delete(e),s.current.filtered.items.delete(e);let r=D();S(4,()=>{R(),(null==r?void 0:r.getAttribute("id"))===e&&E(),C.emit()})}),group:e=>(n.current.has(e)||n.current.set(e,new Set),()=>{o.current.delete(e),n.current.delete(e)}),filter:()=>l.current.shouldFilter,label:c||e["aria-label"],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:_,inputId:b,labelId:y,listInnerRef:w}),[]);function j(e,r){var i,n;let o=null!=(n=null==(i=l.current)?void 0:i.filter)?n:_I;return e?o(e,s.current.search,r):0}function N(){if(!s.current.search||!1===l.current.shouldFilter)return;let e=s.current.filtered.items,r=[];s.current.filtered.groups.forEach(s=>{let i=n.current.get(s),o=0;i.forEach(r=>{o=Math.max(e.get(r),o)}),r.push([s,o])});let i=w.current;T().sort((r,s)=>{var i,n;let o=r.getAttribute("id"),a=s.getAttribute("id");return(null!=(i=e.get(a))?i:0)-(null!=(n=e.get(o))?n:0)}).forEach(e=>{let r=e.closest(_T);r?r.appendChild(e.parentElement===r?e:e.closest(`${_T} > *`)):i.appendChild(e.parentElement===i?e:e.closest(`${_T} > *`))}),r.sort((e,r)=>r[1]-e[1]).forEach(e=>{var r;let s=null==(r=w.current)?void 0:r.querySelector(`${_D}[${_B}="${encodeURIComponent(e[0])}"]`);null==s||s.parentElement.appendChild(s)})}function E(){let e=T().find(e=>"true"!==e.getAttribute("aria-disabled")),r=null==e?void 0:e.getAttribute(_B);C.setState("value",r||void 0)}function R(){var e,r,a,c;if(!s.current.search||!1===l.current.shouldFilter){s.current.filtered.count=i.current.size;return}s.current.filtered.groups=new Set;let d=0;for(let n of i.current){let i=j(null!=(r=null==(e=o.current.get(n))?void 0:e.value)?r:"",null!=(c=null==(a=o.current.get(n))?void 0:a.keywords)?c:[]);s.current.filtered.items.set(n,i),i>0&&d++}for(let[e,r]of n.current)for(let i of r)if(s.current.filtered.items.get(i)>0){s.current.filtered.groups.add(e);break}s.current.filtered.count=d}function M(){var e,r,s;let i=D();i&&((null==(e=i.parentElement)?void 0:e.firstChild)===i&&(null==(s=null==(r=i.closest(_D))?void 0:r.querySelector('[cmdk-group-heading=""]'))||s.scrollIntoView({block:"nearest"})),i.scrollIntoView({block:"nearest"}))}function D(){var e;return null==(e=w.current)?void 0:e.querySelector(`${_P}[aria-selected="true"]`)}function T(){var e;return Array.from((null==(e=w.current)?void 0:e.querySelectorAll(_L))||[])}function P(e){let r=T()[e];r&&C.setState("value",r.getAttribute(_B))}function L(e){var r;let s=D(),i=T(),n=i.findIndex(e=>e===s),o=i[n+e];null!=(r=l.current)&&r.loop&&(o=n+e<0?i[i.length-1]:n+e===i.length?i[0]:i[n+e]),o&&C.setState("value",o.getAttribute(_B))}function A(e){let r=D(),s=null==r?void 0:r.closest(_D),i;for(;s&&!i;)i=null==(s=e>0?function(e,r){let s=e.nextElementSibling;for(;s;){if(s.matches(r))return s;s=s.nextElementSibling}}(s,_D):function(e,r){let s=e.previousElementSibling;for(;s;){if(s.matches(r))return s;s=s.previousElementSibling}}(s,_D))?void 0:s.querySelector(_L);i?C.setState("value",i.getAttribute(_B)):L(e)}let B=()=>P(T().length-1),I=e=>{e.preventDefault(),e.metaKey?B():e.altKey?A(1):L(1)},O=e=>{e.preventDefault(),e.metaKey?P(0):e.altKey?A(-1):L(-1)};return W.createElement(_M.div,{ref:r,tabIndex:-1,...x,"cmdk-root":"",onKeyDown:e=>{var r;null==(r=x.onKeyDown)||r.call(x,e);let s=e.nativeEvent.isComposing||229===e.keyCode;if(!(e.defaultPrevented||s))switch(e.key){case"n":case"j":v&&e.ctrlKey&&I(e);break;case"ArrowDown":I(e);break;case"p":case"k":v&&e.ctrlKey&&O(e);break;case"ArrowUp":O(e);break;case"Home":e.preventDefault(),P(0);break;case"End":e.preventDefault(),B();break;case"Enter":{e.preventDefault();let r=D();if(r){let e=new Event(_A);r.dispatchEvent(e)}}}}},W.createElement("label",{"cmdk-label":"",htmlFor:k.inputId,id:k.labelId,style:_1},c),_0(e,e=>W.createElement(_z.Provider,{value:C},W.createElement(_O.Provider,{value:k},e))))}),_$=W.forwardRef((e,r)=>{var s,i;let n=ej(),o=W.useRef(null),a=W.useContext(_F),l=W.useContext(_O),c=_Y(e),d=null!=(i=null==(s=c.current)?void 0:s.forceMount)?i:null==a?void 0:a.forceMount;_X(()=>{if(!d)return l.item(n,null==a?void 0:a.id)},[d]);let h=_Z(n,o,[e.value,e.children,o],e.keywords),u=W.useContext(_z),f=_J(e=>e.value&&e.value===h.current),p=_J(e=>!!d||!1===l.filter()||!e.search||e.filtered.items.get(n)>0);function m(){var e,r;g(),null==(r=(e=c.current).onSelect)||r.call(e,h.current)}function g(){u.setState("value",h.current,!0)}if(W.useEffect(()=>{let r=o.current;if(!(!r||e.disabled))return r.addEventListener(_A,m),()=>r.removeEventListener(_A,m)},[p,e.onSelect,e.disabled]),!p)return null;let{disabled:v,value:x,onSelect:_,forceMount:y,keywords:b,...w}=e;return W.createElement(_M.div,{ref:(0,U.composeRefs)(o,r),...w,id:n,"cmdk-item":"",role:"option","aria-disabled":!!v,"aria-selected":!!f,"data-disabled":!!v,"data-selected":!!f,onPointerMove:v||l.getDisablePointerSelection()?void 0:g,onClick:v?void 0:m},e.children)}),_H=W.forwardRef((e,r)=>{let{heading:s,children:i,forceMount:n,...o}=e,a=ej(),l=W.useRef(null),c=W.useRef(null),d=ej(),h=W.useContext(_O),u=_J(e=>!!n||!1===h.filter()||!e.search||e.filtered.groups.has(a));_X(()=>h.group(a),[]),_Z(a,l,[e.value,e.heading,c]);let f=W.useMemo(()=>({id:a,forceMount:n}),[n]);return W.createElement(_M.div,{ref:(0,U.composeRefs)(l,r),...o,"cmdk-group":"",role:"presentation",hidden:!u||void 0},s&&W.createElement("div",{ref:c,"cmdk-group-heading":"","aria-hidden":!0,id:d},s),_0(e,e=>W.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":s?d:void 0},W.createElement(_F.Provider,{value:f},e))))}),_U=W.forwardRef((e,r)=>{let{alwaysRender:s,...i}=e,n=W.useRef(null),o=_J(e=>!e.search);return s||o?W.createElement(_M.div,{ref:(0,U.composeRefs)(n,r),...i,"cmdk-separator":"",role:"separator"}):null}),_K=W.forwardRef((e,r)=>{let{onValueChange:s,...i}=e,n=null!=e.value,o=W.useContext(_z),a=_J(e=>e.search),l=_J(e=>e.selectedItemId),c=W.useContext(_O);return W.useEffect(()=>{null!=e.value&&o.setState("search",e.value)},[e.value]),W.createElement(_M.input,{ref:r,...i,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":l,id:c.inputId,type:"text",value:n?e.value:a,onChange:e=>{n||o.setState("search",e.target.value),null==s||s(e.target.value)}})}),_q=W.forwardRef((e,r)=>{let{children:s,label:i="Suggestions",...n}=e,o=W.useRef(null),a=W.useRef(null),l=_J(e=>e.selectedItemId),c=W.useContext(_O);return W.useEffect(()=>{if(a.current&&o.current){let e=a.current,r=o.current,s,i=new ResizeObserver(()=>{s=requestAnimationFrame(()=>{let s=e.offsetHeight;r.style.setProperty("--cmdk-list-height",s.toFixed(1)+"px")})});return i.observe(e),()=>{cancelAnimationFrame(s),i.unobserve(e)}}},[]),W.createElement(_M.div,{ref:(0,U.composeRefs)(o,r),...n,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":i,id:c.listId},_0(e,e=>W.createElement("div",{ref:(0,U.composeRefs)(a,c.listInnerRef),"cmdk-list-sizer":""},e)))}),_V=W.forwardRef((e,r)=>{let{open:s,onOpenChange:i,overlayClassName:n,contentClassName:o,container:a,...l}=e;return W.createElement(tP,{open:s,onOpenChange:i},W.createElement(tO,{container:a},W.createElement(tF,{"cmdk-overlay":"",className:n}),W.createElement(tU,{"aria-label":e.label,"cmdk-dialog":"",className:o},W.createElement(_W,{ref:r,...l}))))});function _Y(e){let r=W.useRef(e);return _X(()=>{r.current=e}),r}Object.assign(_W,{List:_q,Item:_$,Input:_K,Group:_H,Separator:_U,Dialog:_V,Empty:W.forwardRef((e,r)=>_J(e=>0===e.filtered.count)?W.createElement(_M.div,{ref:r,...e,"cmdk-empty":"",role:"presentation"}):null),Loading:W.forwardRef((e,r)=>{let{progress:s,children:i,label:n="Loading...",...o}=e;return W.createElement(_M.div,{ref:r,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":s,"aria-valuemin":0,"aria-valuemax":100,"aria-label":n},_0(e,e=>W.createElement("div",{"aria-hidden":!0},e)))})});var _X="undefined"==typeof window?W.useEffect:W.useLayoutEffect;function _G(e){let r=W.useRef();return void 0===r.current&&(r.current=e()),r}function _J(e){let r=W.useContext(_z),s=()=>e(r.snapshot());return W.useSyncExternalStore(r.subscribe,s,s)}function _Z(e,r,s,i=[]){let n=W.useRef(),o=W.useContext(_O);return _X(()=>{var a;let l=(()=>{var e;for(let r of s){if("string"==typeof r)return r.trim();if("object"==typeof r&&"current"in r)return r.current?null==(e=r.current.textContent)?void 0:e.trim():n.current}})(),c=i.map(e=>e.trim());o.value(e,l,c),null==(a=r.current)||a.setAttribute(_B,l),n.current=l}),n}var _Q=()=>{let[e,r]=W.useState(),s=_G(()=>new Map);return _X(()=>{s.current.forEach(e=>e()),s.current=new Map},[e]),(e,i)=>{s.current.set(e,i),r({})}};function _0({asChild:e,children:r},s){let i;return e&&W.isValidElement(r)?W.cloneElement("function"==typeof(i=r.type)?i(r.props):"render"in i?i.render(r.props):r,{ref:r.ref},s(r.props.children)):s(r)}var _1={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"},_2="HoverCard",[_5,_3]=K(_2,[iv]),_4=iv(),[_6,_8]=_5(_2),_7=e=>{let{__scopeHoverCard:r,children:s,open:i,defaultOpen:n,onOpenChange:o,openDelay:a=700,closeDelay:l=300}=e,c=_4(r),d=W.useRef(0),h=W.useRef(0),u=W.useRef(!1),f=W.useRef(!1),[p,m]=X({prop:i,defaultProp:n??!1,onChange:o,caller:_2}),g=W.useCallback(()=>{clearTimeout(h.current),d.current=window.setTimeout(()=>m(!0),a)},[a,m]),v=W.useCallback(()=>{clearTimeout(d.current),u.current||f.current||(h.current=window.setTimeout(()=>m(!1),l))},[l,m]),x=W.useCallback(()=>m(!1),[m]);return W.useEffect(()=>()=>{clearTimeout(d.current),clearTimeout(h.current)},[]),(0,F.jsx)(_6,{scope:r,open:p,onOpenChange:m,onOpen:g,onClose:v,onDismiss:x,hasSelectionRef:u,isPointerDownOnContentRef:f,children:(0,F.jsx)(iy,{...c,children:s})})};_7.displayName=_2;var _9="HoverCardTrigger",ye=W.forwardRef((e,r)=>{let{__scopeHoverCard:s,...i}=e,n=_8(_9,s),o=_4(s);return(0,F.jsx)(iw,{asChild:!0,...o,children:(0,F.jsx)(er.a,{"data-state":n.open?"open":"closed",...i,ref:r,onPointerEnter:q(e.onPointerEnter,yl(n.onOpen)),onPointerLeave:q(e.onPointerLeave,yl(n.onClose)),onFocus:q(e.onFocus,n.onOpen),onBlur:q(e.onBlur,n.onClose),onTouchStart:q(e.onTouchStart,e=>e.preventDefault())})})});ye.displayName=_9;var yt="HoverCardPortal",[yr,ys]=_5(yt,{forceMount:void 0}),yi=e=>{let{__scopeHoverCard:r,forceMount:s,children:i,container:n}=e,o=_8(yt,r);return(0,F.jsx)(yr,{scope:r,forceMount:s,children:(0,F.jsx)(Z,{present:s||o.open,children:(0,F.jsx)(e$,{asChild:!0,container:n,children:i})})})};yi.displayName=yt;var yn="HoverCardContent",yo=W.forwardRef((e,r)=>{let s=ys(yn,e.__scopeHoverCard),{forceMount:i=s.forceMount,...n}=e,o=_8(yn,e.__scopeHoverCard);return(0,F.jsx)(Z,{present:i||o.open,children:(0,F.jsx)(ya,{"data-state":o.open?"open":"closed",...n,onPointerEnter:q(e.onPointerEnter,yl(o.onOpen)),onPointerLeave:q(e.onPointerLeave,yl(o.onClose)),ref:r})})});yo.displayName=yn;var ya=W.forwardRef((e,r)=>{let{__scopeHoverCard:s,onEscapeKeyDown:i,onPointerDownOutside:n,onFocusOutside:o,onInteractOutside:a,...l}=e,c=_8(yn,s),d=_4(s),h=W.useRef(null),u=(0,U.useComposedRefs)(r,h),[f,p]=W.useState(!1);return W.useEffect(()=>{if(f){let e=document.body;return z=e.style.userSelect||e.style.webkitUserSelect,e.style.userSelect="none",e.style.webkitUserSelect="none",()=>{e.style.userSelect=z,e.style.webkitUserSelect=z}}},[f]),W.useEffect(()=>{if(h.current){let e=()=>{p(!1),c.isPointerDownOnContentRef.current=!1,setTimeout(()=>{document.getSelection()?.toString()!==""&&(c.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",e),()=>{document.removeEventListener("pointerup",e),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!1}}},[c.isPointerDownOnContentRef,c.hasSelectionRef]),W.useEffect(()=>{h.current&&(function(e){let r=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;s.nextNode();)r.push(s.currentNode);return r})(h.current).forEach(e=>e.setAttribute("tabindex","-1"))}),(0,F.jsx)(eM,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:a,onEscapeKeyDown:i,onPointerDownOutside:n,onFocusOutside:q(o,e=>{e.preventDefault()}),onDismiss:c.onDismiss,children:(0,F.jsx)(ij,{...d,...l,onPointerDown:q(l.onPointerDown,e=>{e.currentTarget.contains(e.target)&&p(!0),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!0}),ref:u,style:{...l.style,userSelect:f?"text":void 0,WebkitUserSelect:f?"text":void 0,"--radix-hover-card-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-hover-card-content-available-width":"var(--radix-popper-available-width)","--radix-hover-card-content-available-height":"var(--radix-popper-available-height)","--radix-hover-card-trigger-width":"var(--radix-popper-anchor-width)","--radix-hover-card-trigger-height":"var(--radix-popper-anchor-height)"}})})});function yl(e){return r=>"touch"===r.pointerType?void 0:e()}function yc({...e}){return(0,F.jsx)(_7,{"data-slot":"hover-card",...e})}function yd({...e}){return(0,F.jsx)(ye,{"data-slot":"hover-card-trigger",...e})}function yh({className:e,align:r="center",sideOffset:s=4,...i}){return(0,F.jsx)(yi,{"data-slot":"hover-card-portal",children:(0,F.jsx)(yo,{"data-slot":"hover-card-content",align:r,sideOffset:s,className:(0,ey.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 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 z-50 w-64 origin-(--radix-hover-card-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",e),...i})})}function yu({className:e,...r}){return(0,F.jsx)("div",{"data-slot":"input-group",role:"group",className:(0,ey.cn)("group/input-group border-input dark:bg-input/30 relative flex w-full items-center rounded-md border shadow-xs transition-[color,box-shadow] outline-none","h-9 min-w-0 has-[textarea]:h-auto","has-[>[data-align=inline-start]]:[&>input]:pl-2","has-[>[data-align=inline-end]]:[&>input]:pr-2","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3","has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot=input-group-control]:focus-visible]:ring-[3px]","has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",e),...r})}W.forwardRef((e,r)=>{let{__scopeHoverCard:s,...i}=e,n=_4(s);return(0,F.jsx)(iR,{...n,...i,ref:r})}).displayName="HoverCardArrow";let yf=(0,lT.cva)("text-muted-foreground flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium select-none [&>svg:not([class*='size-'])]:size-4 [&>kbd]:rounded-[calc(var(--radius)-5px)] group-data-[disabled=true]/input-group:opacity-50",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]","block-start":"order-first w-full justify-start px-3 pt-3 [.border-b]:pb-3 group-has-[>input]/input-group:pt-2.5","block-end":"order-last w-full justify-start px-3 pb-3 [.border-t]:pt-3 group-has-[>input]/input-group:pb-2.5"}},defaultVariants:{align:"inline-start"}});function yp({className:e,align:r="inline-start",...s}){return(0,F.jsx)("div",{role:"group","data-slot":"input-group-addon","data-align":r,className:(0,ey.cn)(yf({align:r}),e),onClick:e=>{e.target.closest("button")||e.currentTarget.parentElement?.querySelector("input")?.focus()},...s})}let ym=(0,lT.cva)("text-sm shadow-none flex gap-2 items-center",{variants:{size:{xs:"h-6 gap-1 px-2 rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-3.5 has-[>svg]:px-2",sm:"h-8 px-2.5 gap-1.5 rounded-md has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function yg({className:e,type:r="button",variant:s="ghost",size:i="xs",...n}){return(0,F.jsx)($.Button,{type:r,"data-size":i,variant:s,className:(0,ey.cn)(ym({size:i}),e),...n})}function yv({className:e,...r}){return(0,F.jsx)(ro,{"data-slot":"input-group-control",className:(0,ey.cn)("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent",e),...r})}let yx=(0,ew.default)("corner-down-left",[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]]),y_=(0,ew.default)("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);(0,ew.default)("mic",[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]]);let yy=(0,ew.default)("paperclip",[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]]),yb=(e=21)=>{let r="",s=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)r+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&s[e]];return r},yw=(0,W.createContext)(null),yS=(0,W.createContext)(null),yC=()=>(0,W.useContext)(yw),yk=(0,W.createContext)(null),yj=()=>{let e=(0,W.useContext)(yS),r=(0,W.useContext)(yk),s=e??r;if(!s)throw Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return s};function yN({data:e,className:r,...s}){let i=yj(),n=e.filename||"",o="image"==(e.mediaType?.startsWith("image/")&&e.url?"image":"file"),a=n||(o?"Image":"Attachment");return(0,F.jsxs)(yz,{children:[(0,F.jsx)(yd,{asChild:!0,children:(0,F.jsxs)("div",{className:(0,ey.cn)("group relative flex h-8 cursor-pointer select-none items-center gap-1.5 rounded-md border border-border px-1.5 font-medium text-sm transition-all hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",r),...s,children:[(0,F.jsxs)("div",{className:"relative size-5 shrink-0",children:[(0,F.jsx)("div",{className:"absolute inset-0 flex size-5 items-center justify-center overflow-hidden rounded bg-background transition-opacity group-hover:opacity-0",children:o?(0,F.jsx)("img",{alt:n||"attachment",className:"size-5 object-cover",height:20,src:e.url,width:20}):(0,F.jsx)("div",{className:"flex size-5 items-center justify-center text-muted-foreground",children:(0,F.jsx)(yy,{className:"size-3"})})}),(0,F.jsxs)($.Button,{"aria-label":"Remove attachment",className:"absolute inset-0 size-5 cursor-pointer rounded p-0 opacity-0 transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 [&>svg]:size-2.5",onClick:r=>{r.stopPropagation(),i.remove(e.id)},type:"button",variant:"ghost",children:[(0,F.jsx)(t6,{}),(0,F.jsx)("span",{className:"sr-only",children:"Remove"})]})]}),(0,F.jsx)("span",{className:"flex-1 truncate",children:a})]},e.id)}),(0,F.jsx)(yF,{className:"w-auto p-2",children:(0,F.jsxs)("div",{className:"w-auto space-y-3",children:[o&&(0,F.jsx)("div",{className:"flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",children:(0,F.jsx)("img",{alt:n||"attachment preview",className:"max-h-full max-w-full object-contain",height:384,src:e.url,width:448})}),(0,F.jsx)("div",{className:"flex items-center gap-2.5",children:(0,F.jsxs)("div",{className:"min-w-0 flex-1 space-y-1 px-0.5",children:[(0,F.jsx)("h4",{className:"truncate font-semibold text-sm leading-none",children:n||(o?"Image":"Attachment")}),e.mediaType&&(0,F.jsx)("p",{className:"truncate font-mono text-muted-foreground text-xs",children:e.mediaType})]})})]})})]})}function yE({children:e,className:r,...s}){let i=yj();return i.files.length?(0,F.jsx)("div",{className:(0,ey.cn)("flex flex-wrap items-center gap-2 p-3 w-full",r),...s,children:i.files.map(r=>(0,F.jsx)(W.Fragment,{children:e(r)},r.id))}):null}let yR=({label:e="Add photos or files",...r})=>{let s=yj();return(0,F.jsxs)(nJ,{...r,onSelect:e=>{e.preventDefault(),s.openFileDialog()},children:[(0,F.jsx)(y_,{className:"mr-2 size-4"})," ",e]})},yM=({className:e,accept:r,multiple:s,globalDrop:i,syncHiddenInput:n,maxFiles:o,maxFileSize:a,onError:l,onSubmit:c,children:d,...h})=>{let u=yC(),f=!!u,p=(0,W.useRef)(null),m=(0,W.useRef)(null),[g,v]=(0,W.useState)([]),x=f?u.attachments.files:g,_=(0,W.useRef)(x);_.current=x;let y=(0,W.useCallback)(()=>{p.current?.click()},[]),b=(0,W.useCallback)(e=>!r||""===r.trim()||r.split(",").map(e=>e.trim()).filter(Boolean).some(r=>{if(r.endsWith("/*")){let s=r.slice(0,-1);return e.type.startsWith(s)}return e.type===r}),[r]),w=(0,W.useCallback)(e=>{let r=Array.from(e),s=r.filter(e=>b(e));if(r.length&&0===s.length)return void l?.({code:"accept",message:"No files match the accepted types."});let i=s.filter(e=>!a||e.size<=a);s.length>0&&0===i.length?l?.({code:"max_file_size",message:"All files exceed the maximum size."}):v(e=>{let r="number"==typeof o?Math.max(0,o-e.length):void 0,s="number"==typeof r?i.slice(0,r):i;"number"==typeof r&&i.length>r&&l?.({code:"max_files",message:"Too many files. Some were not added."});let n=[];for(let e of s)n.push({id:yb(),type:"file",url:URL.createObjectURL(e),mediaType:e.type,filename:e.name});return e.concat(n)})},[b,o,a,l]),S=(0,W.useCallback)(e=>v(r=>{let s=r.find(r=>r.id===e);return s?.url&&URL.revokeObjectURL(s.url),r.filter(r=>r.id!==e)}),[]),C=(0,W.useCallback)(()=>v(e=>{for(let r of e)r.url&&URL.revokeObjectURL(r.url);return[]}),[]),k=f?u.attachments.add:w,j=f?u.attachments.remove:S,N=f?u.attachments.clear:C,E=f?u.attachments.openFileDialog:y;(0,W.useEffect)(()=>{f&&u.__registerFileInput(p,()=>p.current?.click())},[f,u]),(0,W.useEffect)(()=>{n&&p.current&&0===x.length&&(p.current.value="")},[x,n]),(0,W.useEffect)(()=>{let e=m.current;if(!e||i)return;let r=e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault()},s=e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault(),e.dataTransfer?.files&&e.dataTransfer.files.length>0&&k(e.dataTransfer.files)};return e.addEventListener("dragover",r),e.addEventListener("drop",s),()=>{e.removeEventListener("dragover",r),e.removeEventListener("drop",s)}},[k,i]),(0,W.useEffect)(()=>{if(!i)return;let e=e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault()},r=e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault(),e.dataTransfer?.files&&e.dataTransfer.files.length>0&&k(e.dataTransfer.files)};return document.addEventListener("dragover",e),document.addEventListener("drop",r),()=>{document.removeEventListener("dragover",e),document.removeEventListener("drop",r)}},[k,i]),(0,W.useEffect)(()=>()=>{if(!f)for(let e of _.current)e.url&&URL.revokeObjectURL(e.url)},[f]);let R=async e=>{try{let r=await fetch(e),s=await r.blob();return new Promise(e=>{let r=new FileReader;r.onloadend=()=>e(r.result),r.onerror=()=>e(null),r.readAsDataURL(s)})}catch{return null}},M=(0,W.useMemo)(()=>({files:x.map(e=>({...e,id:e.id})),add:k,remove:j,clear:N,openFileDialog:E,fileInputRef:p}),[x,k,j,N,E]),D=(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)("input",{accept:r,"aria-label":"Upload files",className:"hidden",multiple:s,onChange:e=>{e.currentTarget.files&&k(e.currentTarget.files),e.currentTarget.value=""},ref:p,title:"Upload files",type:"file"}),(0,F.jsx)("form",{className:(0,ey.cn)("w-full",e),onSubmit:e=>{e.preventDefault();let r=e.currentTarget,s=f?u.textInput.value:new FormData(r).get("message")||"";f||r.reset(),Promise.all(x.map(async({id:e,...r})=>{if(r.url&&r.url.startsWith("blob:")){let e=await R(r.url);return{...r,url:e??r.url}}return r})).then(r=>{try{let i=c({text:s,files:r},e);i instanceof Promise?i.then(()=>{N(),f&&u.textInput.clear()}).catch(()=>{}):(N(),f&&u.textInput.clear())}catch{}}).catch(()=>{})},ref:m,...h,children:(0,F.jsx)(yu,{className:"overflow-hidden",children:d})})]});return f?D:(0,F.jsx)(yk.Provider,{value:M,children:D})},yD=({onChange:e,onKeyDown:r,onPasteText:s,className:i,placeholder:n="What would you like to know?",...o})=>{let a=yC(),l=yj(),[c,d]=(0,W.useState)(!1),h=a?{value:a.textInput.value,onChange:r=>{a.textInput.setInput(r.currentTarget.value),e?.(r)}}:{onChange:e};return(0,F.jsx)(yv,{className:(0,ey.cn)("field-sizing-content max-h-48 min-h-9",i),name:"message",onCompositionEnd:()=>d(!1),onCompositionStart:()=>d(!0),onKeyDown:e=>{if(r?.(e),!e.defaultPrevented){if("Enter"===e.key){if(c||e.nativeEvent.isComposing||e.shiftKey)return;e.preventDefault();let r=e.currentTarget.form,s=r?.querySelector('button[type="submit"]');if(s?.disabled)return;r?.requestSubmit()}if("Backspace"===e.key&&""===e.currentTarget.value&&l.files.length>0){e.preventDefault();let r=l.files.at(-1);r&&l.remove(r.id)}}},onPaste:e=>{let r=e.clipboardData?.items;if(!r)return;let i=[];for(let e of r)if("file"===e.kind){let r=e.getAsFile();r&&i.push(r)}if(i.length>0){e.preventDefault(),l.add(i);return}if(s){let r=e.clipboardData.getData("text");r.length>0&&s(e,r)}},placeholder:n,...o,...h})},yT=({className:e,...r})=>(0,F.jsx)(yp,{align:"block-end",className:(0,ey.cn)("order-first flex-wrap gap-1",e),...r}),yP=({variant:e="ghost",className:r,size:s,...i})=>{let n=s??(W.Children.count(i.children)>1?"sm":"icon-sm");return(0,F.jsx)(yg,{className:(0,ey.cn)(r),size:n,type:"button",variant:e,...i})},yL=e=>(0,F.jsx)(nY,{...e}),yA=({className:e,children:r,...s})=>(0,F.jsx)(nX,{asChild:!0,children:(0,F.jsx)(yP,{className:e,...s,children:r??(0,F.jsx)(eS,{className:"size-4"})})}),yB=({className:e,...r})=>(0,F.jsx)(nG,{align:"start",className:(0,ey.cn)(e),...r}),yI=({className:e,...r})=>(0,F.jsx)(nJ,{className:(0,ey.cn)(e),...r}),yO=({className:e,variant:r="default",size:s="icon-sm",status:i,children:n,...o})=>{let a=(0,F.jsx)(yx,{className:"size-4"});return"submitted"===i?a=(0,F.jsx)(n2,{className:"size-4 animate-spin"}):"streaming"===i?a=(0,F.jsx)(lA,{className:"size-4"}):"error"===i&&(a=(0,F.jsx)(t6,{className:"size-4"})),(0,F.jsx)(yg,{"aria-label":"Submit",className:(0,ey.cn)(e),size:s,type:"submit",variant:r,...o,children:n??a})},yz=({openDelay:e=0,closeDelay:r=0,...s})=>(0,F.jsx)(yc,{closeDelay:r,openDelay:e,...s}),yF=({align:e="start",...r})=>(0,F.jsx)(yh,{align:e,...r}),yW=({size:e=16})=>(0,F.jsxs)("svg",{height:e,strokeLinejoin:"round",style:{color:"currentcolor"},viewBox:"0 0 16 16",width:e,children:[(0,F.jsx)("title",{children:"Loader"}),(0,F.jsxs)("g",{clipPath:"url(#clip0_2393_1490)",children:[(0,F.jsx)("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),(0,F.jsx)("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),(0,F.jsx)("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),(0,F.jsx)("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),(0,F.jsx)("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),(0,F.jsx)("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),(0,F.jsx)("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),(0,F.jsx)("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),(0,F.jsx)("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),(0,F.jsx)("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),(0,F.jsx)("defs",{children:(0,F.jsx)("clipPath",{id:"clip0_2393_1490",children:(0,F.jsx)("rect",{fill:"white",height:"16",width:"16"})})})]}),y$=({className:e,size:r=16,...s})=>(0,F.jsx)("div",{className:(0,ey.cn)("inline-flex animate-spin items-center justify-center",e),...s,children:(0,F.jsx)(yW,{size:r})}),yH=(0,ew.default)("wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]),yU=(0,ew.default)("wifi-off",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),yK=(0,ew.default)("square-pen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]),yq=(0,ew.default)("languages",[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]]),yV=(0,ew.default)("clipboard-list",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);function yY({mode:e,onModeChange:r,disabled:s}){return(0,F.jsxs)("div",{className:"inline-flex items-center rounded-md border bg-muted/50 px-0.5 text-xs",children:[(0,F.jsxs)("button",{onClick:()=>r("plan"),disabled:s,className:(0,ey.cn)("inline-flex items-center gap-1 rounded-sm px-2 py-0.5 transition-colors","plan"===e?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground",s&&"opacity-50 cursor-not-allowed"),children:[(0,F.jsx)(yV,{className:"h-3 w-3"}),"Plan"]}),(0,F.jsxs)("button",{onClick:()=>r("edit"),disabled:s,className:(0,ey.cn)("inline-flex items-center gap-1 rounded-sm px-2 py-0.5 transition-colors","edit"===e?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground",s&&"opacity-50 cursor-not-allowed"),children:[(0,F.jsx)(rp,{className:"h-3 w-3"}),"Edit"]})]})}function yX(e){if(!e)return[];try{let r=window.localStorage.getItem(e);if(!r)return[];let s=JSON.parse(r);if(!Array.isArray(s))return[];return s.filter(e=>"string"==typeof e)}catch{return[]}}function yG(e){if(!e)return"";try{return window.localStorage.getItem(e)??""}catch{return""}}function yJ(e){let r=e.parentElement;for(;r;){let{overflowY:e}=getComputedStyle(r);if("auto"===e||"scroll"===e)return r;r=r.parentElement}return null}function yZ({messages:e,contentRef:r}){let[s,i]=(0,W.useState)([]),[n,o]=(0,W.useState)(!1),[a,l]=(0,W.useState)(null),c=(0,W.useRef)(null),d=(0,W.useCallback)(()=>{let s=r.current;if(!s)return;c.current||(c.current=yJ(s));let n=c.current;if(!n)return;let a=n.scrollHeight>n.clientHeight;if(o(a),!a)return void i([]);let l=s.querySelectorAll("[data-user-msg-idx]"),d=n.getBoundingClientRect(),h=[];l.forEach(r=>{let s=parseInt(r.dataset.userMsgIdx,10),i=(r.getBoundingClientRect().top-d.top+n.scrollTop)/n.scrollHeight;h.push({index:s,position:Math.max(0,Math.min(1,i)),preview:function(e){if("user"!==e.type)return"";let r=e.content,s="string"==typeof r?r:r.filter(e=>"text"===e.type).map(e=>e.text).join(" "),i="string"!=typeof r&&r.some(e=>"image"===e.type),n=s.split("\n")[0]??"";return(n.length>80?n.slice(0,77)+"...":n)||(i?"(Image)":"")}(e[s])})}),i(h)},[e,r]);(0,W.useEffect)(()=>{let e=r.current;if(!e)return;let s=yJ(e);if(!s)return;c.current=s,d();let i=new ResizeObserver(d);return i.observe(s),i.observe(e),()=>{i.disconnect()}},[e,d,r]);let h=(0,W.useCallback)(e=>{let s=r.current;if(!s)return;let i=s.querySelector(`[data-user-msg-idx="${e}"]`);i&&i.scrollIntoView({block:"start",behavior:"smooth"})},[r]);return n&&0!==s.length?(0,F.jsx)("div",{className:"absolute right-0 top-0 bottom-0 w-5 z-20 pointer-events-none",children:s.map(e=>(0,F.jsxs)("div",{className:"absolute right-0.5 -translate-y-1/2 pointer-events-auto",style:{top:`${100*e.position}%`},children:[(0,F.jsx)("div",{className:"w-3 h-[3px] rounded-sm bg-primary/50 hover:bg-primary cursor-pointer transition-colors",onClick:()=>h(e.index),onMouseEnter:()=>l(e.index),onMouseLeave:()=>l(null)}),a===e.index&&e.preview&&(0,F.jsxs)("div",{className:"absolute right-full mr-2 top-1/2 -translate-y-1/2 max-w-64 px-2.5 py-1.5 bg-popover border border-border rounded-md shadow-md text-xs text-popover-foreground whitespace-nowrap overflow-hidden text-ellipsis pointer-events-none",children:[e.preview,(0,F.jsx)("div",{className:"absolute top-1/2 -translate-y-1/2 -right-1 w-2 h-2 bg-popover border-r border-t border-border rotate-45"})]})]},e.index))}):null}function yQ({projectId:e,branch:r,currentSessionId:s,currentEntryCount:i,onSwitch:n,onDelete:o}){let[a,l]=(0,W.useState)([]),[c,d]=(0,W.useState)(null),[h,u]=(0,W.useState)(""),[f,p]=(0,W.useState)(!1),m=(0,W.useCallback)(async()=>{try{let s=await (0,rg.listBranchSessions)(e,r);l(s.sessions)}catch(e){console.error("[SessionHistoryDropdown] refresh failed:",e)}},[e,r]);(0,W.useEffect)(()=>{f&&m()},[f,m]),(0,W.useEffect)(()=>{m()},[m,s]);let g=(0,W.useRef)({sessionId:null,count:0});(0,W.useEffect)(()=>{let e=g.current,r=i??0;e.sessionId===s&&0===e.count&&r>0&&m(),g.current={sessionId:s,count:r}},[s,i,m]);let v=async(e,r)=>{let s=r.trim().length>0?r.trim():null;try{await (0,rg.renameSession)(e,s),l(r=>r.map(r=>r.id===e?{...r,title:s}:r)),d(null),p_.toast.success("Renamed")}catch(e){p_.toast.error("Rename failed"),console.error(e)}},x=async e=>{if(window.confirm("Delete this conversation? This cannot be undone."))try{await (0,rg.deleteSession)(e);let r=a.filter(r=>r.id!==e);l(r),o?.(e,r),p_.toast.success("Deleted")}catch(e){p_.toast.error("Delete failed"),console.error(e)}},_=e=>e.title&&e.title.trim().length>0?e.title:e.updated_at?new Date(e.updated_at).toLocaleString():new Date(e.created_at).toLocaleString(),y=a.find(e=>e.id===s),b=y?_(y):"History";return(0,F.jsxs)(nY,{open:f,onOpenChange:p,children:[(0,F.jsx)(nX,{asChild:!0,children:(0,F.jsxs)($.Button,{variant:"ghost",size:"sm",className:"h-7 text-xs gap-1 max-w-[200px]",title:b,children:[(0,F.jsx)("span",{className:"truncate",children:b}),(0,F.jsx)(r7,{className:"h-3 w-3 flex-shrink-0"})]})}),(0,F.jsxs)(nG,{align:"start",className:"w-80 max-h-96 overflow-y-auto",children:[0===a.length&&(0,F.jsx)("div",{className:"px-2 py-3 text-xs text-muted-foreground",children:"No history yet."}),a.map(e=>{let r=e.id===s,i=c===e.id;return(0,F.jsxs)(nJ,{onSelect:s=>{i?s.preventDefault():r||n(e.id)},className:`flex items-center gap-2 group ${r?"bg-accent text-accent-foreground":""}`,children:[(0,F.jsx)("div",{className:"flex-1 min-w-0",children:i?(0,F.jsxs)("div",{className:"flex items-center gap-1",children:[(0,F.jsx)(rn,{value:h,onChange:e=>u(e.target.value),onKeyDown:r=>{"Enter"===r.key&&v(e.id,h),"Escape"===r.key&&d(null)},autoFocus:!0,className:"h-6 text-xs"}),(0,F.jsx)("button",{type:"button","aria-label":"Save rename",onClick:r=>{r.stopPropagation(),v(e.id,h)},children:(0,F.jsx)(rf.Check,{className:"h-3 w-3"})}),(0,F.jsx)("button",{type:"button","aria-label":"Cancel rename",onClick:e=>{e.stopPropagation(),d(null)},children:(0,F.jsx)(t6,{className:"h-3 w-3"})})]}):(0,F.jsx)("div",{className:"truncate text-xs",title:`${e.updated_at?new Date(e.updated_at).toLocaleString():new Date(e.created_at).toLocaleString()} • ${e.entry_count??0} messages • status: ${e.status}`,children:_(e)})}),!i&&(0,F.jsxs)("div",{className:"opacity-0 group-hover:opacity-100 flex items-center gap-1",children:[(0,F.jsx)("button",{type:"button","aria-label":"Rename conversation",onClick:r=>{r.stopPropagation(),d(e.id),u(e.title??"")},className:"p-1 hover:bg-muted rounded",children:(0,F.jsx)(rp,{className:"h-3 w-3"})}),(0,F.jsx)("button",{type:"button","aria-label":"Delete conversation",onClick:r=>{r.stopPropagation(),x(e.id)},className:"p-1 hover:bg-muted rounded text-destructive",children:(0,F.jsx)(ra,{className:"h-3 w-3"})})]})]},e.id)}),a.length>0&&(0,F.jsx)(n0,{}),(0,F.jsx)(nJ,{onSelect:()=>void m(),className:"text-xs text-muted-foreground",children:"Refresh"})]})]})}let y0=(0,ew.default)("quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]]);function y1(e,r){let s=e;for(;s&&s!==r;){if(s.nodeType===Node.ELEMENT_NODE){let e=s.getAttribute("data-message-idx");if(null!==e)return e}s=s.parentNode}return null}function y2({containerRef:e,onQuote:r}){let[s,i]=(0,W.useState)(null);if((0,W.useEffect)(()=>{function r(){let r=e.current;if(!r)return void i(null);let s=window.getSelection();if(!s||s.isCollapsed||0===s.rangeCount)return void i(null);let n=s.toString();if(!n.trim())return void i(null);let{anchorNode:o,focusNode:a}=s;if(!o||!a||!r.contains(o)||!r.contains(a))return void i(null);let l=y1(o,r),c=y1(a,r);if(null===l||null===c||l!==c)return void i(null);let d=s.getRangeAt(0).getBoundingClientRect();0===d.width&&0===d.height?i(null):i({text:n,rect:{top:d.top,bottom:d.bottom,left:d.left,width:d.width}})}function s(){let e=window.getSelection();e&&!e.isCollapsed&&e.toString().trim()||i(null)}return document.addEventListener("mouseup",r),document.addEventListener("keyup",r),document.addEventListener("touchend",r),document.addEventListener("selectionchange",s),window.addEventListener("scroll",r,!0),window.addEventListener("resize",r),()=>{document.removeEventListener("mouseup",r),document.removeEventListener("keyup",r),document.removeEventListener("touchend",r),document.removeEventListener("selectionchange",s),window.removeEventListener("scroll",r,!0),window.removeEventListener("resize",r)}},[e]),!s||"undefined"==typeof document)return null;let n=s.rect.top-8-28<8?s.rect.bottom+8:s.rect.top-8-28,o=s.rect.left+s.rect.width/2,a=Math.max(8,Math.min(window.innerWidth-8,o));return(0,ee.createPortal)((0,F.jsxs)("button",{type:"button",onMouseDown:e=>{e.preventDefault(),r(s.text),window.getSelection()?.removeAllRanges(),i(null)},style:{position:"fixed",top:n,left:a,transform:"translateX(-50%)",zIndex:50},className:"inline-flex items-center gap-1 rounded-md border border-border bg-popover px-2 py-1 text-xs font-medium text-popover-foreground shadow-md hover:bg-accent",children:[(0,F.jsx)(y0,{className:"h-3 w-3"}),"Quote"]}),document.body)}function y5(){return 0===yj().files.length?null:(0,F.jsx)(yT,{children:(0,F.jsx)(yE,{children:e=>(0,F.jsx)(yN,{data:e})})})}let y3=(0,W.createContext)(null);function y4(){let e=(0,W.useContext)(y3);if(!e)throw Error("useAgentConversation must be used within AgentConversationContext");return e}let y6=/\[📎 paste #(\d+) \([^)]+\)\]/g;function y8(e,r){return`[📎 paste #${e} (${function(e){if(e<1024)return`${e}B`;let r=e/1024;return r<10?`${r.toFixed(1)}KB`:`${Math.round(r)}KB`}(r)})]`}let y7=(0,W.forwardRef)(function({projectId:e,branch:r,sessionId:s,setSessionUrlParam:i,project:n,onAgentModeChange:o,onTaskCompleted:a,onSessionStarted:l,onStatusChange:c},d){let h,u,f,p,[m,g]=function(e,r){let s=e&&r?`vibedeckx:agent-draft:${e}:${r}`:null,[i,n]=(0,W.useState)(()=>yG(s)),[o,a]=(0,W.useState)(s);return o!==s&&(a(s),n(yG(s))),[i,(0,W.useCallback)(e=>{n(e);if(s)try{e?window.localStorage.setItem(s,e):window.localStorage.removeItem(s)}catch{}},[s])]}(e,r),[v,x]=(0,W.useState)([]),[_,y]=(0,W.useState)(1),[b,w]=(0,W.useState)("edit"),[S,C]=(0,W.useState)(!1),[k,j]=(0,W.useState)(!1),[N,E]=(0,W.useState)(!1),[R,M]=(0,W.useState)("claude-code"),[D,T]=(0,W.useState)([]),P=(0,W.useRef)(null),L=(0,W.useRef)(null),A=function(e,r,s){let i=r&&s?`vibedeckx:agent-input-history:${r}:${s}`:null,n=(0,W.useRef)(yX(i)),o=(0,W.useRef)(-1),a=(0,W.useRef)(""),[l,c]=(0,W.useState)(i);return l!==i&&(c(i),n.current=yX(i),o.current=-1,a.current=""),{push:(0,W.useCallback)(e=>{let r=e.trim();if(!r)return;let s=n.current;if(s.length>0&&s[s.length-1]===r){o.current=-1;return}s.push(r),s.length>50&&s.shift(),o.current=-1;if(i)try{0===s.length?window.localStorage.removeItem(i):window.localStorage.setItem(i,JSON.stringify(s))}catch{}},[i]),handleKeyDown:(0,W.useCallback)(r=>{let s=r.currentTarget,i=n.current;if(0!==i.length)if("ArrowUp"===r.key){if(0!==s.selectionStart||0!==s.selectionEnd)return;if(r.preventDefault(),-1===o.current)a.current=s.value,o.current=i.length-1;else{if(!(o.current>0))return;o.current--}e(i[o.current])}else if("ArrowDown"===r.key){if(-1===o.current)return;let n=s.value.length;if(s.selectionStart!==n||s.selectionEnd!==n)return;r.preventDefault(),o.current<i.length-1?(o.current++,e(i[o.current])):(o.current=-1,e(a.current))}else -1!==o.current&&(o.current=-1)},[e])}}(g,e,r),{remotes:B}=r8(n?.id??void 0),I=[];for(let e of(n?.path&&I.push({id:"local",label:"Local",icon:n4.Monitor}),B))I.push({id:e.remote_server_id,label:e.server_name,icon:n6});let{session:O,messages:z,status:H,isConnected:U,isInitialized:K,isLoading:q,error:V,remoteStatus:Y,startSession:X,sendMessage:G,uploadPaste:J,stopSession:Z,restartSession:Q,startNewConversation:ee,switchMode:et,acceptPlan:er}=function(e,r,s,i,n){let o=n?.sessionId??null,[a,l]=(0,W.useState)(null),[c,d]=(0,W.useState)([]),[h,u]=(0,W.useState)("stopped"),[f,p]=(0,W.useState)(!1),[m,g]=(0,W.useState)(!1),[v,x]=(0,W.useState)(!1),[_,y]=(0,W.useState)(null),[b,w]=(0,W.useState)(null),S=(0,W.useRef)(null),C=(0,W.useRef)(null),k=(0,W.useRef)(null),j=(0,W.useRef)(0),N=(0,W.useRef)({entries:[],status:"stopped"}),E=(0,W.useRef)(!1),R=(0,W.useRef)(!0),M=(0,W.useRef)(null),D=(0,W.useRef)(null),T=(0,W.useRef)(0),P=(0,W.useRef)(!1),L=(0,W.useRef)(0),A=(0,W.useRef)(!1),B=(0,W.useRef)(!1),I=(0,W.useRef)(n?.onTaskCompleted),O=(0,W.useRef)(n?.onSessionStarted),z=(0,W.useRef)(e),F=(0,W.useRef)(r),$=(0,W.useRef)(o);(0,W.useEffect)(()=>{I.current=n?.onTaskCompleted,O.current=n?.onSessionStarted,z.current=e,F.current=r,$.current=o});let H=(0,W.useCallback)(e=>{let r=()=>{let e=z.current;if(!e)return;let r=F.current;v1.delete(v2(e,r,$.current));let s=C.current;s&&v1.delete(v2(e,r,s))};if(S.current&&C.current!==e&&(console.log(`[AgentSession] Closing stale WS for ${C.current}, switching to ${e}`),S.current.close(1e3,"session-switch"),S.current=null,C.current=null),S.current?.readyState===WebSocket.OPEN||S.current?.readyState===WebSocket.CONNECTING)return;0===N.current.entries.filter(Boolean).length&&(N.current={entries:[],status:"running"}),E.current=!1,P.current=!0;let s=(0,rg.getWebSocketUrl)(`/api/agent-sessions/${e}/stream`);console.log("[AgentSession] Connecting to WebSocket:",s);let i=new WebSocket(s);S.current=i,C.current=e,i.onopen=()=>{console.log("[AgentSession] WebSocket connected"),p(!0),y(null),w(null),M.current=Date.now(),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{console.log("[AgentSession] Connection stable, resetting backoff counter"),j.current=0,T.current=0},5e3)},i.onmessage=e=>{try{let n=JSON.parse(e.data);if("JsonPatch"in n){var s;let e=n.JsonPatch;s=N.current,N.current=vK(s,r=>{for(let s of e){let{op:e,path:i,value:n}=s;if("/entries"===i&&"replace"===e&&n?.type==="ENTRY"&&n.content?.type==="system"&&n.content?.content==="__CLEAR_ALL__"){console.log("[JsonPatch] Received clearAll signal - clearing all entries"),r.entries=[];continue}if(i.startsWith("/entries/")){let s=parseInt(i.replace("/entries/",""),10);if(isNaN(s)){console.warn(`[JsonPatch] Invalid index in path: ${i}`);continue}if(n?.type!=="ENTRY"){console.warn("[JsonPatch] Expected ENTRY type for entries path");continue}switch(e){case"add":for(;r.entries.length<=s;)r.entries.push(null);r.entries[s]=n.content;break;case"replace":s<r.entries.length?r.entries[s]=n.content:console.warn(`[JsonPatch] Replace index out of bounds: ${s}`);break;case"remove":s<r.entries.length&&r.entries.splice(s,1)}}else"/status"===i&&n?.type==="STATUS"&&(console.log("[AgentSession] /status patch →",n.content),r.status=n.content)}}),P.current?console.log("[AgentSession] /status patch applied during replay (no setStatus), container.status =",N.current.status):(d([...N.current.entries.filter(Boolean)]),console.log("[AgentSession] setStatus(live) →",N.current.status),u(N.current.status),("stopped"===N.current.status||"error"===N.current.status)&&r());return}if("Ready"in n){console.log("[AgentSession] Received Ready signal - history complete, status=",N.current.status),P.current=!1,d([...N.current.entries.filter(Boolean)]),u(N.current.status),g(!0);return}if("finished"in n){console.log("[AgentSession] Received finished signal, invalidating cache"),E.current=!0,r(),i.close(1e3,"finished");return}if("taskCompleted"in n){let{duration_ms:e,cost_usd:r,input_tokens:s,output_tokens:i}=n.taskCompleted,o=[];if(null!=e){let r=(e/1e3).toFixed(1);o.push(`${r}s`)}if(null!=r)o.push(`$${r.toFixed(4)}`);else if(null!=s||null!=i){let e=(s??0)+(i??0),r=e>1e3?`${(e/1e3).toFixed(1)}K`:String(e);o.push(`${r} tokens`)}p_.toast.success("Task completed",{description:o.length>0?o.join(" · "):void 0}),I.current?.();return}if("remoteStatus"in n)return void w(n.remoteStatus);if("error"in n){console.error("[AgentSession] Server error:",n.error),y(n.error),"Session not found"===n.error&&(console.log("[AgentSession] Session invalid, invalidating cache, will create new session"),r(),E.current=!0,l(null),u("stopped"),g(!1),R.current=!0);return}}catch(e){console.error("[AgentSession] Failed to parse message:",e)}},i.onclose=e=>{let s,i;console.log("[AgentSession] WebSocket disconnected",e.code,e.reason),p(!1),D.current&&(clearTimeout(D.current),D.current=null);let n=M.current?Date.now()-M.current:0;if(M.current=null,n>0&&n<5e3){if(T.current++,console.log(`[AgentSession] Short-lived connection (${n}ms), count: ${T.current}, backoff attempt: ${j.current}`),T.current>=3){if(console.log("[AgentSession] Multiple short-lived connections detected, session likely invalid - will recreate"),A.current){console.log("[AgentSession] Skipping auto-restart: last session creation failed"),y("Unable to connect to remote server. Please check the server configuration.");return}r(),l(null),y(null),j.current=0,T.current=0,R.current=!0;return}}else n>=5e3&&(T.current=0);if(E.current||1e3===e.code)return;if(j.current>=10){console.log("[AgentSession] Max reconnect attempts reached"),y("Unable to connect to server. Please check if the backend is running.");return}let o=(i=(s=Math.min(3e4,1e3*Math.pow(2,j.current)))*Math.random()*.25,s+i);console.log(`[AgentSession] Reconnecting in ${Math.round(o)}ms (attempt ${j.current+1})`),j.current++,k.current=setTimeout(()=>{let e=C.current;e&&!E.current&&H(e)},o)},i.onerror=e=>{console.error("[AgentSession] WebSocket error:",e)}},[]),U=(0,W.useCallback)(async s=>{if(!e)return null;if(B.current)return console.log("[AgentSession] startSession already in progress, skipping"),null;B.current=!0;let n=L.current;y(null),w(null),g(!1),A.current=!1;let a=v2(e,r,o),c=v1.get(a);if(c)return console.log(`[AgentSession] Cache hit for ${a}, reconnecting WebSocket directly`),l(c),u(c.status),H(c.id),O.current?.(),B.current=!1,c;x(!0);try{console.log(`[AgentSession] Starting REST call: projectId=${e}, branch=${r}, sessionId=${o??"latest"}, agentType=${i}, generation=${n}`);let{session:c,messages:h}=o?await v5(o):await vY(e,r,s,i);if(console.log(`[AgentSession] REST response: sessionId=${c.id}, msgCount=${h?.length??0}, status=${c.status}, explicitSessionIdRequested=${o??"<null>"}`),L.current!==n)return console.log("[AgentSession] Discarding stale session response (generation mismatch)"),null;return v1.set(a,c),o&&v1.set(v2(e,r,c.id),c),l(c),u(c.status),h&&h.length>0&&(d(h),N.current={entries:[...h],status:c.status}),H(c.id),O.current?.(),c}catch(e){if(console.error("[AgentSession] startSession error:",e),L.current!==n)return console.log("[AgentSession] Discarding error (generation mismatch)"),null;return y(e instanceof Error?e.message:"Failed to start session"),A.current=!0,null}finally{B.current=!1,L.current===n&&x(!1)}},[e,r,i,o,H]),K=(0,W.useCallback)(async(s,i)=>{let n=i||a?.id;if(!n)return void console.warn("[AgentSession] sendMessage: no session ID available (sessionId param:",i,", session?.id:",a?.id,")");if(("string"!=typeof s||s.trim())&&(!Array.isArray(s)||0!==s.length)){console.log(`[AgentSession] sendMessage: targetSessionId=${n}, source=${i?"explicit":"state"}`);try{let e="string"==typeof s?s.trim():s;await vX(n,e)}catch(i){let s=i instanceof Error?i.message:"Failed to send message";console.error("[AgentSession] Failed to send message:",s),s.includes("[404]")&&(e&&(v1.delete(v2(e,r,o)),a?.id&&v1.delete(v2(e,r,a.id))),l(null),u("stopped"),g(!1),R.current=!0),y(s),p_.toast.error("Failed to send message",{description:s})}}},[a?.id,e,r,o]),q=(0,W.useCallback)(async(e,r)=>{let s=r||a?.id;if(!s)throw Error("No session id available for paste upload");return vG(s,e)},[a?.id]),V=(0,W.useCallback)(async()=>{if(a?.id)try{await vZ(a.id)}catch(e){e instanceof Error&&e.message,console.error("[AgentSession] Failed to stop session:",e),p_.toast.error("Failed to stop session")}},[a?.id]),Y=(0,W.useCallback)(async s=>{if(a?.id){e&&(v1.delete(v2(e,r,o)),v1.delete(v2(e,r,a.id))),x(!0),y(null);try{await vJ(a.id,s),s&&l(e=>e?{...e,agentType:s}:null)}catch(e){y(e instanceof Error?e.message:"Failed to restart session"),console.error("[AgentSession] Failed to restart session:",e)}finally{x(!1)}}},[a?.id,e,r,o]),X=(0,W.useCallback)(async s=>{if(a?.id){y(null);try{await vQ(a.id,s),l(i=>{if(!i)return i;let n={...i,permissionMode:s};return e&&(v1.set(v2(e,r,o),n),v1.set(v2(e,r,n.id),n)),n})}catch(e){y(e instanceof Error?e.message:"Failed to switch mode"),console.error("[AgentSession] Failed to switch mode:",e)}}},[a?.id,e,r,o]),G=(0,W.useCallback)(async s=>{if(a?.id){y(null);try{await v0(a.id,s),l(s=>{if(!s)return s;let i={...s,permissionMode:"edit"};return e&&(v1.set(v2(e,r,o),i),v1.set(v2(e,r,i.id),i)),i})}catch(e){y(e instanceof Error?e.message:"Failed to accept plan"),console.error("[AgentSession] Failed to accept plan:",e)}}},[a?.id,e,r,o]),J=(0,W.useCallback)(async s=>{if(!e)return null;if(a?.id)try{await vZ(a.id)}catch(e){console.warn("[AgentSession] startNewConversation: stop of prior session failed:",e)}x(!0),y(null);try{let n=await (0,rg.createNewAgentSession)(e,r,a?.permissionMode,s??a?.agentType??i);return l(null),u("stopped"),g(!1),y(null),w(null),d([]),N.current={entries:[],status:"stopped"},n.session.id}catch(e){return y(e instanceof Error?e.message:"Failed to start new conversation"),console.error("[AgentSession] startNewConversation:",e),null}finally{x(!1)}},[e,r,a?.id,a?.status,a?.permissionMode,a?.agentType,i]);return(0,W.useEffect)(()=>()=>{S.current&&(E.current=!0,S.current.close(),C.current=null),k.current&&clearTimeout(k.current),D.current&&clearTimeout(D.current)},[]),(0,W.useEffect)(()=>{S.current&&(S.current.close(1e3,"branch-switch"),S.current=null,C.current=null),k.current&&(clearTimeout(k.current),k.current=null),D.current&&(clearTimeout(D.current),D.current=null),L.current+=1,l(null),u("stopped"),p(!1),g(!1),y(null),x(!1),w(null),d([]),N.current={entries:[],status:"stopped"},E.current=!1,j.current=0,M.current=null,T.current=0,A.current=!1,B.current=!1,R.current=!0,e&&v1.delete(v2(e,r,o))},[e,r,s,o]),(0,W.useEffect)(()=>{!R.current||!e||a||v||A.current||(R.current=!1,console.log(`[AgentSession] Auto-start: projectId=${e}, branch=${r}, agentMode=${s}`),U())},[e,a,v,U]),(0,W.useEffect)(()=>{let e=()=>{if("visible"===document.visibilityState&&a?.id&&!E.current){let e=S.current;e&&e.readyState!==WebSocket.CLOSED&&e.readyState!==WebSocket.CLOSING||(console.log("[AgentSession] Tab visible, WebSocket disconnected - reconnecting"),j.current=0,T.current=0,k.current&&(clearTimeout(k.current),k.current=null),H(a.id))}};return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[a?.id,H]),(0,W.useEffect)(()=>{a?.id&&!E.current&&H(a.id)},[a?.id,H]),{session:a,messages:c,status:h,isConnected:f,isInitialized:m,isLoading:v,error:_,remoteStatus:b,startSession:U,sendMessage:K,uploadPaste:q,stopSession:V,restartSession:Y,startNewConversation:J,switchMode:X,acceptPlan:G}}(e,r,n?.agent_mode,R,{sessionId:s,onTaskCompleted:a,onSessionStarted:l});(0,W.useEffect)(()=>{(0,rg.getAgentProviders)().then(T).catch(()=>{})},[]),(0,W.useEffect)(()=>{O?.permissionMode&&w(O.permissionMode)},[O?.permissionMode]),(0,W.useEffect)(()=>{O?.agentType&&M(O.agentType)},[O?.agentType]),(0,W.useEffect)(()=>{x([]),y(1)},[e,r]);let es=(0,W.useRef)(!1);(0,W.useEffect)(()=>{let e="running"===H&&z.length>0;e&&!es.current&&c?.(),es.current=e},[H,z.length,c]);let ei=async e=>{w(e),O&&await et(e)},en=async e=>{await er(e),w("edit"),c?.()},eo=(0,W.useCallback)(e=>{g(e.replace(/\r?\n/g,"\n").split("\n").map(e=>`> ${e}`).join("\n")+"\n\n"+m),requestAnimationFrame(()=>{let e=L.current?.querySelector("textarea");if(!e)return;e.focus();let r=e.value.length;try{e.setSelectionRange(r,r)}catch{}})},[g,m]);(0,W.useImperativeHandle)(d,()=>({submitMessage:async e=>{if(O&&"running"===H)G(e);else{c?.();let r=await X(b);r&&G(e,r.id)}}}),[O,H,X,G,b]);let ea=(0,W.useCallback)((e,r)=>{if(r.length<=2e3)return;e.preventDefault();let s=e.currentTarget,i=s.selectionStart??m.length,n=s.selectionEnd??m.length,o=new TextEncoder().encode(r).length,a=y8(_,o);g(m.slice(0,i)+a+m.slice(n)),x(e=>[...e,{id:_,content:r,size:o}]),y(_+1);let l=i+a.length;requestAnimationFrame(()=>{try{s.setSelectionRange(l,l)}catch{}})},[m,_,g]);async function el(e,r,s,i){let n=new Set;for(let r of e.matchAll(y6))n.add(Number(r[1]));let o=r.filter(e=>n.has(e.id));if(0===o.length)return e;let a=e;for(let e of o){let r=await s(e.content,i),n=y8(e.id,e.size),o=`<vpaste path="${r.path}" size="${r.size}" />`;a=a.split(n).join(o)}return a}let ec=async e=>{let r=e.text,s=e.files.length>0,i=v.length>0,n=r.trim();if(n||s){E(!0);try{let o;g(""),A.push(n);let a=O?.id,l=null;if(!O||"running"!==H){if(c?.(),!(l=await X(b)))return void g(r);a=l.id}let d=n;if(i)try{d=(await el(r,v,J,a)).trim()}catch(s){let e=s instanceof Error?s.message:"Failed to upload paste";p_.toast.error("Paste upload failed",{description:e}),g(r);return}if(d.length>2e3)try{let e=await J(d,a);d=`<vpaste path="${e.path}" size="${e.size}" />`}catch(s){let e=s instanceof Error?s.message:"Failed to upload paste";p_.toast.error("Paste upload failed",{description:e}),g(r);return}if(x([]),y(1),s){let r=[];for(let s of(d&&r.push({type:"text",text:d}),e.files))if(s.mediaType&&s.url){let e=s.url.match(/^data:[^;]+;base64,(.+)$/);e&&r.push({type:"image",mediaType:s.mediaType,data:e[1]})}o=r}else o=d;if(S){let e="string"==typeof o?o:o.filter(e=>"text"===e.type).map(e=>e.text).join("\n");if(e.trim()){j(!0);try{let s=await (0,rg.translateText)(e);if(s.error){g(r),x(v),y(_),p_.toast.error("Translation failed",{description:"Disable translation to send the original text."});return}o="string"==typeof o?s.translatedText:o.map(e=>"text"===e.type?{...e,text:s.translatedText}:e)}catch{g(r),x(v),y(_),p_.toast.error("Translation failed",{description:"Disable translation to send the original text."});return}finally{j(!1)}}}l?(console.log(`[AgentConversation] handleSubmit: using freshly started session ${l.id}`),await G(o,l.id)):(console.log(`[AgentConversation] handleSubmit: existing session ${O.id}, status=${H}`),await G(o))}finally{E(!1)}}};return e?(0,F.jsxs)("div",{className:"h-full flex flex-col min-h-0",children:[(0,F.jsxs)("div",{className:"flex-shrink-0 flex items-center justify-between px-4 h-10 border-b border-border/60 bg-muted/20",children:[(0,F.jsxs)("div",{className:"flex items-center gap-2",children:[D.length>1?(0,F.jsxs)(nY,{children:[(0,F.jsx)(nX,{asChild:!0,children:(0,F.jsxs)("button",{disabled:null!==O&&z.length>0,className:(0,ey.cn)("inline-flex items-center gap-1 rounded-md border bg-muted/50 px-2 py-0.5 text-xs font-medium transition-colors hover:bg-muted",null!==O&&z.length>0&&"opacity-50 cursor-not-allowed"),children:[(0,F.jsx)(n3,{className:`h-3 w-3 ${"codex"===R?"text-green-500":"text-violet-500"}`}),D.find(e=>e.type===R)?.displayName??("codex"===R?"Codex":"Claude Code"),(0,F.jsx)(r7,{className:"h-3 w-3 text-muted-foreground"})]})}),(0,F.jsx)(nG,{align:"start",children:(0,F.jsx)(nZ,{value:R,onValueChange:e=>{M(e),O&&Q(e)},children:D.map(e=>(0,F.jsxs)(nQ,{value:e.type,disabled:!e.available,className:"text-xs",children:[(0,F.jsx)(n3,{className:`h-3 w-3 ${"codex"===e.type?"text-green-500":"text-violet-500"}`}),e.displayName]},e.type))})})]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(n3,{className:`h-4 w-4 ${"codex"===R?"text-green-500":"text-violet-500"}`}),(0,F.jsx)("span",{className:"text-sm font-medium",children:"codex"===R?"Codex":"Claude Code"})]}),(0,F.jsx)(yY,{mode:b,onModeChange:ei,disabled:q}),I.length>=1&&o&&(0,F.jsx)(n1,{targets:I,activeTarget:n?.agent_mode??"local",onTargetChange:o}),O&&(h=O.id.startsWith("remote-"),u="text-muted-foreground",f=(0,F.jsx)(yU,{className:"h-3 w-3"}),p="Disconnected",U&&(h&&"connected"!==Y&&null!==Y?"reconnecting"===Y?(u="text-amber-500",f=(0,F.jsx)(yH,{className:"h-3 w-3 animate-pulse"}),p="Reconnecting..."):"disconnected"===Y&&(u="text-red-500",f=(0,F.jsx)(yU,{className:"h-3 w-3"}),p="Remote disconnected"):(u="text-green-500",f=(0,F.jsx)(yH,{className:"h-3 w-3"}),p="Connected")),(0,F.jsxs)("span",{className:`flex items-center gap-1 text-xs ${u}`,children:[f,p]}))]}),O&&(0,F.jsxs)("div",{className:"flex items-center gap-1",children:[e&&(0,F.jsx)(yQ,{projectId:e,branch:r,currentSessionId:O?.id??null,currentEntryCount:z.length,onSwitch:e=>{i?.(e)},onDelete:(e,r)=>{if(e===O?.id){let e=r[0];i?.(e?e.id:null)}}}),(0,F.jsx)($.Button,{variant:"ghost",size:"icon",onClick:async()=>{if(console.log("[NewConv] click",{liveStatus:H,sessionStatus:O?.status,sessionId:O?.id}),"running"===H&&!window.confirm("Current conversation is running. Stop it and start a new conversation?"))return;let e=await ee();e&&i&&i(e)},disabled:q,className:"h-7 w-7",title:"New Conversation",children:(0,F.jsx)(yK,{className:"h-3.5 w-3.5"})}),(0,F.jsxs)($.Button,{variant:"ghost",size:"sm",onClick:()=>Z(),disabled:"running"!==O.status,className:"h-7 text-xs",children:[(0,F.jsx)(lA,{className:"h-3 w-3 mr-1"}),"Stop"]})]})]}),(0,F.jsxs)("div",{className:"flex-1 min-h-0 relative",children:[(0,F.jsxs)(_w,{className:"h-full",initial:"instant",children:[(0,F.jsxs)(_S,{className:"gap-1 p-4",children:[O||0!==z.length?(0,F.jsx)(y3.Provider,{value:{sendMessage:G,messages:z,acceptPlan:en,permissionMode:O?.permissionMode??b,agentType:O?.agentType??R,sessionId:O?.id??null},children:(0,F.jsxs)("div",{className:"space-y-1",ref:P,children:[z.map((e,r)=>(0,F.jsx)("div",{"data-message-idx":r,..."user"===e.type?{"data-user-msg-idx":r}:{},children:(0,F.jsx)(_t,{message:e,messageIndex:r})},r)),q&&(0,F.jsxs)("div",{className:"flex items-center gap-2 py-4 text-muted-foreground",children:[(0,F.jsx)(y$,{className:"h-4 w-4"}),(0,F.jsx)("span",{className:"text-sm",children:"Connecting to agent..."})]})]})}):(0,F.jsx)("div",{className:"text-center py-16",children:q||e&&!K?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(y$,{className:"h-6 w-6 mx-auto mb-4"}),(0,F.jsx)("h3",{className:"text-sm font-semibold mb-1 text-foreground",children:"Connecting to agent..."}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"Setting up the session for this worktree"})]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)("div",{className:"mx-auto w-12 h-12 rounded-xl bg-primary/10 flex items-center justify-center mb-4",children:(0,F.jsx)(n3,{className:"h-6 w-6 text-primary/60"})}),(0,F.jsx)("h3",{className:"text-sm font-semibold mb-1 text-foreground",children:"Start a conversation"}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"Ask the agent to help you with coding tasks in this worktree"})]})}),V&&(0,F.jsxs)("div",{className:"flex items-center gap-2 p-3 bg-red-500/10 rounded-lg text-red-500 text-sm mt-4",children:[(0,F.jsx)(v8,{className:"h-4 w-4"}),V]})]}),(0,F.jsx)(_C,{})]}),(0,F.jsx)(yZ,{messages:z,contentRef:P}),(0,F.jsx)(y2,{containerRef:P,onQuote:eo})]}),(0,F.jsx)("div",{className:"flex-shrink-0 border-t border-border/60 p-3",children:(0,F.jsxs)(yM,{onSubmit:ec,accept:"image/*",className:"w-full",children:[(0,F.jsx)(y5,{}),(0,F.jsxs)("div",{className:"relative flex w-full flex-col",children:[S&&(0,F.jsx)("div",{className:"flex items-center pl-12 pr-2 pt-1.5 pb-0.5",children:(0,F.jsxs)("button",{type:"button",onClick:()=>C(!1),className:"inline-flex shrink-0 items-center gap-1.5 rounded-full bg-blue-500/10 text-blue-600 dark:text-blue-400 px-2.5 py-0.5 text-xs font-medium hover:bg-blue-500/20 transition-colors",children:[k?(0,F.jsx)(n2,{className:"size-3 animate-spin"}):(0,F.jsx)(yq,{className:"size-3"}),"Translate",(0,F.jsx)(t6,{className:"size-3"})]})}),(0,F.jsxs)("div",{className:"flex w-full items-center",children:[(0,F.jsxs)(yL,{children:[(0,F.jsx)(yA,{className:"ml-1"}),(0,F.jsxs)(yB,{children:[(0,F.jsx)(yR,{label:"Add images"}),(0,F.jsxs)(yI,{onSelect:()=>{C(!S)},children:[(0,F.jsx)(yq,{className:"mr-2 size-4"}),S?"Disable translation":"Translate"]})]})]}),(0,F.jsx)("div",{ref:L,className:"contents",children:(0,F.jsx)(yD,{value:m,onChange:e=>g(e.target.value),onPasteText:ea,onKeyDown:A.handleKeyDown,placeholder:O?"Ask the agent to help with your code...":"Type your first message to start...",className:"pr-12"})}),(0,F.jsx)(yO,{className:"absolute bottom-1 right-1",disabled:!m.trim()&&!q||k||N,status:N||k?"submitted":q?"streaming":"ready"})]})]})]})})]}):(0,F.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,F.jsxs)("div",{className:"text-center",children:[(0,F.jsx)("div",{className:"mx-auto w-10 h-10 rounded-xl bg-muted flex items-center justify-center mb-3",children:(0,F.jsx)(n3,{className:"h-5 w-5 text-muted-foreground/50"})}),(0,F.jsx)("p",{className:"text-sm",children:"Select a project to start coding"})]})})});function y9(){return"localhost"===window.location.hostname&&"3000"===window.location.port?"http://localhost:5173":""}function be(e){let r={};e&&(r["Content-Type"]=e);let s=(0,rg.getAuthToken)();return s&&(r.Authorization=`Bearer ${s}`),r}async function bt(e,r){let s=await fetch(`${y9()}/api/projects/${e}/chat-sessions`,{method:"POST",headers:be("application/json"),body:JSON.stringify({branch:r})});if(!s.ok)throw Error("Failed to create chat session");return s.json()}async function br(e,r){if(!(await fetch(`${y9()}/api/chat-sessions/${e}/message`,{method:"POST",headers:be("application/json"),body:JSON.stringify({content:r})})).ok)throw Error("Failed to send message")}async function bs(e){if(!(await fetch(`${y9()}/api/chat-sessions/${e}/stop`,{method:"POST",headers:be()})).ok)throw Error("Failed to stop generation")}let bi=new Map;function bn(e,r){return`chat:${e}:${r??""}`}var bo=e.i(286235);let ba=(0,W.forwardRef)(function({projectId:e,branch:r},s){let{session:i,messages:n,status:o,isInitialized:a,isLoading:l,error:c,sendMessage:d,stopGeneration:h,restartSession:u}=function(e,r){let[s,i]=(0,W.useState)(null),[n,o]=(0,W.useState)([]),[a,l]=(0,W.useState)("stopped"),[c,d]=(0,W.useState)(!1),[h,u]=(0,W.useState)(!1),[f,p]=(0,W.useState)(!1),[m,g]=(0,W.useState)(null),v=(0,W.useRef)(null),x=(0,W.useRef)(null),_=(0,W.useRef)(0),y=(0,W.useRef)({entries:[],status:"stopped"}),b=(0,W.useRef)(!1),w=(0,W.useRef)(!0),S=(0,W.useRef)(!1),C=(0,W.useRef)(0),k=(0,W.useRef)(null),j=(0,W.useRef)(null),N=(0,W.useRef)(0),E=(0,W.useRef)(!1),R=(0,W.useCallback)(n=>{if(v.current?.readyState===WebSocket.OPEN||v.current?.readyState===WebSocket.CONNECTING)return;y.current={entries:[],status:"stopped"},b.current=!1,S.current=!0;let a=new WebSocket((0,rg.getWebSocketUrl)(`/api/chat-sessions/${n}/stream`));v.current=a;let c=C.current;a.onopen=()=>{d(!0),g(null),k.current=Date.now(),j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{_.current=0,N.current=0},5e3)},a.onmessage=s=>{if(c===C.current)try{let c=JSON.parse(s.data);if("JsonPatch"in c){var i,n;let e=y.current.entries.filter(Boolean).length;i=y.current,n=c.JsonPatch,y.current=vK(i,e=>{for(let r of n){let{op:s,path:i,value:n}=r;if("/entries"===i&&"replace"===s&&n?.type==="ENTRY"&&n.content?.type==="system"&&n.content?.content==="__CLEAR_ALL__"){e.entries=[];continue}if(i.startsWith("/entries/")){let r=parseInt(i.replace("/entries/",""),10);if(isNaN(r)||n?.type!=="ENTRY")continue;switch(s){case"add":for(;e.entries.length<=r;)e.entries.push(null);e.entries[r]=n.content;break;case"replace":r<e.entries.length&&(e.entries[r]=n.content);break;case"remove":r<e.entries.length&&e.entries.splice(r,1)}}else"/status"===i&&n?.type==="STATUS"&&(e.status=n.content)}});let r=y.current.entries.filter(Boolean).length;S.current?r!==e&&console.log(`[ChatSession] WS patch added message (${e} → ${r}) but isReplaying=true, state NOT updated`):(r!==e&&console.log(`[ChatSession] New message via WS patch (${e} → ${r}), calling setMessages`),o([...y.current.entries.filter(Boolean)]),l(y.current.status));return}if("Ready"in c){S.current=!1;let e=y.current.entries.filter(Boolean).length;console.log(`[ChatSession] Ready received, isReplaying → false, ${e} messages`),o([...y.current.entries.filter(Boolean)]),l(y.current.status),u(!0);return}if("finished"in c){b.current=!0,a.close(1e3,"finished");return}if("openPreviewFrame"in c)return void(0,vs.openPreviewFrame)(c.openPreviewFrame.projectId,c.openPreviewFrame.url);if("browserCommand"in c){let r=c.browserCommand;e&&(0,vs.sendCommandToIframe)(e,{type:"vibedeckx-command",...r}).then(e=>{e&&a.readyState===WebSocket.OPEN&&a.send(JSON.stringify({type:"browser_result",result:{id:r.id,success:e.success??!1,error:e.error,content:e.content,found:e.found,tag:e.tag,text:e.text}}))});return}if("error"in c){g(c.error),"Session not found"===c.error&&(e&&bi.delete(bn(e,r)),b.current=!0);return}}catch(e){console.error("[ChatSession] Failed to parse message:",e)}},a.onclose=n=>{let o,a;if(c!==C.current)return;d(!1),v.current=null,j.current&&(clearTimeout(j.current),j.current=null);let l=4e3===n.code,h=k.current?Date.now()-k.current:0;if(k.current=null,!l&&h>0&&h<5e3){if(N.current++,N.current>=3)return E.current?void g("Unable to connect to remote server. Please check the server configuration."):(e&&bi.delete(bn(e,r)),i(null),g(null),_.current=0,N.current=0,void(w.current=!0))}else h>=5e3&&(N.current=0);if(b.current||1e3===n.code)return;if(_.current>=10)return void g("Unable to connect to server.");let u=(a=(o=Math.min(3e4,1e3*Math.pow(2,_.current)))*Math.random()*.25,o+a);_.current++,x.current=setTimeout(()=>{s?.id&&!b.current&&R(s.id)},u)},a.onerror=()=>{}},[s?.id]),M=(0,W.useCallback)(async()=>{if(!e)return null;let s=C.current;g(null),u(!1),E.current=!1;let n=bn(e,r),a=bi.get(n);if(a)return i(a),l(a.status),R(a.id),a;p(!0);try{let{session:a,messages:c}=await bt(e,r);if(C.current!==s)return null;return bi.set(n,a),i(a),l(a.status),c&&c.length>0&&o(c),R(a.id),a}catch(e){if(C.current!==s)return null;return g(e instanceof Error?e.message:"Failed to start session"),E.current=!0,null}finally{C.current===s&&p(!1)}},[e,r,R]),D=(0,W.useCallback)(async e=>{let r=s?.id;if(r&&e.trim())try{await br(r,e.trim())}catch(r){let e=r instanceof Error?r.message:"Failed to send message";g(e),p_.toast.error("Failed to send message",{description:e})}},[s?.id]),T=(0,W.useCallback)(async()=>{if(s?.id)try{await bs(s.id)}catch(e){console.error("[ChatSession] Failed to stop generation:",e)}},[s?.id]),P=(0,W.useCallback)(async()=>{if(s?.id)try{await rg.api.resetChatSession(s.id),o([]),l("stopped"),y.current={entries:[],status:"stopped"}}catch(e){console.error("[ChatSession] Failed to reset session:",e),p_.toast.error("Failed to start new conversation")}},[s?.id]);return(0,W.useEffect)(()=>()=>{v.current&&(b.current=!0,v.current.close()),x.current&&clearTimeout(x.current),j.current&&clearTimeout(j.current)},[]),(0,W.useEffect)(()=>{v.current&&(v.current.close(1e3,"branch-switch"),v.current=null),x.current&&(clearTimeout(x.current),x.current=null),j.current&&(clearTimeout(j.current),j.current=null),C.current+=1,i(null),l("stopped"),d(!1),u(!1),g(null),p(!1),y.current={entries:[],status:"stopped"},b.current=!1,_.current=0,k.current=null,N.current=0,E.current=!1,w.current=!0},[e,r]),(0,W.useEffect)(()=>{!w.current||!e||s||f||E.current||(w.current=!1,M())},[e,s,f,M]),(0,W.useEffect)(()=>{!s?.id||c||b.current||R(s.id)},[s?.id,c,R]),(0,W.useEffect)(()=>{let e=()=>{if("visible"!==document.visibilityState||!s?.id||b.current)return;let e=v.current,r=y.current.entries.filter(Boolean).length;console.log(`[ChatSession] Tab visible: ws.readyState=${e?.readyState??"null"}, isReplaying=${S.current}, messages=${r}`),e&&e.readyState===WebSocket.OPEN&&e.close(4e3,"visibility-recovery")};return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[s?.id]),{session:s,messages:n,status:a,isConnected:c,isInitialized:h,isLoading:f,error:m,sendMessage:D,stopGeneration:T,restartSession:P}}(e,r);(0,W.useImperativeHandle)(s,()=>({sendMessage:async e=>{let r=e.trim();r&&await d(r)}}),[d]);let[f,p]=(0,W.useState)(""),[m,g]=(0,W.useState)(!1);(0,W.useEffect)(()=>{i?.eventListeningEnabled!=null&&g(i.eventListeningEnabled)},[i?.eventListeningEnabled]);let v="running"===o,x=(0,W.useCallback)(async e=>{let r=e.text.trim();r&&(p(""),await d(r))},[d]);return e?(0,F.jsxs)("div",{className:"h-full flex flex-col min-h-0",children:[(0,F.jsxs)("div",{className:"flex-shrink-0 flex items-center justify-between px-4 h-10 border-b border-border/60 bg-muted/20",children:[(0,F.jsxs)("div",{className:"flex items-center gap-2",children:[(0,F.jsx)(pw,{className:"h-3.5 w-3.5 text-primary"}),(0,F.jsx)("span",{className:"text-xs font-medium text-foreground",children:"Main Chat"}),v&&(0,F.jsx)(n2,{className:"h-3 w-3 animate-spin text-primary/60"})]}),i&&(0,F.jsxs)("div",{className:"flex items-center gap-1",children:[(0,F.jsx)($.Button,{variant:"ghost",size:"icon",onClick:async()=>{let e=!m;try{await rg.api.setChatEventListening(i.id,e),g(e)}catch{p_.toast.error("Failed to toggle event listening")}},className:`h-7 w-7 ${m?"text-amber-500":""}`,title:m?"Listening to executor events (click to disable)":"Listen to executor events (click to enable)",children:(0,F.jsx)(bo.Radio,{className:"h-3.5 w-3.5"})}),(0,F.jsx)($.Button,{variant:"ghost",size:"icon",onClick:()=>u(),disabled:v,className:"h-7 w-7",title:"New Conversation",children:(0,F.jsx)(yK,{className:"h-3.5 w-3.5"})})]})]}),(0,F.jsxs)(_w,{className:"flex-1 min-h-0",initial:"instant",children:[(0,F.jsxs)(_S,{className:"gap-4 p-4",children:[l&&0===n.length&&(0,F.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,F.jsx)(n2,{className:"h-6 w-6 animate-spin text-muted-foreground"})}),!l&&a&&0===n.length&&(0,F.jsxs)("div",{className:"text-center py-16",children:[(0,F.jsx)("div",{className:"mx-auto w-12 h-12 rounded-xl bg-primary/10 flex items-center justify-center mb-4",children:(0,F.jsx)(pw,{className:"h-6 w-6 text-primary/60"})}),(0,F.jsx)("h3",{className:"text-sm font-semibold mb-1 text-foreground",children:"Start a conversation"}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"Chat with the AI assistant about your project"})]}),n.map((e,r)=>"user"===e.type?(0,F.jsx)(xm,{from:"user",children:(0,F.jsx)(xg,{children:e.content})},r):"assistant"===e.type?(0,F.jsx)(xm,{from:"assistant",children:(0,F.jsx)(xg,{children:(0,F.jsx)(xv,{children:e.content})})},r):"tool_use"===e.type?(0,F.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 text-xs text-muted-foreground",children:[(0,F.jsx)(xs,{className:"w-3.5 h-3.5 animate-pulse"}),(0,F.jsx)("span",{children:function(e){switch(e){case"getExecutorStatus":return"Checking executor status...";case"getAgentConversation":return"Checking agent conversation...";case"listTerminals":return"Listing terminals...";case"runInTerminal":return"Sending command to terminal...";default:return`Running ${e}...`}}(e.tool)})]},r):"tool_result"===e.type?(0,F.jsx)("div",{className:"px-4 py-2",children:(0,F.jsxs)("details",{className:"text-xs text-muted-foreground",children:[(0,F.jsx)("summary",{className:"cursor-pointer hover:text-foreground",children:"Tool result"}),(0,F.jsx)("pre",{className:"mt-1 p-2 bg-muted/50 rounded text-xs overflow-x-auto whitespace-pre-wrap",children:e.output})]})},r):"error"===e.type?(0,F.jsx)("div",{className:"mx-auto max-w-[90%] rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:e.message},r):null),c&&(0,F.jsx)("div",{className:"mx-auto max-w-[90%] rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:c})]}),(0,F.jsx)(_C,{})]}),(0,F.jsxs)("div",{className:"flex-shrink-0 border-t border-border/60 p-3",children:[v&&(0,F.jsx)("div",{className:"flex justify-center mb-2",children:(0,F.jsxs)($.Button,{variant:"outline",size:"sm",onClick:h,className:"gap-1.5",children:[(0,F.jsx)(lA,{className:"h-3 w-3"}),"Stop generating"]})}),(0,F.jsxs)(yM,{onSubmit:x,className:"w-full",children:[(0,F.jsx)(yD,{disabled:!a||v,placeholder:a?v?"Waiting for response...":"Type a message...":"Connecting...",className:"pr-12",value:f,onChange:e=>p(e.currentTarget.value)}),(0,F.jsx)(yO,{className:"absolute bottom-1 right-1",disabled:!a||v||!f.trim()})]})]})]}):(0,F.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,F.jsxs)("div",{className:"text-center",children:[(0,F.jsx)("div",{className:"mx-auto w-10 h-10 rounded-xl bg-muted flex items-center justify-center mb-3",children:(0,F.jsx)(pw,{className:"h-5 w-5 text-muted-foreground/50"})}),(0,F.jsx)("p",{className:"text-sm",children:"Select a project to start chatting"})]})})}),bl=(0,W.createContext)(null);bl.displayName="PanelGroupContext";let bc="data-panel-group-direction",bd="data-panel-group-id",bh="data-resize-handle",bu="data-panel-resize-handle-id",bf=W.useLayoutEffect,bp=W["useId".toString()],bm="function"==typeof bp?bp:()=>null,bg=0;function bv(e=null){let r=bm(),s=(0,W.useRef)(e||r||null);return null===s.current&&(s.current=""+bg++),null!=e?e:s.current}function bx({children:e,className:r="",collapsedSize:s,collapsible:i,defaultSize:n,forwardedRef:o,id:a,maxSize:l,minSize:c,onCollapse:d,onExpand:h,onResize:u,order:f,style:p,tagName:m="div",...g}){let v=(0,W.useContext)(bl);if(null===v)throw Error("Panel components must be rendered within a PanelGroup container");let{collapsePanel:x,expandPanel:_,getPanelSize:y,getPanelStyle:b,groupId:w,isPanelCollapsed:S,reevaluatePanelConstraints:C,registerPanel:k,resizePanel:j,unregisterPanel:N}=v,E=bv(a),R=(0,W.useRef)({callbacks:{onCollapse:d,onExpand:h,onResize:u},constraints:{collapsedSize:s,collapsible:i,defaultSize:n,maxSize:l,minSize:c},id:E,idIsFromProps:void 0!==a,order:f});(0,W.useRef)({didLogMissingDefaultSizeWarning:!1}),bf(()=>{let{callbacks:e,constraints:r}=R.current,o={...r};R.current.id=E,R.current.idIsFromProps=void 0!==a,R.current.order=f,e.onCollapse=d,e.onExpand=h,e.onResize=u,r.collapsedSize=s,r.collapsible=i,r.defaultSize=n,r.maxSize=l,r.minSize=c,(o.collapsedSize!==r.collapsedSize||o.collapsible!==r.collapsible||o.maxSize!==r.maxSize||o.minSize!==r.minSize)&&C(R.current,o)}),bf(()=>{let e=R.current;return k(e),()=>{N(e)}},[f,E,k,N]),(0,W.useImperativeHandle)(o,()=>({collapse:()=>{x(R.current)},expand:e=>{_(R.current,e)},getId:()=>E,getSize:()=>y(R.current),isCollapsed:()=>S(R.current),isExpanded:()=>!S(R.current),resize:e=>{j(R.current,e)}}),[x,_,y,S,E,j]);let M=b(R.current,n);return(0,W.createElement)(m,{...g,children:e,className:r,id:E,style:{...M,...p},[bd]:w,"data-panel":"","data-panel-collapsible":i||void 0,"data-panel-id":E,"data-panel-size":parseFloat(""+M.flexGrow).toFixed(1)})}let b_=(0,W.forwardRef)((e,r)=>(0,W.createElement)(bx,{...e,forwardedRef:r}));bx.displayName="Panel",b_.displayName="forwardRef(Panel)";let by=null,bb=-1,bw=null;function bS(e,s){var i,n,o;let a=function(e,r){if(r){let e=(r&bP)!=0,s=(r&bL)!=0,i=(r&bA)!=0,n=(r&bB)!=0;if(e)if(i)return"se-resize";else if(n)return"ne-resize";else return"e-resize";if(s)if(i)return"sw-resize";else if(n)return"nw-resize";else return"w-resize";if(i)return"s-resize";else if(n)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}(e,s);by!==a&&(by=a,null===bw&&(bw=document.createElement("style"),r&&bw.setAttribute("nonce",r),document.head.appendChild(bw)),bb>=0&&(null==(o=bw.sheet)||o.removeRule(bb)),bb=null!=(i=null==(n=bw.sheet)?void 0:n.insertRule(`*{cursor: ${a} !important;}`))?i:-1)}function bC(e){return"keydown"===e.type}function bk(e){return e.type.startsWith("pointer")}function bj(e){return e.type.startsWith("mouse")}function bN(e){if(bk(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(bj(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}let bE=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function bR(e){let r=e.length;for(;r--;){let s=e[r];if(bZ(s,"Missing node"),function(e){var r;let s,i=getComputedStyle(e);return"fixed"===i.position||!!("auto"!==i.zIndex&&("static"!==i.position||"flex"===(s=getComputedStyle(null!=(r=bT(e))?r:e).display)||"inline-flex"===s)||1>+i.opacity||"transform"in i&&"none"!==i.transform||"webkitTransform"in i&&"none"!==i.webkitTransform||"mixBlendMode"in i&&"normal"!==i.mixBlendMode||"filter"in i&&"none"!==i.filter||"webkitFilter"in i&&"none"!==i.webkitFilter||"isolation"in i&&"isolate"===i.isolation||bE.test(i.willChange))||"touch"===i.webkitOverflowScrolling}(s))return s}return null}function bM(e){return e&&Number(getComputedStyle(e).zIndex)||0}function bD(e){let r=[];for(;e;)r.push(e),e=bT(e);return r}function bT(e){let{parentNode:r}=e;return r&&r instanceof ShadowRoot?r.host:r}let bP=1,bL=2,bA=4,bB=8,bI="coarse"===function(){if("function"==typeof matchMedia)return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}(),bO=[],bz=!1,bF=new Map,bW=new Map,b$=new Set;function bH(e){let{target:r}=e,{x:s,y:i}=bN(e);bz=!0,bV({target:r,x:s,y:i}),bG(),bO.length>0&&(bJ("down",e),e.preventDefault(),bq(r)||e.stopImmediatePropagation())}function bU(e){let{x:r,y:s}=bN(e);if(bz&&0===e.buttons&&(bz=!1,bJ("up",e)),!bz){let{target:i}=e;bV({target:i,x:r,y:s})}bJ("move",e),bY(),bO.length>0&&e.preventDefault()}function bK(e){let{target:r}=e,{x:s,y:i}=bN(e);bW.clear(),bz=!1,bO.length>0&&(e.preventDefault(),bq(r)||e.stopImmediatePropagation()),bJ("up",e),bV({target:r,x:s,y:i}),bY(),bG()}function bq(e){let r=e;for(;r;){if(r.hasAttribute(bh))return!0;r=r.parentElement}return!1}function bV({target:e,x:r,y:s}){bO.splice(0);let i=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(i=e),b$.forEach(e=>{let{element:n,hitAreaMargins:o}=e,a=n.getBoundingClientRect(),{bottom:l,left:c,right:d,top:h}=a,u=bI?o.coarse:o.fine;if(r>=c-u&&r<=d+u&&s>=h-u&&s<=l+u){if(null!==i&&document.contains(i)&&n!==i&&!n.contains(i)&&!i.contains(n)&&function(e,r){let s;if(e===r)throw Error("Cannot compare node with itself");let i={a:bD(e),b:bD(r)};for(;i.a.at(-1)===i.b.at(-1);)e=i.a.pop(),r=i.b.pop(),s=e;bZ(s,"Stacking order can only be calculated for elements with a common ancestor");let n={a:bM(bR(i.a)),b:bM(bR(i.b))};if(n.a===n.b){let e=s.childNodes,r={a:i.a.at(-1),b:i.b.at(-1)},n=e.length;for(;n--;){let s=e[n];if(s===r.a)return 1;if(s===r.b)return -1}}return Math.sign(n.a-n.b)}(i,n)>0){let e=i,r=!1;for(;e;){var f;if(e.contains(n))break;if(f=e.getBoundingClientRect(),f.x<a.x+a.width&&f.x+f.width>a.x&&f.y<a.y+a.height&&f.y+f.height>a.y){r=!0;break}e=e.parentElement}if(r)return}bO.push(e)}})}function bY(){let e=!1,r=!1;bO.forEach(s=>{let{direction:i}=s;"horizontal"===i?e=!0:r=!0});let s=0;bW.forEach(e=>{s|=e}),e&&r?bS("intersection",s):e?bS("horizontal",s):r?bS("vertical",s):null!==bw&&(document.head.removeChild(bw),by=null,bw=null,bb=-1)}let bX=new AbortController;function bG(){bX.abort();let e={capture:!0,signal:(bX=new AbortController).signal};b$.size&&(bz?(bO.length>0&&bF.forEach((r,s)=>{let{body:i}=s;r>0&&(i.addEventListener("contextmenu",bK,e),i.addEventListener("pointerleave",bU,e),i.addEventListener("pointermove",bU,e))}),window.addEventListener("pointerup",bK,e),window.addEventListener("pointercancel",bK,e)):bF.forEach((r,s)=>{let{body:i}=s;r>0&&(i.addEventListener("pointerdown",bH,e),i.addEventListener("pointermove",bU,e))}))}function bJ(e,r){b$.forEach(s=>{let{setResizeHandlerState:i}=s;i(e,bO.includes(s),r)})}function bZ(e,r){if(!e)throw console.error(r),Error(r)}function bQ(e,r,s=10){return e.toFixed(s)===r.toFixed(s)?0:e>r?1:-1}function b0(e,r,s=10){return 0===bQ(e,r,s)}function b1(e,r,s){return 0===bQ(e,r,s)}function b2({panelConstraints:e,panelIndex:r,size:s}){let i=e[r];bZ(null!=i,`Panel constraints not found for index ${r}`);let{collapsedSize:n=0,collapsible:o,maxSize:a=100,minSize:l=0}=i;return 0>bQ(s,l)&&(s=o&&0>bQ(s,(n+l)/2)?n:l),s=parseFloat((s=Math.min(a,s)).toFixed(10))}function b5({delta:e,initialLayout:r,panelConstraints:s,pivotIndices:i,prevLayout:n,trigger:o}){if(b1(e,0))return r;let a=[...r],[l,c]=i;bZ(null!=l,"Invalid first pivot index"),bZ(null!=c,"Invalid second pivot index");let d=0;if("keyboard"===o){{let i=e<0?c:l,n=s[i];bZ(n,`Panel constraints not found for index ${i}`);let{collapsedSize:o=0,collapsible:a,minSize:d=0}=n;if(a){let s=r[i];if(bZ(null!=s,`Previous layout not found for panel index ${i}`),b1(s,o)){let r=d-s;bQ(r,Math.abs(e))>0&&(e=e<0?0-r:r)}}}{let i=e<0?l:c,n=s[i];bZ(n,`No panel constraints found for index ${i}`);let{collapsedSize:o=0,collapsible:a,minSize:d=0}=n;if(a){let s=r[i];if(bZ(null!=s,`Previous layout not found for panel index ${i}`),b1(s,d)){let r=s-o;bQ(r,Math.abs(e))>0&&(e=e<0?0-r:r)}}}}{let i=e<0?1:-1,n=e<0?c:l,o=0;for(;;){let e=r[n];if(bZ(null!=e,`Previous layout not found for panel index ${n}`),o+=b2({panelConstraints:s,panelIndex:n,size:100})-e,(n+=i)<0||n>=s.length)break}let a=Math.min(Math.abs(e),Math.abs(o));e=e<0?0-a:a}{let i=e<0?l:c;for(;i>=0&&i<s.length;){let n=Math.abs(e)-Math.abs(d),o=r[i];bZ(null!=o,`Previous layout not found for panel index ${i}`);let l=b2({panelConstraints:s,panelIndex:i,size:o-n});if(!b1(o,l)&&(d+=o-l,a[i]=l,d.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?i--:i++}}if(function(e,r,s){if(e.length!==r.length)return!1;for(let s=0;s<e.length;s++)if(!b1(e[s],r[s],void 0))return!1;return!0}(n,a))return n;{let i=e<0?c:l,n=r[i];bZ(null!=n,`Previous layout not found for panel index ${i}`);let o=n+d,h=b2({panelConstraints:s,panelIndex:i,size:o});if(a[i]=h,!b1(h,o)){let r=o-h,i=e<0?c:l;for(;i>=0&&i<s.length;){let n=a[i];bZ(null!=n,`Previous layout not found for panel index ${i}`);let o=b2({panelConstraints:s,panelIndex:i,size:n+r});if(b1(n,o)||(r-=o-n,a[i]=o),b1(r,0))break;e>0?i--:i++}}}return b1(a.reduce((e,r)=>r+e,0),100)?a:n}function b3(e,r=document){return Array.from(r.querySelectorAll(`[${bu}][data-panel-group-id="${e}"]`))}function b4(e,r,s=document){let i=b3(e,s).findIndex(e=>e.getAttribute(bu)===r);return null!=i?i:null}function b6(e,r,s){let i=b4(e,r,s);return null!=i?[i,i+1]:[-1,-1]}function b8(e,r=document){var s;if(r instanceof HTMLElement&&(null==r||null==(s=r.dataset)?void 0:s.panelGroupId)==e)return r;let i=r.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return i||null}function b7(e,r=document){let s=r.querySelector(`[${bu}="${e}"]`);return s||null}function b9(e,r){if(e.length!==r.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!==r[s])return!1;return!0}function we(e,r){let{x:s,y:i}=bN(r);return"horizontal"===e?s:i}function wt(e,r,s){r.forEach((r,i)=>{let n=e[i];bZ(n,`Panel data not found for index ${i}`);let{callbacks:o,constraints:a,id:l}=n,{collapsedSize:c=0,collapsible:d}=a,h=s[l];if(null==h||r!==h){s[l]=r;let{onCollapse:e,onExpand:i,onResize:n}=o;n&&n(r,h),d&&(e||i)&&(i&&(null==h||b0(h,c))&&!b0(r,c)&&i(),e&&(null==h||!b0(h,c))&&b0(r,c)&&e())}})}function wr(e,r){if(e.length!==r.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!=r[s])return!1;return!0}function ws(e){try{if("undefined"!=typeof localStorage)e.getItem=e=>localStorage.getItem(e),e.setItem=(e,r)=>{localStorage.setItem(e,r)};else throw Error("localStorage not supported in this environment")}catch(r){console.error(r),e.getItem=()=>null,e.setItem=()=>{}}}function wi(e){return`react-resizable-panels:${e}`}function wn(e){return e.map(e=>{let{constraints:r,id:s,idIsFromProps:i,order:n}=e;return i?s:n?`${n}:${JSON.stringify(r)}`:JSON.stringify(r)}).sort((e,r)=>e.localeCompare(r)).join(",")}function wo(e,r){try{let s=wi(e),i=r.getItem(s);if(i){let e=JSON.parse(i);if("object"==typeof e&&null!=e)return e}}catch(e){}return null}function wa(e,r,s,i,n){var o;let a=wi(e),l=wn(r),c=null!=(o=wo(e,n))?o:{};c[l]={expandToSizes:Object.fromEntries(s.entries()),layout:i};try{n.setItem(a,JSON.stringify(c))}catch(e){console.error(e)}}function wl({layout:e,panelConstraints:r}){let s=[...e],i=s.reduce((e,r)=>e+r,0);if(s.length!==r.length)throw Error(`Invalid ${r.length} panel layout: ${s.map(e=>`${e}%`).join(", ")}`);if(!b1(i,100)&&s.length>0)for(let e=0;e<r.length;e++){let r=s[e];bZ(null!=r,`No layout data found for index ${e}`);let n=100/i*r;s[e]=n}let n=0;for(let e=0;e<r.length;e++){let i=s[e];bZ(null!=i,`No layout data found for index ${e}`);let o=b2({panelConstraints:r,panelIndex:e,size:i});i!=o&&(n+=i-o,s[e]=o)}if(!b1(n,0))for(let e=0;e<r.length;e++){let i=s[e];bZ(null!=i,`No layout data found for index ${e}`);let o=b2({panelConstraints:r,panelIndex:e,size:i+n});if(i!==o&&(n-=o-i,s[e]=o,b1(n,0)))break}return s}let wc={getItem:e=>(ws(wc),wc.getItem(e)),setItem:(e,r)=>{ws(wc),wc.setItem(e,r)}},wd={};function wh({autoSaveId:e=null,children:r,className:s="",direction:i,forwardedRef:n,id:o=null,onLayout:a=null,keyboardResizeBy:l=null,storage:c=wc,style:d,tagName:h="div",...u}){let f=bv(o),p=(0,W.useRef)(null),[m,g]=(0,W.useState)(null),[v,x]=(0,W.useState)([]),_=function(){let[e,r]=(0,W.useState)(0);return(0,W.useCallback)(()=>r(e=>e+1),[])}(),y=(0,W.useRef)({}),b=(0,W.useRef)(new Map),w=(0,W.useRef)(0),S=(0,W.useRef)({autoSaveId:e,direction:i,dragState:m,id:f,keyboardResizeBy:l,onLayout:a,storage:c}),C=(0,W.useRef)({layout:v,panelDataArray:[],panelDataArrayChanged:!1});(0,W.useRef)({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),(0,W.useImperativeHandle)(n,()=>({getId:()=>S.current.id,getLayout:()=>{let{layout:e}=C.current;return e},setLayout:e=>{let{onLayout:r}=S.current,{layout:s,panelDataArray:i}=C.current,n=wl({layout:e,panelConstraints:i.map(e=>e.constraints)});b9(s,n)||(x(n),C.current.layout=n,r&&r(n),wt(i,n,y.current))}}),[]),bf(()=>{S.current.autoSaveId=e,S.current.direction=i,S.current.dragState=m,S.current.id=f,S.current.onLayout=a,S.current.storage=c}),function({committedValuesRef:e,eagerValuesRef:r,groupId:s,layout:i,panelDataArray:n,panelGroupElement:o,setLayout:a}){(0,W.useRef)({didWarnAboutMissingResizeHandle:!1}),bf(()=>{if(!o)return;let e=b3(s,o);for(let r=0;r<n.length-1;r++){let{valueMax:s,valueMin:o,valueNow:a}=function({layout:e,panelsArray:r,pivotIndices:s}){let i=0,n=100,o=0,a=0,l=s[0];return bZ(null!=l,"No pivot index found"),r.forEach((e,r)=>{let{constraints:s}=e,{maxSize:c=100,minSize:d=0}=s;r===l?(i=d,n=c):(o+=d,a+=c)}),{valueMax:Math.min(n,100-o),valueMin:Math.max(i,100-a),valueNow:e[l]}}({layout:i,panelsArray:n,pivotIndices:[r,r+1]}),l=e[r];if(null==l);else{let e=n[r];bZ(e,`No panel data found for index "${r}"`),l.setAttribute("aria-controls",e.id),l.setAttribute("aria-valuemax",""+Math.round(s)),l.setAttribute("aria-valuemin",""+Math.round(o)),l.setAttribute("aria-valuenow",null!=a?""+Math.round(a):"")}}return()=>{e.forEach((e,r)=>{e.removeAttribute("aria-controls"),e.removeAttribute("aria-valuemax"),e.removeAttribute("aria-valuemin"),e.removeAttribute("aria-valuenow")})}},[s,i,n,o]),(0,W.useEffect)(()=>{if(!o)return;let e=r.current;bZ(e,"Eager values not found");let{panelDataArray:n}=e;bZ(null!=b8(s,o),`No group found for id "${s}"`);let l=b3(s,o);bZ(l,`No resize handles found for group id "${s}"`);let c=l.map(e=>{let r=e.getAttribute(bu);bZ(r,"Resize handle element has no handle id attribute");let[l,c]=function(e,r,s,i=document){var n,o,a,l;let c=b7(r,i),d=b3(e,i),h=c?d.indexOf(c):-1;return[null!=(n=null==(o=s[h])?void 0:o.id)?n:null,null!=(a=null==(l=s[h+1])?void 0:l.id)?a:null]}(s,r,n,o);if(null==l||null==c)return()=>{};let d=e=>{if(!e.defaultPrevented&&"Enter"===e.key){e.preventDefault();let c=n.findIndex(e=>e.id===l);if(c>=0){let e=n[c];bZ(e,`No panel data found for index ${c}`);let l=i[c],{collapsedSize:d=0,collapsible:h,minSize:u=0}=e.constraints;if(null!=l&&h){let e=b5({delta:b1(l,d)?u-d:d-l,initialLayout:i,panelConstraints:n.map(e=>e.constraints),pivotIndices:b6(s,r,o),prevLayout:i,trigger:"keyboard"});i!==e&&a(e)}}}};return e.addEventListener("keydown",d),()=>{e.removeEventListener("keydown",d)}});return()=>{c.forEach(e=>e())}},[o,e,r,s,i,n,a])}({committedValuesRef:S,eagerValuesRef:C,groupId:f,layout:v,panelDataArray:C.current.panelDataArray,setLayout:x,panelGroupElement:p.current}),(0,W.useEffect)(()=>{let{panelDataArray:r}=C.current;if(e){if(0===v.length||v.length!==r.length)return;let s=wd[e];null==s&&(s=function(e,r=10){let s=null;return(...i)=>{null!==s&&clearTimeout(s),s=setTimeout(()=>{e(...i)},r)}}(wa,100),wd[e]=s),s(e,[...r],new Map(b.current),v,c)}},[e,v,c]),(0,W.useEffect)(()=>{});let k=(0,W.useCallback)(e=>{let{onLayout:r}=S.current,{layout:s,panelDataArray:i}=C.current;if(e.constraints.collapsible){let n=i.map(e=>e.constraints),{collapsedSize:o=0,panelSize:a,pivotIndices:l}=wp(i,e,s);if(bZ(null!=a,`Panel size not found for panel "${e.id}"`),!b0(a,o)){b.current.set(e.id,a);let c=b5({delta:wf(i,e)===i.length-1?a-o:o-a,initialLayout:s,panelConstraints:n,pivotIndices:l,prevLayout:s,trigger:"imperative-api"});wr(s,c)||(x(c),C.current.layout=c,r&&r(c),wt(i,c,y.current))}}},[]),j=(0,W.useCallback)((e,r)=>{let{onLayout:s}=S.current,{layout:i,panelDataArray:n}=C.current;if(e.constraints.collapsible){let o=n.map(e=>e.constraints),{collapsedSize:a=0,panelSize:l=0,minSize:c=0,pivotIndices:d}=wp(n,e,i),h=null!=r?r:c;if(b0(l,a)){let r=b.current.get(e.id),a=null!=r&&r>=h?r:h,c=b5({delta:wf(n,e)===n.length-1?l-a:a-l,initialLayout:i,panelConstraints:o,pivotIndices:d,prevLayout:i,trigger:"imperative-api"});wr(i,c)||(x(c),C.current.layout=c,s&&s(c),wt(n,c,y.current))}}},[]),N=(0,W.useCallback)(e=>{let{layout:r,panelDataArray:s}=C.current,{panelSize:i}=wp(s,e,r);return bZ(null!=i,`Panel size not found for panel "${e.id}"`),i},[]),E=(0,W.useCallback)((e,r)=>{let{panelDataArray:s}=C.current,i=wf(s,e);return function({defaultSize:e,dragState:r,layout:s,panelData:i,panelIndex:n,precision:o=3}){let a=s[n];return{flexBasis:0,flexGrow:null==a?void 0!=e?e.toPrecision(o):"1":1===i.length?"1":a.toPrecision(o),flexShrink:1,overflow:"hidden",pointerEvents:null!==r?"none":void 0}}({defaultSize:r,dragState:m,layout:v,panelData:s,panelIndex:i})},[m,v]),R=(0,W.useCallback)(e=>{let{layout:r,panelDataArray:s}=C.current,{collapsedSize:i=0,collapsible:n,panelSize:o}=wp(s,e,r);return bZ(null!=o,`Panel size not found for panel "${e.id}"`),!0===n&&b0(o,i)},[]),M=(0,W.useCallback)(e=>{let{layout:r,panelDataArray:s}=C.current,{collapsedSize:i=0,collapsible:n,panelSize:o}=wp(s,e,r);return bZ(null!=o,`Panel size not found for panel "${e.id}"`),!n||bQ(o,i)>0},[]),D=(0,W.useCallback)(e=>{let{panelDataArray:r}=C.current;r.push(e),r.sort((e,r)=>{let s=e.order,i=r.order;return null==s&&null==i?0:null==s?-1:null==i?1:s-i}),C.current.panelDataArrayChanged=!0,_()},[_]);bf(()=>{if(C.current.panelDataArrayChanged){C.current.panelDataArrayChanged=!1;let{autoSaveId:s,onLayout:i,storage:n}=S.current,{layout:o,panelDataArray:a}=C.current,l=null;if(s){var e,r;let i=null!=(r=(null!=(e=wo(s,n))?e:{})[wn(a)])?r:null;i&&(b.current=new Map(Object.entries(i.expandToSizes)),l=i.layout)}null==l&&(l=function({panelDataArray:e}){let r=Array(e.length),s=e.map(e=>e.constraints),i=0,n=100;for(let o=0;o<e.length;o++){let e=s[o];bZ(e,`Panel constraints not found for index ${o}`);let{defaultSize:a}=e;null!=a&&(i++,r[o]=a,n-=a)}for(let o=0;o<e.length;o++){let a=s[o];bZ(a,`Panel constraints not found for index ${o}`);let{defaultSize:l}=a;if(null!=l)continue;let c=n/(e.length-i);i++,r[o]=c,n-=c}return r}({panelDataArray:a}));let c=wl({layout:l,panelConstraints:a.map(e=>e.constraints)});b9(o,c)||(x(c),C.current.layout=c,i&&i(c),wt(a,c,y.current))}}),bf(()=>{let e=C.current;return()=>{e.layout=[]}},[]);let T=(0,W.useCallback)(e=>{let r=!1,s=p.current;return s&&"rtl"===window.getComputedStyle(s,null).getPropertyValue("direction")&&(r=!0),function(s){var i,n;s.preventDefault();let o=p.current;if(!o)return()=>null;let{direction:a,dragState:l,id:c,keyboardResizeBy:d,onLayout:h}=S.current,{layout:u,panelDataArray:f}=C.current,{initialLayout:m}=null!=l?l:{},g=b6(c,e,o),v=function(e,r,s,i,n,o){if(bC(e)){let r="horizontal"===s,i=0;i=e.shiftKey?100:null!=n?n:10;let o=0;switch(e.key){case"ArrowDown":o=r?0:i;break;case"ArrowLeft":o=r?-i:0;break;case"ArrowRight":o=r?i:0;break;case"ArrowUp":o=r?0:-i;break;case"End":o=100;break;case"Home":o=-100}return o}return null==i?0:function(e,r,s,i,n){let o="horizontal"===s,a=b7(r,n);bZ(a,`No resize handle element found for id "${r}"`);let l=a.getAttribute(bd);bZ(l,"Resize handle element has no group id attribute");let{initialCursorPosition:c}=i,d=we(s,e),h=b8(l,n);bZ(h,`No group element found for id "${l}"`);let u=h.getBoundingClientRect();return(d-c)/(o?u.width:u.height)*100}(e,r,s,i,o)}(s,e,a,l,d,o),_="horizontal"===a;_&&r&&(v=-v);let b=b5({delta:v,initialLayout:null!=m?m:u,panelConstraints:f.map(e=>e.constraints),pivotIndices:g,prevLayout:u,trigger:bC(s)?"keyboard":"mouse-or-touch"}),k=!wr(u,b);(bk(s)||bj(s))&&w.current!=v&&((w.current=v,k||0===v)?bW.set(e,0):_?(i=v<0?bP:bL,bW.set(e,i)):(n=v<0?bA:bB,bW.set(e,n))),k&&(x(b),C.current.layout=b,h&&h(b),wt(f,b,y.current))}},[]),P=(0,W.useCallback)((e,r)=>{let{onLayout:s}=S.current,{layout:i,panelDataArray:n}=C.current,o=n.map(e=>e.constraints),{panelSize:a,pivotIndices:l}=wp(n,e,i);bZ(null!=a,`Panel size not found for panel "${e.id}"`);let c=b5({delta:wf(n,e)===n.length-1?a-r:r-a,initialLayout:i,panelConstraints:o,pivotIndices:l,prevLayout:i,trigger:"imperative-api"});wr(i,c)||(x(c),C.current.layout=c,s&&s(c),wt(n,c,y.current))},[]),L=(0,W.useCallback)((e,r)=>{let{layout:s,panelDataArray:i}=C.current,{collapsedSize:n=0,collapsible:o}=r,{collapsedSize:a=0,collapsible:l,maxSize:c=100,minSize:d=0}=e.constraints,{panelSize:h}=wp(i,e,s);null!=h&&(o&&l&&b0(h,n)?b0(n,a)||P(e,a):h<d?P(e,d):h>c&&P(e,c))},[P]),A=(0,W.useCallback)((e,r)=>{let{direction:s}=S.current,{layout:i}=C.current;if(!p.current)return;let n=b7(e,p.current);bZ(n,`Drag handle element not found for id "${e}"`);let o=we(s,r);g({dragHandleId:e,dragHandleRect:n.getBoundingClientRect(),initialCursorPosition:o,initialLayout:i})},[]),B=(0,W.useCallback)(()=>{g(null)},[]),I=(0,W.useCallback)(e=>{let{panelDataArray:r}=C.current,s=wf(r,e);s>=0&&(r.splice(s,1),delete y.current[e.id],C.current.panelDataArrayChanged=!0,_())},[_]),O=(0,W.useMemo)(()=>({collapsePanel:k,direction:i,dragState:m,expandPanel:j,getPanelSize:N,getPanelStyle:E,groupId:f,isPanelCollapsed:R,isPanelExpanded:M,reevaluatePanelConstraints:L,registerPanel:D,registerResizeHandle:T,resizePanel:P,startDragging:A,stopDragging:B,unregisterPanel:I,panelGroupElement:p.current}),[k,m,i,j,N,E,f,R,M,L,D,T,P,A,B,I]);return(0,W.createElement)(bl.Provider,{value:O},(0,W.createElement)(h,{...u,children:r,className:s,id:o,ref:p,style:{display:"flex",flexDirection:"horizontal"===i?"row":"column",height:"100%",overflow:"hidden",width:"100%",...d},"data-panel-group":"",[bc]:i,[bd]:f}))}let wu=(0,W.forwardRef)((e,r)=>(0,W.createElement)(wh,{...e,forwardedRef:r}));function wf(e,r){return e.findIndex(e=>e===r||e.id===r.id)}function wp(e,r,s){let i=wf(e,r),n=i===e.length-1,o=s[i];return{...r.constraints,panelSize:o,pivotIndices:n?[i-1,i]:[i,i+1]}}function wm({children:e=null,className:r="",disabled:s=!1,hitAreaMargins:i,id:n,onBlur:o,onClick:a,onDragging:l,onFocus:c,onPointerDown:d,onPointerUp:h,style:u={},tabIndex:f=0,tagName:p="div",...m}){var g,v;let x=(0,W.useRef)(null),_=(0,W.useRef)({onClick:a,onDragging:l,onPointerDown:d,onPointerUp:h});(0,W.useEffect)(()=>{_.current.onClick=a,_.current.onDragging=l,_.current.onPointerDown=d,_.current.onPointerUp=h});let y=(0,W.useContext)(bl);if(null===y)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");let{direction:b,groupId:w,registerResizeHandle:S,startDragging:C,stopDragging:k,panelGroupElement:j}=y,N=bv(n),[E,R]=(0,W.useState)("inactive"),[M,D]=(0,W.useState)(!1),[T,P]=(0,W.useState)(null),L=(0,W.useRef)({state:E});bf(()=>{L.current.state=E}),(0,W.useEffect)(()=>{if(s)P(null);else{let e=S(N);P(()=>e)}},[s,N,S]);let A=null!=(g=null==i?void 0:i.coarse)?g:15,B=null!=(v=null==i?void 0:i.fine)?v:5;return(0,W.useEffect)(()=>{if(s||null==T)return;let e=x.current;bZ(e,"Element ref not attached");let r=!1;return function(e,r,s,i,n){var o;let{ownerDocument:a}=r,l={direction:s,element:r,hitAreaMargins:i,setResizeHandlerState:n},c=null!=(o=bF.get(a))?o:0;return bF.set(a,c+1),b$.add(l),bG(),function(){var r;bW.delete(e),b$.delete(l);let s=null!=(r=bF.get(a))?r:1;if(bF.set(a,s-1),bG(),1===s&&bF.delete(a),bO.includes(l)){let e=bO.indexOf(l);e>=0&&bO.splice(e,1),bY(),n("up",!0,null)}}}(N,e,b,{coarse:A,fine:B},(e,s,i)=>{if(!s)return void R("inactive");switch(e){case"down":{R("drag"),r=!1,bZ(i,'Expected event to be defined for "down" action'),C(N,i);let{onDragging:e,onPointerDown:s}=_.current;null==e||e(!0),null==s||s();break}case"move":{let{state:e}=L.current;r=!0,"drag"!==e&&R("hover"),bZ(i,'Expected event to be defined for "move" action'),T(i);break}case"up":{R("hover"),k();let{onClick:e,onDragging:s,onPointerUp:i}=_.current;null==s||s(!1),null==i||i(),r||null==e||e()}}})},[A,b,s,B,S,N,T,C,k]),!function({disabled:e,handleId:r,resizeHandler:s,panelGroupElement:i}){(0,W.useEffect)(()=>{if(e||null==s||null==i)return;let n=b7(r,i);if(null==n)return;let o=e=>{if(!e.defaultPrevented)switch(e.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":e.preventDefault(),s(e);break;case"F6":{e.preventDefault();let s=n.getAttribute(bd);bZ(s,`No group element found for id "${s}"`);let o=b3(s,i),a=b4(s,r,i);bZ(null!==a,`No resize element found for id "${r}"`);let l=e.shiftKey?a>0?a-1:o.length-1:a+1<o.length?a+1:0;o[l].focus()}}};return n.addEventListener("keydown",o),()=>{n.removeEventListener("keydown",o)}},[i,e,r,s])}({disabled:s,handleId:N,resizeHandler:T,panelGroupElement:j}),(0,W.createElement)(p,{...m,children:e,className:r,id:n,onBlur:()=>{D(!1),null==o||o()},onFocus:()=>{D(!0),null==c||c()},ref:x,role:"separator",style:{touchAction:"none",userSelect:"none",...u},tabIndex:f,[bc]:b,[bd]:w,[bh]:"","data-resize-handle-active":"drag"===E?"pointer":M?"keyboard":void 0,"data-panel-resize-handle-enabled":!s,[bu]:N,"data-resize-handle-state":E})}wh.displayName="PanelGroup",wu.displayName="forwardRef(PanelGroup)",wm.displayName="PanelResizeHandle";let wg=({className:e,...r})=>(0,F.jsx)(wu,{className:(0,ey.cn)("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...r}),wv=({withHandle:e,className:r,...s})=>(0,F.jsx)(wm,{className:(0,ey.cn)("relative flex w-px items-center justify-center bg-border/60 after:absolute after:inset-y-0 after:-left-1 after:-right-1 after:content-[''] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:inset-x-0 data-[panel-group-direction=vertical]:after:-top-1 data-[panel-group-direction=vertical]:after:-bottom-1 data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:right-0 [&[data-resize-handle-active]]:bg-ring",r),...s,children:e&&(0,F.jsx)("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:(0,F.jsx)(lI,{className:"h-2.5 w-2.5"})})}),wx=(0,ew.default)("columns-3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]),w_=(0,ew.default)("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);function wy({status:e}){return e&&"idle"!==e?"assigned"===e?(0,F.jsx)("span",{className:"h-2 w-2 rounded-full bg-yellow-500 shrink-0"}):"working"===e?(0,F.jsx)("span",{className:"h-2 w-2 rounded-full bg-blue-500 animate-pulse shrink-0"}):(0,F.jsx)("span",{className:"h-2 w-2 rounded-full bg-green-500 shrink-0"}):(0,F.jsx)("span",{className:"h-2 w-2 rounded-full bg-muted-foreground/30 shrink-0"})}function wb({project:e}){let r=!!e.path,s=e.is_remote||!!e.remote_path;return r&&s?(0,F.jsx)("span",{className:"h-2 w-2 rounded-full bg-purple-500 shrink-0"}):s?(0,F.jsx)("span",{className:"h-2 w-2 rounded-full bg-blue-500 shrink-0"}):(0,F.jsx)("span",{className:"h-2 w-2 rounded-full bg-muted-foreground/30 shrink-0"})}function ww({activeView:e,onViewChange:r,worktrees:s,selectedBranch:i,onBranchChange:n,currentProject:o,onCreateWorktreeOpen:a,onDeleteWorktree:l,workspaceStatuses:c,hasProject:d=!0,projects:h,onSelectProject:u,onCreateProjectOpen:f}){return(0,F.jsxs)("nav",{className:"w-52 border-r border-border/60 bg-sidebar flex flex-col p-3",children:[(0,F.jsxs)("div",{className:"space-y-0.5",children:[(0,F.jsxs)("div",{className:"flex items-center justify-between px-3 mb-2",children:[(0,F.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Projects"}),(0,F.jsx)("button",{onClick:f,className:"p-0.5 rounded-md hover:bg-accent hover:text-accent-foreground transition-colors text-muted-foreground",title:"Create new project",children:(0,F.jsx)(eS,{className:"h-3 w-3"})})]}),h&&h.length>0?(0,F.jsx)(g3,{delayDuration:300,children:(0,F.jsx)("div",{className:"flex flex-col gap-0.5 max-h-40 overflow-y-auto",children:h.map(s=>{let i=o?.id===s.id,n=i&&"project-info"===e;return(0,F.jsxs)(g4,{children:[(0,F.jsx)(g6,{asChild:!0,children:(0,F.jsxs)("button",{onClick:()=>{u?.(s),r("project-info")},className:(0,ey.cn)("w-full flex items-center gap-2 rounded-lg px-3 py-1.5 text-xs transition-all duration-150 min-w-0","hover:bg-accent/80 hover:text-accent-foreground",n?"bg-primary/10 text-primary font-medium shadow-sm":i?"font-medium text-foreground":"text-muted-foreground"),children:[(0,F.jsx)(wb,{project:s}),(0,F.jsx)("span",{className:"truncate flex-1 text-left",children:s.name}),i&&(0,F.jsx)(rv,{className:"h-3 w-3 shrink-0 text-primary ml-auto"})]})}),(0,F.jsx)(g8,{side:"right",children:s.name})]},s.id)})})}):(0,F.jsx)("span",{className:"px-3 text-xs text-muted-foreground/60",children:"No projects yet"})]}),(0,F.jsxs)("div",{className:"mt-4 space-y-0.5",children:[(0,F.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70 px-3 mb-2 block",children:"Navigation"}),(0,F.jsxs)("button",{onClick:()=>{d&&(n?.(null),r("tasks"))},disabled:!d,className:(0,ey.cn)("w-full flex items-center gap-2 rounded-lg px-3 py-1.5 text-xs font-medium transition-all duration-150",d?"hover:bg-accent/80 hover:text-accent-foreground":"text-muted-foreground/40 cursor-not-allowed","tasks"===e&&d?"bg-primary/10 text-primary shadow-sm":d?"text-muted-foreground":""),children:[(0,F.jsx)(xt,{className:"h-3 w-3 shrink-0"}),(0,F.jsx)("span",{children:"Tasks"})]}),(0,F.jsxs)("button",{onClick:()=>{d&&r("files")},disabled:!d,className:(0,ey.cn)("w-full flex items-center gap-2 rounded-lg px-3 py-1.5 text-xs font-medium transition-all duration-150",d?"hover:bg-accent/80 hover:text-accent-foreground":"text-muted-foreground/40 cursor-not-allowed","files"===e&&d?"bg-primary/10 text-primary shadow-sm":d?"text-muted-foreground":""),children:[(0,F.jsx)(rv,{className:"h-3 w-3 shrink-0"}),(0,F.jsx)("span",{children:"Files"})]})]}),(0,F.jsxs)("div",{className:"mt-4 space-y-0.5",children:[(0,F.jsxs)("div",{className:"flex items-center justify-between px-3 mb-2",children:[(0,F.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Workspace"}),o&&(0,F.jsx)("button",{onClick:a,className:"p-0.5 rounded-md hover:bg-accent hover:text-accent-foreground transition-colors text-muted-foreground",title:"Create new worktree",children:(0,F.jsx)(eS,{className:"h-3 w-3"})})]}),s&&s.length>0&&(0,F.jsx)(g3,{delayDuration:300,children:(0,F.jsx)("div",{className:"flex flex-col gap-0.5",children:s.map(s=>(0,F.jsxs)("div",{className:"group relative flex items-center min-w-0",children:[(0,F.jsxs)(g4,{children:[(0,F.jsx)(g6,{asChild:!0,children:(0,F.jsxs)("button",{onClick:()=>{n?.(s.branch),r("workspace")},className:(0,ey.cn)("flex-1 min-w-0 flex items-center gap-2 rounded-lg pl-3 pr-6 py-1.5 text-xs transition-all duration-150 overflow-hidden","hover:bg-accent/80 hover:text-accent-foreground","workspace"===e&&i===s.branch?"bg-primary/10 text-primary font-medium shadow-sm":"text-muted-foreground"),children:[(0,F.jsx)(wy,{status:c?.get(null===s.branch?"":s.branch)}),(0,F.jsx)("span",{className:"truncate",children:s.branch??"main"})]})}),(0,F.jsx)(g8,{side:"right",children:s.branch??"main"})]}),null!==s.branch&&(0,F.jsx)("button",{onClick:e=>{e.stopPropagation(),l?.(s)},className:"absolute right-1.5 p-0.5 rounded-md opacity-0 group-hover:opacity-100 hover:bg-destructive/15 hover:text-destructive transition-all",title:"Delete worktree",children:(0,F.jsx)(ra,{className:"h-3 w-3"})})]},s.branch??"__main__"))})}),(!s||0===s.length)&&(0,F.jsxs)("button",{onClick:()=>r("workspace"),className:(0,ey.cn)("w-full flex items-center gap-2.5 rounded-lg px-3 py-2 text-sm font-medium transition-all duration-150","hover:bg-accent/80 hover:text-accent-foreground","workspace"===e?"bg-primary/10 text-primary shadow-sm":"text-muted-foreground"),children:[(0,F.jsx)(wx,{className:"h-4 w-4 shrink-0"}),(0,F.jsx)("span",{children:"Workspace"})]})]}),(0,F.jsxs)("div",{className:"mt-auto space-y-0.5",children:[(0,F.jsx)("div",{className:"border-t border-border/40 mb-3"}),(0,F.jsxs)("button",{onClick:()=>r("remote-servers"),className:(0,ey.cn)("w-full flex items-center gap-2.5 rounded-lg px-3 py-2 text-sm font-medium transition-all duration-150","hover:bg-accent/80 hover:text-accent-foreground","remote-servers"===e?"bg-primary/10 text-primary shadow-sm":"text-muted-foreground"),children:[(0,F.jsx)(rx,{className:"h-4 w-4 shrink-0"}),(0,F.jsx)("span",{children:"Remote Servers"})]}),(0,F.jsxs)("button",{onClick:()=>r("settings"),className:(0,ey.cn)("w-full flex items-center gap-2.5 rounded-lg px-3 py-2 text-sm font-medium transition-all duration-150","hover:bg-accent/80 hover:text-accent-foreground","settings"===e?"bg-primary/10 text-primary shadow-sm":"text-muted-foreground"),children:[(0,F.jsx)(w_,{className:"h-4 w-4 shrink-0"}),(0,F.jsx)("span",{children:"Settings"})]})]})]})}let wS={todo:{label:"To Do",color:"bg-muted text-muted-foreground"},in_progress:{label:"In Progress",color:"bg-blue-100 text-blue-800 dark:bg-blue-900/40 dark:text-blue-300"},done:{label:"Done",color:"bg-green-100 text-green-800 dark:bg-green-900/40 dark:text-green-300"},cancelled:{label:"Cancelled",color:"bg-neutral-100 text-neutral-500 dark:bg-neutral-800 dark:text-neutral-400 line-through"}},wC={low:{label:"Low",color:"bg-muted text-muted-foreground"},medium:{label:"Medium",color:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/40 dark:text-yellow-300"},high:{label:"High",color:"bg-orange-100 text-orange-800 dark:bg-orange-900/40 dark:text-orange-300"},urgent:{label:"Urgent",color:"bg-red-100 text-red-800 dark:bg-red-900/40 dark:text-red-300"}},wk=["todo","in_progress","done","cancelled"],wj=["low","medium","high","urgent"];function wN({task:e,onUpdate:r,onDelete:s,onClick:i,worktrees:n,assignedBranches:o,onAssign:a}){let[l,c]=(0,W.useState)(!1),[d,h]=(0,W.useState)(e.title),u=(0,W.useRef)(null);(0,W.useEffect)(()=>{l&&(u.current?.focus(),u.current?.select())},[l]),(0,W.useEffect)(()=>{h(e.title)},[e.title]);let f=()=>{c(!1);let s=d.trim();s&&s!==e.title?r(e.id,{title:s}):h(e.title)},p="done"===e.status||"cancelled"===e.status;return(0,F.jsxs)(o4,{className:"group cursor-pointer",onClick:()=>i?.(e),children:[(0,F.jsx)(o8,{className:"w-10",onClick:e=>e.stopPropagation(),children:(0,F.jsx)(eb,{checked:"done"===e.status,onCheckedChange:s=>{r(e.id,{status:s?"done":"todo"})}})}),(0,F.jsx)(o8,{className:"font-medium",children:l?(0,F.jsx)("input",{ref:u,className:"w-full bg-transparent border-b border-primary outline-none text-sm py-0.5",value:d,onChange:e=>h(e.target.value),onBlur:f,onClick:e=>e.stopPropagation(),onKeyDown:r=>{"Enter"===r.key&&f(),"Escape"===r.key&&(h(e.title),c(!1))}}):(0,F.jsxs)("div",{children:[(0,F.jsx)("span",{className:`cursor-pointer hover:underline text-sm ${p?"line-through text-muted-foreground":""}`,onClick:e=>{e.stopPropagation(),c(!0)},children:e.title}),e.description&&(0,F.jsx)("p",{className:"text-xs text-muted-foreground truncate max-w-[400px] mt-0.5",children:e.description.length>80?e.description.slice(0,80)+"...":e.description})]})}),(0,F.jsx)(o8,{onClick:e=>e.stopPropagation(),children:(0,F.jsxs)(nY,{children:[(0,F.jsx)(nX,{asChild:!0,children:(0,F.jsx)("button",{className:"focus:outline-none",children:(0,F.jsx)(lL,{variant:"outline",className:`cursor-pointer text-xs ${wS[e.status].color}`,children:wS[e.status].label})})}),(0,F.jsx)(nG,{align:"start",children:wk.map(s=>(0,F.jsxs)(nJ,{onClick:()=>r(e.id,{status:s}),children:[(0,F.jsx)("span",{className:`inline-block w-2 h-2 rounded-full mr-2 ${wS[s].color}`}),wS[s].label]},s))})]})}),(0,F.jsx)(o8,{onClick:e=>e.stopPropagation(),children:(0,F.jsxs)(nY,{children:[(0,F.jsx)(nX,{asChild:!0,children:(0,F.jsx)("button",{className:"focus:outline-none",children:(0,F.jsx)(lL,{variant:"outline",className:`cursor-pointer text-xs ${wC[e.priority].color}`,children:wC[e.priority].label})})}),(0,F.jsx)(nG,{align:"start",children:wj.map(s=>(0,F.jsxs)(nJ,{onClick:()=>r(e.id,{priority:s}),children:[(0,F.jsx)("span",{className:`inline-block w-2 h-2 rounded-full mr-2 ${wC[s].color}`}),wC[s].label]},s))})]})}),(0,F.jsx)(o8,{onClick:e=>e.stopPropagation(),children:(0,F.jsxs)(nY,{children:[(0,F.jsx)(nX,{asChild:!0,children:(0,F.jsx)("button",{className:"focus:outline-none",children:(0,F.jsxs)(lL,{variant:"outline",className:`cursor-pointer text-xs ${null!==e.assigned_branch?"bg-blue-500/10 text-blue-600 border-blue-500/30":"text-muted-foreground"}`,children:[(0,F.jsx)(la,{className:"h-3 w-3 mr-1"}),null!==e.assigned_branch?""===e.assigned_branch?"main":e.assigned_branch:"Unassigned"]})})}),(0,F.jsxs)(nG,{align:"start",children:[null!==e.assigned_branch&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(nJ,{onClick:()=>a(e.id,null),children:"Unassign"}),(0,F.jsx)(n0,{})]}),n.filter(r=>{let s=null===r.branch?"":r.branch;return!(e.assigned_branch===s||o.has(s))}).map(r=>{let s=null===r.branch?"":r.branch,i=r.branch??"main";return(0,F.jsxs)(nJ,{onClick:()=>a(e.id,s),children:[(0,F.jsx)(la,{className:"h-3 w-3 mr-2"}),i]},s)})]})]})}),(0,F.jsx)(o8,{className:"text-muted-foreground text-xs",children:new Date(e.created_at).toLocaleDateString()}),(0,F.jsx)(o8,{className:"w-10",onClick:e=>e.stopPropagation(),children:(0,F.jsx)($.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>s(e.id),children:(0,F.jsx)(ra,{className:"h-3.5 w-3.5 text-muted-foreground"})})})]})}function wE({task:e,open:r,onOpenChange:s}){return e?(0,F.jsx)(t8,{open:r,onOpenChange:s,children:(0,F.jsxs)(re,{className:"sm:max-w-lg",children:[(0,F.jsx)(rt,{children:(0,F.jsx)(rs,{className:"text-base leading-snug",children:e.title})}),(0,F.jsxs)("div",{className:"space-y-4",children:[(0,F.jsxs)("div",{className:"flex items-center gap-2",children:[(0,F.jsx)(lL,{variant:"outline",className:`text-xs ${wS[e.status].color}`,children:wS[e.status].label}),(0,F.jsx)(lL,{variant:"outline",className:`text-xs ${wC[e.priority].color}`,children:wC[e.priority].label})]}),e.description&&(0,F.jsx)("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:e.description}),(0,F.jsxs)("div",{className:"flex gap-4 text-xs text-muted-foreground pt-2 border-t",children:[(0,F.jsxs)("span",{children:["Created: ",new Date(e.created_at).toLocaleString()]}),(0,F.jsxs)("span",{children:["Updated: ",new Date(e.updated_at).toLocaleString()]})]})]})]})}):null}let wR={todo:0,in_progress:1,done:2,cancelled:3},wM={urgent:0,high:1,medium:2,low:3};function wD({tasks:e,onUpdate:r,onDelete:s,worktrees:i,onAssign:n}){let[o,a]=(0,W.useState)(null),[l,c]=(0,W.useState)("asc"),[d,h]=(0,W.useState)(null),[u,f]=(0,W.useState)(!1),p=e=>{o===e?c(e=>"asc"===e?"desc":"asc"):(a(e),c("asc"))},m=(0,W.useMemo)(()=>{if(!o)return e;let r="asc"===l?1:-1;return[...e].sort((e,s)=>{switch(o){case"title":return r*e.title.localeCompare(s.title);case"status":return r*(wR[e.status]-wR[s.status]);case"priority":return r*(wM[e.priority]-wM[s.priority]);case"created_at":return r*(new Date(e.created_at).getTime()-new Date(s.created_at).getTime());default:return 0}})},[e,o,l]),g=e=>o!==e?null:"asc"===l?" ↑":" ↓",v=(0,W.useMemo)(()=>new Set(e.filter(e=>null!==e.assigned_branch).map(e=>e.assigned_branch)),[e]);return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(o2,{children:[(0,F.jsx)(o5,{children:(0,F.jsxs)(o4,{children:[(0,F.jsx)(o6,{className:"w-10"}),(0,F.jsxs)(o6,{className:"cursor-pointer select-none",onClick:()=>p("title"),children:["Title",g("title")]}),(0,F.jsxs)(o6,{className:"cursor-pointer select-none w-32",onClick:()=>p("status"),children:["Status",g("status")]}),(0,F.jsxs)(o6,{className:"cursor-pointer select-none w-28",onClick:()=>p("priority"),children:["Priority",g("priority")]}),(0,F.jsx)(o6,{className:"w-32",children:"Assign"}),(0,F.jsxs)(o6,{className:"cursor-pointer select-none w-28",onClick:()=>p("created_at"),children:["Created",g("created_at")]}),(0,F.jsx)(o6,{className:"w-10"})]})}),(0,F.jsxs)(o3,{children:[m.map(e=>(0,F.jsx)(wN,{task:e,onUpdate:r,onDelete:s,onClick:e=>{h(e),f(!0)},worktrees:i,assignedBranches:v,onAssign:n},e.id)),0===e.length&&(0,F.jsx)(o4,{children:(0,F.jsx)("td",{colSpan:7,className:"text-center text-muted-foreground py-12 text-sm",children:(0,F.jsxs)("div",{className:"flex flex-col items-center gap-1",children:[(0,F.jsx)("p",{className:"text-sm font-medium text-foreground/60",children:"No tasks yet"}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground",children:"Create one to get started."})]})})})]})]}),(0,F.jsx)(wE,{task:d,open:u,onOpenChange:f})]})}function wT({open:e,onOpenChange:r,onSubmit:s}){let[i,n]=(0,W.useState)(""),[o,a]=(0,W.useState)("todo"),[l,c]=(0,W.useState)("medium");return(0,F.jsx)(t8,{open:e,onOpenChange:r,children:(0,F.jsxs)(re,{className:"sm:max-w-md max-h-[85vh] flex flex-col",children:[(0,F.jsx)(rt,{children:(0,F.jsx)(rs,{children:"Create Task"})}),(0,F.jsxs)("form",{onSubmit:e=>{e.preventDefault(),i.trim()&&(s({description:i.trim(),status:o,priority:l}),n(""),a("todo"),c("medium"),r(!1))},className:"space-y-4 overflow-y-auto min-h-0 px-0.5",children:[(0,F.jsx)("div",{className:"space-y-2",children:(0,F.jsx)(ro,{placeholder:"Describe the task...",value:i,onChange:e=>n(e.target.value),className:"max-h-[40vh]",rows:3,autoFocus:!0})}),(0,F.jsxs)("div",{className:"flex gap-3",children:[(0,F.jsxs)("div",{className:"flex-1 space-y-1",children:[(0,F.jsx)("label",{className:"text-xs text-muted-foreground",children:"Status"}),(0,F.jsxs)(a4,{value:o,onValueChange:e=>a(e),children:[(0,F.jsx)(a8,{children:(0,F.jsx)(a6,{})}),(0,F.jsx)(a7,{children:wk.map(e=>(0,F.jsx)(a9,{value:e,children:wS[e].label},e))})]})]}),(0,F.jsxs)("div",{className:"flex-1 space-y-1",children:[(0,F.jsx)("label",{className:"text-xs text-muted-foreground",children:"Priority"}),(0,F.jsxs)(a4,{value:l,onValueChange:e=>c(e),children:[(0,F.jsx)(a8,{children:(0,F.jsx)(a6,{})}),(0,F.jsx)(a7,{children:wj.map(e=>(0,F.jsx)(a9,{value:e,children:wC[e].label},e))})]})]})]}),(0,F.jsxs)(rr,{children:[(0,F.jsx)($.Button,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),(0,F.jsx)($.Button,{type:"submit",disabled:!i.trim(),children:"Create"})]})]})]})})}function wP({projectId:e,tasks:r,loading:s,worktrees:i,onCreateTask:n,onUpdateTask:o,onDeleteTask:a}){let[l,c]=(0,W.useState)(!1);return e?(0,F.jsxs)("div",{className:"flex flex-col h-full",children:[(0,F.jsxs)("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border/60 flex-shrink-0",children:[(0,F.jsxs)("div",{children:[(0,F.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:"Tasks"}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Manage and track your project tasks"})]}),(0,F.jsxs)($.Button,{size:"sm",onClick:()=>c(!0),className:"shadow-sm",children:[(0,F.jsx)(eS,{className:"h-3.5 w-3.5 mr-1.5"}),"New Task"]})]}),(0,F.jsx)("div",{className:"flex-1 overflow-auto px-5",children:s?(0,F.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:"Loading tasks..."}):(0,F.jsx)(wD,{tasks:r,onUpdate:o,onDelete:a,worktrees:i,onAssign:(e,r)=>{o(e,{assigned_branch:r})}})}),(0,F.jsx)(wT,{open:l,onOpenChange:c,onSubmit:n})]}):(0,F.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:(0,F.jsxs)("div",{className:"text-center",children:[(0,F.jsx)("div",{className:"mx-auto w-10 h-10 rounded-xl bg-muted flex items-center justify-center mb-3",children:(0,F.jsx)(eS,{className:"h-5 w-5 text-muted-foreground/50"})}),(0,F.jsx)("p",{className:"text-sm",children:"Select a project to view tasks."})]})})}let wL=(0,ew.default)("file",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]]),wA=(0,ew.default)("file-code",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]]),wB=new Set(["ts","tsx","js","jsx","py","rb","go","rs","java","c","cpp","h","css","scss","html","vue","svelte","php","swift","kt","sh","bash","yaml","yml","toml","json","xml","sql","graphql","proto"]),wI=new Set(["md","txt","log","csv","env","gitignore","dockerignore","editorconfig"]);function wO({path:e}){let[r,s]=(0,W.useState)(!1),i=(0,W.useCallback)(r=>{r.stopPropagation(),navigator.clipboard.writeText(e),s(!0),setTimeout(()=>s(!1),1500)},[e]);return(0,F.jsx)("button",{onClick:i,className:"p-0.5 rounded hover:bg-muted-foreground/20 transition-colors",title:`Copy path: ${e}`,children:r?(0,F.jsx)(rf.Check,{className:"h-3 w-3 text-green-500"}):(0,F.jsx)(ae.Copy,{className:"h-3 w-3 text-muted-foreground"})})}function wz({entry:e,path:r,depth:s,expandedDirs:i,directoryContents:n,loadingDirs:o,selectedFile:a,onToggleDirectory:l,onSelectFile:c}){var d,h,u;let f,p,m,g,v,x=i.has(r),_=o.has(r),y=n.get(r);if("directory"===e.type){let d=x?rv:oL;return(0,F.jsxs)("div",{children:[(0,F.jsxs)("div",{className:"group flex items-center w-full px-2 py-1 text-sm rounded-sm hover:bg-accent transition-colors cursor-pointer",style:{paddingLeft:`${16*s+8}px`},onClick:()=>l(r),children:[(0,F.jsxs)("div",{className:"flex items-center gap-1 min-w-0 flex-1",children:[_?(0,F.jsx)(n2,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground"}):(0,F.jsx)(x?r7:nq,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,F.jsx)(d,{className:"h-4 w-4 shrink-0 text-blue-500"}),(0,F.jsx)("span",{className:"truncate",children:e.name})]}),(0,F.jsx)("div",{className:"shrink-0 hidden group-hover:block ml-1",children:(0,F.jsx)(wO,{path:r})})]}),x&&y&&(0,F.jsx)("div",{children:y.map(e=>{let d=r?`${r}/${e.name}`:e.name;return(0,F.jsx)(wz,{entry:e,path:d,depth:s+1,expandedDirs:i,directoryContents:n,loadingDirs:o,selectedFile:a,onToggleDirectory:l,onSelectFile:c},d)})})]})}let b=(d=e.name,f=d.split(".").pop()?.toLowerCase()??"",wB.has(f)?wA:wI.has(f)?xr:wL),w=a===r;return(0,F.jsxs)("div",{className:(0,ey.cn)("group flex items-center w-full px-2 py-1 text-sm rounded-sm transition-colors cursor-pointer",w?"bg-accent text-accent-foreground":"hover:bg-accent/50"),style:{paddingLeft:`${16*s+8+18}px`},onClick:()=>c(r),children:[(0,F.jsxs)("div",{className:"flex items-center gap-1 min-w-0 flex-1",children:[(0,F.jsx)(b,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,F.jsx)("span",{className:"truncate",children:e.name})]}),(0,F.jsxs)("div",{className:"shrink-0 flex items-center gap-2 ml-1",children:[(0,F.jsx)("span",{className:"text-[11px] text-muted-foreground/70 group-hover:hidden whitespace-nowrap w-[52px] text-right tabular-nums",children:e.mtime&&(h=e.mtime,p=Date.now(),v=Math.floor((g=Math.floor((m=Math.floor(Math.floor((p-new Date(h).getTime())/1e3)/60))/60))/24),m<1?"just now":m<60?`${m}m ago`:g<24?`${g}h ago`:v<30?`${v}d ago`:new Date(h).toLocaleDateString(void 0,{month:"short",day:"numeric"}))}),(0,F.jsx)("span",{className:"text-[11px] text-muted-foreground/70 group-hover:hidden whitespace-nowrap w-[52px] text-right tabular-nums",children:null!=e.size&&((u=e.size)<1024?`${u} B`:u<1048576?`${(u/1024).toFixed(1)} KB`:`${(u/1048576).toFixed(1)} MB`)}),(0,F.jsx)("div",{className:"hidden group-hover:block",children:(0,F.jsx)(wO,{path:r})})]})]})}function wF({entries:e,expandedDirs:r,directoryContents:s,loadingDirs:i,selectedFile:n,onToggleDirectory:o,onSelectFile:a}){return 0===e.length?(0,F.jsx)("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-sm",children:"No files found."}):(0,F.jsx)("div",{className:"py-1",children:e.map(e=>{let l=e.name;return(0,F.jsx)(wz,{entry:e,path:l,depth:0,expandedDirs:r,directoryContents:s,loadingDirs:i,selectedFile:n,onToggleDirectory:o,onSelectFile:a},l)})})}var wW=e.i(166520);let w$=(0,ew.default)("file-exclamation-point",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);var H=H,wH=e.i(829692),wH=wH,wU=e.i(615742);let wK=(0,W.createContext)({code:""}),wq={name:"line-numbers",line(e,r){e.children.unshift({type:"element",tagName:"span",properties:{className:["inline-block","min-w-10","mr-4","text-right","select-none","text-muted-foreground"]},children:[{type:"text",value:String(r)}]})}};async function wV(e,r,s=!1){let i=s?[wq]:[];return await Promise.all([(0,wU.codeToHtml)(e,{lang:r,theme:"one-light",transformers:i}),(0,wU.codeToHtml)(e,{lang:r,theme:"one-dark-pro",transformers:i})])}let wY=({code:e,language:r,showLineNumbers:s=!1,className:i,children:n,...o})=>{let[a,l]=(0,W.useState)(""),[c,d]=(0,W.useState)(""),h=(0,W.useRef)(!1);return(0,W.useEffect)(()=>(wV(e,r,s).then(([e,r])=>{h.current||(l(e),d(r),h.current=!0)}),()=>{h.current=!1}),[e,r,s]),(0,F.jsx)(wK.Provider,{value:{code:e},children:(0,F.jsx)("div",{className:(0,ey.cn)("group relative w-full overflow-hidden rounded-md border bg-background text-foreground",i),...o,children:(0,F.jsxs)("div",{className:"relative",children:[(0,F.jsx)("div",{className:"overflow-auto dark:hidden [&>pre]:m-0 [&>pre]:bg-background! [&>pre]:p-4 [&>pre]:text-foreground! [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm",dangerouslySetInnerHTML:{__html:a}}),(0,F.jsx)("div",{className:"hidden overflow-auto dark:block [&>pre]:m-0 [&>pre]:bg-background! [&>pre]:p-4 [&>pre]:text-foreground! [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm",dangerouslySetInnerHTML:{__html:c}}),n&&(0,F.jsx)("div",{className:"absolute top-2 right-2 flex items-center gap-2",children:n})]})})})},wX=({onCopy:e,onError:r,timeout:s=2e3,children:i,className:n,...o})=>{let[a,l]=(0,W.useState)(!1),{code:c}=(0,W.useContext)(wK),d=async()=>{if(!navigator?.clipboard?.writeText)return void r?.(Error("Clipboard API not available"));try{await navigator.clipboard.writeText(c),l(!0),e?.(),setTimeout(()=>l(!1),s)}catch(e){r?.(e)}},h=a?H.default:wH.default;return(0,F.jsx)($.Button,{className:(0,ey.cn)("shrink-0",n),onClick:d,size:"icon",variant:"ghost",...o,children:i??(0,F.jsx)(h,{size:14})})};function wG({className:e,...r}){return(0,F.jsx)("div",{"data-slot":"skeleton",className:(0,ey.cn)("bg-accent animate-pulse rounded-md",e),...r})}let wJ={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",c:"c",cpp:"cpp",h:"c",cs:"csharp",css:"css",scss:"scss",html:"html",vue:"vue",svelte:"svelte",php:"php",swift:"swift",kt:"kotlin",sh:"bash",bash:"bash",zsh:"bash",yaml:"yaml",yml:"yaml",toml:"toml",json:"json",xml:"xml",sql:"sql",graphql:"graphql",md:"markdown",mdx:"mdx",dockerfile:"dockerfile",makefile:"makefile",lua:"lua",r:"r",scala:"scala",zig:"zig"};function wZ(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function wQ({filePath:e,fileContent:r,loading:s,downloadUrl:i}){let n;if(!e)return(0,F.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Select a file to preview."});if(s)return(0,F.jsxs)("div",{className:"flex flex-col h-full",children:[(0,F.jsx)("div",{className:"flex items-center justify-between px-4 py-2 border-b flex-shrink-0",children:(0,F.jsx)(wG,{className:"h-4 w-48"})}),(0,F.jsxs)("div",{className:"flex-1 p-4",children:[(0,F.jsx)(wG,{className:"h-4 w-full mb-2"}),(0,F.jsx)(wG,{className:"h-4 w-3/4 mb-2"}),(0,F.jsx)(wG,{className:"h-4 w-5/6 mb-2"}),(0,F.jsx)(wG,{className:"h-4 w-2/3"})]})]});if(!r)return(0,F.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Failed to load file."});let o=()=>{i&&window.open(i,"_blank")};return(0,F.jsxs)("div",{className:"flex flex-col h-full",children:[(0,F.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b flex-shrink-0 gap-2",children:[(0,F.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,F.jsx)("span",{className:"text-sm font-mono truncate",children:e}),(0,F.jsx)("span",{className:"text-xs text-muted-foreground shrink-0",children:wZ(r.size)})]}),(0,F.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,F.jsx)($.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{navigator.clipboard.writeText(e)},title:"Copy path",children:(0,F.jsx)(ae.Copy,{className:"h-3.5 w-3.5"})}),i&&(0,F.jsx)($.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:o,title:"Download",children:(0,F.jsx)(wW.Download,{className:"h-3.5 w-3.5"})})]})]}),(0,F.jsx)("div",{className:"flex-1 overflow-auto",children:r.tooLarge?(0,F.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-muted-foreground",children:[(0,F.jsx)(w$,{className:"h-10 w-10"}),(0,F.jsxs)("p",{className:"text-sm",children:["File too large to preview (",wZ(r.size),")"]}),i&&(0,F.jsxs)($.Button,{variant:"outline",size:"sm",onClick:o,children:[(0,F.jsx)(wW.Download,{className:"h-4 w-4 mr-2"}),"Download"]})]}):r.binary?(0,F.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-muted-foreground",children:[(0,F.jsx)(w$,{className:"h-10 w-10"}),(0,F.jsxs)("p",{className:"text-sm",children:["Binary file (",wZ(r.size),")"]}),i&&(0,F.jsxs)($.Button,{variant:"outline",size:"sm",onClick:o,children:[(0,F.jsx)(wW.Download,{className:"h-4 w-4 mr-2"}),"Download"]})]}):null!==r.content?(0,F.jsx)(wY,{code:r.content,language:"dockerfile"===(n=e.split("/").pop()?.toLowerCase()??"")?"dockerfile":"makefile"===n?"makefile":wJ[n.split(".").pop()?.toLowerCase()??""]??"text",showLineNumbers:!0,className:"border-0 rounded-none",children:(0,F.jsx)(wX,{})}):(0,F.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Empty file."})})]})}function w0({projectId:e,project:r,selectedBranch:s}){let i=r&&!r.path?"remote":void 0,{rootEntries:n,directoryContents:o,expandedDirs:a,selectedFile:l,fileContent:c,fileLoading:d,rootLoading:h,loadingDirs:u,fetchRoot:f,toggleDirectory:p,selectFile:m}=function({projectId:e,branch:r,target:s}){let[i,n]=(0,W.useState)([]),[o,a]=(0,W.useState)(new Map),[l,c]=(0,W.useState)(new Set),[d,h]=(0,W.useState)(null),[u,f]=(0,W.useState)(null),[p,m]=(0,W.useState)(!1),[g,v]=(0,W.useState)(!1),[x,_]=(0,W.useState)(new Set),y=(0,W.useRef)(0),b=(0,W.useCallback)(async()=>{if(!e)return;v(!0);let i=++y.current;try{let o=await rg.api.browseProjectDirectory(e,void 0,r,s);if(i!==y.current)return;n(o.items),a(new Map),c(new Set),h(null),f(null)}catch(e){if(console.error("Failed to browse root directory:",e),i!==y.current)return;n([])}finally{i===y.current&&v(!1)}},[e,r,s]),w=(0,W.useCallback)(async i=>{if(e&&(c(e=>{let r=new Set(e);return r.has(i)?r.delete(i):r.add(i),r}),!o.has(i))){_(e=>new Set(e).add(i));try{let n=await rg.api.browseProjectDirectory(e,i,r,s);a(e=>{let r=new Map(e);return r.set(i,n.items),r})}catch(e){console.error("Failed to browse directory:",e)}finally{_(e=>{let r=new Set(e);return r.delete(i),r})}}},[e,r,s,o]);return{rootEntries:i,directoryContents:o,expandedDirs:l,selectedFile:d,fileContent:u,fileLoading:p,rootLoading:g,loadingDirs:x,fetchRoot:b,toggleDirectory:w,selectFile:(0,W.useCallback)(async i=>{if(e){h(i),m(!0),f(null);try{let n=await rg.api.getFileContent(e,i,r,s);f(n)}catch(e){console.error("Failed to get file content:",e),f(null)}finally{m(!1)}}},[e,r,s])}}({projectId:e,branch:s,target:i});if((0,W.useEffect)(()=>{f()},[f]),!e)return(0,F.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:(0,F.jsxs)("div",{className:"text-center",children:[(0,F.jsx)("div",{className:"mx-auto w-10 h-10 rounded-xl bg-muted flex items-center justify-center mb-3",children:(0,F.jsx)(gg,{className:"h-5 w-5 text-muted-foreground/50"})}),(0,F.jsx)("p",{className:"text-sm",children:"Select a project to browse files."})]})});let g=l&&e?rg.api.getFileDownloadUrl(e,l,s,i):null;return(0,F.jsxs)("div",{className:"flex flex-col h-full",children:[(0,F.jsxs)("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border/60 flex-shrink-0",children:[(0,F.jsxs)("div",{children:[(0,F.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:"Files"}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Browse and preview project files"})]}),(0,F.jsx)($.Button,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:f,title:"Refresh",children:(0,F.jsx)(gg,{className:`h-3.5 w-3.5 ${h?"animate-spin":""}`})})]}),(0,F.jsxs)(wg,{direction:"horizontal",autoSaveId:"files-panels",className:"flex-1",children:[(0,F.jsx)(b_,{defaultSize:33,minSize:20,children:(0,F.jsx)(oT,{className:"h-full",children:h&&0===n.length?(0,F.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:"Loading files..."}):(0,F.jsx)(wF,{entries:n,expandedDirs:a,directoryContents:o,loadingDirs:u,selectedFile:l,onToggleDirectory:p,onSelectFile:m})})}),(0,F.jsx)(wv,{withHandle:!0}),(0,F.jsx)(b_,{defaultSize:67,minSize:25,children:(0,F.jsx)("div",{className:"h-full overflow-hidden",children:(0,F.jsx)(wQ,{filePath:l,fileContent:c,loading:d,downloadUrl:g})})})]})]})}let w1=new Set(["workspace","tasks","files","remote-servers","settings","project-info"]),w2="tasks";function w5(){let e=window.location.pathname,r=new URLSearchParams(window.location.search),s=r.get("project");if(s){let e=r.get("tab");return{projectId:s,tab:e&&w1.has(e)?e:w2,branch:r.get("branch")}}let i=e.split("/").filter(Boolean);if(1===i.length&&w1.has(i[0])){let e=i[0];if("remote-servers"===e||"settings"===e)return{projectId:null,tab:e,branch:null}}let n=null,o=w2;if("p"===i[0]&&i[1]){n=i[1];let e=i[2];e&&w1.has(e)&&(o=e)}return{projectId:n,tab:o,branch:r.get("branch")}}function w3(e){let{projectId:r,tab:s,branch:i}=e;if("remote-servers"===s||"settings"===s)return`/${s}`;if(!r)return"/";let n=`/p/${r}`;return s&&s!==w2&&(n+=`/${s}`),i&&(n+=`?branch=${encodeURIComponent(i)}`),n}function w4(e){return null===e?"":e}function w6(e,r){let s=new Map(e);return s.set(w4(r),"working"),s}function w8(e,r){let s=new Map(e);return s.delete(w4(r)),s}function w7(){var e,r;let s,i,n,o,{projectId:a,tab:l,branch:c}=function(){let[e,r]=(0,W.useState)(w5);return(0,W.useEffect)(()=>{let e=()=>r(w5());return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)},[]),e}(),[d,h]=(0,W.useState)(()=>new URLSearchParams(window.location.search).get("session")),u=(0,W.useCallback)(e=>{h(e);let r=new URL(window.location.href);e?r.searchParams.set("session",e):r.searchParams.delete("session"),window.history.replaceState(null,"",r.toString())},[]);(0,W.useEffect)(()=>{let e=()=>{h(new URLSearchParams(window.location.search).get("session"))};return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)},[]),(0,W.useEffect)(()=>{if(new URLSearchParams(window.location.search).has("project")){let e=w3({projectId:a,tab:l,branch:c});window.history.replaceState(null,"",e)}},[]);let[f,p]=(0,W.useState)(!1),[m,g]=(0,W.useState)(!1),[v,x]=(0,W.useState)(!1),[_,y]=(0,W.useState)(null),[b,w]=(0,W.useState)(c),[S,C]=(0,W.useState)(l),k=(0,W.useRef)(null),j=(0,W.useRef)(void 0),[N,E]=(0,W.useTransition)(),{projects:R,currentProject:M,loading:D,addProject:T,createProject:P,updateProject:L,deleteProject:A,selectProject:B}=function(e){let[r,s]=(0,W.useState)([]),[i,n]=(0,W.useState)(null),[o,a]=(0,W.useState)(!0),l=(0,W.useCallback)(async()=>{a(!0);try{let r=await rg.api.getProjects();if(s(r),r.length>0&&!i){let s=e?r.find(r=>r.id===e):null;n(s??r[0])}}finally{a(!1)}},[i,e]);(0,W.useEffect)(()=>{l()},[]);let c=async(e,r)=>{let o=await rg.api.updateProject(e,r);return s(r=>r.map(r=>r.id===e?o:r)),i?.id===e&&n(o),o},d=async e=>{await rg.api.deleteProject(e),s(r=>r.filter(r=>r.id!==e)),i?.id===e&&n(r.find(r=>r.id!==e)??null)};return{projects:r,currentProject:i,loading:o,addProject:e=>{s(r=>[e,...r]),n(e)},createProject:async e=>{let r=await rg.api.createProject(e);return s(e=>[r,...e]),n(r),r},updateProject:c,deleteProject:d,selectProject:e=>{n(e)},refresh:l}}(a),{worktrees:I,loading:O,refetch:z}=function(e){let[r,s]=(0,W.useState)([]),[i,n]=(0,W.useState)(!0),o=(0,W.useCallback)(async()=>{if(!e){s([]),n(!1);return}try{let r=await rg.api.getProjectWorktrees(e);s(r)}catch(e){console.error("Failed to fetch worktrees:",e),s([{branch:null}])}finally{n(!1)}},[e]);return(0,W.useEffect)(()=>{o()},[o]),{worktrees:r,loading:i,refetch:o}}(M?.id??null),{tasks:H,loading:U,createTask:K,updateTask:q,deleteTask:V,refetch:Y}=function(e){let[r,s]=(0,W.useState)([]),[i,n]=(0,W.useState)(!0),o=(0,W.useCallback)(async()=>{if(!e){s([]),n(!1);return}try{let r=await rg.api.getTasks(e);s(r)}catch(e){console.error("Failed to fetch tasks:",e)}finally{n(!1)}},[e]);(0,W.useEffect)(()=>{o()},[o]);let a=(0,W.useCallback)(async r=>{if(!e)return null;try{let i=await rg.api.createTask(e,r);return s(e=>[...e,i]),i}catch(e){return console.error("Failed to create task:",e),null}},[e]),l=(0,W.useCallback)(async(e,i)=>{s(r=>r.map(r=>r.id===e?{...r,...i,updated_at:new Date().toISOString()}:r));try{let r=await rg.api.updateTask(e,i);return s(s=>s.map(s=>s.id===e?r:s)),r}catch(e){return console.error("Failed to update task:",e),s(r),null}},[r]),c=(0,W.useCallback)(async e=>{s(r=>r.filter(r=>r.id!==e));try{await rg.api.deleteTask(e)}catch(e){console.error("Failed to delete task:",e),s(r)}},[r]),d=(0,W.useCallback)(async i=>{if(e){s(i.map(e=>r.find(r=>r.id===e)).filter(e=>void 0!==e));try{await rg.api.reorderTasks(e,i)}catch(e){console.error("Failed to reorder tasks:",e),s(r)}}},[e,r]);return{tasks:r,loading:i,createTask:a,updateTask:l,deleteTask:c,reorderTasks:d,refetch:o}}(M?.id??null),{statuses:X,refetch:G}=function(e){let[r,s]=(0,W.useState)(new Map),i=(0,W.useRef)(null),n=(0,W.useCallback)(async()=>{if(!e)return void s(new Map);try{let r={},i=(0,rg.getAuthToken)();i&&(r.Authorization=`Bearer ${i}`);let n=await fetch(`${"localhost"===window.location.hostname&&"3000"===window.location.port?"http://localhost:5173":""}/api/projects/${e}/agent-sessions`,{headers:r});if(!n.ok)return;let o=await n.json(),a=new Map;for(let e of o.sessions)a.has(e.branch)&&"running"!==e.status||a.set(e.branch,e.status);s(a)}catch{}},[e]);return(0,W.useEffect)(()=>(n(),i.current=setInterval(n,5e3),()=>{i.current&&clearInterval(i.current)}),[n]),{statuses:r,refetch:n,updateStatus:(0,W.useCallback)((e,r)=>{s(s=>{let i=new Map(s);return i.set(e,r),i})},[])}}(M?.id??null),{rules:J,createRule:Z,updateRule:Q,deleteRule:ee}=function(e,r){let[s,i]=(0,W.useState)([]),[n,o]=(0,W.useState)(!0),a=(0,W.useCallback)(async()=>{if(!e){i([]),o(!1);return}try{let s=await rg.api.getRules(e,r);i(s)}catch(e){console.error("Failed to fetch rules:",e)}finally{o(!1)}},[e,r]);(0,W.useEffect)(()=>{a()},[a]);let l=(0,W.useCallback)(async s=>{if(!e)return null;try{let n=await rg.api.createRule(e,{...s,branch:r});return i(e=>[...e,n]),n}catch(e){return console.error("Failed to create rule:",e),null}},[e,r]),c=(0,W.useCallback)(async(e,r)=>{i(s=>s.map(s=>s.id===e?{...s,...r,enabled:void 0!==r.enabled?+!!r.enabled:s.enabled,updated_at:new Date().toISOString()}:s));try{let s=await rg.api.updateRule(e,r);return i(r=>r.map(r=>r.id===e?s:r)),s}catch(e){return console.error("Failed to update rule:",e),i(s),null}},[s]),d=(0,W.useCallback)(async e=>{i(r=>r.filter(r=>r.id!==e));try{await rg.api.deleteRule(e)}catch(e){console.error("Failed to delete rule:",e),i(s)}},[s]);return{rules:s,loading:n,createRule:l,updateRule:c,deleteRule:d,refetch:a}}(M?.id??null,b),{commands:et,createCommand:er,updateCommand:es,deleteCommand:ei}=function(e,r){let[s,i]=(0,W.useState)([]),[n,o]=(0,W.useState)(!0),a=(0,W.useCallback)(async()=>{if(!e){i([]),o(!1);return}try{let s=await rg.api.getCommands(e,r);i(s)}catch(e){console.error("Failed to fetch commands:",e)}finally{o(!1)}},[e,r]);(0,W.useEffect)(()=>{a()},[a]);let l=(0,W.useCallback)(async s=>{if(!e)return null;try{let n=await rg.api.createCommand(e,{...s,branch:r});return i(e=>[...e,n]),n}catch(e){return console.error("Failed to create command:",e),null}},[e,r]),c=(0,W.useCallback)(async(e,r)=>{i(s=>s.map(s=>s.id===e?{...s,...r,updated_at:new Date().toISOString()}:s));try{let s=await rg.api.updateCommand(e,r);return i(r=>r.map(r=>r.id===e?s:r)),s}catch(e){return console.error("Failed to update command:",e),i(s),null}},[s]),d=(0,W.useCallback)(async e=>{i(r=>r.filter(r=>r.id!==e));try{await rg.api.deleteCommand(e)}catch(e){console.error("Failed to delete command:",e),i(s)}},[s]);return{commands:s,loading:n,createCommand:l,updateCommand:c,deleteCommand:d,refetch:a}}(M?.id??null,b),en=(0,W.useRef)(null),[eo,ea]=(0,W.useState)(new Map),el=(0,W.useMemo)(()=>(function(e,r,s,i,n){let o=new Map;if(!e)return o;let a=w4(n);for(let n of e){let e=w4(n.branch),l=r.get(e);if(void 0!==l){o.set(e,l);continue}let c=e===a?void 0:s.get(e),d=i.find(r=>r.assigned_branch===e);d&&"done"===d.status?o.set(e,"completed"):"running"===c?o.set(e,"working"):d?o.set(e,"assigned"):o.set(e,"idle")}return o})(I,eo,X,H,b),[I,X,H,b,eo]),ec=(0,W.useCallback)(()=>{ea(e=>w6(e,b))},[b]),ed=(0,W.useCallback)(()=>{ea(e=>{let r;return(r=new Map(e)).set(w4(b),"completed"),r}),Y(),G()},[b,Y,G]),eh=(0,W.useCallback)(()=>{G()},[G]),eu=(0,W.useCallback)((e,r)=>{ea(s=>{let i="running"===r?{realtimeStatuses:w6(s,e),shouldRefetchTasks:!1}:{realtimeStatuses:w8(s,e),shouldRefetchTasks:!0};return i.shouldRefetchTasks&&Y(),i.realtimeStatuses}),G()},[G,Y]),ef=(0,W.useCallback)(e=>{ea(r=>w8(r,e)),Y(),G()},[Y,G]),ep=(0,W.useCallback)(()=>{Y()},[Y]);e=M?.id??null,r={onSessionStatus:eu,onSessionFinished:ef,onTaskChanged:ep},s=(0,W.useRef)(r.onSessionStatus),i=(0,W.useRef)(r.onSessionFinished),n=(0,W.useRef)(r.onSessionTaskCompleted),o=(0,W.useRef)(r.onTaskChanged),(0,W.useEffect)(()=>{s.current=r.onSessionStatus,i.current=r.onSessionFinished,n.current=r.onSessionTaskCompleted,o.current=r.onTaskChanged}),(0,W.useEffect)(()=>{if(!e)return;let r=(0,rg.getAuthToken)(),a=r?`?token=${encodeURIComponent(r)}`:"",l=new EventSource(`${"localhost"===window.location.hostname&&"3000"===window.location.port?"http://localhost:5173":""}/api/events${a}`);return l.onmessage=r=>{try{let a=JSON.parse(r.data);if(a.projectId!==e)return;"session:status"===a.type?s.current?.(a.branch,a.status):"session:finished"===a.type?i.current?.(a.branch):"session:taskCompleted"===a.type?n.current?.(a.branch,{duration_ms:a.duration_ms,cost_usd:a.cost_usd,input_tokens:a.input_tokens,output_tokens:a.output_tokens}):("task:created"===a.type||"task:updated"===a.type||"task:deleted"===a.type)&&o.current?.()}catch{}},()=>{l.close()}},[e]);let em=(0,W.useMemo)(()=>{let e=w4(b);return H.find(r=>r.assigned_branch===e)??null},[H,b]);(0,W.useCallback)(e=>{E(async()=>{await k.current?.submitMessage(e.description??e.title)})},[]),(0,W.useCallback)(e=>{ea(e=>w8(e,b)),q(e,{assigned_branch:null})},[b,q]),(0,W.useEffect)(()=>{void 0!==j.current&&j.current!==M?.id&&w(null),j.current=M?.id},[M?.id]),(0,W.useEffect)(()=>{!O&&0!==I.length&&(I.some(e=>e.branch===b)||w(I[0].branch))},[I,O,b]);let eg=(0,W.useRef)(b),ev=(0,W.useRef)(M?.id),ex=(0,W.useRef)(!1);(0,W.useEffect)(()=>{if(D)return;let e=!ex.current,r=!e&&eg.current!==b,s=!e&&ev.current!==M?.id;if(eg.current=b,ev.current=M?.id,ex.current=!0,(r||s)&&d)return void u(null);let i=w3({projectId:M?.id,tab:S,branch:b});if(d){let e=new URL(i,window.location.origin);e.searchParams.set("session",d),window.history.replaceState(null,"",e.pathname+e.search)}else window.history.replaceState(null,"",i)},[M?.id,S,b,D,d,u]);let e_=(0,W.useCallback)(e=>{z(),w(e)},[z]);(0,W.useCallback)((e,r)=>{M&&r!==M.agent_mode?L(M.id,{agentMode:r}).then(()=>{k.current?.submitMessage(e)}):k.current?.submitMessage(e)},[M,L]);let ey=(0,W.useCallback)(e=>{en.current?.sendMessage(e)},[]),eb=(0,W.useCallback)(()=>{let e=`Please perform the following git operations for this worktree:
23
+
24
+ 1. Commit all current uncommitted changes with an appropriate commit message
25
+ 2. Fetch the latest changes from the remote main branch
26
+ 3. Rebase the current branch onto main (resolve any conflicts if needed)
27
+ 4. Merge the current branch into main
28
+
29
+ Please proceed step by step and let me know if there are any issues or conflicts that need manual resolution.`;k.current?.submitMessage(e)},[]),ew=(0,W.useCallback)(async e=>{if(M)try{await L(M.id,{agentMode:e})}catch(e){console.error("Failed to update agent mode:",e)}},[M,L]),eC=(0,W.useCallback)(async e=>{if(M)try{await L(M.id,{executorMode:e})}catch(e){console.error("Failed to update executor mode:",e)}},[M,L]),ek=!M;return(0,F.jsxs)("div",{className:"h-screen flex flex-col w-full",children:[(0,F.jsxs)("div",{className:"border-b border-border/60 bg-card/80 backdrop-blur-sm px-4 h-12 flex items-center justify-between sticky top-0 z-10",children:[(0,F.jsxs)("div",{className:"flex items-center gap-2",children:[(0,F.jsx)("div",{className:"h-6 w-6 rounded-md bg-primary flex items-center justify-center",children:(0,F.jsx)("span",{className:"text-[10px] font-bold text-primary-foreground tracking-tighter",children:"VDX"})}),(0,F.jsx)("h1",{className:"text-sm font-semibold tracking-tight text-foreground",children:"VibeDeckX"})]}),(0,F.jsx)(lo,{})]}),(0,F.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,F.jsx)(ww,{activeView:S,onViewChange:C,worktrees:I,selectedBranch:b,onBranchChange:w,currentProject:M,onCreateWorktreeOpen:()=>g(!0),onDeleteWorktree:e=>{y(e),x(!0)},workspaceStatuses:el,hasProject:!ek,projects:R,onSelectProject:B,onCreateProjectOpen:()=>p(!0)}),(0,F.jsx)("div",{className:ek&&("workspace"===S||"tasks"===S||"files"===S||"project-info"===S)?"flex-1 overflow-hidden":"hidden",children:(0,F.jsx)("div",{className:"h-full flex items-center justify-center bg-background",children:(0,F.jsxs)("div",{className:"text-center space-y-6",children:[(0,F.jsx)("div",{className:"mx-auto w-16 h-16 rounded-2xl bg-primary/10 flex items-center justify-center",children:(0,F.jsx)(eS,{className:"h-8 w-8 text-primary"})}),(0,F.jsx)("h1",{className:"text-3xl font-bold tracking-tight text-foreground",children:"Welcome to VibeDeckX"}),(0,F.jsx)("p",{className:"text-muted-foreground max-w-sm mx-auto leading-relaxed",children:"Create your first project to get started with AI-powered development."}),(0,F.jsxs)($.Button,{size:"lg",onClick:()=>p(!0),className:"shadow-md",children:[(0,F.jsx)(eS,{className:"h-5 w-5 mr-2"}),"Create Project"]})]})})}),(0,F.jsx)("div",{className:"workspace"!==S||ek?"hidden":"flex-1 overflow-hidden flex",children:(0,F.jsxs)(wg,{direction:"horizontal",autoSaveId:"workspace-panels",children:[(0,F.jsx)(b_,{defaultSize:33,minSize:25,children:(0,F.jsxs)("div",{className:"h-full flex flex-col overflow-hidden",children:[M&&(0,F.jsx)("div",{className:"px-4 py-3 border-b border-border/60 flex-shrink-0",children:(0,F.jsx)(rm,{assignedTask:em,rules:J,commands:et,onCreateRule:Z,onUpdateRule:Q,onDeleteRule:ee,onCreateCommand:er,onUpdateCommand:es,onDeleteCommand:ei,onExecuteCommand:ey,onUpdateTaskTitle:(e,r)=>q(e,{title:r}),onCompleteTask:e=>{q(e,{status:"done",assigned_branch:null}),ea(e=>w8(e,b))}})}),(0,F.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,F.jsx)(ba,{ref:en,projectId:M?.id??null,branch:b})})]})}),(0,F.jsx)(wv,{withHandle:!0}),(0,F.jsx)(b_,{defaultSize:67,minSize:25,children:(0,F.jsx)("div",{className:"h-full flex flex-col overflow-hidden",children:(0,F.jsx)(vn,{projectId:M?.id??null,selectedBranch:b,onMergeRequest:eb,project:M,onExecutorModeChange:eC,agentSlot:(0,F.jsx)(y7,{ref:k,projectId:M?.id??null,branch:b,sessionId:d,setSessionUrlParam:u,project:M,onAgentModeChange:ew,onTaskCompleted:ed,onSessionStarted:eh,onStatusChange:ec})})})})]})}),(0,F.jsx)("div",{className:"tasks"!==S||ek?"hidden":"flex-1 overflow-hidden",children:(0,F.jsx)(wP,{projectId:M?.id??null,tasks:H,loading:U,worktrees:I,onCreateTask:K,onUpdateTask:q,onDeleteTask:V})}),(0,F.jsx)("div",{className:"files"!==S||ek?"hidden":"flex-1 overflow-hidden",children:(0,F.jsx)(w0,{projectId:M?.id??null,project:M,selectedBranch:b})}),(0,F.jsx)("div",{className:"project-info"!==S||ek?"hidden":"flex-1 overflow-hidden",children:M&&(0,F.jsx)(oU,{project:M,onProjectUpdated:L})}),(0,F.jsx)("div",{className:"remote-servers"!==S?"hidden":"flex-1 overflow-hidden",children:(0,F.jsxs)("div",{className:"h-full flex flex-col overflow-auto",children:[(0,F.jsxs)("div",{className:"border-b border-border/60 px-6 py-4 flex-shrink-0",children:[(0,F.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:"Remote Servers"}),(0,F.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Manage your remote server connections"})]}),(0,F.jsx)("div",{className:"flex-1 px-6 py-5 flex justify-center",children:(0,F.jsx)("div",{className:"w-full max-w-2xl",children:(0,F.jsx)(ar,{})})})]})}),(0,F.jsx)("div",{className:"settings"!==S?"hidden":"flex-1 overflow-hidden",children:(0,F.jsx)(o1,{})})]}),M&&(0,F.jsx)(lr,{projectId:M.id,project:M,open:m,onOpenChange:g,onWorktreeCreated:e_}),(0,F.jsx)(oK,{open:f,onOpenChange:p,onProjectCreated:e=>{T(e),C("project-info")}}),M&&(0,F.jsx)(ls,{projectId:M.id,worktree:_,open:v,onOpenChange:x,onWorktreeDeleted:z})]})}e.s(["default",()=>w7],837031)}]);