tmex-cli 0.6.7 → 0.6.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- var Et=e=>{throw TypeError(e)};var gt=(e,t,n)=>t.has(e)||Et("Cannot "+n);var F=(e,t,n)=>(gt(e,t,"read from private field"),n?n.call(e):t.get(e)),qe=(e,t,n)=>t.has(e)?Et("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),We=(e,t,n,o)=>(gt(e,t,"write to private field"),o?o.call(e,n):t.set(e,n),n),Ye=(e,t,n)=>(gt(e,t,"access private method"),n);import{T as on,U as rn,V as Ct,W as ln,X as Dt,a as an,r as s,Y as cn,Z as un,c as Rt,j as v,q as Ie,_ as ut,$ as H,a0 as dn,a1 as Ft,a2 as kt,a3 as Pt,a4 as wt,a5 as fn,a6 as pn,a7 as f,a8 as It,a9 as gn,aa as we,ab as He,ac as dt,ad as hn,ae as mn,af as xn,ag as bn,ah as vn,ai as yn,aj as Bt,ak as Sn,al as zt,am as Rn,an as wn,ao as je,ap as Mt,aq as Vt,ar as In,as as Mn,at as Tn,au as An,av as En,aw as _t,ax as ze,ay as Cn,az as Ee,aA as Pn,aB as Vn,aC as bt,aD as ht,aE as Hn,aF as jn,aG as Nn,aH as Un,aI as Ln,aJ as On,aK as Dn,aL as Fn,aM as kn,aN as Bn,aO as qt,aP as Wt,aQ as zn,aR as _n,aS as qn,aT as mt,aU as Ht,aV as Wn,aW as Yn,aX as vt,aY as $n,aZ as Kn,a_ as Yt,a$ as Xn,b0 as Gn,b1 as Jn,b2 as xt}from"./index-CmLsM0XA.js";import{u as Zn}from"./useValueChanged-CHeT2_Oy.js";var Pe,De,he,Ve,Ne,at,yt,Ot,Qn=(Ot=class extends on{constructor(t,n){super();qe(this,Ne);qe(this,Pe);qe(this,De);qe(this,he);qe(this,Ve);We(this,Pe,t),this.setOptions(n),this.bindMethods(),Ye(this,Ne,at).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var o;const n=this.options;this.options=F(this,Pe).defaultMutationOptions(t),rn(this.options,n)||F(this,Pe).getMutationCache().notify({type:"observerOptionsUpdated",mutation:F(this,he),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&Ct(n.mutationKey)!==Ct(this.options.mutationKey)?this.reset():((o=F(this,he))==null?void 0:o.state.status)==="pending"&&F(this,he).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=F(this,he))==null||t.removeObserver(this)}onMutationUpdate(t){Ye(this,Ne,at).call(this),Ye(this,Ne,yt).call(this,t)}getCurrentResult(){return F(this,De)}reset(){var t;(t=F(this,he))==null||t.removeObserver(this),We(this,he,void 0),Ye(this,Ne,at).call(this),Ye(this,Ne,yt).call(this)}mutate(t,n){var o;return We(this,Ve,n),(o=F(this,he))==null||o.removeObserver(this),We(this,he,F(this,Pe).getMutationCache().build(F(this,Pe),this.options)),F(this,he).addObserver(this),F(this,he).execute(t)}},Pe=new WeakMap,De=new WeakMap,he=new WeakMap,Ve=new WeakMap,Ne=new WeakSet,at=function(){var n;const t=((n=F(this,he))==null?void 0:n.state)??ln();We(this,De,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},yt=function(t){Dt.batch(()=>{var n,o,g,r,p,c,u,N;if(F(this,Ve)&&this.hasListeners()){const S=F(this,De).variables,R=F(this,De).context,m={client:F(this,Pe),meta:this.options.meta,mutationKey:this.options.mutationKey};if((t==null?void 0:t.type)==="success"){try{(o=(n=F(this,Ve)).onSuccess)==null||o.call(n,t.data,S,R,m)}catch(C){Promise.reject(C)}try{(r=(g=F(this,Ve)).onSettled)==null||r.call(g,t.data,null,S,R,m)}catch(C){Promise.reject(C)}}else if((t==null?void 0:t.type)==="error"){try{(c=(p=F(this,Ve)).onError)==null||c.call(p,t.error,S,R,m)}catch(C){Promise.reject(C)}try{(N=(u=F(this,Ve)).onSettled)==null||N.call(u,void 0,t.error,S,R,m)}catch(C){Promise.reject(C)}}}this.listeners.forEach(S=>{S(F(this,De))})})},Ot);function Ds(e,t){const n=an(),[o]=s.useState(()=>new Qn(n,e));s.useEffect(()=>{o.setOptions(e)},[o,e]);const g=s.useSyncExternalStore(s.useCallback(p=>o.subscribe(Dt.batchCalls(p)),[o]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),r=s.useCallback((p,c)=>{o.mutate(p,c).catch(cn)},[o]);if(g.error&&un(o.options.throwOnError,[g.error]))throw g.error;return{...g,mutate:r,mutateAsync:g.mutate}}/**
1
+ var Et=e=>{throw TypeError(e)};var gt=(e,t,n)=>t.has(e)||Et("Cannot "+n);var F=(e,t,n)=>(gt(e,t,"read from private field"),n?n.call(e):t.get(e)),qe=(e,t,n)=>t.has(e)?Et("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),We=(e,t,n,o)=>(gt(e,t,"write to private field"),o?o.call(e,n):t.set(e,n),n),Ye=(e,t,n)=>(gt(e,t,"access private method"),n);import{T as on,U as rn,V as Ct,W as ln,X as Dt,a as an,r as s,Y as cn,Z as un,c as Rt,j as v,q as Ie,_ as ut,$ as H,a0 as dn,a1 as Ft,a2 as kt,a3 as Pt,a4 as wt,a5 as fn,a6 as pn,a7 as f,a8 as It,a9 as gn,aa as we,ab as He,ac as dt,ad as hn,ae as mn,af as xn,ag as bn,ah as vn,ai as yn,aj as Bt,ak as Sn,al as zt,am as Rn,an as wn,ao as je,ap as Mt,aq as Vt,ar as In,as as Mn,at as Tn,au as An,av as En,aw as _t,ax as ze,ay as Cn,az as Ee,aA as Pn,aB as Vn,aC as bt,aD as ht,aE as Hn,aF as jn,aG as Nn,aH as Un,aI as Ln,aJ as On,aK as Dn,aL as Fn,aM as kn,aN as Bn,aO as qt,aP as Wt,aQ as zn,aR as _n,aS as qn,aT as mt,aU as Ht,aV as Wn,aW as Yn,aX as vt,aY as $n,aZ as Kn,a_ as Yt,a$ as Xn,b0 as Gn,b1 as Jn,b2 as xt}from"./index-YVZKH9DX.js";import{u as Zn}from"./useValueChanged-CFS5t0R_.js";var Pe,De,he,Ve,Ne,at,yt,Ot,Qn=(Ot=class extends on{constructor(t,n){super();qe(this,Ne);qe(this,Pe);qe(this,De);qe(this,he);qe(this,Ve);We(this,Pe,t),this.setOptions(n),this.bindMethods(),Ye(this,Ne,at).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var o;const n=this.options;this.options=F(this,Pe).defaultMutationOptions(t),rn(this.options,n)||F(this,Pe).getMutationCache().notify({type:"observerOptionsUpdated",mutation:F(this,he),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&Ct(n.mutationKey)!==Ct(this.options.mutationKey)?this.reset():((o=F(this,he))==null?void 0:o.state.status)==="pending"&&F(this,he).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=F(this,he))==null||t.removeObserver(this)}onMutationUpdate(t){Ye(this,Ne,at).call(this),Ye(this,Ne,yt).call(this,t)}getCurrentResult(){return F(this,De)}reset(){var t;(t=F(this,he))==null||t.removeObserver(this),We(this,he,void 0),Ye(this,Ne,at).call(this),Ye(this,Ne,yt).call(this)}mutate(t,n){var o;return We(this,Ve,n),(o=F(this,he))==null||o.removeObserver(this),We(this,he,F(this,Pe).getMutationCache().build(F(this,Pe),this.options)),F(this,he).addObserver(this),F(this,he).execute(t)}},Pe=new WeakMap,De=new WeakMap,he=new WeakMap,Ve=new WeakMap,Ne=new WeakSet,at=function(){var n;const t=((n=F(this,he))==null?void 0:n.state)??ln();We(this,De,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},yt=function(t){Dt.batch(()=>{var n,o,g,r,p,c,u,N;if(F(this,Ve)&&this.hasListeners()){const S=F(this,De).variables,R=F(this,De).context,m={client:F(this,Pe),meta:this.options.meta,mutationKey:this.options.mutationKey};if((t==null?void 0:t.type)==="success"){try{(o=(n=F(this,Ve)).onSuccess)==null||o.call(n,t.data,S,R,m)}catch(C){Promise.reject(C)}try{(r=(g=F(this,Ve)).onSettled)==null||r.call(g,t.data,null,S,R,m)}catch(C){Promise.reject(C)}}else if((t==null?void 0:t.type)==="error"){try{(c=(p=F(this,Ve)).onError)==null||c.call(p,t.error,S,R,m)}catch(C){Promise.reject(C)}try{(N=(u=F(this,Ve)).onSettled)==null||N.call(u,void 0,t.error,S,R,m)}catch(C){Promise.reject(C)}}}this.listeners.forEach(S=>{S(F(this,De))})})},Ot);function Ds(e,t){const n=an(),[o]=s.useState(()=>new Qn(n,e));s.useEffect(()=>{o.setOptions(e)},[o,e]);const g=s.useSyncExternalStore(s.useCallback(p=>o.subscribe(Dt.batchCalls(p)),[o]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),r=s.useCallback((p,c)=>{o.mutate(p,c).catch(cn)},[o]);if(g.error&&un(o.options.throwOnError,[g.error]))throw g.error;return{...g,mutate:r,mutateAsync:g.mutate}}/**
2
2
  * @license lucide-react v0.564.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -14,4 +14,4 @@ var Et=e=>{throw TypeError(e)};var gt=(e,t,n)=>t.has(e)||Et("Cannot "+n);var F=(
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
16
  */const ss=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],os=Rt("chevron-up",ss);function Fs({className:e,size:t="default",...n}){return v.jsx("div",{"data-slot":"card","data-size":t,className:Ie("ring-foreground/10 bg-card text-card-foreground gap-4 overflow-hidden rounded-xl py-4 text-sm ring-1 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl group/card flex flex-col",e),...n})}function ks({className:e,...t}){return v.jsx("div",{"data-slot":"card-header",className:Ie("gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3 group/card-header @container/card-header grid auto-rows-min items-start has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto]",e),...t})}function Bs({className:e,...t}){return v.jsx("div",{"data-slot":"card-title",className:Ie("text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",e),...t})}function zs({className:e,...t}){return v.jsx("div",{"data-slot":"card-description",className:Ie("text-muted-foreground text-sm",e),...t})}function _s({className:e,...t}){return v.jsx("div",{"data-slot":"card-content",className:Ie("px-4 group-data-[size=sm]/card:px-3",e),...t})}const Kt=s.createContext(null),Xt=s.createContext(null);function Ce(){const e=s.useContext(Kt);if(e===null)throw new Error(ut(60));return e}function Gt(){const e=s.useContext(Xt);if(e===null)throw new Error(ut(61));return e}const rs=(e,t)=>Object.is(e,t);function Ke(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function ls(e,t,n){return!e||e.length===0?!1:e.some(o=>o===void 0?!1:Ke(t,o,n))}function tt(e,t,n){return!e||e.length===0?-1:e.findIndex(o=>o===void 0?!1:Ke(o,t,n))}function is(e,t,n){return e.filter(o=>!Ke(t,o,n))}function St(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function Jt(e){return e!=null&&e.length>0&&typeof e[0]=="object"&&e[0]!=null&&"items"in e[0]}function as(e){if(!Array.isArray(e))return e!=null&&!("null"in e);if(Jt(e)){for(const t of e)for(const n of t.items)if(n&&n.value==null&&n.label!=null)return!0;return!1}for(const t of e)if(t&&t.value==null&&t.label!=null)return!0;return!1}function cs(e,t){if(t&&e!=null)return t(e)??"";if(e&&typeof e=="object"){if("label"in e&&e.label!=null)return String(e.label);if("value"in e)return String(e.value)}return St(e)}function $e(e,t){return t&&e!=null?t(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?St(e.value):St(e)}function Zt(e,t,n){function o(){return cs(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e=="object"&&"label"in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return t[e]??o();if(Array.isArray(t)){const g=Jt(t)?t.flatMap(r=>r.items):t;if(e==null||typeof e!="object"){const r=g.find(p=>p.value===e);return r&&r.label!=null?r.label:o()}if("value"in e){const r=g.find(p=>p&&p.value===e.value);if(r&&r.label!=null)return r.label}}return o()}function us(e,t,n){return e.reduce((o,g,r)=>(r>0&&o.push(", "),o.push(v.jsx(s.Fragment,{children:Zt(g,t,n)},r)),o),[])}const a={id:H(e=>e.id),modal:H(e=>e.modal),multiple:H(e=>e.multiple),items:H(e=>e.items),itemToStringLabel:H(e=>e.itemToStringLabel),itemToStringValue:H(e=>e.itemToStringValue),isItemEqualToValue:H(e=>e.isItemEqualToValue),value:H(e=>e.value),hasSelectedValue:H(e=>{const{value:t,multiple:n,itemToStringValue:o}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:$e(t,o)!==""}),hasNullItemLabel:H((e,t)=>t?as(e.items):!1),open:H(e=>e.open),mounted:H(e=>e.mounted),forceMount:H(e=>e.forceMount),transitionStatus:H(e=>e.transitionStatus),openMethod:H(e=>e.openMethod),activeIndex:H(e=>e.activeIndex),selectedIndex:H(e=>e.selectedIndex),isActive:H((e,t)=>e.activeIndex===t),isSelected:H((e,t,n)=>{const o=e.isItemEqualToValue,g=e.value;return e.multiple?Array.isArray(g)&&g.some(r=>Ke(n,r,o)):e.selectedIndex===t&&e.selectedIndex!==null?!0:Ke(n,g,o)}),isSelectedByFocus:H((e,t)=>e.selectedIndex===t),popupProps:H(e=>e.popupProps),triggerProps:H(e=>e.triggerProps),triggerElement:H(e=>e.triggerElement),positionerElement:H(e=>e.positionerElement),listElement:H(e=>e.listElement),scrollUpArrowVisible:H(e=>e.scrollUpArrowVisible),scrollDownArrowVisible:H(e=>e.scrollDownArrowVisible),hasScrollArrows:H(e=>e.hasScrollArrows)};function ds(e){const{id:t,value:n,defaultValue:o=null,onValueChange:g,open:r,defaultOpen:p=!1,onOpenChange:c,name:u,autoComplete:N,disabled:S=!1,readOnly:R=!1,required:m=!1,modal:C=!0,actionsRef:Q,inputRef:A,onOpenChangeComplete:U,items:L,multiple:M=!1,itemToStringLabel:b,itemToStringValue:y,isItemEqualToValue:z=rs,highlightItemOnHover:ve=!0,children:ne}=e,{clearErrors:k}=dn(),{setDirty:K,setTouched:ue,setFocused:B,shouldValidateOnChange:_,validityData:q,setFilled:x,name:oe,disabled:X,validation:D,validationMode:G}=Ft(),l=kt({id:t}),E=X||S,P=oe??u,[i,le]=Pt({controlled:n,default:M?o??Vt:o,name:"Select",state:"value"}),[h,W]=Pt({controlled:r,default:p,name:"Select",state:"open"}),d=s.useRef([]),j=s.useRef([]),ee=s.useRef(null),Me=s.useRef(null),Ue=s.useRef(0),T=s.useRef(null),V=s.useRef([]),de=s.useRef(!1),se=s.useRef(!1),ie=s.useRef(null),me=s.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}),J=s.useRef(!1),{mounted:re,setMounted:fe,transitionStatus:Y}=wt(h),{openMethod:te,triggerProps:$,reset:pe}=fn(h),w=pn(()=>new In({id:l,modal:C,multiple:M,itemToStringLabel:b,itemToStringValue:y,isItemEqualToValue:z,value:i,open:h,mounted:re,transitionStatus:Y,items:L,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:{},triggerProps:{},triggerElement:null,positionerElement:null,listElement:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1})).current,Te=f(w,a.activeIndex),Re=f(w,a.selectedIndex),Le=f(w,a.triggerElement),_e=f(w,a.positionerElement),Z=s.useMemo(()=>M&&Array.isArray(i)&&i.length===0?"":$e(i,y),[M,i,y]),xe=s.useMemo(()=>M&&Array.isArray(i)?i.map(I=>$e(I,y)):$e(i,y),[M,i,y]),ge=It(w.state.triggerElement);gn({id:l,commit:D.commit,value:i,controlRef:ge,name:P,getValue:()=>xe});const ye=s.useRef(i);we(()=>{i!==ye.current&&w.set("forceMount",!0)},[w,i]),we(()=>{x(M?Array.isArray(i)&&i.length>0:i!=null)},[M,i,x]),we(function(){if(h)return;const O=V.current;if(M){const Se=Array.isArray(i)?i:[];if(Se.length===0){w.set("selectedIndex",null);return}const be=Se[Se.length-1],Oe=tt(O,be,z);w.set("selectedIndex",Oe===-1?null:Oe);return}const ce=tt(O,i,z);w.set("selectedIndex",ce===-1?null:ce)},[M,h,i,V,z,w]),Zn(i,()=>{k(P),K(i!==q.initialValue),_()?D.commit(i):D.commit(i,!0)});const Xe=He((I,O)=>{if(c==null||c(I,O),!O.isCanceled&&(W(I),!I&&(O.reason===Tn||O.reason===An)&&(ue(!0),B(!1),G==="onBlur"&&D.commit(i)),!I&&w.state.activeIndex!==null)){const ce=d.current[w.state.activeIndex];queueMicrotask(()=>{ce==null||ce.setAttribute("tabindex","-1")})}}),Ge=He(()=>{fe(!1),w.set("activeIndex",null),pe(),U==null||U(!1)});dt({enabled:!Q,open:h,ref:ee,onComplete(){h||Ge()}}),s.useImperativeHandle(Q,()=>({unmount:Ge}),[Ge]);const Fe=He((I,O)=>{g==null||g(I,O),!O.isCanceled&&le(I)}),Je=He(()=>{const I=w.state.listElement||ee.current;if(!I)return;const O=I.scrollTop,ce=I.scrollTop+I.clientHeight,Se=O>1,be=ce<I.scrollHeight-1;w.state.scrollUpArrowVisible!==Se&&w.set("scrollUpArrowVisible",Se),w.state.scrollDownArrowVisible!==be&&w.set("scrollDownArrowVisible",be)}),ae=hn({open:h,onOpenChange:Xe,elements:{reference:Le,floating:_e}}),nt=mn(ae,{enabled:!R&&!E,event:"mousedown"}),st=xn(ae,{bubbles:!1}),Ze=bn(ae,{enabled:!R&&!E,listRef:d,activeIndex:Te,selectedIndex:Re,disabledIndices:Vt,onNavigate(I){I===null&&!h||w.set("activeIndex",I)},focusItemOnHover:!1}),Ae=vn(ae,{enabled:!R&&!E&&(h||!M),listRef:j,activeIndex:Te,selectedIndex:Re,onMatch(I){h?w.set("activeIndex",I):Fe(V.current[I],je("none"))},onTypingChange(I){de.current=I}}),{getReferenceProps:ot,getFloatingProps:ke,getItemProps:Qe}=yn([nt,st,Ze,Ae]),et=s.useMemo(()=>Bt(ot(),$,l?{id:l}:Mn),[ot,$,l]);Sn(()=>{w.update({popupProps:ke(),triggerProps:et})}),we(()=>{w.update({id:l,modal:C,multiple:M,value:i,open:h,mounted:re,transitionStatus:Y,popupProps:ke(),triggerProps:et,items:L,itemToStringLabel:b,itemToStringValue:y,isItemEqualToValue:z,openMethod:te})},[w,l,C,M,i,h,re,Y,ke,et,L,b,y,z,te]);const ft=s.useMemo(()=>({store:w,name:P,required:m,disabled:E,readOnly:R,multiple:M,itemToStringLabel:b,itemToStringValue:y,highlightItemOnHover:ve,setValue:Fe,setOpen:Xe,listRef:d,popupRef:ee,scrollHandlerRef:Me,handleScrollArrowVisibility:Je,scrollArrowsMountedCountRef:Ue,getItemProps:Qe,events:ae.context.events,valueRef:T,valuesRef:V,labelsRef:j,typingRef:de,selectionRef:me,selectedItemTextRef:ie,validation:D,onOpenChangeComplete:U,keyboardActiveRef:se,alignItemWithTriggerActiveRef:J,initialValueRef:ye}),[w,P,m,E,R,M,b,y,ve,Fe,Xe,Qe,ae.context.events,D,U,Je]),rt=zt(A,D.inputRef),lt=M&&Array.isArray(i)&&i.length>0,pt=s.useMemo(()=>!M||!Array.isArray(i)||!P?null:i.map(I=>{const O=$e(I,y);return v.jsx("input",{type:"hidden",name:P,value:O},O)}),[M,i,P,y]);return v.jsx(Kt.Provider,{value:ft,children:v.jsxs(Xt.Provider,{value:ae,children:[ne,v.jsx("input",{...D.getInputValidationProps({onFocus(){var I;(I=w.state.triggerElement)==null||I.focus({focusVisible:!0})},onChange(I){if(I.nativeEvent.defaultPrevented)return;const O=I.target.value,ce=je(Mt,I.nativeEvent);function Se(){if(M)return;const be=V.current.find(Oe=>$e(Oe,y).toLowerCase()===O.toLowerCase());be!=null&&(K(be!==q.initialValue),Fe(be,ce),_()&&D.commit(be))}w.set("forceMount",!0),queueMicrotask(Se)}}),name:M?void 0:P,autoComplete:N,value:Z,disabled:E,required:m&&!lt,readOnly:R,ref:rt,style:P?Rn:wn,tabIndex:-1,"aria-hidden":!0}),pt]})})}const it=2,fs=400,jt=200,ps={...Vn,...Pn,value:()=>null},gs=s.forwardRef(function(t,n){const{render:o,className:g,id:r,disabled:p=!1,nativeButton:c=!0,...u}=t,{setTouched:N,setFocused:S,validationMode:R,state:m,disabled:C}=Ft(),{labelId:Q}=En(),{store:A,setOpen:U,selectionRef:L,validation:M,readOnly:b,required:y,alignItemWithTriggerActiveRef:z,disabled:ve,keyboardActiveRef:ne}=Ce(),k=C||ve||p,K=f(A,a.open),ue=f(A,a.value),B=f(A,a.triggerProps),_=f(A,a.positionerElement),q=f(A,a.listElement),x=f(A,a.id),oe=f(A,a.hasSelectedValue),X=!oe&&K,D=f(A,a.hasNullItemLabel,X),G=r??x;kt({id:G});const l=It(_),E=s.useRef(null),{getButtonProps:P,buttonRef:i}=_t({disabled:k,native:c}),le=He(V=>{A.set("triggerElement",V)}),h=zt(n,E,i,le),W=ze(),d=ze(),j=ze(),ee=ze();s.useEffect(()=>{if(K)return!(oe||D)?j.start(fs,()=>{L.current.allowUnselectedMouseUp=!0,L.current.allowSelectedMouseUp=!0}):ee.start(jt,()=>{L.current.allowUnselectedMouseUp=!0,j.start(jt,()=>{L.current.allowSelectedMouseUp=!0})}),()=>{j.clear(),ee.clear()};L.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1},d.clear()},[K,oe,D,L,d,j,ee]);const Me=s.useMemo(()=>{var V;return(q==null?void 0:q.id)??((V=Cn(_))==null?void 0:V.id)},[q,_]),Ue=Bt(B,{id:G,role:"combobox","aria-expanded":K?"true":"false","aria-haspopup":"listbox","aria-controls":K?Me:void 0,"aria-labelledby":Q,"aria-readonly":b||void 0,"aria-required":y||void 0,tabIndex:k?-1:0,ref:h,onFocus(V){S(!0),K&&z.current&&U(!1,je(Mt,V.nativeEvent)),W.start(0,()=>{A.set("forceMount",!0)})},onBlur(V){ht(_,V.relatedTarget)||(N(!0),S(!1),R==="onBlur"&&M.commit(ue))},onPointerMove(){ne.current=!1},onKeyDown(){ne.current=!0},onMouseDown(V){if(K)return;const de=bt(V.currentTarget);function se(ie){if(!E.current)return;const me=ie.target;if(ht(E.current,me)||ht(l.current,me)||me===E.current)return;const J=Hn(E.current);ie.clientX>=J.left-it&&ie.clientX<=J.right+it&&ie.clientY>=J.top-it&&ie.clientY<=J.bottom+it||U(!1,je(jn,ie))}d.start(0,()=>{de.addEventListener("mouseup",se,{once:!0})})}},M.getValidationProps,u,P);Ue.role="combobox";const T={...m,open:K,disabled:k,value:ue,readOnly:b,placeholder:!oe};return Ee("button",t,{ref:[n,E],state:T,stateAttributesMapping:ps,props:Ue})}),hs={value:()=>null},ms=s.forwardRef(function(t,n){const{className:o,render:g,children:r,placeholder:p,...c}=t,{store:u,valueRef:N}=Ce(),S=f(u,a.value),R=f(u,a.items),m=f(u,a.itemToStringLabel),C=f(u,a.hasSelectedValue),Q=!C&&p!=null&&r==null,A=f(u,a.hasNullItemLabel,Q),U={value:S,placeholder:!C};let L=null;return typeof r=="function"?L=r(S):r!=null?L=r:!C&&p!=null&&!A?L=p:Array.isArray(S)?L=us(S,R,m):L=Zt(S,R,m),Ee("span",t,{state:U,ref:[n,N],props:[{children:L},c],stateAttributesMapping:hs})}),xs=s.forwardRef(function(t,n){const{className:o,render:g,...r}=t,{store:p}=Ce(),u={open:f(p,a.open)};return Ee("span",t,{state:u,ref:n,props:[{"aria-hidden":!0,children:"▼"},r],stateAttributesMapping:Nn})}),bs=s.createContext(void 0),vs=s.forwardRef(function(t,n){const{store:o}=Ce(),g=f(o,a.mounted),r=f(o,a.forceMount);return g||r?v.jsx(bs.Provider,{value:!0,children:v.jsx(Un,{ref:n,...t})}):null}),Qt=s.createContext(void 0);function Tt(){const e=s.useContext(Qt);if(!e)throw new Error(ut(59));return e}function ct(e,t){e&&Object.assign(e.style,t)}const en={position:"relative",maxHeight:"100%",overflowX:"hidden",overflowY:"auto"},ys={position:"fixed"},Ss=s.forwardRef(function(t,n){const{anchor:o,positionMethod:g="absolute",className:r,render:p,side:c="bottom",align:u="center",sideOffset:N=0,alignOffset:S=0,collisionBoundary:R="clipping-ancestors",collisionPadding:m,arrowPadding:C=5,sticky:Q=!1,disableAnchorTracking:A,alignItemWithTrigger:U=!0,collisionAvoidance:L=Ln,...M}=t,{store:b,listRef:y,labelsRef:z,alignItemWithTriggerActiveRef:ve,selectedItemTextRef:ne,valuesRef:k,initialValueRef:K,popupRef:ue,setValue:B}=Ce(),_=Gt(),q=f(b,a.open),x=f(b,a.mounted),oe=f(b,a.modal),X=f(b,a.value),D=f(b,a.openMethod),G=f(b,a.positionerElement),l=f(b,a.triggerElement),E=f(b,a.isItemEqualToValue),P=f(b,a.transitionStatus),i=s.useRef(null),le=s.useRef(null),[h,W]=s.useState(U),d=x&&h&&D!=="touch";!x&&h!==U&&W(U),we(()=>{x||(a.scrollUpArrowVisible(b.state)&&b.set("scrollUpArrowVisible",!1),a.scrollDownArrowVisible(b.state)&&b.set("scrollDownArrowVisible",!1))},[b,x]),s.useImperativeHandle(ve,()=>d),On((d||oe)&&q&&D!=="touch",l);const j=Dn({anchor:o,floatingRootContext:_,positionMethod:g,mounted:x,side:c,sideOffset:N,align:u,alignOffset:S,arrowPadding:C,collisionBoundary:R,collisionPadding:m,sticky:Q,disableAnchorTracking:A??d,collisionAvoidance:L,keepMounted:!0}),ee=d?"none":j.side,Me=d?ys:j.positionerStyles,Ue=s.useMemo(()=>{const J={};return q||(J.pointerEvents="none"),{role:"presentation",hidden:!x,style:{...Me,...J}}},[q,x,Me]),T={open:q,side:ee,align:j.align,anchorHidden:j.anchorHidden},V=He(J=>{b.set("positionerElement",J)}),de=Ee("div",t,{ref:[n,V],state:T,stateAttributesMapping:qt,props:[Ue,Wt(P),M]}),se=s.useRef(0),ie=He(J=>{if(J.size===0&&se.current===0||k.current.length===0)return;const re=se.current;if(se.current=J.size,J.size===re)return;const fe=je(Mt);if(re!==0&&!b.state.multiple&&X!==null&&tt(k.current,X,E)===-1){const te=K.current,pe=te!=null&&tt(k.current,te,E)!==-1?te:null;B(pe,fe),pe===null&&(b.set("selectedIndex",null),ne.current=null)}if(re!==0&&b.state.multiple&&Array.isArray(X)){const Y=$=>tt(k.current,$,E)!==-1,te=X.filter($=>Y($));(te.length!==X.length||te.some($=>!ls(X,$,E)))&&(B(te,fe),te.length===0&&(b.set("selectedIndex",null),ne.current=null))}if(q&&d){b.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});const Y={height:""};ct(G,Y),ct(ue.current,Y)}}),me=s.useMemo(()=>({...j,side:ee,alignItemWithTriggerActive:d,setControlledAlignItemWithTrigger:W,scrollUpArrowRef:i,scrollDownArrowRef:le}),[j,ee,d,W]);return v.jsx(Fn,{elementsRef:y,labelsRef:z,onMapChange:ie,children:v.jsxs(Qt.Provider,{value:me,children:[x&&oe&&v.jsx(kn,{inert:Bn(!q),cutout:l}),de]})})});function tn(e){const t=e.currentTarget.getBoundingClientRect();return t.top+1<=e.clientY&&e.clientY<=t.bottom-1&&t.left+1<=e.clientX&&e.clientX<=t.right-1}const Be=1,Rs={...qt,...Yt},ws=s.forwardRef(function(t,n){const{render:o,className:g,finalFocus:r,...p}=t,{store:c,popupRef:u,onOpenChangeComplete:N,setOpen:S,valueRef:R,selectedItemTextRef:m,keyboardActiveRef:C,multiple:Q,handleScrollArrowVisibility:A,scrollHandlerRef:U,highlightItemOnHover:L}=Ce(),{side:M,align:b,alignItemWithTriggerActive:y,setControlledAlignItemWithTrigger:z,scrollDownArrowRef:ve,scrollUpArrowRef:ne}=Tt(),k=zn()!=null,K=Gt(),{nonce:ue,disableStyleElements:B}=_n(),_=ze(),q=f(c,a.id),x=f(c,a.open),oe=f(c,a.mounted),X=f(c,a.popupProps),D=f(c,a.transitionStatus),G=f(c,a.triggerElement),l=f(c,a.positionerElement),E=f(c,a.listElement),P=s.useRef(0),i=s.useRef(!1),le=s.useRef(0),h=s.useRef(!1),W=s.useRef({}),d=qn(),j=He(T=>{if(!l||!u.current||!h.current)return;if(i.current||!y){A();return}const V=l.style.top==="0px",de=l.style.bottom==="0px",se=l.getBoundingClientRect().height,ie=bt(l),me=getComputedStyle(l),J=parseFloat(me.marginTop),re=parseFloat(me.marginBottom),fe=Nt(getComputedStyle(u.current)),Y=Math.min(ie.documentElement.clientHeight-J-re,fe),te=T.scrollTop,$=Ut(T);let pe=0,w=null,Te=!1,Re=!1;const Le=Z=>{l.style.height=`${Z}px`},_e=(Z,xe)=>{const ge=mt(Z,0,Y-se);ge>0&&Le(se+ge),T.scrollTop=xe,Y-(se+ge)<=Be&&(i.current=!0),A()};if(V){const Z=$-te,xe=se+Z,ge=Math.min(xe,Y);if(pe=ge,Z<=Be){_e(Z,$);return}Y-ge>Be?Re=!0:Te=!0}else if(de){const Z=te,xe=se+Z,ge=Math.min(xe,Y),ye=xe-Y;if(pe=ge,Z<=Be){_e(Z,0);return}Y-ge>Be?w=0:(Te=!0,te<$&&(w=te-(Z-ye)))}if(pe=Math.ceil(pe),pe!==0&&Le(pe),Re||w!=null){const Z=Ut(T),xe=Re?Z:mt(w,0,Z);Math.abs(T.scrollTop-xe)>Be&&(T.scrollTop=xe)}(Te||pe>=Y-Be)&&(i.current=!0),A()});s.useImperativeHandle(U,()=>j,[j]),dt({open:x,ref:u,onComplete(){x&&(N==null||N(!0))}});const ee={open:x,transitionStatus:D,side:M,align:b};we(()=>{!l||!u.current||Object.keys(W.current).length||(W.current={top:l.style.top||"0",left:l.style.left||"0",right:l.style.right,height:l.style.height,bottom:l.style.bottom,minHeight:l.style.minHeight,maxHeight:l.style.maxHeight,marginTop:l.style.marginTop,marginBottom:l.style.marginBottom})},[u,l]),we(()=>{x||y||(h.current=!1,i.current=!1,P.current=0,le.current=0,ct(l,W.current))},[x,y,l,u]),we(()=>{const T=u.current;if(!(!x||!G||!l||!T||c.state.transitionStatus==="ending")){if(!y){h.current=!0,d.request(A),T.style.removeProperty("--transform-origin");return}queueMicrotask(()=>{var de;const V=Is(T);T.style.removeProperty("--transform-origin");try{const se=getComputedStyle(l),ie=getComputedStyle(T),me=bt(G),J=Ht(l),re=G.getBoundingClientRect(),fe=l.getBoundingClientRect(),Y=re.left,te=re.height,$=E||T,pe=$.scrollHeight,w=parseFloat(ie.borderBottomWidth),Te=parseFloat(se.marginTop)||10,Re=parseFloat(se.marginBottom)||10,Le=parseFloat(se.minHeight)||100,_e=Nt(ie),Z=5,xe=5,ge=20,ye=me.documentElement.clientHeight-Te-Re,Xe=me.documentElement.clientWidth,Ge=ye-re.bottom+te,Fe=m.current,Je=R.current;let ae,nt=0,st=0;if(Fe&&Je){const O=Je.getBoundingClientRect();ae=Fe.getBoundingClientRect();const ce=O.left-Y,Se=ae.left-fe.left,be=O.top-re.top+O.height/2,Oe=ae.top-fe.top+ae.height/2;nt=ce-Se,st=Oe-be}const Ze=Ge+st+Re+w;let Ae=Math.min(ye,Ze);const ot=ye-Te-Re,ke=Ze-Ae,Qe=Math.max(Z,Y+nt),et=Xe-xe,ft=Math.max(0,Qe+fe.width-et);l.style.left=`${Qe-ft}px`,l.style.height=`${Ae}px`,l.style.maxHeight="auto",l.style.marginTop=`${Te}px`,l.style.marginBottom=`${Re}px`,T.style.height="100%";const rt=$.scrollHeight-$.clientHeight,lt=ke>=rt;lt&&(Ae=Math.min(ye,fe.height)-(ke-rt));const pt=re.top<ge||re.bottom>ye-ge||Ae<Math.min(pe,Le),I=(((de=J.visualViewport)==null?void 0:de.scale)??1)!==1&&Wn;if(pt||I){h.current=!0,ct(l,W.current),Yn.flushSync(()=>z(!1));return}if(lt){const O=Math.max(0,ye-Ze);l.style.top=fe.height>=ot?"0":`${O}px`,l.style.height=`${Ae}px`,$.scrollTop=$.scrollHeight-$.clientHeight,P.current=Math.max(Le,Ae)}else l.style.bottom="0",P.current=Math.max(Le,Ae),$.scrollTop=ke;if(ae){const O=fe.top,ce=fe.height,Se=ae.top+ae.height/2,be=ce>0?(Se-O)/ce*100:50,Oe=mt(be,0,100);T.style.setProperty("--transform-origin",`50% ${Oe}%`)}(P.current===ye||Ae>=_e)&&(i.current=!0),A(),setTimeout(()=>{h.current=!0})}finally{V()}})}},[c,x,l,G,R,m,u,A,y,z,d,ve,ne,E]),s.useEffect(()=>{if(!y||!l||!x)return;const T=Ht(l);function V(de){S(!1,je(Kn,de))}return T.addEventListener("resize",V),()=>{T.removeEventListener("resize",V)}},[S,y,l,x]);const Me={...E?{role:"presentation","aria-orientation":void 0}:{role:"listbox","aria-multiselectable":Q||void 0,id:`${q}-list`},onKeyDown(T){C.current=!0,k&&Xn.has(T.key)&&T.stopPropagation()},onMouseMove(){C.current=!1},onPointerLeave(T){if(!L||tn(T)||T.pointerType==="touch")return;const V=T.currentTarget;_.start(0,()=>{c.set("activeIndex",null),V.focus({preventScroll:!0})})},onScroll(T){E||j(T.currentTarget)},...y&&{style:E?{height:"100%"}:en}},Ue=Ee("div",t,{ref:[n,u],state:ee,stateAttributesMapping:Rs,props:[X,Me,Wt(D),{className:!E&&y?vt.className:void 0},p]});return v.jsxs(s.Fragment,{children:[!B&&vt.getElement(ue),v.jsx($n,{context:K,modal:!1,disabled:!oe,returnFocus:r,restoreFocus:!0,children:Ue})]})});function Nt(e){const t=e.maxHeight||"";return t.endsWith("px")&&parseFloat(t)||1/0}function Ut(e){return Math.max(0,e.scrollHeight-e.clientHeight)}const Lt=[["transform","none"],["scale","1"],["translate","0 0"]];function Is(e){const{style:t}=e,n={};for(const[o,g]of Lt)n[o]=t.getPropertyValue(o),t.setProperty(o,g,"important");return()=>{for(const[o]of Lt){const g=n[o];g?t.setProperty(o,g):t.removeProperty(o)}}}const Ms=s.forwardRef(function(t,n){const{className:o,render:g,...r}=t,{store:p,scrollHandlerRef:c}=Ce(),{alignItemWithTriggerActive:u}=Tt(),N=f(p,a.hasScrollArrows),S=f(p,a.openMethod),R=f(p,a.multiple),C={id:`${f(p,a.id)}-list`,role:"listbox","aria-multiselectable":R||void 0,onScroll(A){var U;(U=c.current)==null||U.call(c,A.currentTarget)},...u&&{style:en},className:N&&S!=="touch"?vt.className:void 0},Q=He(A=>{p.set("listElement",A)});return Ee("div",t,{ref:[n,Q],props:[C,r]})}),nn=s.createContext(void 0);function At(){const e=s.useContext(nn);if(!e)throw new Error(ut(57));return e}const Ts=s.memo(s.forwardRef(function(t,n){const{render:o,className:g,value:r=null,label:p,disabled:c=!1,nativeButton:u=!1,...N}=t,S=s.useRef(null),R=Gn({label:p,textRef:S,indexGuessBehavior:Jn.GuessFromOrder}),{store:m,getItemProps:C,setOpen:Q,setValue:A,selectionRef:U,typingRef:L,valuesRef:M,keyboardActiveRef:b,multiple:y,highlightItemOnHover:z}=Ce(),ve=ze(),ne=f(m,a.isActive,R.index),k=f(m,a.isSelected,R.index,r),K=f(m,a.isSelectedByFocus,R.index),ue=f(m,a.isItemEqualToValue),B=R.index,_=B!==-1,q=s.useRef(null),x=It(B);we(()=>{if(!_)return;const d=M.current;return d[B]=r,()=>{delete d[B]}},[_,B,r,M]),we(()=>{if(!_)return;const d=m.state.value;let j=d;y&&Array.isArray(d)&&d.length>0&&(j=d[d.length-1]),j!==void 0&&Ke(r,j,ue)&&m.set("selectedIndex",B)},[_,B,y,ue,m,r]);const oe={disabled:c,selected:k,highlighted:ne},X=C({active:ne,selected:k});X.onFocus=void 0,X.id=void 0;const D=s.useRef(null),G=s.useRef("mouse"),l=s.useRef(!1),{getButtonProps:E,buttonRef:P}=_t({disabled:c,focusableWhenDisabled:!0,native:u});function i(d){const j=m.state.value;if(y){const ee=Array.isArray(j)?j:[],Me=k?is(ee,r,ue):[...ee,r];A(Me,je(xt,d))}else A(r,je(xt,d)),Q(!1,je(xt,d))}const le={role:"option","aria-selected":k,tabIndex:ne?0:-1,onFocus(){m.set("activeIndex",B)},onMouseEnter(){!b.current&&m.state.selectedIndex===null&&z&&m.set("activeIndex",B)},onMouseMove(){z&&m.set("activeIndex",B)},onMouseLeave(d){!z||b.current||tn(d)||ve.start(0,()=>{m.state.activeIndex===B&&m.set("activeIndex",null)})},onTouchStart(){U.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}},onKeyDown(d){D.current=d.key,m.set("activeIndex",B)},onClick(d){l.current=!1,!(d.type==="keydown"&&D.current===null)&&(c||D.current===" "&&L.current||G.current!=="touch"&&!ne||(D.current=null,i(d.nativeEvent)))},onPointerEnter(d){G.current=d.pointerType},onPointerDown(d){G.current=d.pointerType,l.current=!0},onMouseUp(d){if(c)return;if(l.current){l.current=!1;return}const j=!U.current.allowSelectedMouseUp&&k,ee=!U.current.allowUnselectedMouseUp&&!k;j||ee||G.current!=="touch"&&!ne||i(d.nativeEvent)}},h=Ee("div",t,{ref:[P,n,R.ref,q],state:oe,props:[X,le,N,E]}),W=s.useMemo(()=>({selected:k,indexRef:x,textRef:S,selectedByFocus:K,hasRegistered:_}),[k,x,S,K,_]);return v.jsx(nn.Provider,{value:W,children:h})})),As=s.forwardRef(function(t,n){const o=t.keepMounted??!1,{selected:g}=At();return o||g?v.jsx(Es,{...t,ref:n}):null}),Es=s.memo(s.forwardRef((e,t)=>{const{render:n,className:o,keepMounted:g,...r}=e,{selected:p}=At(),c=s.useRef(null),{transitionStatus:u,setMounted:N}=wt(p),R=Ee("span",e,{ref:[t,c],state:{selected:p,transitionStatus:u},props:[{"aria-hidden":!0,children:"✔️"},r],stateAttributesMapping:Yt});return dt({open:p,ref:c,onComplete(){p||N(!1)}}),R})),Cs=s.memo(s.forwardRef(function(t,n){const{indexRef:o,textRef:g,selectedByFocus:r,hasRegistered:p}=At(),{selectedItemTextRef:c}=Ce(),{className:u,render:N,...S}=t,R=s.useCallback(C=>{if(!C||!p)return;const Q=c.current===null||!c.current.isConnected;(r||Q&&o.current===0)&&(c.current=C)},[c,o,r,p]);return Ee("div",t,{ref:[R,n,g],props:S})})),sn=s.forwardRef(function(t,n){const{render:o,className:g,direction:r,keepMounted:p=!1,...c}=t,{store:u,popupRef:N,listRef:S,handleScrollArrowVisibility:R,scrollArrowsMountedCountRef:m}=Ce(),{side:C,scrollDownArrowRef:Q,scrollUpArrowRef:A}=Tt(),U=r==="up"?a.scrollUpArrowVisible:a.scrollDownArrowVisible,L=f(u,U),M=f(u,a.openMethod),b=L&&M!=="touch",y=ze(),z=r==="up"?A:Q,{transitionStatus:ve,setMounted:ne}=wt(b);we(()=>(m.current+=1,u.state.hasScrollArrows||u.set("hasScrollArrows",!0),()=>{m.current=Math.max(0,m.current-1),m.current===0&&u.state.hasScrollArrows&&u.set("hasScrollArrows",!1)}),[u,m]),dt({open:b,ref:z,onComplete(){b||ne(!1)}});const ue=Ee("div",t,{ref:[n,z],state:{direction:r,visible:b,side:C,transitionStatus:ve},props:[{"aria-hidden":!0,children:r==="up"?"▲":"▼",style:{position:"absolute"},onMouseMove(_){if(_.movementX===0&&_.movementY===0||y.isStarted())return;u.set("activeIndex",null);function q(){var G;const x=u.state.listElement??N.current;if(!x)return;u.set("activeIndex",null),R();const oe=x.scrollTop===0,X=Math.round(x.scrollTop+x.clientHeight)>=x.scrollHeight;if(S.current.length===0&&(r==="up"?u.set("scrollUpArrowVisible",!oe):u.set("scrollDownArrowVisible",!X)),r==="up"&&oe||r==="down"&&X){y.clear();return}if((u.state.listElement||N.current)&&S.current&&S.current.length>0){const l=S.current,E=((G=z.current)==null?void 0:G.offsetHeight)||0;if(r==="up"){let P=0;const i=x.scrollTop+E;for(let h=0;h<l.length;h+=1){const W=l[h];if(W&&W.offsetTop>=i){P=h;break}}const le=Math.max(0,P-1);if(le<P){const h=l[le];h&&(x.scrollTop=Math.max(0,h.offsetTop-E))}else x.scrollTop=0}else{let P=l.length-1;const i=x.scrollTop+x.clientHeight-E;for(let h=0;h<l.length;h+=1){const W=l[h];if(W&&W.offsetTop+W.offsetHeight>i){P=Math.max(0,h-1);break}}const le=Math.min(l.length-1,P+1);if(le>P){const h=l[le];h&&(x.scrollTop=h.offsetTop+h.offsetHeight-x.clientHeight+E)}else x.scrollTop=x.scrollHeight-x.clientHeight}}y.start(40,q)}y.start(40,q)},onMouseLeave(){y.clear()}},c]});return b||p?ue:null}),Ps=s.forwardRef(function(t,n){return v.jsx(sn,{...t,ref:n,direction:"down"})}),Vs=s.forwardRef(function(t,n){return v.jsx(sn,{...t,ref:n,direction:"up"})}),qs=ds;function Ws({className:e,...t}){return v.jsx(ms,{"data-slot":"select-value",className:Ie("flex flex-1 text-left",e),...t})}function Ys({className:e,size:t="default",children:n,...o}){return v.jsxs(gs,{"data-slot":"select-trigger","data-size":t,className:Ie("border-input data-placeholder:text-muted-foreground dark:bg-input/30 dark:hover:bg-input/50 focus-visible:border-ring focus-visible:ring-ring/30 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 gap-1.5 rounded-lg border bg-transparent py-2 pr-2 pl-2.5 text-sm transition-colors select-none focus-visible:ring-2 aria-invalid:ring-2 data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:gap-1.5 [&_svg:not([class*='size-'])]:size-4 flex w-fit items-center justify-between whitespace-nowrap outline-none disabled:cursor-not-allowed disabled:opacity-50 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center [&_svg]:pointer-events-none [&_svg]:shrink-0",e),...o,children:[n,v.jsx(xs,{render:v.jsx($t,{className:"text-muted-foreground size-4 pointer-events-none"})})]})}function $s({className:e,children:t,side:n="bottom",sideOffset:o=4,align:g="center",alignOffset:r=0,alignItemWithTrigger:p=!0,...c}){return v.jsx(vs,{children:v.jsx(Ss,{side:n,sideOffset:o,align:g,alignOffset:r,alignItemWithTrigger:p,className:"isolate z-50",children:v.jsxs(ws,{"data-slot":"select-content","data-align-trigger":p,className:Ie("bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-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 ring-foreground/10 min-w-36 rounded-lg shadow-md ring-1 duration-100 data-[side=inline-start]:slide-in-from-right-2 data-[side=inline-end]:slide-in-from-left-2 relative isolate z-50 max-h-(--available-height) w-(--anchor-width) origin-(--transform-origin) overflow-x-hidden overflow-y-auto data-[align-trigger=true]:animate-none",e),...c,children:[v.jsx(Hs,{}),v.jsx(Ms,{children:t}),v.jsx(js,{})]})})})}function Ks({className:e,children:t,...n}){return v.jsxs(Ts,{"data-slot":"select-item",className:Ie("focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2 relative flex w-full cursor-default items-center outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",e),...n,children:[v.jsx(Cs,{className:"flex flex-1 gap-2 shrink-0 whitespace-nowrap",children:t}),v.jsx(As,{render:v.jsx("span",{className:"pointer-events-none absolute right-2 flex size-4 items-center justify-center"}),children:v.jsx(ts,{className:"pointer-events-none"})})]})}function Hs({className:e,...t}){return v.jsx(Vs,{"data-slot":"select-scroll-up-button",className:Ie("bg-popover z-10 flex cursor-default items-center justify-center py-1 [&_svg:not([class*='size-'])]:size-4 top-0 w-full",e),...t,children:v.jsx(os,{})})}function js({className:e,...t}){return v.jsx(Ps,{"data-slot":"select-scroll-down-button",className:Ie("bg-popover z-10 flex cursor-default items-center justify-center py-1 [&_svg:not([class*='size-'])]:size-4 bottom-0 w-full",e),...t,children:v.jsx($t,{})})}export{Fs as C,qs as S,ks as a,Bs as b,_s as c,Ys as d,Ws as e,$s as f,Ks as g,zs as h,Ds as u};
17
- //# sourceMappingURL=select-C02R2Kd_.js.map
17
+ //# sourceMappingURL=select-CD0ieoCm.js.map
@@ -1,4 +1,4 @@
1
- import{c as N,r as s,_ as ne,aA as se,a0 as re,a1 as L,av as ie,ab as ce,al as oe,bc as le,a2 as ue,a3 as fe,a9 as he,aa as pe,aw as me,aj as ke,az as _,j as f,as as ve,am as ge,an as be,ao as xe,ap as ye,q as Ce}from"./index-CmLsM0XA.js";import{u as we}from"./useValueChanged-CHeT2_Oy.js";/**
1
+ import{c as N,r as s,_ as ne,aA as se,a0 as re,a1 as L,av as ie,ab as ce,al as oe,bf as le,a2 as ue,a3 as fe,a9 as he,aa as pe,aw as me,aj as ke,az as _,j as f,as as ve,am as ge,an as be,ao as xe,ap as ye,q as Ce}from"./index-YVZKH9DX.js";import{u as we}from"./useValueChanged-CFS5t0R_.js";/**
2
2
  * @license lucide-react v0.564.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -9,4 +9,4 @@ import{c as N,r as s,_ as ne,aA as se,a0 as re,a1 as L,av as ie,ab as ce,al as o
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
11
  */const Pe=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Ve=N("send",Pe),q=s.createContext(void 0);function Ee(){const e=s.useContext(q);if(e===void 0)throw new Error(ne(63));return e}let F=(function(e){return e.checked="data-checked",e.unchecked="data-unchecked",e.disabled="data-disabled",e.readonly="data-readonly",e.required="data-required",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e})({});const S={...se,checked(e){return e?{[F.checked]:""}:{[F.unchecked]:""}}},Ie=s.forwardRef(function(r,o){const{checked:w,className:T,defaultChecked:k,id:v,inputRef:g,name:b,nativeButton:x=!1,onCheckedChange:O,readOnly:h=!1,required:l=!1,disabled:H=!1,render:Me,uncheckedValue:z,value:y,...J}=r,{clearErrors:U}=re(),{state:P,setTouched:Y,setDirty:$,validityData:G,setFilled:C,setFocused:E,shouldValidateOnChange:Q,validationMode:W,disabled:X,name:Z,validation:d}=L(),{labelId:D}=ie(),n=X||H,i=Z??b,p=ce(O),c=s.useRef(null),I=oe(c,g,d.inputRef),m=s.useRef(null),R=le(),M=ue({id:v,implicit:!1,controlRef:m}),j=x?void 0:M,[t,B]=fe({controlled:w,default:!!k,name:"Switch",state:"checked"});he({id:R,commit:d.commit,value:t,controlRef:m,name:i,getValue:()=>t}),pe(()=>{c.current&&C(c.current.checked)},[c,C]),we(t,()=>{U(i),$(t!==G.initialValue),C(t),Q()?d.commit(t):d.commit(t,!0)});const{getButtonProps:A,buttonRef:ee}=me({disabled:n,native:x}),ae={id:x?M:R,role:"switch","aria-checked":t,"aria-readonly":h||void 0,"aria-required":l||void 0,"aria-labelledby":D,onFocus(){n||E(!0)},onBlur(){const a=c.current;!a||n||(Y(!0),E(!1),W==="onBlur"&&d.commit(a.checked))},onClick(a){var u;h||n||(a.preventDefault(),(u=c.current)==null||u.dispatchEvent(new PointerEvent("click",{bubbles:!0,shiftKey:a.shiftKey,ctrlKey:a.ctrlKey,altKey:a.altKey,metaKey:a.metaKey})))}},te=s.useMemo(()=>ke({checked:t,disabled:n,id:j,name:i,required:l,style:i?ge:be,tabIndex:-1,type:"checkbox","aria-hidden":!0,ref:I,onChange(a){if(a.nativeEvent.defaultPrevented)return;const u=a.target.checked,V=xe(ye,a.nativeEvent);p==null||p(u,V),!V.isCanceled&&B(u)},onFocus(){var a;(a=m.current)==null||a.focus()}},d.getInputValidationProps,y!==void 0?{value:y}:ve),[t,n,I,j,i,p,l,B,d,y]),K=s.useMemo(()=>({...P,checked:t,disabled:n,readOnly:h,required:l}),[P,t,n,h,l]),de=_("span",r,{state:K,ref:[o,m,ee],props:[ae,d.getValidationProps,J,A],stateAttributesMapping:S});return f.jsxs(q.Provider,{value:K,children:[de,!t&&i&&z!==void 0&&f.jsx("input",{type:"hidden",name:i,value:z}),f.jsx("input",{...te})]})}),Re=s.forwardRef(function(r,o){const{render:w,className:T,...k}=r,{state:v}=L(),g=Ee(),b={...v,...g};return _("span",r,{state:b,ref:o,stateAttributesMapping:S,props:k})});function Fe({className:e,size:r="default",...o}){return f.jsx(Ie,{"data-slot":"switch","data-size":r,className:Ce("data-checked:bg-primary data-unchecked:bg-input 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:aria-invalid:border-destructive/50 dark:data-unchecked:bg-input/80 shrink-0 rounded-full border border-transparent focus-visible:ring-3 aria-invalid:ring-3 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] peer group/switch relative inline-flex items-center transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 data-disabled:cursor-not-allowed data-disabled:opacity-50",e),...o,children:f.jsx(Re,{"data-slot":"switch-thumb",className:"bg-background dark:data-unchecked:bg-foreground dark:data-checked:bg-primary-foreground rounded-full group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 pointer-events-none block ring-0 transition-transform"})})}export{Ke as L,Fe as S,Ve as a};
12
- //# sourceMappingURL=switch-WtpunVNm.js.map
12
+ //# sourceMappingURL=switch-B4Od47H9.js.map
@@ -1,7 +1,7 @@
1
- import{c as r,r as s,ab as n,aa as c}from"./index-CmLsM0XA.js";/**
1
+ import{c as r,r as s,ab as n,aa as c}from"./index-YVZKH9DX.js";/**
2
2
  * @license lucide-react v0.564.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
6
  */const u=[["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"}]],d=r("trash-2",u);function p(a,o){const t=s.useRef(a),e=n(o);c(()=>{t.current!==a&&e(t.current)},[a,e]),c(()=>{t.current=a},[a])}export{d as T,p as u};
7
- //# sourceMappingURL=useValueChanged-CHeT2_Oy.js.map
7
+ //# sourceMappingURL=useValueChanged-CFS5t0R_.js.map
@@ -17,7 +17,7 @@
17
17
  <link rel="apple-touch-icon" href="/tmex.png" />
18
18
  <meta name="description" content="tmex - Web 接入多设备 tmux 的终端控制平台" />
19
19
  <title>tmex</title>
20
- <script type="module" crossorigin src="/assets/index-CmLsM0XA.js"></script>
20
+ <script type="module" crossorigin src="/assets/index-YVZKH9DX.js"></script>
21
21
  <link rel="stylesheet" crossorigin href="/assets/index-D5hzP84o.css">
22
22
  </head>
23
23
  <body>
@@ -1,36 +0,0 @@
1
- var $t=Object.defineProperty;var jt=(n,e,t)=>e in n?$t(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var f=(n,e,t)=>jt(n,typeof e!="symbol"?e+"":e,t);import{c as be,u as Ke,j as h,b3 as Wt,r as d,s as Z,b4 as dt,g as _e,b5 as it,b6 as qt,b as At,b7 as ot,d as ae,b8 as Xt,e as Jt,b9 as Ot,ba as Se,bb as Qt,B as pe,A as Zt,h as en,i as tn,k as nn,l as sn,m as rn,n as on,o as ln}from"./index-CmLsM0XA.js";import{L as We,S as an,a as ut}from"./switch-WtpunVNm.js";import{T as cn}from"./useValueChanged-CHeT2_Oy.js";/**
2
- * @license lucide-react v0.564.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const dn=[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]],un=be("arrow-down-to-line",dn);/**
7
- * @license lucide-react v0.564.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const hn=[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]],fn=be("clipboard-paste",hn);/**
12
- * @license lucide-react v0.564.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const mn=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],pn=be("copy",mn);/**
17
- * @license lucide-react v0.564.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const wn=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],yn=be("keyboard",wn);/**
22
- * @license lucide-react v0.564.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */const gn=[["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"}]],Sn=be("refresh-cw",gn);/**
27
- * @license lucide-react v0.564.0 - ISC
28
- *
29
- * This source code is licensed under the ISC license.
30
- * See the LICENSE file in the root directory of this source tree.
31
- */const _n=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],bn=be("smartphone",_n);function xn(n){return`rgb(${n.r} ${n.g} ${n.b})`}function qe(n){const e=n.getContext("2d");if(!e)throw new Error("2d canvas context unavailable");return e}class Tn{constructor(e){f(this,"kind","canvas");f(this,"mainCanvas");f(this,"selectionCanvas");f(this,"cursorCanvas");f(this,"mainContext");f(this,"selectionContext");f(this,"cursorContext");f(this,"theme");f(this,"fontFamily");f(this,"fontSize");f(this,"cellDimensions",{width:9,height:17});f(this,"cols",0);f(this,"rows",0);f(this,"lastCursor",null);f(this,"frameCount",0);f(this,"lastDrawnRows",[]);f(this,"colorCache",new Map);f(this,"fontCache",new Map);f(this,"cursorBlinkVisible",!0);f(this,"cursorBlinkTimer",null);this.theme=e.theme,this.fontFamily=e.fontFamily,this.fontSize=e.fontSize,e.screenElement.style.position="relative",e.screenElement.style.overflow="hidden",this.mainCanvas=document.createElement("canvas"),this.selectionCanvas=document.createElement("canvas"),this.cursorCanvas=document.createElement("canvas");for(const[t,s]of[[this.mainCanvas,"main"],[this.selectionCanvas,"selection"],[this.cursorCanvas,"cursor"]])t.dataset.layer=s,t.style.position="absolute",t.style.inset="0",t.style.width="100%",t.style.height="100%",t.style.pointerEvents="none",e.screenElement.appendChild(t);this.mainContext=qe(this.mainCanvas),this.selectionContext=qe(this.selectionCanvas),this.cursorContext=qe(this.cursorCanvas)}setTheme(e){this.theme=e,this.colorCache.clear()}render(e){if(this.frameCount+=1,this.lastDrawnRows=[],this.cellDimensions=e.cellDimensions,this.resize(e.meta.cols,e.meta.rows),this.drawSelection(e.selectionRects??[],e.selectionColor??this.theme.selectionBackground),e.meta.dirty==="clean"){this.drawCursor(e.meta);return}const s=e.meta.dirty==="full"?e.rows:e.rows.filter(r=>r.dirty);for(const r of s)this.drawRow(r,e.meta.colors),this.lastDrawnRows.push(r.y);this.drawCursor(e.meta)}getDebugState(){return{kind:this.kind,frameCount:this.frameCount,lastDrawnRows:[...this.lastDrawnRows]}}dispose(){this.mainCanvas.remove(),this.selectionCanvas.remove(),this.cursorCanvas.remove(),this.colorCache.clear(),this.fontCache.clear(),this.lastCursor=null,this.stopCursorBlink()}startCursorBlink(){this.cursorBlinkTimer||(this.cursorBlinkTimer=setInterval(()=>{this.cursorBlinkVisible=!this.cursorBlinkVisible,this.cursorCanvas.style.opacity=this.cursorBlinkVisible?"1":"0"},1e3))}stopCursorBlink(){this.cursorBlinkTimer&&(clearInterval(this.cursorBlinkTimer),this.cursorBlinkTimer=null),this.cursorBlinkVisible=!0,this.cursorCanvas.style.opacity="1"}resize(e,t){const s=Math.max(1,e),r=Math.max(1,t),i=s*this.cellDimensions.width,o=r*this.cellDimensions.height,l=Math.max(1,globalThis.devicePixelRatio??1);if(this.cols===s&&this.rows===r){const u=`${i}px`,a=`${o}px`;if(this.mainCanvas.style.width===u&&this.mainCanvas.style.height===a)return}this.cols=s,this.rows=r;for(const u of[this.mainCanvas,this.selectionCanvas,this.cursorCanvas])u.width=Math.max(1,Math.ceil(i*l)),u.height=Math.max(1,Math.ceil(o*l)),u.style.width=`${i}px`,u.style.height=`${o}px`;for(const u of[this.mainContext,this.selectionContext,this.cursorContext])u.setTransform(l,0,0,l,0,0),u.textBaseline="top",u.imageSmoothingEnabled=!1}drawSelection(e,t){if(this.selectionContext.clearRect(0,0,this.cols*this.cellDimensions.width,this.rows*this.cellDimensions.height),e.length!==0){this.selectionContext.fillStyle=t;for(const s of e)this.selectionContext.fillRect(s.x*this.cellDimensions.width,s.row*this.cellDimensions.height,s.width*this.cellDimensions.width,this.cellDimensions.height)}}drawRow(e,t){const s=e.y*this.cellDimensions.height,r=this.cols*this.cellDimensions.width,i=this.toCss(t.background);this.mainContext.clearRect(0,s,r,this.cellDimensions.height),this.mainContext.fillStyle=i,this.mainContext.fillRect(0,s,r,this.cellDimensions.height);for(const o of e.cells){if(o.widthKind==="spacer-tail"||o.widthKind==="spacer-head")continue;const l=o.x*this.cellDimensions.width,u=o.style.inverse?o.fgColor??t.foreground:o.bgColor??t.background,a=o.style.inverse?o.bgColor??t.background:o.fgColor??t.foreground,g=o.widthKind==="wide"?this.cellDimensions.width*2:this.cellDimensions.width;(u.r!==t.background.r||u.g!==t.background.g||u.b!==t.background.b)&&(this.mainContext.fillStyle=this.toCss(u),this.mainContext.fillRect(l,s,g,this.cellDimensions.height)),!(!o.text||o.style.invisible)&&(this.mainContext.font=this.resolveFont(o.style),this.mainContext.fillStyle=this.toCss(a),this.mainContext.fillText(o.text,l,s),o.style.underline>0&&this.mainContext.fillRect(l,s+this.cellDimensions.height-2,Math.max(g-1,1),1),o.style.strikethrough&&this.mainContext.fillRect(l,s+this.cellDimensions.height*.55,Math.max(g-1,1),1),o.style.overline&&this.mainContext.fillRect(l,s+1,Math.max(g-1,1),1))}}drawCursor(e){const t=e.colors,s=e.cursor,r=this.lastCursor;if(this.cursorContext.clearRect(0,0,this.cols*this.cellDimensions.width,this.rows*this.cellDimensions.height),!s.visible||s.x===null||s.y===null){this.lastCursor=null,this.stopCursorBlink();return}const i=s.x*this.cellDimensions.width,o=s.y*this.cellDimensions.height,l=s.wideTail?this.cellDimensions.width*2:this.cellDimensions.width,u=t.cursor??t.foreground,a=this.toCss(u);this.cursorContext.fillStyle=a,this.cursorContext.strokeStyle=a,this.cursorContext.globalAlpha=.7,this.cursorContext.fillRect(i,o+this.cellDimensions.height-2,Math.max(l-1,1),2),this.cursorContext.globalAlpha=1,this.startCursorBlink(),this.lastCursor={x:s.x,y:s.y,style:s.style},r&&(r.x!==this.lastCursor.x||r.y!==this.lastCursor.y||r.style!==this.lastCursor.style)&&this.lastDrawnRows.push(r.y)}resolveFont(e){const t=[e.italic?"italic":"normal",e.bold?"700":"400",`${this.fontSize}px`,this.fontFamily].join("|"),s=this.fontCache.get(t);if(s)return s;const r=`${e.italic?"italic ":""}${e.bold?"700 ":""}${this.fontSize}px ${this.fontFamily}`;return this.fontCache.set(t,r),r}toCss(e){const t=`${e.r},${e.g},${e.b}`,s=this.colorCache.get(t);if(s)return s;const r=xn(e);return this.colorCache.set(t,r),r}}const En=0,Rn={Backquote:1,Backslash:2,BracketLeft:3,BracketRight:4,Comma:5,Digit0:6,Digit1:7,Digit2:8,Digit3:9,Digit4:10,Digit5:11,Digit6:12,Digit7:13,Digit8:14,Digit9:15,Equal:16,IntlBackslash:17,IntlRo:18,IntlYen:19,KeyA:20,KeyB:21,KeyC:22,KeyD:23,KeyE:24,KeyF:25,KeyG:26,KeyH:27,KeyI:28,KeyJ:29,KeyK:30,KeyL:31,KeyM:32,KeyN:33,KeyO:34,KeyP:35,KeyQ:36,KeyR:37,KeyS:38,KeyT:39,KeyU:40,KeyV:41,KeyW:42,KeyX:43,KeyY:44,KeyZ:45,Minus:46,Period:47,Quote:48,Semicolon:49,Slash:50,AltLeft:51,AltRight:52,Backspace:53,CapsLock:54,ContextMenu:55,ControlLeft:56,ControlRight:57,Enter:58,MetaLeft:59,MetaRight:60,ShiftLeft:61,ShiftRight:62,Space:63,Tab:64,Convert:65,KanaMode:66,NonConvert:67,Delete:68,End:69,Help:70,Home:71,Insert:72,PageDown:73,PageUp:74,ArrowDown:75,ArrowLeft:76,ArrowRight:77,ArrowUp:78,NumLock:79,Numpad0:80,Numpad1:81,Numpad2:82,Numpad3:83,Numpad4:84,Numpad5:85,Numpad6:86,Numpad7:87,Numpad8:88,Numpad9:89,NumpadAdd:90,NumpadBackspace:91,NumpadClear:92,NumpadClearEntry:93,NumpadComma:94,NumpadDecimal:95,NumpadDivide:96,NumpadEnter:97,NumpadEqual:98,NumpadMemoryAdd:99,NumpadMemoryClear:100,NumpadMemoryRecall:101,NumpadMemoryStore:102,NumpadMemorySubtract:103,NumpadMultiply:104,NumpadParenLeft:105,NumpadParenRight:106,NumpadSubtract:107,NumpadSeparator:108,NumpadUp:109,NumpadDown:110,NumpadRight:111,NumpadLeft:112,NumpadBegin:113,NumpadHome:114,NumpadEnd:115,NumpadInsert:116,NumpadDelete:117,NumpadPageUp:118,NumpadPageDown:119,Escape:120,F1:121,F2:122,F3:123,F4:124,F5:125,F6:126,F7:127,F8:128,F9:129,F10:130,F11:131,F12:132,F13:133,F14:134,F15:135,F16:136,F17:137,F18:138,F19:139,F20:140,F21:141,F22:142,F23:143,F24:144,F25:145,Fn:146,FnLock:147,PrintScreen:148,ScrollLock:149,Pause:150,BrowserBack:151,BrowserFavorites:152,BrowserForward:153,BrowserHome:154,BrowserRefresh:155,BrowserSearch:156,BrowserStop:157,Eject:158,LaunchApp1:159,LaunchApp2:160,LaunchMail:161,MediaPlayPause:162,MediaSelect:163,MediaStop:164,MediaTrackNext:165,MediaTrackPrevious:166,Power:167,Sleep:168,AudioVolumeDown:169,AudioVolumeMute:170,AudioVolumeUp:171,WakeUp:172,Copy:173,Cut:174,Paste:175},lt={Backquote:"`",Backslash:"\\",BracketLeft:"[",BracketRight:"]",Comma:",",Equal:"=",Minus:"-",Period:".",Quote:"'",Semicolon:";",Slash:"/",Space:" ",IntlBackslash:"\\",IntlYen:"¥",IntlRo:"\\"};for(let n=0;n<=9;n+=1)lt[`Digit${n}`]=String(n);for(let n=0;n<26;n+=1){const e=String.fromCharCode(65+n),t=String.fromCharCode(97+n);lt[`Key${e}`]=t}function ht(n){return Rn[n]??En}function Cn(n){const e=lt[n];return e?e.codePointAt(0)??null:null}const xe=0,vn=-2,Mn=1,Dn=2,An=3,On=10,kn=11,In=12,Nn=13,Bn=14,Pn=15,Hn=16,Ln=17,Fn=1,Gn=2,Un=1,zn=2,Yn=3,Vn=4,Kn=5,$n=6,jn=1,Wn=2,qn=3,Xn=4;function at(n){if(n.disposed||n.renderStateHandle===0)throw new Error("render state resources already disposed")}function Jn(n){switch(n){case 2:return"full";case 1:return"partial";default:return"clean"}}function Qn(n){switch(n){case 0:return"bar";case 2:return"underline";case 3:return"block-hollow";default:return"block"}}function Zn(n){switch(n){case 1:return"wide";case 2:return"spacer-tail";case 3:return"spacer-head";default:return"narrow"}}function Re(n,e){return{r:n.view().getUint8(e),g:n.view().getUint8(e+1),b:n.view().getUint8(e+2)}}function ft(n,e){const t=n.bindings.allocStruct("GhosttyColorRgb");try{const s=e(t.ptr);if(s===vn)return null;if(s!==xe)throw new Error(`ghostty optional color read failed with result ${s}`);return Re(n.bindings,t.ptr)}finally{t.free()}}function ce(n,e){const t=n.bindings.allocU8();try{const s=e(t);if(typeof s=="number"&&s!==xe)throw new Error(`ghostty bool read failed with result ${s}`);return n.bindings.readU8(t)!==0}finally{n.bindings.freeU8(t)}}function Be(n,e){const t=n.bindings.allocBytes(2);try{const s=e(t);if(typeof s=="number"&&s!==xe)throw new Error(`ghostty u16 read failed with result ${s}`);return n.bindings.view().getUint16(t,!0)}finally{n.bindings.freeBytes(t,2)}}function es(n,e){const t=n.bindings.allocBytes(4);try{const s=e(t);if(typeof s=="number"&&s!==xe)throw new Error(`ghostty u32 read failed with result ${s}`);return n.bindings.view().getUint32(t,!0)}finally{n.bindings.freeBytes(t,4)}}function nt(n,e){const t=n.bindings.allocBytes(4);try{const s=e(t);if(typeof s=="number"&&s!==xe)throw new Error(`ghostty enum read failed with result ${s}`);return n.bindings.view().getInt32(t,!0)}finally{n.bindings.freeBytes(t,4)}}function mt(n,e){const t=n.bindings.allocBytes(8);try{const s=e(t);if(typeof s=="number"&&s!==xe)throw new Error(`ghostty u64 read failed with result ${s}`);return n.bindings.readU64(t)}finally{n.bindings.freeBytes(t,8)}}function ts(n){const e=n.bindings.allocStruct("GhosttyStyle");try{n.bindings.setField(e.view,"GhosttyStyle","size",n.bindings.typeSize("GhosttyStyle")),n.bindings.getRenderStateRowCellValue(n.rowCellsHandle,zn,e.ptr);const t=s=>n.bindings.field("GhosttyStyle",s).offset;return{bold:e.view.getUint8(t("bold"))!==0,italic:e.view.getUint8(t("italic"))!==0,faint:e.view.getUint8(t("faint"))!==0,blink:e.view.getUint8(t("blink"))!==0,inverse:e.view.getUint8(t("inverse"))!==0,invisible:e.view.getUint8(t("invisible"))!==0,strikethrough:e.view.getUint8(t("strikethrough"))!==0,overline:e.view.getUint8(t("overline"))!==0,underline:e.view.getInt32(t("underline"),!0)}}finally{e.free()}}function ns(n){const e=es(n,s=>n.bindings.getRenderStateRowCellValueResult(n.rowCellsHandle,Yn,s));if(e===0)return[];const t=n.bindings.allocBytes(e*4);try{n.bindings.getRenderStateRowCellValue(n.rowCellsHandle,Vn,t);const s=[];for(let r=0;r<e;r+=1)s.push(n.bindings.view().getUint32(t+r*4,!0));return s}finally{n.bindings.freeBytes(t,e*4)}}function ss(n){if(n.length===0)return"";try{return String.fromCodePoint(...n)}catch{return""}}function rs(n){let e="";for(const t of n)if(!(t.widthKind==="spacer-tail"||t.widthKind==="spacer-head")){if(t.text){e+=t.text;continue}t.widthKind==="narrow"&&(e+=" ")}return e}function is(n){const e=n.bindings.allocStruct("GhosttyRenderStateColors");try{n.bindings.setField(e.view,"GhosttyRenderStateColors","size",n.bindings.typeSize("GhosttyRenderStateColors")),n.bindings.getRenderStateColors(n.renderStateHandle,e.ptr);const t=n.bindings.field("GhosttyRenderStateColors","palette").offset,s=[];for(let o=0;o<256;o+=1){const l=e.ptr+t+o*3;s.push(Re(n.bindings,l))}const r=e.view.getUint8(n.bindings.field("GhosttyRenderStateColors","cursor_has_value").offset)!==0,i=ce(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,Bn,o));return{cols:Be(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,Mn,o)),rows:Be(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,Dn,o)),dirty:Jn(nt(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,An,o))),colors:{background:Re(n.bindings,e.ptr+n.bindings.field("GhosttyRenderStateColors","background").offset),foreground:Re(n.bindings,e.ptr+n.bindings.field("GhosttyRenderStateColors","foreground").offset),cursor:r?Re(n.bindings,e.ptr+n.bindings.field("GhosttyRenderStateColors","cursor").offset):null,palette:s},cursor:{style:Qn(nt(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,On,o))),visible:ce(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,kn,o)),blinking:ce(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,In,o)),passwordInput:ce(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,Nn,o)),x:i?Be(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,Pn,o)):null,y:i?Be(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,Hn,o)):null,wideTail:i?ce(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,Ln,o)):!1}}}finally{e.free()}}function os(n,e){const t=mt(n,i=>n.bindings.getRenderStateRowValueResult(n.rowIteratorHandle,Gn,i));n.bindings.bindRenderStateRowCells(n.rowIteratorHandle,n.rowCellsHandle);const s=[];let r=0;for(;n.bindings.nextRenderStateRowCell(n.rowCellsHandle);){const i=mt(n,a=>n.bindings.getRenderStateRowCellValueResult(n.rowCellsHandle,Un,a)),o=ns(n),l=Zn(nt(n,a=>n.bindings.getRawCellValueResult(i,qn,a))),u={x:r,text:ss(o),codepoints:o,widthKind:l,hasText:ce(n,a=>n.bindings.getRawCellValueResult(i,Xn,a)),style:ts(n),fgColor:ft(n,a=>n.bindings.getRenderStateRowCellValueResult(n.rowCellsHandle,$n,a)),bgColor:ft(n,a=>n.bindings.getRenderStateRowCellValueResult(n.rowCellsHandle,Kn,a))};s.push(u),r+=1}return{y:e,dirty:ce(n,i=>n.bindings.getRenderStateRowValueResult(n.rowIteratorHandle,Fn,i)),wrap:ce(n,i=>n.bindings.getRawRowValueResult(t,jn,i)),wrapContinuation:ce(n,i=>n.bindings.getRawRowValueResult(t,Wn,i)),text:rs(s),cells:s}}function pt(n){return{bindings:n,renderStateHandle:n.createRenderState(),rowIteratorHandle:n.createRenderStateRowIterator(),rowCellsHandle:n.createRenderStateRowCells(),snapshotVersion:0,disposed:!1,cachedMeta:null}}function wt(n,e){at(n),n.bindings.updateRenderState(n.renderStateHandle,e),n.bindings.bindRenderStateRowIterator(n.renderStateHandle,n.rowIteratorHandle),n.snapshotVersion+=1,n.cachedMeta=null}function st(n){return at(n),n.cachedMeta||(n.cachedMeta=is(n)),n.cachedMeta}function*ls(n){at(n);const e=st(n);n.bindings.bindRenderStateRowIterator(n.renderStateHandle,n.rowIteratorHandle);let t=0;for(;t<e.rows&&n.bindings.nextRenderStateRowIterator(n.rowIteratorHandle);)yield os(n,t),t+=1}function Xe(n){n.disposed||(n.disposed=!0,n.rowCellsHandle!==0&&(n.bindings.freeRenderStateRowCells(n.rowCellsHandle),n.rowCellsHandle=0),n.rowIteratorHandle!==0&&(n.bindings.freeRenderStateRowIterator(n.rowIteratorHandle),n.rowIteratorHandle=0),n.renderStateHandle!==0&&(n.bindings.freeRenderState(n.renderStateHandle),n.renderStateHandle=0),n.cachedMeta=null)}const as={colChars:[],contentCols:0,wrappedToNext:!1};function cs(n){for(let e=n.length-1;e>=0;e-=1){const t=n[e];if(t!==null&&t!==""&&t!==" ")return e+1}return 0}function yt(n,e=!1){const t=[];for(const s of n){if(s.widthKind==="spacer-tail"){t.push(null);continue}if(s.widthKind==="spacer-head"){t.push("");continue}t.push(s.text||" ")}return{colChars:t,contentCols:cs(t),wrappedToNext:e}}function ds(n,e){return Math.max(0,Math.min(Math.max(n.colChars.length-1,0),Math.floor(e)))}function ct(n,e){let t=ds(n,e);for(;t>0&&n.colChars[t]===null;)t-=1;return t}function Je(n,e){let t=e;for(;t>0&&n.colChars[t]===null;)t-=1;return n.colChars[t]||""}function gt(n,e){let t=e;for(;t+1<n.colChars.length&&n.colChars[t+1]===null;)t+=1;return t}function us(n,e){return n.line<e.line?{start:n,end:e}:n.line>e.line?{start:e,end:n}:n.col<=e.col?{start:n,end:e}:{start:e,end:n}}function hs(n,e,t){if(t.colChars.length===0)return{start:{line:n,col:0},end:{line:n,col:0}};const s=ct(t,e),r=l=>/[\p{L}\p{N}_-]/u.test(l);if(!r(Je(t,s)))return{start:{line:n,col:s},end:{line:n,col:s}};let i=s,o=s;for(;i>0&&r(Je(t,i-1));)i-=1;for(;o+1<t.colChars.length&&r(Je(t,o+1));)o+=1;return{start:{line:n,col:i},end:{line:n,col:o}}}function kt(n,e){const t=Math.max(e.contentCols-1,0);return{start:{line:n,col:0},end:{line:n,col:t}}}function It(n,e,t){const s=t(n.line);switch(e){case"word":return hs(n.line,n.col,s);case"line":return kt(n.line,s);default:{const r=ct(s,n.col);return{start:{line:n.line,col:r},end:{line:n.line,col:r}}}}}function Nt(){return{anchor:null,focus:null,mode:"character"}}function St(n){return!!(n.anchor&&n.focus)}function fs(){return Nt()}function ms(n,e,t){const s=It(e,e.mode,t);return{anchor:s.start,focus:s.end,mode:e.mode}}function _t(n,e,t){return n.anchor?n.mode==="line"?{...n,focus:kt(e.line,t(e.line)).end}:n.mode==="word"?{...n,focus:It(e,"word",t).end}:{...n,focus:{line:e.line,col:ct(t(e.line),e.col)}}:n}function Bt(n){return!n.anchor||!n.focus?null:us(n.anchor,n.focus)}function ps(n,e,t){const s=n.wrappedToNext?n.colChars.length-1:n.contentCols-1,r=Math.min(t,s);let i=Math.max(0,e);for(;i>0&&n.colChars[i]===null;)i-=1;if(i>r)return"";let o="";for(let l=i;l<=r;l+=1)o+=n.colChars[l]??"";return o}function ws(n,e){const t=Bt(n);if(!t)return null;let s="";for(let r=t.start.line;r<=t.end.line;r+=1){const i=e(r),o=r===t.start.line?t.start.col:0,l=r===t.end.line?t.end.col:i.colChars.length-1;s+=ps(i,o,l),r<t.end.line&&!i.wrappedToNext&&(s+=`
32
- `)}return s}function ys(n,e,t,s){const r=Bt(n);if(!r)return[];const i=e+t-1,o=[];for(let l=Math.max(r.start.line,e);l<=Math.min(r.end.line,i);l+=1){const u=l-e;if(l===r.start.line&&l===r.end.line){const g=s==null?void 0:s(l),E=g?gt(g,r.end.col):r.end.col;o.push({row:u,x:r.start.col,width:E-r.start.col+1});continue}if(l===r.start.line){const g=s?Math.max(s(l).colChars.length-r.start.col,0):Number.MAX_SAFE_INTEGER;o.push({row:u,x:r.start.col,width:g});continue}if(l===r.end.line){const g=s==null?void 0:s(l),E=g?gt(g,r.end.col):r.end.col;o.push({row:u,x:0,width:E+1});continue}const a=s?s(l).colChars.length:Number.MAX_SAFE_INTEGER;o.push({row:u,x:0,width:a})}return o}function Pt(){var e;if(typeof navigator>"u")return!1;const n=((e=navigator.userAgentData)==null?void 0:e.platform)??navigator.platform??"";return/mac|iphone|ipad|ipod/iu.test(n)?!0:/mac os x/iu.test(navigator.userAgent??"")}function gs(n){return n.altKey?!1:!!(Pt()?n.metaKey:n.ctrlKey)}function Ss(n){return gs(n)&&n.key.toLowerCase()==="c"}function _s(n){return n.shiftKey&&n.key==="Insert"&&!n.ctrlKey&&!n.altKey&&!n.metaKey?!0:n.altKey||n.key.toLowerCase()!=="v"?!1:!!(Pt()?n.metaKey:n.ctrlKey)}async function Ht(n){var t;if(!n)return;if(typeof navigator<"u"&&((t=navigator.clipboard)!=null&&t.writeText))try{await navigator.clipboard.writeText(n);return}catch{}if(typeof document>"u"||typeof document.execCommand!="function")throw new Error("clipboard unavailable");const e=document.createElement("textarea");e.value=n,e.setAttribute("readonly","true"),e.style.position="fixed",e.style.left="-9999px",e.style.top="0",document.body.appendChild(e);try{if(e.select(),!document.execCommand("copy"))throw new Error("execCommand copy failed")}finally{e.remove()}}async function bs(n){n&&await Ht(n)}function xs(n,e){return!e||!n.clipboardData?!1:(n.clipboardData.setData("text/plain",e),n.preventDefault(),!0)}const Ts="/assets/ghostty-vt-BKQMf-5X.wasm",Ge=0,bt=-3,Es=11,Rs=12,Cs=13,vs=14,Ms=1,Ds=2,As=9,Os=1,ks=0,Is=1,Ns=2,Bs=0,Ps=1,Hs=2,Ls=4,Fs=2004,Gs=9,Us=1e3,zs=1002,Ys=1003,Vs=1005,xt=1006,Ks=1015,Tt=1016;let Qe=null;function O(n,e){if(n!==Ge)throw new Error(`${e} failed with result ${n}`)}function Lt(n){const e=n.trim().replace(/^#/,"");if(e.length!==6)throw new Error(`expected #RRGGBB color, received: ${n}`);return[Number.parseInt(e.slice(0,2),16),Number.parseInt(e.slice(2,4),16),Number.parseInt(e.slice(4,6),16)]}function $s(n){const t=[...[n.black,n.red,n.green,n.yellow,n.blue,n.magenta,n.cyan,n.white,n.brightBlack,n.brightRed,n.brightGreen,n.brightYellow,n.brightBlue,n.brightMagenta,n.brightCyan,n.brightWhite].map(Lt)],s=[0,95,135,175,215,255];for(const r of s)for(const i of s)for(const o of s)t.push([r,i,o]);for(let r=0;r<24;r+=1){const i=8+r*10;t.push([i,i,i])}return t}function js(n){let e=0;return n&1&&(e+=4),n&4&&(e+=8),n&2&&(e+=16),e}function Ze(n){return n<0||n>223?null:String.fromCharCode(n+32)}function Ws(n){switch(n){case 1:return 0;case 3:return 1;case 2:return 2;case 4:return 64;case 5:return 65;case 6:return 66;case 7:return 67;case 8:return 128;case 9:return 129;case null:case void 0:return 3;default:return null}}function Ft(n){var t,s;let e=0;return n.shiftKey&&(e|=1),n.ctrlKey&&(e|=2),n.altKey&&(e|=4),n.metaKey&&(e|=8),(t=n.getModifierState)!=null&&t.call(n,"CapsLock")&&(e|=16),(s=n.getModifierState)!=null&&s.call(n,"NumLock")&&(e|=32),e}class qs{constructor(e,t,s){this.bindings=e,this.typeName=t,this.ptr=s}get view(){return this.bindings.view(this.ptr,this.bindings.typeSize(this.typeName))}free(){this.bindings.freeBytes(this.ptr,this.bindings.typeSize(this.typeName))}}class Xs{constructor(e,t){f(this,"exports");f(this,"layout");f(this,"decoder",new TextDecoder);f(this,"encoder",new TextEncoder);this.exports=e,this.layout=t}buffer(){return this.exports.memory.buffer}bytes(e=0,t=this.buffer().byteLength-e){return new Uint8Array(this.buffer(),e,t)}view(e=0,t=this.buffer().byteLength-e){return new DataView(this.buffer(),e,t)}typeSize(e){const t=this.layout[e];if(!t)throw new Error(`unknown ghostty type: ${e}`);return t.size}field(e,t){const s=this.layout[e],r=s==null?void 0:s.fields[t];if(!s||!r)throw new Error(`unknown ghostty field: ${e}.${t}`);return r}allocStruct(e){const t=this.allocBytes(this.typeSize(e));return this.bytes(t,this.typeSize(e)).fill(0),new qs(this,e,t)}allocBytes(e){return this.exports.ghostty_wasm_alloc_u8_array(e)}freeBytes(e,t){this.exports.ghostty_wasm_free_u8_array(e,t)}allocOpaque(){return this.exports.ghostty_wasm_alloc_opaque()}freeOpaque(e){this.exports.ghostty_wasm_free_opaque(e)}allocU8(){return this.exports.ghostty_wasm_alloc_u8()}freeU8(e){this.exports.ghostty_wasm_free_u8(e)}allocUsize(){return this.exports.ghostty_wasm_alloc_usize()}freeUsize(e){this.exports.ghostty_wasm_free_usize(e)}readPointer(e){return this.view().getUint32(e,!0)}readU8(e){return this.view().getUint8(e)}readUsize(e){return this.view().getUint32(e,!0)}readU64(e){return this.view().getBigUint64(e,!0)}setField(e,t,s,r){const i=this.field(t,s),o=i.offset;switch(i.type){case"u8":case"bool":e.setUint8(o,Number(r));return;case"u16":e.setUint16(o,Number(r),!0);return;case"u32":e.setUint32(o,Number(r),!0);return;case"u64":e.setBigUint64(o,BigInt(r),!0);return;case"usize":{e.setUint32(o,Number(r),!0);return}case"i32":case"enum":e.setInt32(o,Number(r),!0);return;default:throw new Error(`unsupported field type ${t}.${s}: ${i.type}`)}}writeString(e){const t=this.encoder.encode(e),s=this.allocBytes(t.length);return this.bytes(s,t.length).set(t),{ptr:s,len:t.length,free:()=>this.freeBytes(s,t.length)}}writeBytes(e){const t=this.allocBytes(e.length);return this.bytes(t,e.length).set(e),{ptr:t,len:e.length,free:()=>this.freeBytes(t,e.length)}}readOwnedUtf8(e,t){return this.decoder.decode(this.bytes(e,t))}createTerminal(e,t,s){const r=this.allocStruct("GhosttyTerminalOptions");this.setField(r.view,"GhosttyTerminalOptions","cols",e),this.setField(r.view,"GhosttyTerminalOptions","rows",t),this.setField(r.view,"GhosttyTerminalOptions","max_scrollback",s);const i=this.allocOpaque();try{return O(this.exports.ghostty_terminal_new(0,i,r.ptr),"ghostty_terminal_new"),this.readPointer(i)}finally{r.free(),this.freeOpaque(i)}}freeTerminal(e){this.exports.ghostty_terminal_free(e)}writeVt(e,t){const s=typeof t=="string"?this.encoder.encode(t):t,r=this.writeBytes(s);try{this.exports.ghostty_terminal_vt_write(e,r.ptr,r.len)}finally{r.free()}}resetTerminal(e){this.exports.ghostty_terminal_reset(e)}resizeTerminal(e,t,s,r){O(this.exports.ghostty_terminal_resize(e,t,s,Math.max(1,Math.round(r.width)),Math.max(1,Math.round(r.height))),"ghostty_terminal_resize")}scrollViewportDelta(e,t){const s=this.allocStruct("GhosttyTerminalScrollViewport");try{this.setField(s.view,"GhosttyTerminalScrollViewport","tag",Ns),s.view.setBigInt64(this.field("GhosttyTerminalScrollViewport","value").offset,BigInt(t),!0),this.exports.ghostty_terminal_scroll_viewport(e,s.ptr)}finally{s.free()}}scrollViewportTop(e){const t=this.allocStruct("GhosttyTerminalScrollViewport");try{this.setField(t.view,"GhosttyTerminalScrollViewport","tag",ks),this.exports.ghostty_terminal_scroll_viewport(e,t.ptr)}finally{t.free()}}scrollViewportBottom(e){const t=this.allocStruct("GhosttyTerminalScrollViewport");try{this.setField(t.view,"GhosttyTerminalScrollViewport","tag",Is),this.exports.ghostty_terminal_scroll_viewport(e,t.ptr)}finally{t.free()}}setTerminalTheme(e,t){const s=this.allocStruct("GhosttyColorRgb"),r=this.allocStruct("GhosttyColorRgb"),i=this.allocStruct("GhosttyColorRgb"),o=$s(t),l=this.allocBytes(o.length*3),u=(g,E)=>{const[A,H,T]=Lt(E);this.setField(g.view,"GhosttyColorRgb","r",A),this.setField(g.view,"GhosttyColorRgb","g",H),this.setField(g.view,"GhosttyColorRgb","b",T)};u(s,t.foreground),u(r,t.background),u(i,t.cursor);const a=this.bytes(l,o.length*3);o.forEach(([g,E,A],H)=>{const T=H*3;a[T]=g,a[T+1]=E,a[T+2]=A});try{O(this.exports.ghostty_terminal_set(e,Es,s.ptr),"ghostty_terminal_set(foreground)"),O(this.exports.ghostty_terminal_set(e,Rs,r.ptr),"ghostty_terminal_set(background)"),O(this.exports.ghostty_terminal_set(e,Cs,i.ptr),"ghostty_terminal_set(cursor)"),O(this.exports.ghostty_terminal_set(e,vs,l),"ghostty_terminal_set(palette)")}finally{s.free(),r.free(),i.free(),this.freeBytes(l,o.length*3)}}readTerminalSize(e){const t=this.allocBytes(2),s=this.allocBytes(2);try{return O(this.exports.ghostty_terminal_get(e,Ms,t),"ghostty_terminal_get(cols)"),O(this.exports.ghostty_terminal_get(e,Ds,s),"ghostty_terminal_get(rows)"),{cols:this.view().getUint16(t,!0),rows:this.view().getUint16(s,!0)}}finally{this.freeBytes(t,2),this.freeBytes(s,2)}}readScrollbar(e){const t=this.allocStruct("GhosttyTerminalScrollbar");try{return O(this.exports.ghostty_terminal_get(e,As,t.ptr),"ghostty_terminal_get(scrollbar)"),{total:Number(t.view.getBigUint64(this.field("GhosttyTerminalScrollbar","total").offset,!0)),offset:Number(t.view.getBigUint64(this.field("GhosttyTerminalScrollbar","offset").offset,!0)),len:Number(t.view.getBigUint64(this.field("GhosttyTerminalScrollbar","len").offset,!0))}}finally{t.free()}}isTerminalModeEnabled(e,t){const s=this.allocU8();try{return O(this.exports.ghostty_terminal_mode_get(e,t,s),"ghostty_terminal_mode_get"),this.readU8(s)!==0}finally{this.freeU8(s)}}setTerminalMode(e,t,s){O(this.exports.ghostty_terminal_mode_set(e,t,s?1:0),"ghostty_terminal_mode_set")}createFormatter(e,t,s){const r=this.allocStruct("GhosttyFormatterTerminalOptions"),i=this.field("GhosttyFormatterTerminalOptions","extra").offset,o=this.view(r.ptr+i,this.typeSize("GhosttyFormatterTerminalExtra")),l=this.field("GhosttyFormatterTerminalExtra","screen").offset,u=this.view(r.ptr+i+l,this.typeSize("GhosttyFormatterScreenExtra")),a=this.allocOpaque();try{this.setField(r.view,"GhosttyFormatterTerminalOptions","size",this.typeSize("GhosttyFormatterTerminalOptions")),this.setField(r.view,"GhosttyFormatterTerminalOptions","emit",t),this.setField(r.view,"GhosttyFormatterTerminalOptions","unwrap",s.unwrap),this.setField(r.view,"GhosttyFormatterTerminalOptions","trim",s.trim),this.setField(o,"GhosttyFormatterTerminalExtra","size",this.typeSize("GhosttyFormatterTerminalExtra")),this.setField(o,"GhosttyFormatterTerminalExtra","palette",s.includePalette),this.setField(u,"GhosttyFormatterScreenExtra","size",this.typeSize("GhosttyFormatterScreenExtra"));const g=this.field("GhosttyFormatterTerminalOptions","selection").offset;return r.view.setUint32(g,s.selectionPtr??0,!0),O(this.exports.ghostty_formatter_terminal_new(0,a,e,r.ptr),"ghostty_formatter_terminal_new"),this.readPointer(a)}finally{r.free(),this.freeOpaque(a)}}freeFormatter(e){this.exports.ghostty_formatter_free(e)}resolveViewportGridRef(e,t,s){const r=this.allocStruct("GhosttyPoint"),i=this.allocStruct("GhosttyGridRef");try{this.setField(r.view,"GhosttyPoint","tag",Os);const o=this.field("GhosttyPoint","value").offset,l=this.view(r.ptr+o,this.typeSize("GhosttyPointCoordinate"));return this.setField(l,"GhosttyPointCoordinate","x",t),this.setField(l,"GhosttyPointCoordinate","y",s),this.exports.ghostty_terminal_grid_ref(e,r.ptr,i.ptr)!==Ge?(i.free(),null):i}finally{r.free()}}createViewportSelection(e,t,s){const r=Math.max(1,Math.floor(t)),i=Math.max(1,Math.floor(s)),o=this.resolveViewportGridRef(e,0,0);if(!o)return null;let l=null;for(let a=i-1;a>=0&&(l=this.resolveViewportGridRef(e,r-1,a),!l);a-=1);if(!l)return o.free(),null;const u=this.allocStruct("GhosttySelection");try{this.setField(u.view,"GhosttySelection","size",this.typeSize("GhosttySelection")),this.setField(u.view,"GhosttySelection","rectangle",!1);const a=this.field("GhosttySelection","start").offset,g=this.field("GhosttySelection","end").offset;return this.bytes(u.ptr+a,this.typeSize("GhosttyGridRef")).set(this.bytes(o.ptr,this.typeSize("GhosttyGridRef"))),this.bytes(u.ptr+g,this.typeSize("GhosttyGridRef")).set(this.bytes(l.ptr,this.typeSize("GhosttyGridRef"))),u}finally{o.free(),l.free()}}formatViewport(e,t,s,r){const i=this.readTerminalSize(e),o=this.createViewportSelection(e,Math.max(1,Math.min(i.cols,r.cols)),Math.max(1,Math.min(i.rows,r.rows))),l=this.createFormatter(e,t,{...s,selectionPtr:(o==null?void 0:o.ptr)??null});try{return this.formatFormatter(l)}finally{this.freeFormatter(l),o==null||o.free()}}formatFormatter(e){const t=this.allocOpaque(),s=this.allocUsize();try{O(this.exports.ghostty_formatter_format_alloc(e,0,t,s),"ghostty_formatter_format_alloc");const r=this.readPointer(t),i=this.readUsize(s),o=this.buffer().byteLength;try{if(i===0||r===0)return"";if(r<0||r>o||i>o-r)throw new Error(`ghostty_formatter_format_alloc returned invalid slice ptr=${r} len=${i} mem=${o}`);return this.readOwnedUtf8(r,i)}finally{i>0&&r!==0&&this.exports.ghostty_free(0,r,i)}}finally{this.freeOpaque(t),this.freeUsize(s)}}createRenderState(){const e=this.allocOpaque();try{return O(this.exports.ghostty_render_state_new(0,e),"ghostty_render_state_new"),this.readPointer(e)}finally{this.freeOpaque(e)}}freeRenderState(e){this.exports.ghostty_render_state_free(e)}updateRenderState(e,t){O(this.exports.ghostty_render_state_update(e,t),"ghostty_render_state_update")}getRenderStateValueResult(e,t,s){return this.exports.ghostty_render_state_get(e,t,s)}getRenderStateValue(e,t,s){O(this.getRenderStateValueResult(e,t,s),"ghostty_render_state_get")}setRenderStateValue(e,t,s){O(this.exports.ghostty_render_state_set(e,t,s),"ghostty_render_state_set")}getRenderStateColors(e,t){O(this.exports.ghostty_render_state_colors_get(e,t),"ghostty_render_state_colors_get")}createRenderStateRowIterator(){const e=this.allocOpaque();try{return O(this.exports.ghostty_render_state_row_iterator_new(0,e),"ghostty_render_state_row_iterator_new"),this.readPointer(e)}finally{this.freeOpaque(e)}}freeRenderStateRowIterator(e){this.exports.ghostty_render_state_row_iterator_free(e)}bindRenderStateRowIterator(e,t){const s=this.allocOpaque();try{this.view(s,4).setUint32(0,t,!0),this.getRenderStateValue(e,4,s)}finally{this.freeOpaque(s)}}nextRenderStateRowIterator(e){return this.exports.ghostty_render_state_row_iterator_next(e)!==0}getRenderStateRowValueResult(e,t,s){return this.exports.ghostty_render_state_row_get(e,t,s)}getRenderStateRowValue(e,t,s){O(this.getRenderStateRowValueResult(e,t,s),"ghostty_render_state_row_get")}setRenderStateRowValue(e,t,s){O(this.exports.ghostty_render_state_row_set(e,t,s),"ghostty_render_state_row_set")}createRenderStateRowCells(){const e=this.allocOpaque();try{return O(this.exports.ghostty_render_state_row_cells_new(0,e),"ghostty_render_state_row_cells_new"),this.readPointer(e)}finally{this.freeOpaque(e)}}freeRenderStateRowCells(e){this.exports.ghostty_render_state_row_cells_free(e)}bindRenderStateRowCells(e,t){const s=this.allocOpaque();try{this.view(s,4).setUint32(0,t,!0),this.getRenderStateRowValue(e,3,s)}finally{this.freeOpaque(s)}}nextRenderStateRowCell(e){return this.exports.ghostty_render_state_row_cells_next(e)!==0}selectRenderStateRowCell(e,t){O(this.exports.ghostty_render_state_row_cells_select(e,t),"ghostty_render_state_row_cells_select")}getRenderStateRowCellValueResult(e,t,s){return this.exports.ghostty_render_state_row_cells_get(e,t,s)}getRenderStateRowCellValue(e,t,s){O(this.getRenderStateRowCellValueResult(e,t,s),"ghostty_render_state_row_cells_get")}getRawRowValueResult(e,t,s){return this.exports.ghostty_row_get(e,t,s)}getRawRowValue(e,t,s){O(this.getRawRowValueResult(e,t,s),"ghostty_row_get")}getRawCellValueResult(e,t,s){return this.exports.ghostty_cell_get(e,t,s)}getRawCellValue(e,t,s){O(this.getRawCellValueResult(e,t,s),"ghostty_cell_get")}createKeyEncoder(){const e=this.allocOpaque();try{return O(this.exports.ghostty_key_encoder_new(0,e),"ghostty_key_encoder_new"),this.readPointer(e)}finally{this.freeOpaque(e)}}freeKeyEncoder(e){this.exports.ghostty_key_encoder_free(e)}createMouseEncoder(){const e=this.allocOpaque(),t=this.allocU8();try{O(this.exports.ghostty_mouse_encoder_new(0,e),"ghostty_mouse_encoder_new");const s=this.readPointer(e);return this.view().setUint8(t,1),this.exports.ghostty_mouse_encoder_setopt(s,Ls,t),s}finally{this.freeU8(t),this.freeOpaque(e)}}freeMouseEncoder(e){this.exports.ghostty_mouse_encoder_free(e)}resetMouseEncoder(e){this.exports.ghostty_mouse_encoder_reset(e)}encodeMouseEvent(e,t,s){const r=this.isTerminalModeEnabled(t,Ys),i=this.isTerminalModeEnabled(t,zs),o=this.isTerminalModeEnabled(t,Us),l=this.isTerminalModeEnabled(t,Gs);if(!r&&!i&&!o&&!l||s.action==="motion"&&!(r||i&&s.anyButtonPressed)||l&&s.action!=="press"||!r&&!i&&!l&&s.action==="motion")return null;const u=Ws(s.button);if(u===null)return null;const a=Math.max(1,Math.floor(s.x/Math.max(1,s.cellWidth))+1),g=Math.max(1,Math.floor(s.y/Math.max(1,s.cellHeight))+1),E=Math.round(s.x+1),A=Math.round(s.y+1);let H=s.action==="release"&&!this.isTerminalModeEnabled(t,xt)&&!this.isTerminalModeEnabled(t,Tt)?3:u;if(s.action==="motion"&&(H+=32),H+=js(s.mods),this.isTerminalModeEnabled(t,Tt)){const T=s.action==="release"?"m":"M";return`\x1B[<${H};${E};${A}${T}`}if(this.isTerminalModeEnabled(t,xt)){const T=s.action==="release"?"m":"M";return`\x1B[<${H};${a};${g}${T}`}if(this.isTerminalModeEnabled(t,Ks))return`\x1B[${H};${a};${g}M`;if(this.isTerminalModeEnabled(t,Vs)||o||i||r||l){const T=Ze(H),x=Ze(a),J=Ze(g);return!T||!x||!J?null:`\x1B[M${T}${x}${J}`}return null}encodeKeyEvent(e,t,s){if(s.keyCode<=0)return null;const r=this.allocOpaque();let i=0,o=null;try{return O(this.exports.ghostty_key_event_new(0,r),"ghostty_key_event_new"),i=this.readPointer(r),this.exports.ghostty_key_encoder_setopt_from_terminal(e,t),this.exports.ghostty_key_event_set_action(i,s.action==="release"?Bs:s.action==="repeat"?Hs:Ps),this.exports.ghostty_key_event_set_key(i,s.keyCode),this.exports.ghostty_key_event_set_mods(i,s.mods),this.exports.ghostty_key_event_set_consumed_mods(i,0),this.exports.ghostty_key_event_set_composing(i,s.composing?1:0),s.utf8&&(o=this.writeString(s.utf8),this.exports.ghostty_key_event_set_utf8(i,o.ptr,o.len)),typeof s.unshiftedCodepoint=="number"&&this.exports.ghostty_key_event_set_unshifted_codepoint(i,s.unshiftedCodepoint),this.encodeKeyHandle(e,i)}finally{o==null||o.free(),i!==0&&this.exports.ghostty_key_event_free(i),this.freeOpaque(r)}}encodeKeyHandle(e,t){const s=this.allocUsize();try{const r=this.exports.ghostty_key_encoder_encode(e,t,0,0,s);r!==bt&&r!==Ge&&O(r,"ghostty_key_encoder_encode(size)");const i=Math.max(0,this.readUsize(s));if(i===0)return null;const o=this.allocBytes(i),l=this.allocUsize();try{O(this.exports.ghostty_key_encoder_encode(e,t,o,i,l),"ghostty_key_encoder_encode");const u=this.readUsize(l);return u===0?null:this.readOwnedUtf8(o,u)}finally{this.freeBytes(o,i),this.freeUsize(l)}}finally{this.freeUsize(s)}}encodePaste(e,t){const s=this.writeString(t),r=this.allocUsize();try{const i=this.isTerminalModeEnabled(e,Fs),o=this.exports.ghostty_paste_encode(s.ptr,s.len,i?1:0,0,0,r);o!==bt&&o!==Ge&&O(o,"ghostty_paste_encode(size)");const l=Math.max(0,this.readUsize(r));if(l===0)return"";const u=this.allocBytes(l),a=this.allocUsize();try{return O(this.exports.ghostty_paste_encode(s.ptr,s.len,i?1:0,u,l,a),"ghostty_paste_encode"),this.readOwnedUtf8(u,this.readUsize(a))}finally{this.freeBytes(u,l),this.freeUsize(a)}}finally{s.free(),this.freeUsize(r)}}}async function Js(n){if((n.startsWith("/")||n.startsWith("./")||n.startsWith("../")||/^[A-Za-z]:[\\/]/.test(n))&&typeof Bun<"u")return Bun.file(n).arrayBuffer();const t=await fetch(n);if(!t.ok)throw new Error(`failed to load ghostty wasm: ${t.status} ${t.statusText}`);return t.arrayBuffer()}async function Qs(){return Qe||(Qe=(async()=>{const n=await Js(Ts),t=(await WebAssembly.instantiate(n,{env:{log(){}}})).instance.exports,s=new Uint8Array(t.memory.buffer),r=t.ghostty_type_json();let i=r;for(;s[i]!==0;)i+=1;const o=JSON.parse(new TextDecoder().decode(s.subarray(r,i)));return new Xs(t,o)})()),Qe}const Et=80,Ce=24,et=9,Pe=17,Zs=48,Gt="ghostty-official",Ue=9,ze=1e3,Ye=1002,Ve=1003,tt=1007,He=1047,Le=1049,er=[Ue,ze,Ye,Ve],Rt=1,Ct=3,vt=2,tr=4,nr=5;class sr{constructor(e){this.content=e}translateToString(e){return e?this.content.replace(/\s+$/u,""):this.content}}class rr{constructor(){f(this,"active",{baseY:0,viewportY:0,length:Ce,getLine:e=>{const t=e-this.active.viewportY,s=this.visibleLines[t];return typeof s=="string"?new sr(s):null}});f(this,"visibleLines",Array.from({length:Ce},()=>""))}setViewport(e,t,s,r){this.active.viewportY=e,this.active.baseY=t,this.active.length=s,this.visibleLines=r}}function ir(n){return!(n.key.length===1&&!n.ctrlKey&&!n.altKey&&!n.metaKey)}function or(n,e){const t=n.slice(0,e).map(s=>s.text);for(;t.length<e;)t.push("");return t}function Fe(n){return Ft({shiftKey:!!n.shiftKey,ctrlKey:!!n.ctrlKey,altKey:!!n.altKey,metaKey:!!n.metaKey,getModifierState:()=>!1})}class lr{constructor(){f(this,"terminal",null)}activate(e){this.terminal=e instanceof $e?e:null}fit(){const e=this.proposeDimensions();!this.terminal||!e||this.terminal.resize(e.cols,e.rows)}proposeDimensions(){var e;return((e=this.terminal)==null?void 0:e.measureSizeFromElement())??null}dispose(){this.terminal=null}}class $e{constructor(e,t,s,r,i,o){f(this,"buffer",new rr);f(this,"_core",{_renderService:{dimensions:{css:{cell:{width:et,height:Pe}}}}});f(this,"options");f(this,"element",null);f(this,"textarea",null);f(this,"cols",Et);f(this,"rows",Ce);f(this,"bindings");f(this,"terminalHandle");f(this,"keyEncoderHandle");f(this,"mouseEncoderHandle");f(this,"renderState");f(this,"dataListeners",new Set);f(this,"selectionListeners",new Set);f(this,"lastNotifiedSelectionText",null);f(this,"addons",new Set);f(this,"screenElement",null);f(this,"renderer",null);f(this,"renderRaf",null);f(this,"disposed",!1);f(this,"disableStdin");f(this,"customKeyEventHandler",()=>!0);f(this,"imeIsComposing",!1);f(this,"lastCompositionCommit",null);f(this,"selectionState",Nt());f(this,"lineCache",new Map);f(this,"lastViewportOffset",0);f(this,"lastViewportRows",Ce);f(this,"lastRenderedRows",[]);f(this,"pointerDrag",{active:!1,moved:!1,mode:"character",lastClientX:null,lastClientY:null});f(this,"autoScrollTimer",null);f(this,"domEventDisposers",[]);f(this,"copyShortcutSuppressed",!1);f(this,"scrollbarThumb",null);f(this,"scrollbarFadeTimer",null);f(this,"pressedMouseButtons",new Set);f(this,"wheelPixelDelta",0);f(this,"mouseDragActive",!1);this.bindings=e,this.terminalHandle=t,this.keyEncoderHandle=s,this.mouseEncoderHandle=r,this.renderState=i,this.options=o,this.disableStdin=!!o.disableStdin}static async create(e){const t=await Qs(),s=t.createTerminal(Et,Ce,e.scrollback);let r=0,i=0,o=null;try{return t.setTerminalTheme(s,e.theme),r=t.createKeyEncoder(),i=t.createMouseEncoder(),o=pt(t),new $e(t,s,r,i,o,e)}catch(l){throw o&&Xe(o),r!==0&&t.freeKeyEncoder(r),i!==0&&t.freeMouseEncoder(i),t.freeTerminal(s),l}}open(e){if(this.disposed||this.element)return;const t=document.createElement("div");t.className="xterm",t.style.position="absolute",t.style.inset="0",t.style.overflow="hidden",t.style.width="100%",t.style.height="100%",t.style.backgroundColor=this.options.theme.background,t.style.color=this.options.theme.foreground,t.style.fontFamily=this.options.fontFamily,t.style.fontSize=`${this.options.fontSize}px`,t.style.lineHeight="1.2";const s=document.createElement("div");s.className="xterm-viewport",s.style.width="100%",s.style.height="100%",s.style.overflow="hidden",s.style.position="relative";const r=document.createElement("div");r.className="xterm-screen",r.style.width="100%",r.style.height="100%",r.style.position="relative",r.style.userSelect="none",r.style.webkitUserSelect="none",r.style.backgroundColor=this.options.theme.background;const i=document.createElement("div");i.className="xterm-helper-textarea",i.setAttribute("aria-label","Terminal Input"),i.setAttribute("role","textbox"),i.setAttribute("contenteditable","true"),i.setAttribute("autocorrect","off"),i.setAttribute("autocapitalize","off"),i.setAttribute("spellcheck","false"),i.style.position="absolute",i.style.opacity="1",i.style.pointerEvents="none",i.style.left="0",i.style.top="0",i.style.minWidth="1px",i.style.minHeight="1px",i.style.whiteSpace="pre",i.style.border="0",i.style.padding="0",i.style.margin="0",i.style.color=this.options.theme.foreground,i.style.backgroundColor="transparent",i.style.caretColor="transparent",i.style.overflow="visible",i.style.outline="none",i.style.boxShadow="none",i.style.fontFamily=this.options.fontFamily,i.style.fontSize=`${this.options.fontSize}px`,i.style.userSelect="text",i.style.webkitUserSelect="text";const o=document.createElement("div");o.className="xterm-scrollbar-track",o.style.position="absolute",o.style.top="0",o.style.right="0",o.style.width="8px",o.style.height="100%",o.style.backgroundColor="transparent",o.style.pointerEvents="none";const l=document.createElement("div");l.className="xterm-scrollbar-thumb",l.style.position="absolute",l.style.top="0",l.style.right="0",l.style.width="6px",l.style.marginRight="1px",l.style.borderRadius="3px",l.style.backgroundColor="rgba(128, 128, 128, 0.5)",l.style.pointerEvents="none",l.style.transition="opacity 0.15s ease",l.style.opacity="0",o.appendChild(l),s.appendChild(r),t.appendChild(s),t.appendChild(i),t.appendChild(o),e.appendChild(t),this.element=t,this.screenElement=r,this.textarea=i,this.scrollbarThumb=l,this.renderer=new Tn({screenElement:r,theme:this.options.theme,fontFamily:this.options.fontFamily,fontSize:this.options.fontSize}),this.syncInputState(),this.bindDomEvents(),this.updateCellDimensions();const u=this.measureSizeFromElement();u?this.resize(u.cols,u.rows):this.render()}loadAddon(e){e.activate(this),this.addons.add(e)}onData(e){return this.dataListeners.add(e),{dispose:()=>{this.dataListeners.delete(e)}}}attachCustomKeyEventHandler(e){this.customKeyEventHandler=e}onSelectionChange(e){return this.selectionListeners.add(e),{dispose:()=>{this.selectionListeners.delete(e)}}}hasSelection(){return St(this.selectionState)}getSelection(){return this.getSelectionText()??""}clearSelection(){this.disposed||this.clearSelectionState()}startTouchSelection(e,t,s="word"){return this.disposed?!1:this.beginSelectionAt(e,t,s)}updateTouchSelection(e,t){this.disposed||this.updateSelectionDrag(e,t)}endTouchSelection(){this.disposed||!this.pointerDrag.active||(this.stopAutoScroll(),this.pointerDrag.active=!1,this.render())}write(e){if(this.disposed)return;const t=this.isAltScreenActive();this.bindings.writeVt(this.terminalHandle,e);const s=this.isAltScreenActive();t&&!s&&this.clearMouseTrackingModes(),this.scheduleRender()}clearMouseTrackingModes(){if(!this.disposed){for(const e of er)this.bindings.setTerminalMode(this.terminalHandle,e,!1);this.bindings.resetMouseEncoder(this.mouseEncoderHandle),this.pressedMouseButtons.clear(),this.mouseDragActive=!1}}isAltScreenActive(){return this.isModeEnabled(He)||this.isModeEnabled(Le)}reset(){this.disposed||(this.lineCache.clear(),this.clearSelectionState(!1),this.bindings.resetTerminal(this.terminalHandle),this.scheduleRender())}refresh(){this.disposed||this.render()}resize(e,t){if(this.disposed)return;const s=Math.max(2,Math.floor(e)),r=Math.max(2,Math.floor(t));this.cols=s,this.rows=r,this.clearSelectionState(!1),this.bindings.resizeTerminal(this.terminalHandle,s,r,this.cellDimensions()),this.bindings.resetMouseEncoder(this.mouseEncoderHandle),this.scheduleRender()}scrollLines(e){this.disposed||e===0||(this.bindings.scrollViewportDelta(this.terminalHandle,e),this.render())}scrollToTop(){this.disposed||(this.bindings.scrollViewportTop(this.terminalHandle),this.render())}scrollToBottom(){this.disposed||(this.bindings.scrollViewportBottom(this.terminalHandle),this.render())}exportModeSnapshot(){return{mouseX10:this.isModeEnabled(Ue),mouseNormal:this.isModeEnabled(ze),mouseButton:this.isModeEnabled(Ye),mouseAny:this.isModeEnabled(Ve),mouseUtf8:this.isModeEnabled(1005),mouseSgr:this.isModeEnabled(1006),mouseSgrPixels:this.isModeEnabled(1016),mouseUrxvt:this.isModeEnabled(1015),altScroll:this.isModeEnabled(tt),altScreen1047:this.isModeEnabled(He),altScreen1049:this.isModeEnabled(Le)}}restoreModeSnapshot(e){this.bindings.setTerminalMode(this.terminalHandle,Ue,e.mouseX10),this.bindings.setTerminalMode(this.terminalHandle,ze,e.mouseNormal),this.bindings.setTerminalMode(this.terminalHandle,Ye,e.mouseButton),this.bindings.setTerminalMode(this.terminalHandle,Ve,e.mouseAny),this.bindings.setTerminalMode(this.terminalHandle,1005,e.mouseUtf8),this.bindings.setTerminalMode(this.terminalHandle,1006,e.mouseSgr),this.bindings.setTerminalMode(this.terminalHandle,1016,e.mouseSgrPixels),this.bindings.setTerminalMode(this.terminalHandle,1015,e.mouseUrxvt),this.bindings.setTerminalMode(this.terminalHandle,tt,e.altScroll),this.bindings.setTerminalMode(this.terminalHandle,He,e.altScreen1047),this.bindings.setTerminalMode(this.terminalHandle,Le,e.altScreen1049),this.bindings.resetMouseEncoder(this.mouseEncoderHandle)}handleViewportGesture(e){if(this.disposed||e.deltaY===0)return!1;const t=this.gestureToLines(e);if(t===0)return!1;const s=this.getInputRoutingState();if(s.mouseReporting){const r=t<0?tr:nr;let i=!1;for(let o=0;o<Math.abs(t);o+=1)i=this.emitMouseInput({action:"press",button:r,clientX:e.clientX,clientY:e.clientY,mods:Fe(e),anyButtonPressed:this.pressedMouseButtons.size>0})||i;return i}return s.altScroll?this.emitAltScrollInput(t):(this.scrollLines(t),!0)}paste(e){if(this.disposed||this.disableStdin||!e)return;const t=this.bindings.encodePaste(this.terminalHandle,e);t&&this.emitData(t)}focus(){var e;(e=this.textarea)==null||e.focus({preventScroll:!0})}getRendererKind(){var e;return((e=this.renderer)==null?void 0:e.kind)??"unknown"}setTheme(e){var t;this.bindings.setTerminalTheme(this.terminalHandle,e),this.options.theme=e,this.element&&(this.element.style.backgroundColor=e.background,this.element.style.color=e.foreground),this.screenElement&&(this.screenElement.style.backgroundColor=e.background),(t=this.renderer)==null||t.setTheme(e),this.scheduleRender()}setDisableStdin(e){this.disableStdin=e,this.syncInputState()}measureSizeFromElement(){const e=this.element;if(!e)return null;const t=e.getBoundingClientRect(),{width:s,height:r}=this.cellDimensions();return t.width===0||t.height===0||s<=0||r<=0?null:{cols:Math.max(2,Math.floor(t.width/s)),rows:Math.max(2,Math.floor(t.height/r))}}dispose(){var e,t;if(!this.disposed){this.disposed=!0,this.renderRaf!==null&&(cancelAnimationFrame(this.renderRaf),this.renderRaf=null),this.stopAutoScroll(),this.updateSelectionTextProbe(null),this.clearDomEventListeners(),this.scrollbarFadeTimer&&(clearTimeout(this.scrollbarFadeTimer),this.scrollbarFadeTimer=null);for(const s of this.addons)s.dispose();this.addons.clear(),(e=this.renderer)==null||e.dispose(),this.renderer=null,(t=this.element)==null||t.remove(),this.element=null,this.screenElement=null,this.textarea=null,this.scrollbarThumb=null,Xe(this.renderState),this.bindings.freeMouseEncoder(this.mouseEncoderHandle),this.bindings.freeKeyEncoder(this.keyEncoderHandle),this.bindings.freeTerminal(this.terminalHandle)}}cellDimensions(){return this._core._renderService.dimensions.css.cell}syncInputState(){this.textarea&&(this.textarea.readOnly=this.disableStdin,this.textarea.tabIndex=this.disableStdin?-1:0,this.disableStdin&&document.activeElement===this.textarea&&this.textarea.blur())}bindDomEvents(){const e=this.element,t=this.textarea;if(!e||!t)return;e.addEventListener("click",()=>{this.disableStdin||this.focus()}),(this.screenElement??e).addEventListener("mousedown",i=>{if(i instanceof MouseEvent){if(this.disableStdin||this.focus(),this.getInputRoutingState().mouseReporting){const o=this.mouseButtonFromEvent(i);if(o===null)return;this.clearSelectionState(),this.pressedMouseButtons.add(o),this.mouseDragActive=!0,this.emitMouseInput({action:"press",button:o,clientX:i.clientX,clientY:i.clientY,mods:Fe(i),anyButtonPressed:!0}),i.preventDefault();return}i.button===0&&(this.mouseDragActive=!0,this.beginPointerSelection(i),i.preventDefault())}}),e.addEventListener("wheel",i=>{this.handleViewportGesture({source:"wheel",deltaY:i.deltaY,deltaMode:i.deltaMode,clientX:i.clientX,clientY:i.clientY,shiftKey:i.shiftKey,ctrlKey:i.ctrlKey,altKey:i.altKey,metaKey:i.metaKey})&&i.preventDefault()},{passive:!1});const r=typeof window<"u"&&typeof window.addEventListener=="function"?window:null;if(r){const i=l=>{if(this.mouseDragActive){if(this.getInputRoutingState().mouseReporting){this.emitMouseInput({action:"motion",button:this.mouseButtonFromButtons(l.buttons),clientX:l.clientX,clientY:l.clientY,mods:Fe(l),anyButtonPressed:this.pressedMouseButtons.size>0||l.buttons>0});return}this.updatePointerSelection(l)}},o=l=>{if(this.mouseDragActive){if(this.mouseDragActive=!1,this.getInputRoutingState().mouseReporting){const u=this.mouseButtonFromEvent(l);u!==null&&this.pressedMouseButtons.delete(u),this.emitMouseInput({action:"release",button:u,clientX:l.clientX,clientY:l.clientY,mods:Fe(l),anyButtonPressed:this.pressedMouseButtons.size>0});return}this.finishPointerSelection(l)}};r.addEventListener("mousemove",i),r.addEventListener("mouseup",o),this.domEventDisposers.push(()=>{r.removeEventListener("mousemove",i),r.removeEventListener("mouseup",o)})}t.addEventListener("keydown",i=>{const o=this.getSelectionText();if(o&&Ss(i)){i.preventDefault(),bs(o).catch(()=>{}),this.clearSelectionState(),this.copyShortcutSuppressed=!0,this.clearTextarea();return}if(!this.customKeyEventHandler(i)||this.disableStdin||this.imeIsComposing||i.keyCode===229||_s(i)||!ir(i))return;const l=this.encodeKeyboardEvent(i,i.repeat?"repeat":"press");l&&(i.preventDefault(),this.emitData(l),this.clearTextarea())}),t.addEventListener("keyup",i=>{if(this.copyShortcutSuppressed){const l=i.key.toLowerCase();if(l==="c"){i.preventDefault();return}if(l==="control"||l==="meta"||l==="os"){this.copyShortcutSuppressed=!1,i.preventDefault();return}}if(this.disableStdin||this.imeIsComposing)return;const o=this.encodeKeyboardEvent(i,"release");o&&(i.preventDefault(),this.emitData(o),this.clearTextarea())}),t.addEventListener("compositionstart",()=>{this.imeIsComposing=!0,this.lastCompositionCommit=null,this.syncTextareaPositionToCursor()}),t.addEventListener("compositionupdate",()=>{this.syncTextareaPositionToCursor()}),t.addEventListener("compositionend",i=>{this.imeIsComposing=!1;const o=i.data??"";o&&(this.lastCompositionCommit={data:o,at:Date.now()},this.emitData(o),this.clearTextarea())}),t.addEventListener("beforeinput",i=>{if(this.disableStdin||i.inputType==="insertFromPaste")return;const o=i.data??"";if(!o||i.isComposing||this.imeIsComposing)return;const l=this.lastCompositionCommit;if(l&&l.data===o&&Date.now()-l.at<40){this.lastCompositionCommit=null,i.preventDefault(),this.clearTextarea();return}this.lastCompositionCommit=null,i.preventDefault(),this.emitData(o),this.clearTextarea()}),t.addEventListener("paste",i=>{var l;if(this.disableStdin)return;const o=((l=i.clipboardData)==null?void 0:l.getData("text/plain"))??"";o&&(i.preventDefault(),this.paste(o),this.clearTextarea())}),t.addEventListener("copy",i=>{const o=this.getSelectionText();o&&xs(i,o)}),t.addEventListener("input",()=>{if(this.disableStdin||this.imeIsComposing)return;const i=t.textContent??"";if(!i){this.clearTextarea();return}const o=this.lastCompositionCommit;if(o&&o.data===i&&Date.now()-o.at<40){this.lastCompositionCommit=null,this.clearTextarea();return}this.lastCompositionCommit=null,this.emitData(i),this.clearTextarea()})}encodeKeyboardEvent(e,t){const s=ht(e.code);if(s===0)return null;const r=e.key.length===1&&!e.ctrlKey&&!e.metaKey?e.key:null;return this.bindings.encodeKeyEvent(this.keyEncoderHandle,this.terminalHandle,{action:t,keyCode:s,mods:Ft(e),composing:e.isComposing,utf8:r,unshiftedCodepoint:Cn(e.code)})}getInputRoutingState(){const e=this.isModeEnabled(Ue)||this.isModeEnabled(ze)||this.isModeEnabled(Ye)||this.isModeEnabled(Ve),t=this.isModeEnabled(He)||this.isModeEnabled(Le);return{mouseReporting:e,altScroll:!e&&t&&this.isModeEnabled(tt)}}gestureToLines(e){const t=this.cellDimensions().height||Pe;if(e.source==="wheel"){if(e.deltaMode===1)return this.wheelPixelDelta=0,e.deltaY>0?Math.ceil(e.deltaY):Math.floor(e.deltaY);if(e.deltaMode===2){this.wheelPixelDelta=0;const r=Math.max(1,this.rows),i=e.deltaY*r;return i>0?Math.ceil(i):Math.floor(i)}this.wheelPixelDelta+=e.deltaY;const s=this.wheelPixelDelta>0?Math.floor(this.wheelPixelDelta/t):Math.ceil(this.wheelPixelDelta/t);return s!==0&&(this.wheelPixelDelta-=s*t),s}return e.deltaY>0?Math.ceil(e.deltaY/t):Math.floor(e.deltaY/t)}isModeEnabled(e){return this.bindings.isTerminalModeEnabled(this.terminalHandle,e)}mouseButtonFromEvent(e){switch(e.button){case 0:return Rt;case 1:return Ct;case 2:return vt;default:return null}}mouseButtonFromButtons(e){return e&1?Rt:e&4?Ct:e&2?vt:null}pointerPositionFromClient(e,t){var o;const s=(o=this.screenElement)==null?void 0:o.getBoundingClientRect();if(!s)return null;const r=Math.max(1,s.width),i=Math.max(1,s.height);return{x:Math.max(0,Math.min(r-1,e-s.left)),y:Math.max(0,Math.min(i-1,t-s.top))}}emitMouseInput(e){var o;if(this.disableStdin)return!1;const t=this.pointerPositionFromClient(e.clientX,e.clientY);if(!t)return!1;const s=this.cellDimensions(),r=(o=this.screenElement)==null?void 0:o.getBoundingClientRect();if(!r)return!1;const i=this.bindings.encodeMouseEvent(this.mouseEncoderHandle,this.terminalHandle,{action:e.action,button:e.button,mods:e.mods,x:t.x,y:t.y,anyButtonPressed:e.anyButtonPressed,screenWidth:Math.max(1,Math.round(r.width)),screenHeight:Math.max(1,Math.round(r.height)),cellWidth:Math.max(1,Math.round(s.width||et)),cellHeight:Math.max(1,Math.round(s.height||Pe))});return i?(this.emitData(i),!0):!1}emitAltScrollInput(e){const t=ht(e<0?"ArrowUp":"ArrowDown");if(t===0)return!1;let s=!1;for(let r=0;r<Math.abs(e);r+=1){const i=this.bindings.encodeKeyEvent(this.keyEncoderHandle,this.terminalHandle,{action:"press",keyCode:t,mods:0,composing:!1,utf8:null,unshiftedCodepoint:null});i&&(this.emitData(i),s=!0)}return s}emitData(e){for(const t of this.dataListeners)t(e)}clearTextarea(){this.textarea&&(this.textarea.textContent="")}syncTextareaPositionToCursor(){const e=this.textarea,t=this.screenElement;if(!e||!t)return;const{width:s,height:r}=this.cellDimensions();if(s<=0||r<=0)return;const i=pt(this.bindings);let o=0,l=0;try{wt(i,this.terminalHandle);const g=st(i);g.cursor.x!==null&&g.cursor.y!==null&&(o=g.cursor.x,l=g.cursor.y)}finally{Xe(i)}const u=o*s,a=l*r;e.style.left=`${u}px`,e.style.top=`${a}px`,e.style.width=`${Math.max(1,s)}px`,e.style.height=`${Math.max(1,r)}px`,e.style.lineHeight=`${r}px`,e.style.fontFamily=this.options.fontFamily,e.style.fontSize=`${this.options.fontSize}px`}scheduleRender(){this.renderRaf===null&&(this.renderRaf=requestAnimationFrame(()=>{this.renderRaf=null,this.render()}))}render(){if(this.disposed||!this.screenElement||!this.renderer)return;const e=this.bindings.readScrollbar(this.terminalHandle),t=Math.max(1,e.len||this.rows);wt(this.renderState,this.terminalHandle);const s=st(this.renderState),r=Array.from(ls(this.renderState));this.cols=Math.max(2,s.cols),this.rows=Math.max(2,s.rows||t),this.lastViewportOffset=e.offset,this.lastViewportRows=this.rows,this.lastRenderedRows=r;for(const a of r)this.lineCache.set(e.offset+a.y,yt(a.cells,a.wrap));const i=ys(this.selectionState,this.lastViewportOffset,this.lastViewportRows,a=>this.getLineModel(a)),o=this.getSelectionText();this.renderer.render({meta:s,rows:r,cellDimensions:this.cellDimensions(),selectionRects:i,selectionColor:this.options.theme.selectionBackground});const l=or(r,this.rows),u=Math.max(0,e.total-e.len);this.buffer.setViewport(e.offset,u,e.total,l),this.updateSelectionTextProbe(o),this.updateScrollbar(e)}updateScrollbar(e){var u;const t=this.scrollbarThumb;if(!t)return;const s=((u=this.screenElement)==null?void 0:u.clientHeight)??0;if(s===0||e.total<=e.len){t.style.opacity="0";return}const r=e.len/e.total,i=Math.max(20,r*s),l=e.offset/Math.max(1,e.total-e.len)*(s-i);t.style.height=`${i}px`,t.style.transform=`translateY(${l}px)`,t.style.opacity="1",this.scrollbarFadeTimer&&clearTimeout(this.scrollbarFadeTimer),this.scrollbarFadeTimer=setTimeout(()=>{t.style.opacity="0"},800)}updateCellDimensions(){if(!this.element)return;const e=document.createElement("span");e.textContent="WWWWWWWWWW",e.style.position="absolute",e.style.visibility="hidden",e.style.whiteSpace="pre",e.style.fontFamily=this.options.fontFamily,e.style.fontSize=`${this.options.fontSize}px`,e.style.lineHeight="1.2",this.element.appendChild(e);const t=e.getBoundingClientRect();e.remove(),this._core._renderService.dimensions.css.cell.width=t.width>0?t.width/10:et,this._core._renderService.dimensions.css.cell.height=t.height>0?t.height:Pe}clearSelectionState(e=!0){this.selectionState=fs(),this.pressedMouseButtons.clear(),this.wheelPixelDelta=0,this.pointerDrag={active:!1,moved:!1,mode:"character",lastClientX:null,lastClientY:null},this.copyShortcutSuppressed=!1,this.stopAutoScroll(),this.updateSelectionTextProbe(null),e&&this.screenElement&&this.renderer&&this.render()}beginSelectionAt(e,t,s){const r=this.hitTest(e,t);return r?(this.pointerDrag={active:!0,moved:!1,mode:s,lastClientX:e,lastClientY:t},this.selectionState=ms(this.selectionState,{...r,mode:s},i=>this.getLineModel(i)),this.updateAutoScroll(),this.render(),!0):!1}updateSelectionDrag(e,t){if(!this.pointerDrag.active)return;const s=this.hitTest(e,t);this.pointerDrag.lastClientX=e,this.pointerDrag.lastClientY=t,s&&(this.pointerDrag.moved=!0,this.selectionState=_t(this.selectionState,s,r=>this.getLineModel(r)),this.render()),this.updateAutoScroll()}beginPointerSelection(e){this.beginSelectionAt(e.clientX,e.clientY,this.selectionModeFromClickDetail(e.detail))}updatePointerSelection(e){this.updateSelectionDrag(e.clientX,e.clientY)}finishPointerSelection(e){var s,r,i,o;if(!this.pointerDrag.active||e.button!==0)return;this.pointerDrag.lastClientX=e.clientX,this.pointerDrag.lastClientY=e.clientY,this.stopAutoScroll();const t=this.pointerDrag.mode==="character"&&!this.pointerDrag.moved&&((s=this.selectionState.anchor)==null?void 0:s.line)===((r=this.selectionState.focus)==null?void 0:r.line)&&((i=this.selectionState.anchor)==null?void 0:i.col)===((o=this.selectionState.focus)==null?void 0:o.col);if(this.pointerDrag.active=!1,t){this.clearSelectionState();return}this.render()}selectionModeFromClickDetail(e){return e>=3?"line":e===2?"word":"character"}hitTest(e,t){var A;const s=(A=this.screenElement)==null?void 0:A.getBoundingClientRect();if(!s)return null;const{width:r,height:i}=this.cellDimensions();if(r<=0||i<=0)return null;const o=e-s.left,l=t-s.top,u=Math.max(this.cols-1,0),a=Math.max(this.lastViewportRows-1,0),g=Math.max(0,Math.min(u,Math.floor(o/r))),E=Math.max(0,Math.min(a,Math.floor(l/i)));return{line:this.lastViewportOffset+E,col:g}}getLineModel(e){const t=this.lineCache.get(e);if(t)return t;const s=e-this.lastViewportOffset,r=this.lastRenderedRows[s];return r?yt(r.cells,r.wrap):as}getSelectionText(){return St(this.selectionState)?ws(this.selectionState,e=>this.getLineModel(e)):null}updateSelectionTextProbe(e){if(globalThis.__tmexE2eTerminalSelectionText=e,e!==this.lastNotifiedSelectionText){this.lastNotifiedSelectionText=e;for(const t of this.selectionListeners)t(e)}}updateAutoScroll(){var s;if(!this.pointerDrag.active||this.pointerDrag.lastClientY===null){this.stopAutoScroll();return}const e=(s=this.screenElement)==null?void 0:s.getBoundingClientRect();if(!e){this.stopAutoScroll();return}if(!(this.pointerDrag.lastClientY<e.top||this.pointerDrag.lastClientY>e.bottom)){this.stopAutoScroll();return}this.autoScrollTimer===null&&(this.autoScrollTimer=setInterval(()=>{this.stepAutoScroll()},Zs))}stepAutoScroll(){var r;if(!this.pointerDrag.active||this.pointerDrag.lastClientX===null||this.pointerDrag.lastClientY===null){this.stopAutoScroll();return}const e=(r=this.screenElement)==null?void 0:r.getBoundingClientRect();if(!e){this.stopAutoScroll();return}let t=0;if(this.pointerDrag.lastClientY<e.top?t=-1:this.pointerDrag.lastClientY>e.bottom&&(t=1),t===0){this.stopAutoScroll();return}this.bindings.scrollViewportDelta(this.terminalHandle,t),this.render();const s=this.hitTest(this.pointerDrag.lastClientX,this.pointerDrag.lastClientY);s&&(this.selectionState=_t(this.selectionState,s,i=>this.getLineModel(i)),this.pointerDrag.moved=!0,this.render())}stopAutoScroll(){this.autoScrollTimer!==null&&(clearInterval(this.autoScrollTimer),this.autoScrollTimer=null)}clearDomEventListeners(){for(;this.domEventDisposers.length>0;){const e=this.domEventDisposers.pop();e==null||e()}}}async function ar(n){return $e.create(n)}function cr({visible:n,canPaste:e,onCopy:t,onPaste:s,onDismiss:r}){const{t:i}=Ke();if(!n)return null;const o=l=>{l.preventDefault()};return h.jsxs("div",{className:"absolute top-2 left-1/2 z-20 flex -translate-x-1/2 items-center gap-1 rounded-lg border bg-background/95 p-1 shadow-md backdrop-blur","data-testid":"terminal-selection-toolbar",children:[h.jsxs("button",{type:"button",className:"flex h-9 items-center gap-1.5 rounded-md px-3 text-sm font-medium hover:bg-accent hover:text-accent-foreground",onMouseDown:o,onClick:t,"data-testid":"terminal-selection-copy",children:[h.jsx(pn,{className:"h-4 w-4"}),i("terminal.copy")]}),e&&h.jsxs("button",{type:"button",className:"flex h-9 items-center gap-1.5 rounded-md px-3 text-sm font-medium hover:bg-accent hover:text-accent-foreground",onMouseDown:o,onClick:s,"data-testid":"terminal-selection-paste",children:[h.jsx(fn,{className:"h-4 w-4"}),i("terminal.paste")]}),h.jsx("button",{type:"button",className:"flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-accent-foreground",onMouseDown:o,onClick:r,"aria-label":i("terminal.clearSelection"),"data-testid":"terminal-selection-dismiss",children:h.jsx(Wt,{className:"h-4 w-4"})})]})}function Ut(n){if(!n)return n;const e=n.replace(/\r\n/g,`
33
- `);return(e.endsWith(`
34
- `)?e.slice(0,-1):e).replace(/\n/g,`\r
35
- `)}const dr="\x1B[?1049h\x1B[H\x1B[2J";function ur(n){return dr+Ut(n)}function Mt(n,e){let t=e,s=0;for(const l of n)l===10&&!t&&(s+=1),t=l===13;const r=t;if(s===0)return{normalized:n,endedWithCR:r};const i=new Uint8Array(n.length+s);let o=0;t=e;for(const l of n)l===10&&!t&&(i[o]=13,o+=1),i[o]=l,o+=1,t=l===13;return{normalized:i,endedWithCR:r}}const zt={background:"#e1e1e1",foreground:"#616161",cursor:"#616161",selectionBackground:"rgba(97, 97, 97, 0.25)",black:"#171717",red:"#bf2172",green:"#009799",yellow:"#9a7200",blue:"#007299",magenta:"#9b1d72",cyan:"#007173",white:"#d9d9d9",brightBlack:"#4e4e4e",brightRed:"#e12672",brightGreen:"#00bddf",brightYellow:"#ffdd00",brightBlue:"#7299bc",brightMagenta:"#e17899",brightCyan:"#6fbcbd",brightWhite:"#f1f1f1"},Yt={background:"#262626",foreground:"#d0d0d0",cursor:"#c5c5c5",selectionBackground:"rgba(197, 197, 197, 0.25)",black:"#000000",red:"#ba3c3c",green:"#5d876d",yellow:"#d5a54e",blue:"#887c8d",magenta:"#cd6d6d",cyan:"#618484",white:"#cfcdc3",brightBlack:"#000000",brightRed:"#ea7171",brightGreen:"#7aab7a",brightYellow:"#d1d194",brightBlue:"#afa3b5",brightMagenta:"#e29f9f",brightCyan:"#a0aea3",brightWhite:"#d0d0d0"},hr='"JetBrains Mono", "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Noto Sans Mono CJK SC", "Source Han Mono SC", "Sarasa Mono SC", "Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji", monospace',fr=1.3,mr=36,pr=500,wr=12;function yr(n,e){const t=d.useRef(!1);return d.useEffect(()=>{const s=n.current;if(!s||!(window.innerWidth<768||navigator.maxTouchPoints>0||"ontouchstart"in window))return;t.current=!0;let i=0,o=null,l=!1,u=0,a=0,g=0,E=null,A=!1;const H=()=>{E!==null&&(clearTimeout(E),E=null)},T=b=>b?!!(b.closest(".scrollbar")||b.closest(".slider")||b.closest(".xterm-scroll-area")):!1,x=(b,C,N)=>{const L=N instanceof Element?N:null;if(T(L))return!0;const V=document.elementFromPoint(b,C);if(T(V))return!0;const S=s.querySelector(".xterm");if(!(S instanceof HTMLElement))return!1;const R=S.getBoundingClientRect(),B=b>=R.left&&b<=R.right,F=C>=R.top&&C<=R.bottom;return!B||!F?!1:b>=R.right-mr},J=()=>[s.querySelector(".xterm-viewport"),s.querySelector(".xterm-scrollable-element")].filter(C=>C instanceof HTMLElement),y=b=>{if(o===null)return null;for(let C=0;C<b.length;C+=1){const N=b.item(C);if(N&&N.identifier===o)return N}return null},U=b=>{if(H(),b.touches.length!==1)return;const C=b.touches.item(0);C&&(o=C.identifier,i=C.clientY,u=0,l=x(C.clientX,C.clientY,b.target),a=C.clientX,g=C.clientY,A=!1,l||(E=setTimeout(()=>{var L;E=null;const N=(e==null?void 0:e())??null;(L=N==null?void 0:N.startTouchSelection)!=null&&L.call(N,a,g,"word")&&(A=!0)},pr)))},k=b=>{var B,F,I,j,Q,te,se,D,ie;const C=y(b.touches)??b.touches.item(0);if(!C)return;if(A){const G=(e==null?void 0:e())??null;(B=G==null?void 0:G.updateTouchSelection)==null||B.call(G,C.clientX,C.clientY),b.cancelable&&b.preventDefault();return}if(E!==null&&Math.hypot(C.clientX-a,C.clientY-g)>wr&&H(),l||(l=x(C.clientX,C.clientY,b.target),l&&(u=0)),l)return;const N=C.clientY,L=i-N;if(i=N,L===0)return;let V=!1,S=!1;const R=(e==null?void 0:e())??null;if(R){const G=R==null?void 0:R._core,z=((Q=(j=(I=(F=G==null?void 0:G._renderService)==null?void 0:F.dimensions)==null?void 0:I.css)==null?void 0:j.cell)==null?void 0:Q.height)??18;u+=L*fr;const P=u>0?Math.floor(u/z):Math.ceil(u/z);if(typeof R.handleViewportGesture=="function")P!==0&&(V=R.handleViewportGesture({source:"touch",deltaY:P*z,clientX:C.clientX,clientY:C.clientY}),u-=P*z);else if(P!==0){const $=((se=(te=R.buffer)==null?void 0:te.active)==null?void 0:se.viewportY)??0;R.scrollLines(P);const w=((ie=(D=R.buffer)==null?void 0:D.active)==null?void 0:ie.viewportY)??0;V=$!==w,S=P<0&&$<=0&&w<=0,u-=P*z}}else{const G=J();if(G.length===0)return;for(const z of G){const P=z.scrollTop;z.scrollTop+=L;const $=z.scrollTop;Math.abs($-P)>0&&(V=!0),L<0&&$<=0&&(S=!0)}if(!V){const z=s.querySelector(".xterm");if(z instanceof HTMLElement){const P=new WheelEvent("wheel",{bubbles:!0,cancelable:!0,deltaMode:WheelEvent.DOM_DELTA_PIXEL,deltaY:L}),$=z.dispatchEvent(P);V=P.defaultPrevented||!$}}}b.cancelable&&(V||S)&&b.preventDefault()},K=b=>{var N;if(H(),!(o===null||!y(b.changedTouches))&&(o=null,u=0,l=!1,A)){A=!1;const L=(e==null?void 0:e())??null;(N=L==null?void 0:L.endTouchSelection)==null||N.call(L)}},Y=b=>{A&&b.preventDefault()};return s.addEventListener("touchstart",U,{passive:!0}),s.addEventListener("touchmove",k,{passive:!1}),s.addEventListener("touchend",K,{passive:!0}),s.addEventListener("touchcancel",K,{passive:!0}),s.addEventListener("contextmenu",Y),()=>{t.current=!1,H(),s.removeEventListener("touchstart",U),s.removeEventListener("touchmove",k),s.removeEventListener("touchend",K),s.removeEventListener("touchcancel",K),s.removeEventListener("contextmenu",Y)}},[n,e]),t}function gr({now:n,remoteSize:e,pendingLocalSize:t,ttlMs:s=2e3}){return!t||n-t.at>s?!0:t.cols===e.cols&&t.rows===e.rows}function Sr({currentSize:n,containerSize:e,force:t=!1}){return t?!0:n.cols!==e.cols||n.rows!==e.rows}function _r({deviceId:n,paneId:e,deviceConnected:t,isSelectionInvalid:s,onResize:r,onSync:i,getContainerRect:o}){const l=d.useRef(null),u=d.useRef(null),a=d.useRef(null),g=d.useRef(null),E=d.useRef(0),A=d.useRef([]),H=d.useRef(null),T=d.useRef(null),x=d.useRef(o),J=d.useRef(!1),y=d.useRef(r),U=d.useRef(i);d.useEffect(()=>{y.current=r},[r]),d.useEffect(()=>{U.current=i},[i]),d.useEffect(()=>{x.current=o},[o]);const k=d.useCallback(()=>{var te,se,D,ie,G,z,P,$,w,_;const S=T.current,R=H.current;if(!S||!R||!S.element)return null;let B;try{const v=R.proposeDimensions();if(!v)throw new Error("fitAddon.proposeDimensions() returned null");B=Math.max(2,v.cols)}catch{const v=S._core,W=((ie=(D=(se=(te=v==null?void 0:v._renderService)==null?void 0:te.dimensions)==null?void 0:se.css)==null?void 0:D.cell)==null?void 0:ie.width)??9,q=(G=x.current)==null?void 0:G.call(x);if(!q||q.width===0)return null;B=Math.max(2,Math.floor(q.width/W))}const F=(z=x.current)==null?void 0:z.call(x);if(!F||F.height===0)return null;const I=S._core,j=((_=(w=($=(P=I==null?void 0:I._renderService)==null?void 0:P.dimensions)==null?void 0:$.css)==null?void 0:w.cell)==null?void 0:_.height)??17,Q=Math.max(2,Math.floor(F.height/j));return{cols:B,rows:Q}},[]),K=d.useCallback((S,R)=>{const B=T.current;B&&(B.cols===S&&B.rows===R||B.resize(S,R))},[]),Y=d.useCallback((S,R=!1)=>{if(!n||!e||!t||s&&S!=="sync"||!R&&Date.now()<E.current||!T.current)return!1;const F=k();if(!F)return!1;const{cols:I,rows:j}=F,Q=a.current;return!R&&Q&&Q.cols===I&&Q.rows===j?(K(I,j),!0):(K(I,j),S==="sync"?U.current(I,j):y.current(I,j),a.current={cols:I,rows:j},g.current={cols:I,rows:j,at:Date.now()},!0)},[K,t,n,s,k,e]),b=d.useCallback((S="resize",R={})=>{const{immediate:B=!1,force:F=!1}=R;u.current!==null&&(window.clearTimeout(u.current),u.current=null),l.current!==null&&(cancelAnimationFrame(l.current),l.current=null);const I=()=>{l.current=requestAnimationFrame(()=>{l.current=null,Y(S,F)})};if(B){I();return}u.current=window.setTimeout(()=>{u.current=null,I()},150)},[Y]),C=d.useCallback(()=>{for(const S of A.current)window.clearTimeout(S);A.current=[]},[]),N=d.useCallback(()=>{var R;C(),b("sync",{immediate:!0,force:!0});const S=window.setTimeout(()=>{b("sync",{immediate:!0,force:!0})},60);A.current.push(S),typeof document<"u"&&"fonts"in document&&((R=document.fonts)!=null&&R.ready)&&document.fonts.ready.then(()=>{b("sync",{immediate:!0,force:!0})}).catch(()=>{})},[C,b]);d.useEffect(()=>{let S=null;const R=()=>{S!==null&&cancelAnimationFrame(S),S=requestAnimationFrame(()=>{S=null,b("resize")})};return window.addEventListener("resize",R),()=>{window.removeEventListener("resize",R),S!==null&&cancelAnimationFrame(S)}},[b]),d.useEffect(()=>{const S=()=>{var te;const I=T.current,j=k();if(!I||!j)return;if(!Sr({currentSize:{cols:Math.max(2,I.cols),rows:Math.max(2,I.rows)},containerSize:j})){(te=I.refresh)==null||te.call(I);return}b("sync",{force:!0})},R=()=>{if(document.visibilityState!=="visible"){J.current=!0;return}J.current&&(J.current=!1,S())},B=()=>{J.current=!0},F=()=>{J.current&&(J.current=!1,S())};return document.addEventListener("visibilitychange",R),window.addEventListener("blur",B),window.addEventListener("focus",F),()=>{document.removeEventListener("visibilitychange",R),window.removeEventListener("blur",B),window.removeEventListener("focus",F)}},[k,b]),d.useEffect(()=>()=>{C(),u.current!==null&&window.clearTimeout(u.current),l.current!==null&&cancelAnimationFrame(l.current)},[C]);const L=d.useCallback(S=>{H.current=S},[]),V=d.useCallback(S=>{T.current=S},[]);return{scheduleResize:b,runPostSelectResize:N,clearPostSelectResizeTimers:C,setFitAddon:L,setTerminal:V,lastReportedSize:a,pendingLocalSize:g,suppressLocalResizeUntil:E}}const br={fontFamily:hr,fontSize:13,scrollback:1e4},rt="tmex:terminal-mode-cache";function xr(n,e){try{const t=sessionStorage.getItem(rt);return t?JSON.parse(t)[`${n}:${e}`]??null:null}catch{return null}}function Tr(n,e,t){try{const s=sessionStorage.getItem(rt),r=s?JSON.parse(s):{},i=`${n}:${e}`;t?r[i]=t:delete r[i],sessionStorage.setItem(rt,JSON.stringify(r))}catch{}}function Er(){return{mouseX10:!1,mouseNormal:!0,mouseButton:!1,mouseAny:!1,mouseUtf8:!1,mouseSgr:!0,mouseSgrPixels:!1,mouseUrxvt:!1,altScroll:!0,altScreen1047:!1,altScreen1049:!1}}function Rr(n,e){if(!e)return n?{...n,mouseX10:!1,mouseNormal:!1,mouseButton:!1,mouseAny:!1,mouseUtf8:!1,mouseSgrPixels:!1,mouseUrxvt:!1,altScreen1047:!1,altScreen1049:!1}:null;const t=Er();if(!n)return t;const s=n.mouseNormal||n.mouseButton||n.mouseAny;return{...n,mouseX10:!1,mouseUtf8:!1,mouseSgr:!0,mouseSgrPixels:!1,mouseUrxvt:!1,altScroll:!0,altScreen1047:!1,altScreen1049:!1,mouseNormal:s?n.mouseNormal:t.mouseNormal}}function Cr(n){var t;const e=globalThis;e.__tmexE2eXterm=n,e.__tmexE2eTerminal=n,e.__tmexE2eTerminalEngine=Gt,e.__tmexE2eTerminalRenderer=((t=n.getRendererKind)==null?void 0:t.call(n))??null}function vr(n){if(!n)return;const e=globalThis;e.__tmexE2eTerminal!==n&&e.__tmexE2eXterm!==n||(e.__tmexE2eXterm=null,e.__tmexE2eTerminal=null,e.__tmexE2eTerminalEngine=null,e.__tmexE2eTerminalRenderer=null,e.__tmexE2eTerminalSelectionText=null)}const Vt=d.forwardRef(({deviceId:n,paneId:e,theme:t,inputMode:s,deviceConnected:r,isSelectionInvalid:i,onResize:o,onSync:l},u)=>{const[a,g]=d.useState(null),[E,A]=d.useState(!1),H=Z(w=>w.sendInput),{t:T}=Ke(),x=d.useMemo(()=>{switch(t){case"light":return zt;default:return Yt}},[t]),J=d.useRef(null),y=d.useRef(null),U=d.useRef(null),k=d.useRef(n),K=d.useRef(e),Y=d.useRef(n),b=d.useRef(e),C=d.useRef(r&&!i),N=d.useRef(s),L=d.useRef(x),V=d.useRef(!1),S=d.useRef(!1),R=d.useRef(null),B=d.useRef(!1),F=d.useCallback((w,_,v)=>{!(w!=null&&w.exportModeSnapshot)||!_||!v||Tr(_,v,w.exportModeSnapshot())},[]),I=d.useCallback(()=>a,[a]);yr(J,I),d.useEffect(()=>{k.current=n,K.current=e,S.current=!1},[n,e]),d.useEffect(()=>{C.current=r&&!i},[r,i]),d.useEffect(()=>{N.current=s},[s]),d.useEffect(()=>{L.current=x},[x]);const j=d.useCallback(w=>{if(!w||s!=="direct"||!C.current)return;const _=k.current,v=K.current;!_||!v||H(_,v,w,!1)},[s,H]),{pendingLocalSize:Q,scheduleResize:te,runPostSelectResize:se,setFitAddon:D,setTerminal:ie}=_r({deviceId:n,paneId:e,deviceConnected:r,isSelectionInvalid:i,onResize:o,onSync:l,getContainerRect:()=>{const w=J.current;if(!w)return null;const _=w.getBoundingClientRect();return{width:_.width,height:_.height}}});d.useEffect(()=>{let w=!1,_=null;return ar({...br,theme:L.current,disableStdin:N.current==="editor"}).then(v=>{if(w){v.dispose();return}_=v,y.current&&v.open(y.current),Cr(v),g(v)}),()=>{w=!0,g(null),vr(_),_==null||_.dispose()}},[]),d.useEffect(()=>{!a||!("setTheme"in a)||a.setTheme(x)},[a,x]),d.useEffect(()=>{!a||!("setDisableStdin"in a)||a.setDisableStdin(s==="editor")},[a,s]),d.useEffect(()=>{!a||s!=="direct"||window.innerWidth<768||"ontouchstart"in window||a.focus()},[a,s]);const G=d.useMemo(()=>a?{onResetTerminal:w=>{k.current===w&&(F(a,Y.current,b.current),B.current=!0,a.reset(),V.current=!1,se())},onApplyHistory:(w,_,v)=>{var X;if(k.current!==w)return;const W=Rr(xr(k.current,K.current),v);W&&((X=a.restoreModeSnapshot)==null||X.call(a,W));const q=v?ur(_):Ut(_);S.current=!0,a.write(q),B.current=!1,Y.current=k.current,b.current=K.current,F(a,k.current,K.current)},onFlushBuffer:(w,_)=>{if(k.current===w){for(const v of _){const W=Mt(v,V.current);V.current=W.endedWithCR,a.write(W.normalized)}S.current&&(a.buffer.active.baseY<=1&&a.scrollToTop(),S.current=!1),Y.current=k.current,b.current=K.current,F(a,k.current,K.current)}},onOutput:(w,_,v)=>{if(k.current!==w||K.current!==_)return;const W=Mt(v,V.current);V.current=W.endedWithCR,a.write(W.normalized),S.current&&(a.buffer.active.baseY<=1&&a.scrollToTop(),S.current=!1),Y.current=k.current,b.current=K.current,F(a,k.current,K.current)}}:{},[a,F,se]);d.useEffect(()=>{a?R.current!==a&&(V.current=!1,Y.current=k.current,b.current=K.current,R.current=a):R.current=null},[a]),d.useEffect(()=>{if(!(!a||!n||!e))return()=>{if(B.current){B.current=!1;return}F(a,Y.current,b.current)}},[n,a,e,F]),d.useEffect(()=>{dt(G)},[G]),d.useEffect(()=>()=>{dt({})},[]),d.useEffect(()=>{if(!a){U.current=null,D(null),ie(null);return}const w=new lr;return a.loadAddon(w),U.current=w,D(w),ie(a),se(),()=>{try{w.dispose()}finally{U.current=null,D(null),ie(null)}}},[a,se,D,ie]),d.useEffect(()=>{const w=J.current;if(!w)return;let _=null;const v=new ResizeObserver(()=>{_!==null&&cancelAnimationFrame(_),_=requestAnimationFrame(()=>{_=null,te("resize")})});return v.observe(w),()=>{v.disconnect(),_!==null&&cancelAnimationFrame(_)}},[te]),d.useEffect(()=>{if(!a||!n||!e)return;const w=a.onData(_=>{!r||i||j(_)});return a.attachCustomKeyEventHandler(_=>!r||i||_.type!=="keydown"||s!=="direct"?!0:_.shiftKey&&_.key==="Enter"?(_.preventDefault(),j("\x1B[13;2u"),!1):!0),()=>{w.dispose(),a.attachCustomKeyEventHandler(()=>!0)}},[a,r,i,s,j,n,e]),d.useEffect(()=>{if(!(a!=null&&a.onSelectionChange)){A(!1);return}const w=a.onSelectionChange(_=>{A(!!_)});return()=>{w.dispose(),A(!1)}},[a]);const z=d.useCallback(()=>{var _;if(!a)return;const w=((_=a.getSelection)==null?void 0:_.call(a))??"";w&&Ht(w).then(()=>{_e.success(T("terminal.copied"))}).catch(()=>{_e.error(T("terminal.copyFailed"))}).finally(()=>{var v;(v=a.clearSelection)==null||v.call(a),a.focus()})},[a,T]),P=d.useCallback(()=>{var _;if(!a)return;((_=navigator.clipboard)!=null&&_.readText?navigator.clipboard.readText():Promise.reject(new Error("clipboard unavailable"))).then(v=>{var W;v&&a.paste(v),(W=a.clearSelection)==null||W.call(a),a.focus()}).catch(()=>{_e.error(T("terminal.pasteFailed"))})},[a,T]),$=d.useCallback(()=>{var w;(w=a==null?void 0:a.clearSelection)==null||w.call(a),a==null||a.focus()},[a]);return d.useImperativeHandle(u,()=>({write:w=>a==null?void 0:a.write(w),reset:()=>{a==null||a.reset(),V.current=!1},scrollToBottom:()=>a==null?void 0:a.scrollToBottom(),resize:(w,_)=>a==null?void 0:a.resize(w,_),getTerminal:()=>a??null,getSize:()=>a?{cols:Math.max(2,a.cols),rows:Math.max(2,a.rows)}:null,runPostSelectResize:()=>se(),scheduleResize:(w,_)=>te(w,_),calculateSizeFromContainer:()=>{var De,Ae,oe,we,de,le,ee,ye,ue,ge,Te,Oe,ke,Ie,Ne,Ee;const w=J.current,_=a,v=U.current;if(!w||!_)return null;const W=w.getBoundingClientRect();if(W.width===0||W.height===0)return null;const q=_._core;let X;if(v)try{const c=v.proposeDimensions();if(c)X=Math.max(2,c.cols);else{const m=((we=(oe=(Ae=(De=q==null?void 0:q._renderService)==null?void 0:De.dimensions)==null?void 0:Ae.css)==null?void 0:oe.cell)==null?void 0:we.width)??9;X=Math.max(2,Math.floor(W.width/m))}}catch{const c=((ye=(ee=(le=(de=q==null?void 0:q._renderService)==null?void 0:de.dimensions)==null?void 0:le.css)==null?void 0:ee.cell)==null?void 0:ye.width)??9;X=Math.max(2,Math.floor(W.width/c))}else{const c=((Oe=(Te=(ge=(ue=q==null?void 0:q._renderService)==null?void 0:ue.dimensions)==null?void 0:ge.css)==null?void 0:Te.cell)==null?void 0:Oe.width)??9;X=Math.max(2,Math.floor(W.width/c))}const Me=((Ee=(Ne=(Ie=(ke=q==null?void 0:q._renderService)==null?void 0:ke.dimensions)==null?void 0:Ie.css)==null?void 0:Ne.cell)==null?void 0:Ee.height)??17,fe=Math.max(2,Math.floor(W.height/Me));return{cols:X,rows:fe}},getPendingLocalSize:()=>Q.current}),[a,Q,se,te]),h.jsxs("div",{ref:J,className:"h-full w-full relative",style:{backgroundColor:x.background},"data-terminal-engine":Gt,children:[h.jsx("div",{ref:y,className:"absolute inset-0"}),h.jsx(cr,{visible:E,canPaste:s==="direct"&&r&&!i,onCopy:z,onPaste:P,onDismiss:$})]})});Vt.displayName="Terminal";const Mr=1200,Dr=2e3;function he(n,e){return!n||!e?!1:n.windowId===e.windowId&&n.paneId===e.paneId}function Kt(n,e){const t=n.filter(s=>e-s.at<Mr);return t.length===0?null:t.reduce((s,r)=>r.at>s.at?r:s)}function ve(n,e=Date.now()){return!n||e-n.at>Dr?null:n}function Ar(n){const e=n.now??Date.now(),t=Kt(n.recentSelectRequests,e);if(t&&!he(t,n.activePaneFromEvent)||he(n.currentRoute,n.activePaneFromEvent)||he(n.lastHandledActive,n.activePaneFromEvent))return!0;const s=ve(n.pendingUserSelection,e);return!!(s&&!he(s,n.activePaneFromEvent))}function Or(n){const e=n.now??Date.now(),t=Kt(n.recentSelectRequests,e),s=ve(n.pendingUserSelection,e);return!!(s&&!he(s,n.snapshotActive)||t&&!he(t,n.snapshotActive))}function kr(n){const e=n.now??Date.now(),t=ve(n.pendingUserSelection,e);return!(t&&he(t,n.routeTarget)||n.snapshotActive&&he(n.snapshotActive,n.routeTarget))}const Ir=[{key:"enter",label:"ENTER",payload:"\r"},{key:"ctrl-c",label:"CTRL-C",payload:""},{key:"ctrl-d",label:"CTRL-D",payload:""},{key:"up",label:"↑",payload:"\x1B[A"},{key:"down",label:"↓",payload:"\x1B[B"},{key:"left",label:"←",payload:"\x1B[D"},{key:"right",label:"→",payload:"\x1B[C"},{key:"shift-enter",label:"SHIFT+ENTER",payload:"\x1B[13;2u"},{key:"tab",label:"TAB",payload:" "},{key:"backspace",label:"BACKSPACE",payload:"\b"},{key:"esc",label:"ESC",payload:"\x1B"},{key:"delete",label:"DELETE",payload:""},{key:":",label:":",payload:":"},{key:"/",label:"/",payload:"/"},{key:"'",label:"'",payload:"'"},{key:'"',label:'"',payload:'"'},{key:"`",label:"`",payload:"`"}],Dt=d.memo(function({onSend:e,onFocusEditor:t,disabled:s,isMobile:r,inputMode:i}){return h.jsx("div",{className:"terminal-shortcuts-strip my-2 bg-muted rounded-xl","data-testid":"terminal-shortcuts-strip",children:h.jsx("div",{className:"shortcut-row flex items-center gap-1.5 p-2 overflow-x-auto scrollbar-thin","data-testid":"editor-shortcuts-row",children:Ir.map(o=>h.jsx(pe,{variant:"secondary",size:"sm",className:"h-7 min-w-9 px-2.5 rounded-full text-[11px] font-medium tracking-wide shrink-0 [@media(any-pointer:coarse)]:h-9 [@media(any-pointer:coarse)]:min-w-10 [@media(any-pointer:coarse)]:px-3",title:o.label,"aria-label":o.label,"data-testid":`editor-shortcut-${o.key}`,onMouseDown:l=>l.preventDefault(),onClick:()=>{e(o.payload),r&&i==="editor"&&(t==null||t())},disabled:s,children:o.label},o.key))})})});function Lr(){var Ee;const{t:n}=Ke(),{deviceId:e,windowId:t,paneId:s}=it(),r=qt(),i=d.useRef(null),o=d.useRef(null),l=d.useRef(null),u=d.useRef(null),a=d.useRef(!1),g=d.useRef(!1),E=d.useRef(null),A=Z(c=>c.selectPane),H=Z(c=>e?c.snapshots[e]:void 0),T=Z(c=>{var m;return e?(m=c.deviceErrors)==null?void 0:m[e]:void 0}),x=Z(c=>{var m;return e?((m=c.deviceConnected)==null?void 0:m[e])??!1:!1}),J=At(c=>{var m;return((m=c.settings)==null?void 0:m.siteName)??"tmex"}),y=d.useMemo(()=>ot(s),[s]),U=d.useMemo(()=>e&&y?`${e}:${y}`:null,[e,y]),[k,K]=d.useState(!1),[Y,b]=d.useState(""),C=d.useRef(!1),N=!x||!y,[L,V]=d.useState(!1),S=ae(c=>c.inputMode),R=ae(c=>c.theme),B=ae(c=>c.editorSendWithEnter),F=ae(c=>c.setEditorSendWithEnter),I=ae(c=>c.addEditorHistory),j=ae(c=>c.setEditorDraft),Q=ae(c=>c.removeEditorDraft),te=ae(c=>U?c.editorDrafts[U]??"":""),se=d.useMemo(()=>Xt(),[]),D=(Ee=H==null?void 0:H.session)==null?void 0:Ee.windows,ie=R==="light"?zt:Yt,{data:G}=Jt({queryKey:["devices"],queryFn:async()=>{const c=await fetch("/api/devices");if(!c.ok)throw new Error("Failed to fetch devices");return c.json()},throwOnError:!1}),z=d.useMemo(()=>{if(e)return G==null?void 0:G.devices.find(c=>c.id===e)},[e,G==null?void 0:G.devices]),P=d.useMemo(()=>{if(!(!t||!D))return D.find(c=>c.id===t)},[t,D]),$=d.useMemo(()=>{if(!(!y||!P))return P.panes.find(c=>c.id===y)},[y,P]),w=!!D,q=!!(w&&!!t&&!P||w&&!!t&&!!y&&!!P&&!$?n("wsError.checkGateway"):null),X=!!(x&&y&&!q),Me=d.useMemo(()=>{if(!P||!$)return null;const c=(z==null?void 0:z.name)??e;return Ot({paneIdx:$.index,windowIdx:P.index,paneTitle:$.title,windowName:P.name,windowCustomName:P.customName,deviceName:c})},[z==null?void 0:z.name,e,$,P]),fe=d.useMemo(()=>{if(!D||D.length===0)return null;const c=D.find(p=>p.active),m=c==null?void 0:c.panes.find(p=>p.active);return!c||!m?null:{windowId:c.id,paneId:m.id}},[D]),De=d.useCallback((c,m)=>{!e||!y||Z.getState().resizePane(e,y,c,m)},[e,y]),Ae=d.useCallback((c,m)=>{!e||!y||Z.getState().syncPaneSize(e,y,c,m)},[e,y]),oe=d.useCallback((c,m)=>{const p=u.current,M=(p==null?void 0:p.calculateSizeFromContainer())??(p==null?void 0:p.getSize())??void 0;if(M)return M;if(!c||!m||!D)return;const ne=D.find(me=>me.id===c),re=ne==null?void 0:ne.panes.find(me=>me.id===m);if(!(!re||re.width<=1||re.height<=1))return{cols:re.width,rows:re.height}},[D]);d.useEffect(()=>{const c=()=>{K(window.innerWidth<768||"ontouchstart"in window)};return c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[]),d.useEffect(()=>{if(!k||!se||g.current)return;g.current=!0;const c=()=>{window.scrollTo(0,1)},m=window.requestAnimationFrame(c),p=window.setTimeout(c,120),M=window.setTimeout(c,420);return()=>{window.cancelAnimationFrame(m),window.clearTimeout(p),window.clearTimeout(M)}},[se,k]),d.useEffect(()=>{e&&(a.current=!1,ye.current=null,ue.current=null,E.current=null,de.current=[])},[e]),d.useEffect(()=>{x||(a.current=!1)},[x]),d.useEffect(()=>{if(!e||!x||!t||!D)return;if(D.length===0){r("/devices",{replace:!0});return}const c=D.find(p=>p.id===t);if(!c)return;if(!y){const p=c.panes.find(M=>M.active)??c.panes[0];p&&r(`/devices/${e}/windows/${t}/panes/${Se(p.id)}`,{replace:!0});return}if(!c.panes.find(p=>p.id===y)){const p=c.panes.find(M=>M.active)??c.panes[0];p&&r(`/devices/${e}/windows/${t}/panes/${Se(p.id)}`,{replace:!0});return}},[e,x,D,t,y,r]),d.useEffect(()=>{if(!e||!x||!D||D.length===0||t&&y||a.current)return;const c=D.find(p=>p.active)??D[0],m=c.panes.find(p=>p.active)??c.panes[0];m&&(a.current=!0,r(`/devices/${e}/windows/${c.id}/panes/${Se(m.id)}`,{replace:!0}))},[x,e,r,y,t,D]);const we=d.useRef(null);d.useEffect(()=>{we.current=null},[e,y]),d.useEffect(()=>{if(!e||!t||!y||N||!x)return;const c=`${e}:${t}:${y}`;if(we.current===c)return;we.current=c;const m=oe(t,y);le(t,y),A(e,t,y,m)},[x,e,oe,N,y,A,t]),d.useEffect(()=>{if(!e||!x||!t||!y)return;const c={windowId:t,paneId:y};kr({routeTarget:c,snapshotActive:fe,pendingUserSelection:E.current})&&(E.current={windowId:c.windowId,paneId:c.paneId,at:Date.now()})},[x,e,y,fe,t]);const de=d.useRef([]),le=d.useCallback((c,m)=>{const p=Date.now(),M=[...de.current.filter(ne=>p-ne.at<2e3),{windowId:c,paneId:m,at:p}];de.current=M.slice(-8)},[]),ee=Z(c=>e?c.activePaneFromEvent[e]:void 0),ye=d.useRef(null);d.useEffect(()=>{if(!e||!x||!t||!y||!ee)return;const c=Date.now(),m=ve(E.current,c);if(E.current=m,Ar({now:c,pendingUserSelection:m,activePaneFromEvent:ee,currentRoute:{windowId:t,paneId:y},recentSelectRequests:de.current,lastHandledActive:ye.current}))return;ye.current={...ee},m&&m.windowId===ee.windowId&&m.paneId===ee.paneId&&(E.current=null);const p=oe(ee.windowId,ee.paneId);le(ee.windowId,ee.paneId),A(e,ee.windowId,ee.paneId,p),r(`/devices/${e}/windows/${ee.windowId}/panes/${Se(ee.paneId)}`,{replace:!0})},[e,x,t,y,ee,le,oe,A,r]);const ue=d.useRef(null);d.useEffect(()=>{if(!e||!x||!D||D.length===0)return;const c=de.current,m=D.find(je=>je.active);if(!m)return;const p=m.panes.find(je=>je.active);if(!p)return;const M={windowId:m.id,paneId:p.id},ne=Date.now(),re=ve(E.current,ne);if(E.current=re,Or({now:ne,pendingUserSelection:re,snapshotActive:M,recentSelectRequests:c})||ue.current&&ue.current.windowId===M.windowId&&ue.current.paneId===M.paneId||(ue.current={...M},re&&re.windowId===M.windowId&&re.paneId===M.paneId&&(E.current=null),t===M.windowId&&y===M.paneId))return;const me=oe(M.windowId,M.paneId);le(M.windowId,M.paneId),A(e,M.windowId,M.paneId,me),r(`/devices/${e}/windows/${M.windowId}/panes/${Se(M.paneId)}`,{replace:!0})},[e,x,D,t,y,le,oe,A,r]);const ge=Z(c=>e?c.pendingCreateWindowAt[e]:void 0);d.useEffect(()=>{if(!e||!x||!ge)return;const c=5e3,m=Date.now()-ge;if(m>c){Z.getState().clearPendingCreateWindow(e);return}if(!fe){const ne=window.setTimeout(()=>{Z.getState().clearPendingCreateWindow(e)},c-m);return()=>window.clearTimeout(ne)}const p=fe;if(t===p.windowId&&y===p.paneId){const ne=window.setTimeout(()=>{Z.getState().clearPendingCreateWindow(e)},c-m);return()=>window.clearTimeout(ne)}E.current={windowId:p.windowId,paneId:p.paneId,at:Date.now()};const M=oe(p.windowId,p.paneId);le(p.windowId,p.paneId),A(e,p.windowId,p.paneId,M),r(`/devices/${e}/windows/${p.windowId}/panes/${Se(p.paneId)}`,{replace:!0}),Z.getState().clearPendingCreateWindow(e)},[e,x,ge,fe,t,y,le,oe,A,r]),d.useEffect(()=>{if(!X||!$||N)return;const c=u.current,m=c==null?void 0:c.getTerminal();if(!m)return;const p=Math.max(2,Math.floor($.width||0)),M=Math.max(2,Math.floor($.height||0));if(!p||!M)return;const ne=Date.now(),re={cols:p,rows:M},me=(c==null?void 0:c.getPendingLocalSize())??null;gr({now:ne,remoteSize:re,pendingLocalSize:me})&&(m.cols===p&&m.rows===M||m.resize(p,M))},[X,N,$]),d.useEffect(()=>{const c=window.requestAnimationFrame(()=>{var p;(p=u.current)==null||p.scrollToBottom()}),m=window.setTimeout(()=>{var p;(p=u.current)==null||p.scrollToBottom()},120);return()=>{window.cancelAnimationFrame(c),window.clearTimeout(m)}},[S]),d.useEffect(()=>{T!=null&&T.message&&_e.error(T.message)},[T==null?void 0:T.message]),d.useEffect(()=>(document.title=Qt(Me),()=>{document.title=J}),[J,Me]),d.useEffect(()=>{const c=()=>{var m;(m=u.current)==null||m.scrollToBottom()};return window.addEventListener("tmex:jump-to-latest",c),()=>{window.removeEventListener("tmex:jump-to-latest",c)}},[]),d.useEffect(()=>{const c=m=>{const{deviceId:p,windowId:M,paneId:ne}=m.detail;p===e&&(E.current={windowId:M,paneId:ne,at:Date.now()})};return window.addEventListener("tmex:user-initiated-selection",c),()=>{window.removeEventListener("tmex:user-initiated-selection",c)}},[e]),d.useEffect(()=>{b(te)},[te]);const Te=d.useCallback(c=>{if(!e||!y||!X)return;Z.getState().sendInput(e,y,c,!1)},[X,e,y]),Oe=d.useCallback(()=>{if(!X){_e.error(n("wsError.checkGateway"));return}if(!e||!y||!Y.trim())return;V(!0),window.setTimeout(()=>V(!1),150);const c=B?`${Y}\r`:Y;Z.getState().sendInput(e,y,c,!1),I(Y),U&&Q(U),b("")},[I,X,e,U,B,Y,Q,y,n]),ke=d.useCallback(()=>{if(!X){_e.error(n("wsError.checkGateway"));return}if(!e||!y||!Y.trim())return;V(!0),window.setTimeout(()=>V(!1),150);const c=Y.split(/\r?\n/),m=Z.getState();for(const p of c)p.trim()&&m.sendInput(e,y,`${p}\r`,!1);I(Y),U&&Q(U),b("")},[I,X,e,U,Y,Q,y,n]),Ie=d.useCallback(()=>{var c;(c=l.current)==null||c.focus({preventScroll:!0})},[]);if(!e)return h.jsx("div",{className:"flex h-full items-center justify-center p-4",children:h.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-3 text-sm text-muted-foreground",children:n("device.noDevices")})});const Ne=!x&&!T;return h.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background","data-testid":"device-page",children:[h.jsxs("div",{className:`flex-1 relative overflow-hidden min-h-0 min-w-0 ${k&&S==="editor"?"pb-1":""}`,children:[h.jsx("div",{className:"h-full px-3 py-1 min-h-0 min-w-0 w-full relative flex rounded-xl",style:{backgroundColor:ie.background},children:x&&y?h.jsx("div",{ref:i,className:"flex-1 h-full min-h-0 w-full","data-virtual-keyboard-avoid":!0,children:h.jsx(Vt,{ref:u,deviceId:e,paneId:y,theme:R,inputMode:S,deviceConnected:x,isSelectionInvalid:q,onResize:De,onSync:Ae},`${e}:${y}`)}):h.jsx("div",{className:"absolute inset-0 flex flex-col items-center justify-center p-8 text-center",children:h.jsx("div",{className:"max-w-sm space-y-4",children:x?t?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:h.jsx(We,{className:"h-6 w-6 text-muted-foreground animate-spin"})}),h.jsx("h3",{className:"text-lg font-medium",children:n("terminal.connecting")})]}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:h.jsx("span",{className:"text-2xl text-muted-foreground",children:"📋"})}),h.jsx("h3",{className:"text-lg font-medium",children:n("window.noWindowSelected")}),h.jsx("p",{className:"text-sm text-muted-foreground",children:n("window.selectWindowToStart")})]}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:h.jsx("span",{className:"text-2xl text-muted-foreground",children:"🔌"})}),h.jsx("h3",{className:"text-lg font-medium",children:n("device.disconnected")}),h.jsx("p",{className:"text-sm text-muted-foreground",children:n("device.connectToStart")})]})})})}),Ne&&h.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/85 backdrop-blur-sm","data-testid":"terminal-status-overlay",children:h.jsxs("div",{className:"flex flex-col items-center gap-2 rounded-lg border border-border bg-card/90 px-4 py-3 shadow-sm",children:[h.jsx("div",{className:"h-7 w-7 rounded-full border-2 border-primary border-t-transparent animate-spin"}),h.jsx("span",{className:"text-xs text-muted-foreground","data-testid":"terminal-status-text",children:n("terminal.connecting")})]})})]}),S==="direct"&&h.jsx("div",{className:"",children:h.jsx(Dt,{onSend:Te,disabled:!X,isMobile:k,inputMode:S})}),S==="editor"&&h.jsxs("div",{ref:o,"data-virtual-keyboard-avoid":!0,className:"editor-mode-input bg-card/85 backdrop-blur-sm",children:[k&&h.jsx(Dt,{onSend:Te,onFocusEditor:Ie,disabled:!X,isMobile:k,inputMode:S}),h.jsx("textarea",{ref:l,"data-testid":"editor-input",className:"min-h-[88px] max-h-[28vh] w-full resize-y rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground shadow-xs outline-none transition-colors focus:border-ring",value:Y,onChange:c=>{const m=c.target.value;if(b(m),!!U){if(m){j(U,m);return}Q(U)}},placeholder:n("terminal.inputPlaceholder"),onCompositionStart:()=>{C.current=!0},onCompositionEnd:()=>{C.current=!1}}),h.jsx("div",{className:"actions mt-2",children:h.jsxs("div",{className:"send-row flex flex-wrap items-center justify-end gap-2","data-testid":"editor-send-row",children:[h.jsxs("div",{className:"send-with-enter-toggle mr-auto flex items-center gap-2 text-xs text-muted-foreground","data-testid":"editor-send-with-enter-toggle",children:[h.jsx(an,{size:"sm",checked:B,onCheckedChange:c=>F(!!c)}),h.jsx("span",{children:n("terminal.editorSendWithEnter")})]}),h.jsxs(pe,{variant:"outline",size:"sm","data-testid":"editor-clear",onMouseDown:c=>c.preventDefault(),onClick:()=>{var c;b(""),U&&Q(U),k&&S==="editor"&&((c=l.current)==null||c.focus({preventScroll:!0}))},title:n("terminal.clear"),children:[h.jsx(cn,{className:"h-4 w-4"}),n("terminal.clear")]}),h.jsxs(pe,{variant:"secondary",size:"sm","data-testid":"editor-send-line-by-line",onMouseDown:c=>c.preventDefault(),onClick:()=>{var c;ke(),k&&S==="editor"&&((c=l.current)==null||c.focus({preventScroll:!0}))},disabled:!X||L,children:[L?h.jsx(We,{className:"h-4 w-4 animate-spin"}):h.jsx(ut,{className:"h-4 w-4"}),n("terminal.editorSendLineByLine")]}),h.jsxs(pe,{variant:"default",size:"sm","data-testid":"editor-send",onMouseDown:c=>c.preventDefault(),onClick:()=>{var c;Oe(),k&&S==="editor"&&((c=l.current)==null||c.focus({preventScroll:!0}))},disabled:!X||L,children:[L?h.jsx(We,{className:"h-4 w-4 animate-spin"}):h.jsx(ut,{className:"h-4 w-4"}),n("common.send")]})]})})]})]})}function Fr(){const{deviceId:n,windowId:e,paneId:t}=it(),s=t?ot(t):void 0,r=Z(g=>g.snapshots),i=At(g=>{var E;return((E=g.settings)==null?void 0:E.siteName)??"tmex"}),o=n?r[n]:void 0,l=d.useMemo(()=>{var g;if(!(!e||!((g=o==null?void 0:o.session)!=null&&g.windows)))return o.session.windows.find(E=>E.id===e)},[e,o]),u=d.useMemo(()=>{if(!(!s||!l))return l.panes.find(g=>g.id===s)},[s,l]),a=d.useMemo(()=>l&&u?Ot({paneIdx:u.index,windowIdx:l.index,paneTitle:u.title,windowName:l.name,windowCustomName:l.customName,deviceName:i}):n??"",[l,u,i,n]);return h.jsx(h.Fragment,{children:a})}function Gr(){const{t:n}=Ke(),{deviceId:e,paneId:t}=it(),s=t?ot(t):void 0,r=ae(T=>T.inputMode),i=ae(T=>T.setInputMode),o=Z(T=>{var x;return e?((x=T.deviceConnected)==null?void 0:x[e])??!1:!1}),[l,u]=d.useState(!1),a=!!(s&&o),g=()=>{i(r==="direct"?"editor":"direct")},E=()=>{window.dispatchEvent(new CustomEvent("tmex:jump-to-latest"))},A=()=>{u(!0)},H=()=>{window.location.reload()};return h.jsxs(h.Fragment,{children:[h.jsx(pe,{variant:"ghost",size:"icon-sm",onClick:A,"aria-label":n("nav.refreshPage"),title:n("nav.refreshPage"),children:h.jsx(Sn,{className:"h-4 w-4"})}),h.jsx(pe,{variant:"ghost",size:"icon-sm",onClick:g,disabled:!a,"data-testid":"terminal-input-mode-toggle","aria-label":n(r==="direct"?"nav.switchToEditor":"nav.switchToDirect"),title:n(r==="direct"?"nav.switchToEditor":"nav.switchToDirect"),children:r==="direct"?h.jsx(yn,{className:"h-4 w-4"}):h.jsx(bn,{className:"h-4 w-4"})}),h.jsx(pe,{variant:"ghost",size:"icon-sm",onClick:E,disabled:!a,"aria-label":n("nav.jumpToLatest"),title:n("nav.jumpToLatest"),children:h.jsx(un,{className:"h-4 w-4"})}),h.jsx(Zt,{open:l,onOpenChange:u,children:h.jsxs(en,{children:[h.jsxs(tn,{children:[h.jsx(nn,{children:n("nav.refreshPage")}),h.jsx(sn,{children:n("nav.refreshPageConfirm")})]}),h.jsxs(rn,{children:[h.jsx(on,{onClick:()=>u(!1),children:n("common.cancel")}),h.jsx(ln,{onClick:H,children:n("common.confirm")})]})]})})]})}export{Gr as PageActions,Fr as PageTitle,Lr as default};
36
- //# sourceMappingURL=DevicePage-DtUN4_7I.js.map