@dev-anywhere/relay 0.9.13 → 0.9.14

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
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/jmuxer.min-CRmhZDB4.js","assets/__vite-browser-external-D7Ct-6yo.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/jmuxer.min-ZEZpvKJO.js","assets/__vite-browser-external-D7Ct-6yo.js"])))=>i.map(i=>d[i]);
2
2
  var AW=Object.defineProperty;var NW=(e,t,n)=>t in e?AW(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var je=(e,t,n)=>NW(e,typeof t!="symbol"?t+"":t,n);function MW(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in e)){const s=Object.getOwnPropertyDescriptor(r,i);s&&Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();function rm(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function iDe(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var n=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}),n}var vx={exports:{}},bh={};/**
3
3
  * @license React
4
4
  * react-jsx-runtime.production.js
@@ -597,7 +597,7 @@ ${s}`,l=d5(`${a1(r.kind)}:${r.path}`,o,r.kind);n.push(l.kind==="diff"?{...l,co
597
597
 
598
598
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
599
599
 
600
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return b.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},pae="DialogDescriptionWarning",mae=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Q5(pae).contentName}}.`;return b.useEffect(()=>{var s;const i=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&i&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},ok=z5,gae=F5,ak=H5,lk=U5,ck=W5,J5=V5,e3=K5,Rb=X5;function vae(e){const t=b.useRef({value:e,previous:e});return b.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}function yae(e){const[t,n]=b.useState(void 0);return Qi(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let o,l;if("borderBoxSize"in s){const u=s.borderBoxSize,d=Array.isArray(u)?u[0]:u;o=d.inlineSize,l=d.blockSize}else o=e.offsetWidth,l=e.offsetHeight;n({width:o,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}const bae=["top","right","bottom","left"],ec=Math.min,$s=Math.max,zy=Math.round,gv=Math.floor,aa=e=>({x:e,y:e}),_ae={left:"right",right:"left",bottom:"top",top:"bottom"};function p1(e,t,n){return $s(e,ec(t,n))}function Va(e,t){return typeof e=="function"?e(t):e}function Ya(e){return e.split("-")[0]}function vf(e){return e.split("-")[1]}function uk(e){return e==="x"?"y":"x"}function dk(e){return e==="y"?"height":"width"}function ra(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function fk(e){return uk(ra(e))}function wae(e,t,n){n===void 0&&(n=!1);const r=vf(e),i=fk(e),s=dk(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(o=jy(o)),[o,jy(o)]}function xae(e){const t=jy(e);return[m1(e),t,m1(t)]}function m1(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Y2=["left","right"],K2=["right","left"],Sae=["top","bottom"],Eae=["bottom","top"];function Cae(e,t,n){switch(e){case"top":case"bottom":return n?t?K2:Y2:t?Y2:K2;case"left":case"right":return t?Sae:Eae;default:return[]}}function kae(e,t,n,r){const i=vf(e);let s=Cae(Ya(e),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),t&&(s=s.concat(s.map(m1)))),s}function jy(e){const t=Ya(e);return _ae[t]+e.slice(t.length)}function Tae(e){return{top:0,right:0,bottom:0,left:0,...e}}function t3(e){return typeof e!="number"?Tae(e):{top:e,right:e,bottom:e,left:e}}function Fy(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function G2(e,t,n){let{reference:r,floating:i}=e;const s=ra(t),o=fk(t),l=dk(o),u=Ya(t),d=s==="y",f=r.x+r.width/2-i.width/2,h=r.y+r.height/2-i.height/2,y=r[l]/2-i[l]/2;let g;switch(u){case"top":g={x:f,y:r.y-i.height};break;case"bottom":g={x:f,y:r.y+r.height};break;case"right":g={x:r.x+r.width,y:h};break;case"left":g={x:r.x-i.width,y:h};break;default:g={x:r.x,y:r.y}}switch(vf(t)){case"start":g[o]-=y*(n&&d?-1:1);break;case"end":g[o]+=y*(n&&d?-1:1);break}return g}async function Rae(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:s,rects:o,elements:l,strategy:u}=e,{boundary:d="clippingAncestors",rootBoundary:f="viewport",elementContext:h="floating",altBoundary:y=!1,padding:g=0}=Va(t,e),_=t3(g),S=l[y?h==="floating"?"reference":"floating":h],x=Fy(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(S)))==null||n?S:S.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:d,rootBoundary:f,strategy:u})),k=h==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,R=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),A=await(s.isElement==null?void 0:s.isElement(R))?await(s.getScale==null?void 0:s.getScale(R))||{x:1,y:1}:{x:1,y:1},M=Fy(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:k,offsetParent:R,strategy:u}):k);return{top:(x.top-M.top+_.top)/A.y,bottom:(M.bottom-x.bottom+_.bottom)/A.y,left:(x.left-M.left+_.left)/A.x,right:(M.right-x.right+_.right)/A.x}}const Aae=50,Nae=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,l=o.detectOverflow?o:{...o,detectOverflow:Rae},u=await(o.isRTL==null?void 0:o.isRTL(t));let d=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:f,y:h}=G2(d,r,u),y=r,g=0;const _={};for(let w=0;w<s.length;w++){const S=s[w];if(!S)continue;const{name:x,fn:k}=S,{x:R,y:A,data:M,reset:T}=await k({x:f,y:h,initialPlacement:r,placement:y,strategy:i,middlewareData:_,rects:d,platform:l,elements:{reference:e,floating:t}});f=R??f,h=A??h,_[x]={..._[x],...M},T&&g<Aae&&(g++,typeof T=="object"&&(T.placement&&(y=T.placement),T.rects&&(d=T.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):T.rects),{x:f,y:h}=G2(d,y,u)),w=-1)}return{x:f,y:h,placement:y,strategy:i,middlewareData:_}},Mae=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:s,platform:o,elements:l,middlewareData:u}=t,{element:d,padding:f=0}=Va(e,t)||{};if(d==null)return{};const h=t3(f),y={x:n,y:r},g=fk(i),_=dk(g),w=await o.getDimensions(d),S=g==="y",x=S?"top":"left",k=S?"bottom":"right",R=S?"clientHeight":"clientWidth",A=s.reference[_]+s.reference[g]-y[g]-s.floating[_],M=y[g]-s.reference[g],T=await(o.getOffsetParent==null?void 0:o.getOffsetParent(d));let P=T?T[R]:0;(!P||!await(o.isElement==null?void 0:o.isElement(T)))&&(P=l.floating[R]||s.floating[_]);const z=A/2-M/2,Y=P/2-w[_]/2-1,U=ec(h[x],Y),G=ec(h[k],Y),I=U,N=P-w[_]-G,L=P/2-w[_]/2+z,B=p1(I,L,N),O=!u.arrow&&vf(i)!=null&&L!==B&&s.reference[_]/2-(L<I?U:G)-w[_]/2<0,D=O?L<I?L-I:L-N:0;return{[g]:y[g]+D,data:{[g]:B,centerOffset:L-B-D,...O&&{alignmentOffset:D}},reset:O}}}),Pae=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:s,rects:o,initialPlacement:l,platform:u,elements:d}=t,{mainAxis:f=!0,crossAxis:h=!0,fallbackPlacements:y,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:_="none",flipAlignment:w=!0,...S}=Va(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=Ya(i),k=ra(l),R=Ya(l)===l,A=await(u.isRTL==null?void 0:u.isRTL(d.floating)),M=y||(R||!w?[jy(l)]:xae(l)),T=_!=="none";!y&&T&&M.push(...kae(l,w,_,A));const P=[l,...M],z=await u.detectOverflow(t,S),Y=[];let U=((r=s.flip)==null?void 0:r.overflows)||[];if(f&&Y.push(z[x]),h){const L=wae(i,o,A);Y.push(z[L[0]],z[L[1]])}if(U=[...U,{placement:i,overflows:Y}],!Y.every(L=>L<=0)){var G,I;const L=(((G=s.flip)==null?void 0:G.index)||0)+1,B=P[L];if(B&&(!(h==="alignment"?k!==ra(B):!1)||U.every(F=>ra(F.placement)===k?F.overflows[0]>0:!0)))return{data:{index:L,overflows:U},reset:{placement:B}};let O=(I=U.filter(D=>D.overflows[0]<=0).sort((D,F)=>D.overflows[1]-F.overflows[1])[0])==null?void 0:I.placement;if(!O)switch(g){case"bestFit":{var N;const D=(N=U.filter(F=>{if(T){const V=ra(F.placement);return V===k||V==="y"}return!0}).map(F=>[F.placement,F.overflows.filter(V=>V>0).reduce((V,j)=>V+j,0)]).sort((F,V)=>F[1]-V[1])[0])==null?void 0:N[0];D&&(O=D);break}case"initialPlacement":O=l;break}if(i!==O)return{reset:{placement:O}}}return{}}}};function X2(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Z2(e){return bae.some(t=>e[t]>=0)}const Iae=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...s}=Va(e,t);switch(i){case"referenceHidden":{const o=await r.detectOverflow(t,{...s,elementContext:"reference"}),l=X2(o,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:Z2(l)}}}case"escaped":{const o=await r.detectOverflow(t,{...s,altBoundary:!0}),l=X2(o,n.floating);return{data:{escapedOffsets:l,escaped:Z2(l)}}}default:return{}}}}},n3=new Set(["left","top"]);async function Oae(e,t){const{placement:n,platform:r,elements:i}=e,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Ya(n),l=vf(n),u=ra(n)==="y",d=n3.has(o)?-1:1,f=s&&u?-1:1,h=Va(t,e);let{mainAxis:y,crossAxis:g,alignmentAxis:_}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return l&&typeof _=="number"&&(g=l==="end"?_*-1:_),u?{x:g*f,y:y*d}:{x:y*d,y:g*f}}const Lae=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:s,placement:o,middlewareData:l}=t,u=await Oae(t,e);return o===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:i+u.x,y:s+u.y,data:{...u,placement:o}}}}},Dae=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:s}=t,{mainAxis:o=!0,crossAxis:l=!1,limiter:u={fn:x=>{let{x:k,y:R}=x;return{x:k,y:R}}},...d}=Va(e,t),f={x:n,y:r},h=await s.detectOverflow(t,d),y=ra(Ya(i)),g=uk(y);let _=f[g],w=f[y];if(o){const x=g==="y"?"top":"left",k=g==="y"?"bottom":"right",R=_+h[x],A=_-h[k];_=p1(R,_,A)}if(l){const x=y==="y"?"top":"left",k=y==="y"?"bottom":"right",R=w+h[x],A=w-h[k];w=p1(R,w,A)}const S=u.fn({...t,[g]:_,[y]:w});return{...S,data:{x:S.x-n,y:S.y-r,enabled:{[g]:o,[y]:l}}}}}},Bae=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:s,middlewareData:o}=t,{offset:l=0,mainAxis:u=!0,crossAxis:d=!0}=Va(e,t),f={x:n,y:r},h=ra(i),y=uk(h);let g=f[y],_=f[h];const w=Va(l,t),S=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(u){const R=y==="y"?"height":"width",A=s.reference[y]-s.floating[R]+S.mainAxis,M=s.reference[y]+s.reference[R]-S.mainAxis;g<A?g=A:g>M&&(g=M)}if(d){var x,k;const R=y==="y"?"width":"height",A=n3.has(Ya(i)),M=s.reference[h]-s.floating[R]+(A&&((x=o.offset)==null?void 0:x[h])||0)+(A?0:S.crossAxis),T=s.reference[h]+s.reference[R]+(A?0:((k=o.offset)==null?void 0:k[h])||0)-(A?S.crossAxis:0);_<M?_=M:_>T&&(_=T)}return{[y]:g,[h]:_}}}},zae=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:i,rects:s,platform:o,elements:l}=t,{apply:u=()=>{},...d}=Va(e,t),f=await o.detectOverflow(t,d),h=Ya(i),y=vf(i),g=ra(i)==="y",{width:_,height:w}=s.floating;let S,x;h==="top"||h==="bottom"?(S=h,x=y===(await(o.isRTL==null?void 0:o.isRTL(l.floating))?"start":"end")?"left":"right"):(x=h,S=y==="end"?"top":"bottom");const k=w-f.top-f.bottom,R=_-f.left-f.right,A=ec(w-f[S],k),M=ec(_-f[x],R),T=!t.middlewareData.shift;let P=A,z=M;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(z=R),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(P=k),T&&!y){const U=$s(f.left,0),G=$s(f.right,0),I=$s(f.top,0),N=$s(f.bottom,0);g?z=_-2*(U!==0||G!==0?U+G:$s(f.left,f.right)):P=w-2*(I!==0||N!==0?I+N:$s(f.top,f.bottom))}await u({...t,availableWidth:z,availableHeight:P});const Y=await o.getDimensions(l.floating);return _!==Y.width||w!==Y.height?{reset:{rects:!0}}:{}}}};function Ab(){return typeof window<"u"}function yf(e){return r3(e)?(e.nodeName||"").toLowerCase():"#document"}function Us(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function pa(e){var t;return(t=(r3(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function r3(e){return Ab()?e instanceof Node||e instanceof Us(e).Node:!1}function Oo(e){return Ab()?e instanceof Element||e instanceof Us(e).Element:!1}function Za(e){return Ab()?e instanceof HTMLElement||e instanceof Us(e).HTMLElement:!1}function Q2(e){return!Ab()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Us(e).ShadowRoot}function vm(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=Lo(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function jae(e){return/^(table|td|th)$/.test(yf(e))}function Nb(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Fae=/transform|translate|scale|rotate|perspective|filter/,$ae=/paint|layout|strict|content/,zc=e=>!!e&&e!=="none";let h0;function hk(e){const t=Oo(e)?Lo(e):e;return zc(t.transform)||zc(t.translate)||zc(t.scale)||zc(t.rotate)||zc(t.perspective)||!pk()&&(zc(t.backdropFilter)||zc(t.filter))||Fae.test(t.willChange||"")||$ae.test(t.contain||"")}function Hae(e){let t=tc(e);for(;Za(t)&&!rf(t);){if(hk(t))return t;if(Nb(t))return null;t=tc(t)}return null}function pk(){return h0==null&&(h0=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),h0}function rf(e){return/^(html|body|#document)$/.test(yf(e))}function Lo(e){return Us(e).getComputedStyle(e)}function Mb(e){return Oo(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function tc(e){if(yf(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Q2(e)&&e.host||pa(e);return Q2(t)?t.host:t}function i3(e){const t=tc(e);return rf(t)?e.ownerDocument?e.ownerDocument.body:e.body:Za(t)&&vm(t)?t:i3(t)}function $p(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=i3(e),s=i===((r=e.ownerDocument)==null?void 0:r.body),o=Us(i);if(s){const l=g1(o);return t.concat(o,o.visualViewport||[],vm(i)?i:[],l&&n?$p(l):[])}else return t.concat(i,$p(i,[],n))}function g1(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function s3(e){const t=Lo(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Za(e),s=i?e.offsetWidth:n,o=i?e.offsetHeight:r,l=zy(n)!==s||zy(r)!==o;return l&&(n=s,r=o),{width:n,height:r,$:l}}function mk(e){return Oo(e)?e:e.contextElement}function qd(e){const t=mk(e);if(!Za(t))return aa(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:s}=s3(t);let o=(s?zy(n.width):n.width)/r,l=(s?zy(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const Uae=aa(0);function o3(e){const t=Us(e);return!pk()||!t.visualViewport?Uae:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Wae(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Us(e)?!1:t}function cu(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),s=mk(e);let o=aa(1);t&&(r?Oo(r)&&(o=qd(r)):o=qd(e));const l=Wae(s,n,r)?o3(s):aa(0);let u=(i.left+l.x)/o.x,d=(i.top+l.y)/o.y,f=i.width/o.x,h=i.height/o.y;if(s){const y=Us(s),g=r&&Oo(r)?Us(r):r;let _=y,w=g1(_);for(;w&&r&&g!==_;){const S=qd(w),x=w.getBoundingClientRect(),k=Lo(w),R=x.left+(w.clientLeft+parseFloat(k.paddingLeft))*S.x,A=x.top+(w.clientTop+parseFloat(k.paddingTop))*S.y;u*=S.x,d*=S.y,f*=S.x,h*=S.y,u+=R,d+=A,_=Us(w),w=g1(_)}}return Fy({width:f,height:h,x:u,y:d})}function Pb(e,t){const n=Mb(e).scrollLeft;return t?t.left+n:cu(pa(e)).left+n}function a3(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Pb(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function qae(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const s=i==="fixed",o=pa(r),l=t?Nb(t.floating):!1;if(r===o||l&&s)return n;let u={scrollLeft:0,scrollTop:0},d=aa(1);const f=aa(0),h=Za(r);if((h||!h&&!s)&&((yf(r)!=="body"||vm(o))&&(u=Mb(r)),h)){const g=cu(r);d=qd(r),f.x=g.x+r.clientLeft,f.y=g.y+r.clientTop}const y=o&&!h&&!s?a3(o,u):aa(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-u.scrollLeft*d.x+f.x+y.x,y:n.y*d.y-u.scrollTop*d.y+f.y+y.y}}function Vae(e){return Array.from(e.getClientRects())}function Yae(e){const t=pa(e),n=Mb(e),r=e.ownerDocument.body,i=$s(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=$s(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+Pb(e);const l=-n.scrollTop;return Lo(r).direction==="rtl"&&(o+=$s(t.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:l}}const J2=25;function Kae(e,t){const n=Us(e),r=pa(e),i=n.visualViewport;let s=r.clientWidth,o=r.clientHeight,l=0,u=0;if(i){s=i.width,o=i.height;const f=pk();(!f||f&&t==="fixed")&&(l=i.offsetLeft,u=i.offsetTop)}const d=Pb(r);if(d<=0){const f=r.ownerDocument,h=f.body,y=getComputedStyle(h),g=f.compatMode==="CSS1Compat"&&parseFloat(y.marginLeft)+parseFloat(y.marginRight)||0,_=Math.abs(r.clientWidth-h.clientWidth-g);_<=J2&&(s-=_)}else d<=J2&&(s+=d);return{width:s,height:o,x:l,y:u}}function Gae(e,t){const n=cu(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=Za(e)?qd(e):aa(1),o=e.clientWidth*s.x,l=e.clientHeight*s.y,u=i*s.x,d=r*s.y;return{width:o,height:l,x:u,y:d}}function eI(e,t,n){let r;if(t==="viewport")r=Kae(e,n);else if(t==="document")r=Yae(pa(e));else if(Oo(t))r=Gae(t,n);else{const i=o3(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Fy(r)}function l3(e,t){const n=tc(e);return n===t||!Oo(n)||rf(n)?!1:Lo(n).position==="fixed"||l3(n,t)}function Xae(e,t){const n=t.get(e);if(n)return n;let r=$p(e,[],!1).filter(l=>Oo(l)&&yf(l)!=="body"),i=null;const s=Lo(e).position==="fixed";let o=s?tc(e):e;for(;Oo(o)&&!rf(o);){const l=Lo(o),u=hk(o);!u&&l.position==="fixed"&&(i=null),(s?!u&&!i:!u&&l.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||vm(o)&&!u&&l3(e,o))?r=r.filter(f=>f!==o):i=l,o=tc(o)}return t.set(e,r),r}function Zae(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[...n==="clippingAncestors"?Nb(t)?[]:Xae(t,this._c):[].concat(n),r],l=eI(t,o[0],i);let u=l.top,d=l.right,f=l.bottom,h=l.left;for(let y=1;y<o.length;y++){const g=eI(t,o[y],i);u=$s(g.top,u),d=ec(g.right,d),f=ec(g.bottom,f),h=$s(g.left,h)}return{width:d-h,height:f-u,x:h,y:u}}function Qae(e){const{width:t,height:n}=s3(e);return{width:t,height:n}}function Jae(e,t,n){const r=Za(t),i=pa(t),s=n==="fixed",o=cu(e,!0,s,t);let l={scrollLeft:0,scrollTop:0};const u=aa(0);function d(){u.x=Pb(i)}if(r||!r&&!s)if((yf(t)!=="body"||vm(i))&&(l=Mb(t)),r){const g=cu(t,!0,s,t);u.x=g.x+t.clientLeft,u.y=g.y+t.clientTop}else i&&d();s&&!r&&i&&d();const f=i&&!r&&!s?a3(i,l):aa(0),h=o.left+l.scrollLeft-u.x-f.x,y=o.top+l.scrollTop-u.y-f.y;return{x:h,y,width:o.width,height:o.height}}function p0(e){return Lo(e).position==="static"}function tI(e,t){if(!Za(e)||Lo(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return pa(e)===n&&(n=n.ownerDocument.body),n}function c3(e,t){const n=Us(e);if(Nb(e))return n;if(!Za(e)){let i=tc(e);for(;i&&!rf(i);){if(Oo(i)&&!p0(i))return i;i=tc(i)}return n}let r=tI(e,t);for(;r&&jae(r)&&p0(r);)r=tI(r,t);return r&&rf(r)&&p0(r)&&!hk(r)?n:r||Hae(e)||n}const ele=async function(e){const t=this.getOffsetParent||c3,n=this.getDimensions,r=await n(e.floating);return{reference:Jae(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function tle(e){return Lo(e).direction==="rtl"}const nle={convertOffsetParentRelativeRectToViewportRelativeRect:qae,getDocumentElement:pa,getClippingRect:Zae,getOffsetParent:c3,getElementRects:ele,getClientRects:Vae,getDimensions:Qae,getScale:qd,isElement:Oo,isRTL:tle};function u3(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function rle(e,t){let n=null,r;const i=pa(e);function s(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function o(l,u){l===void 0&&(l=!1),u===void 0&&(u=1),s();const d=e.getBoundingClientRect(),{left:f,top:h,width:y,height:g}=d;if(l||t(),!y||!g)return;const _=gv(h),w=gv(i.clientWidth-(f+y)),S=gv(i.clientHeight-(h+g)),x=gv(f),R={rootMargin:-_+"px "+-w+"px "+-S+"px "+-x+"px",threshold:$s(0,ec(1,u))||1};let A=!0;function M(T){const P=T[0].intersectionRatio;if(P!==u){if(!A)return o();P?o(!1,P):r=setTimeout(()=>{o(!1,1e-7)},1e3)}P===1&&!u3(d,e.getBoundingClientRect())&&o(),A=!1}try{n=new IntersectionObserver(M,{...R,root:i.ownerDocument})}catch{n=new IntersectionObserver(M,R)}n.observe(e)}return o(!0),s}function ile(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,d=mk(e),f=i||s?[...d?$p(d):[],...t?$p(t):[]]:[];f.forEach(x=>{i&&x.addEventListener("scroll",n,{passive:!0}),s&&x.addEventListener("resize",n)});const h=d&&l?rle(d,n):null;let y=-1,g=null;o&&(g=new ResizeObserver(x=>{let[k]=x;k&&k.target===d&&g&&t&&(g.unobserve(t),cancelAnimationFrame(y),y=requestAnimationFrame(()=>{var R;(R=g)==null||R.observe(t)})),n()}),d&&!u&&g.observe(d),t&&g.observe(t));let _,w=u?cu(e):null;u&&S();function S(){const x=cu(e);w&&!u3(w,x)&&n(),w=x,_=requestAnimationFrame(S)}return n(),()=>{var x;f.forEach(k=>{i&&k.removeEventListener("scroll",n),s&&k.removeEventListener("resize",n)}),h==null||h(),(x=g)==null||x.disconnect(),g=null,u&&cancelAnimationFrame(_)}}const sle=Lae,ole=Dae,ale=Pae,lle=zae,cle=Iae,nI=Mae,ule=Bae,dle=(e,t,n)=>{const r=new Map,i={platform:nle,...n},s={...i.platform,_c:r};return Nae(e,t,{...i,platform:s})};var fle=typeof document<"u",hle=function(){},oy=fle?b.useLayoutEffect:hle;function $y(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!$y(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&e.$$typeof)&&!$y(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function d3(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function rI(e,t){const n=d3(e);return Math.round(t*n)/n}function m0(e){const t=b.useRef(e);return oy(()=>{t.current=e}),t}function ple(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:o}={},transform:l=!0,whileElementsMounted:u,open:d}=e,[f,h]=b.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[y,g]=b.useState(r);$y(y,r)||g(r);const[_,w]=b.useState(null),[S,x]=b.useState(null),k=b.useCallback(F=>{F!==T.current&&(T.current=F,w(F))},[]),R=b.useCallback(F=>{F!==P.current&&(P.current=F,x(F))},[]),A=s||_,M=o||S,T=b.useRef(null),P=b.useRef(null),z=b.useRef(f),Y=u!=null,U=m0(u),G=m0(i),I=m0(d),N=b.useCallback(()=>{if(!T.current||!P.current)return;const F={placement:t,strategy:n,middleware:y};G.current&&(F.platform=G.current),dle(T.current,P.current,F).then(V=>{const j={...V,isPositioned:I.current!==!1};L.current&&!$y(z.current,j)&&(z.current=j,xu.flushSync(()=>{h(j)}))})},[y,t,n,G,I]);oy(()=>{d===!1&&z.current.isPositioned&&(z.current.isPositioned=!1,h(F=>({...F,isPositioned:!1})))},[d]);const L=b.useRef(!1);oy(()=>(L.current=!0,()=>{L.current=!1}),[]),oy(()=>{if(A&&(T.current=A),M&&(P.current=M),A&&M){if(U.current)return U.current(A,M,N);N()}},[A,M,N,U,Y]);const B=b.useMemo(()=>({reference:T,floating:P,setReference:k,setFloating:R}),[k,R]),O=b.useMemo(()=>({reference:A,floating:M}),[A,M]),D=b.useMemo(()=>{const F={position:n,left:0,top:0};if(!O.floating)return F;const V=rI(O.floating,f.x),j=rI(O.floating,f.y);return l?{...F,transform:"translate("+V+"px, "+j+"px)",...d3(O.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:V,top:j}},[n,l,O.floating,f.x,f.y]);return b.useMemo(()=>({...f,update:N,refs:B,elements:O,floatingStyles:D}),[f,N,B,O,D])}const mle=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?nI({element:r.current,padding:i}).fn(n):{}:r?nI({element:r,padding:i}).fn(n):{}}}},gle=(e,t)=>{const n=sle(e);return{name:n.name,fn:n.fn,options:[e,t]}},vle=(e,t)=>{const n=ole(e);return{name:n.name,fn:n.fn,options:[e,t]}},yle=(e,t)=>({fn:ule(e).fn,options:[e,t]}),ble=(e,t)=>{const n=ale(e);return{name:n.name,fn:n.fn,options:[e,t]}},_le=(e,t)=>{const n=lle(e);return{name:n.name,fn:n.fn,options:[e,t]}},wle=(e,t)=>{const n=cle(e);return{name:n.name,fn:n.fn,options:[e,t]}},xle=(e,t)=>{const n=mle(e);return{name:n.name,fn:n.fn,options:[e,t]}};var Sle="Arrow",f3=b.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...s}=e;return m.jsx(yn.svg,{...s,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:m.jsx("polygon",{points:"0,0 30,0 15,10"})})});f3.displayName=Sle;var Ele=f3,gk="Popper",[h3,cc]=Xa(gk),[Cle,p3]=h3(gk),m3=e=>{const{__scopePopper:t,children:n}=e,[r,i]=b.useState(null);return m.jsx(Cle,{scope:t,anchor:r,onAnchorChange:i,children:n})};m3.displayName=gk;var g3="PopperAnchor",v3=b.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...i}=e,s=p3(g3,n),o=b.useRef(null),l=or(t,o),u=b.useRef(null);return b.useEffect(()=>{const d=u.current;u.current=(r==null?void 0:r.current)||o.current,d!==u.current&&s.onAnchorChange(u.current)}),r?null:m.jsx(yn.div,{...i,ref:l})});v3.displayName=g3;var vk="PopperContent",[kle,Tle]=h3(vk),y3=b.forwardRef((e,t)=>{var Q,ce,re,le,we,Ce;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:s="center",alignOffset:o=0,arrowPadding:l=0,avoidCollisions:u=!0,collisionBoundary:d=[],collisionPadding:f=0,sticky:h="partial",hideWhenDetached:y=!1,updatePositionStrategy:g="optimized",onPlaced:_,...w}=e,S=p3(vk,n),[x,k]=b.useState(null),R=or(t,ye=>k(ye)),[A,M]=b.useState(null),T=yae(A),P=(T==null?void 0:T.width)??0,z=(T==null?void 0:T.height)??0,Y=r+(s!=="center"?"-"+s:""),U=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},G=Array.isArray(d)?d:[d],I=G.length>0,N={padding:U,boundary:G.filter(Ale),altBoundary:I},{refs:L,floatingStyles:B,placement:O,isPositioned:D,middlewareData:F}=ple({strategy:"fixed",placement:Y,whileElementsMounted:(...ye)=>ile(...ye,{animationFrame:g==="always"}),elements:{reference:S.anchor},middleware:[gle({mainAxis:i+z,alignmentAxis:o}),u&&vle({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?yle():void 0,...N}),u&&ble({...N}),_le({...N,apply:({elements:ye,rects:Re,availableWidth:Rt,availableHeight:Ke})=>{const{width:et,height:$e}=Re.reference,Fe=ye.floating.style;Fe.setProperty("--radix-popper-available-width",`${Rt}px`),Fe.setProperty("--radix-popper-available-height",`${Ke}px`),Fe.setProperty("--radix-popper-anchor-width",`${et}px`),Fe.setProperty("--radix-popper-anchor-height",`${$e}px`)}}),A&&xle({element:A,padding:l}),Nle({arrowWidth:P,arrowHeight:z}),y&&wle({strategy:"referenceHidden",...N})]}),[V,j]=w3(O),q=Io(_);Qi(()=>{D&&(q==null||q())},[D,q]);const K=(Q=F.arrow)==null?void 0:Q.x,$=(ce=F.arrow)==null?void 0:ce.y,te=((re=F.arrow)==null?void 0:re.centerOffset)!==0,[J,ne]=b.useState();return Qi(()=>{x&&ne(window.getComputedStyle(x).zIndex)},[x]),m.jsx("div",{ref:L.setFloating,"data-radix-popper-content-wrapper":"",style:{...B,transform:D?B.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:J,"--radix-popper-transform-origin":[(le=F.transformOrigin)==null?void 0:le.x,(we=F.transformOrigin)==null?void 0:we.y].join(" "),...((Ce=F.hide)==null?void 0:Ce.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:m.jsx(kle,{scope:n,placedSide:V,onArrowChange:M,arrowX:K,arrowY:$,shouldHideArrow:te,children:m.jsx(yn.div,{"data-side":V,"data-align":j,...w,ref:R,style:{...w.style,animation:D?void 0:"none"}})})})});y3.displayName=vk;var b3="PopperArrow",Rle={top:"bottom",right:"left",bottom:"top",left:"right"},_3=b.forwardRef(function(t,n){const{__scopePopper:r,...i}=t,s=Tle(b3,r),o=Rle[s.placedSide];return m.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:m.jsx(Ele,{...i,ref:n,style:{...i.style,display:"block"}})})});_3.displayName=b3;function Ale(e){return e!==null}var Nle=e=>({name:"transformOrigin",options:e,fn(t){var S,x,k;const{placement:n,rects:r,middlewareData:i}=t,o=((S=i.arrow)==null?void 0:S.centerOffset)!==0,l=o?0:e.arrowWidth,u=o?0:e.arrowHeight,[d,f]=w3(n),h={start:"0%",center:"50%",end:"100%"}[f],y=(((x=i.arrow)==null?void 0:x.x)??0)+l/2,g=(((k=i.arrow)==null?void 0:k.y)??0)+u/2;let _="",w="";return d==="bottom"?(_=o?h:`${y}px`,w=`${-u}px`):d==="top"?(_=o?h:`${y}px`,w=`${r.floating.height+u}px`):d==="right"?(_=`${-u}px`,w=o?h:`${g}px`):d==="left"&&(_=`${r.floating.width+u}px`,w=o?h:`${g}px`),{data:{x:_,y:w}}}});function w3(e){const[t,n="center"]=e.split("-");return[t,n]}var ym=m3,bm=v3,Ib=y3,Ob=_3,g0="rovingFocusGroup.onEntryFocus",Mle={bubbles:!1,cancelable:!0},_m="RovingFocusGroup",[v1,x3,Ple]=tk(_m),[Ile,S3]=Xa(_m,[Ple]),[Ole,Lle]=Ile(_m),E3=b.forwardRef((e,t)=>m.jsx(v1.Provider,{scope:e.__scopeRovingFocusGroup,children:m.jsx(v1.Slot,{scope:e.__scopeRovingFocusGroup,children:m.jsx(Dle,{...e,ref:t})})}));E3.displayName=_m;var Dle=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:s,currentTabStopId:o,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:u,onEntryFocus:d,preventScrollOnEntryFocus:f=!1,...h}=e,y=b.useRef(null),g=or(t,y),_=nk(s),[w,S]=Jl({prop:o,defaultProp:l??null,onChange:u,caller:_m}),[x,k]=b.useState(!1),R=Io(d),A=x3(n),M=b.useRef(!1),[T,P]=b.useState(0);return b.useEffect(()=>{const z=y.current;if(z)return z.addEventListener(g0,R),()=>z.removeEventListener(g0,R)},[R]),m.jsx(Ole,{scope:n,orientation:r,dir:_,loop:i,currentTabStopId:w,onItemFocus:b.useCallback(z=>S(z),[S]),onItemShiftTab:b.useCallback(()=>k(!0),[]),onFocusableItemAdd:b.useCallback(()=>P(z=>z+1),[]),onFocusableItemRemove:b.useCallback(()=>P(z=>z-1),[]),children:m.jsx(yn.div,{tabIndex:x||T===0?-1:0,"data-orientation":r,...h,ref:g,style:{outline:"none",...e.style},onMouseDown:Wt(e.onMouseDown,()=>{M.current=!0}),onFocus:Wt(e.onFocus,z=>{const Y=!M.current;if(z.target===z.currentTarget&&Y&&!x){const U=new CustomEvent(g0,Mle);if(z.currentTarget.dispatchEvent(U),!U.defaultPrevented){const G=A().filter(O=>O.focusable),I=G.find(O=>O.active),N=G.find(O=>O.id===w),B=[I,N,...G].filter(Boolean).map(O=>O.ref.current);T3(B,f)}}M.current=!1}),onBlur:Wt(e.onBlur,()=>k(!1))})})}),C3="RovingFocusGroupItem",k3=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:s,children:o,...l}=e,u=vi(),d=s||u,f=Lle(C3,n),h=f.currentTabStopId===d,y=x3(n),{onFocusableItemAdd:g,onFocusableItemRemove:_,currentTabStopId:w}=f;return b.useEffect(()=>{if(r)return g(),()=>_()},[r,g,_]),m.jsx(v1.ItemSlot,{scope:n,id:d,focusable:r,active:i,children:m.jsx(yn.span,{tabIndex:h?0:-1,"data-orientation":f.orientation,...l,ref:t,onMouseDown:Wt(e.onMouseDown,S=>{r?f.onItemFocus(d):S.preventDefault()}),onFocus:Wt(e.onFocus,()=>f.onItemFocus(d)),onKeyDown:Wt(e.onKeyDown,S=>{if(S.key==="Tab"&&S.shiftKey){f.onItemShiftTab();return}if(S.target!==S.currentTarget)return;const x=jle(S,f.orientation,f.dir);if(x!==void 0){if(S.metaKey||S.ctrlKey||S.altKey||S.shiftKey)return;S.preventDefault();let R=y().filter(A=>A.focusable).map(A=>A.ref.current);if(x==="last")R.reverse();else if(x==="prev"||x==="next"){x==="prev"&&R.reverse();const A=R.indexOf(S.currentTarget);R=f.loop?Fle(R,A+1):R.slice(A+1)}setTimeout(()=>T3(R))}}),children:typeof o=="function"?o({isCurrentTabStop:h,hasTabStop:w!=null}):o})})});k3.displayName=C3;var Ble={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function zle(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function jle(e,t,n){const r=zle(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Ble[r]}function T3(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Fle(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var $le=E3,Hle=k3,y1=["Enter"," "],Ule=["ArrowDown","PageUp","Home"],R3=["ArrowUp","PageDown","End"],Wle=[...Ule,...R3],qle={ltr:[...y1,"ArrowRight"],rtl:[...y1,"ArrowLeft"]},Vle={ltr:["ArrowLeft"],rtl:["ArrowRight"]},wm="Menu",[Hp,Yle,Kle]=tk(wm),[Su,A3]=Xa(wm,[Kle,cc,S3]),xm=cc(),N3=S3(),[M3,uc]=Su(wm),[Gle,Sm]=Su(wm),P3=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,l=xm(t),[u,d]=b.useState(null),f=b.useRef(!1),h=Io(s),y=nk(i);return b.useEffect(()=>{const g=()=>{f.current=!0,document.addEventListener("pointerdown",_,{capture:!0,once:!0}),document.addEventListener("pointermove",_,{capture:!0,once:!0})},_=()=>f.current=!1;return document.addEventListener("keydown",g,{capture:!0}),()=>{document.removeEventListener("keydown",g,{capture:!0}),document.removeEventListener("pointerdown",_,{capture:!0}),document.removeEventListener("pointermove",_,{capture:!0})}},[]),m.jsx(ym,{...l,children:m.jsx(M3,{scope:t,open:n,onOpenChange:h,content:u,onContentChange:d,children:m.jsx(Gle,{scope:t,onClose:b.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:f,dir:y,modal:o,children:r})})})};P3.displayName=wm;var Xle="MenuAnchor",yk=b.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=xm(n);return m.jsx(bm,{...i,...r,ref:t})});yk.displayName=Xle;var bk="MenuPortal",[Zle,I3]=Su(bk,{forceMount:void 0}),O3=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=uc(bk,t);return m.jsx(Zle,{scope:t,forceMount:n,children:m.jsx(wo,{present:n||s.open,children:m.jsx(gf,{asChild:!0,container:i,children:r})})})};O3.displayName=bk;var mo="MenuContent",[Qle,_k]=Su(mo),L3=b.forwardRef((e,t)=>{const n=I3(mo,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=uc(mo,e.__scopeMenu),o=Sm(mo,e.__scopeMenu);return m.jsx(Hp.Provider,{scope:e.__scopeMenu,children:m.jsx(wo,{present:r||s.open,children:m.jsx(Hp.Slot,{scope:e.__scopeMenu,children:o.modal?m.jsx(Jle,{...i,ref:t}):m.jsx(ece,{...i,ref:t})})})})}),Jle=b.forwardRef((e,t)=>{const n=uc(mo,e.__scopeMenu),r=b.useRef(null),i=or(t,r);return b.useEffect(()=>{const s=r.current;if(s)return kb(s)},[]),m.jsx(wk,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Wt(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),ece=b.forwardRef((e,t)=>{const n=uc(mo,e.__scopeMenu);return m.jsx(wk,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),tce=Ql("MenuContent.ScrollLock"),wk=b.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEntryFocus:u,onEscapeKeyDown:d,onPointerDownOutside:f,onFocusOutside:h,onInteractOutside:y,onDismiss:g,disableOutsideScroll:_,...w}=e,S=uc(mo,n),x=Sm(mo,n),k=xm(n),R=N3(n),A=Yle(n),[M,T]=b.useState(null),P=b.useRef(null),z=or(t,P,S.onContentChange),Y=b.useRef(0),U=b.useRef(""),G=b.useRef(0),I=b.useRef(null),N=b.useRef("right"),L=b.useRef(0),B=_?gm:b.Fragment,O=_?{as:tce,allowPinchZoom:!0}:void 0,D=V=>{var Q,ce;const j=U.current+V,q=A().filter(re=>!re.disabled),K=document.activeElement,$=(Q=q.find(re=>re.ref.current===K))==null?void 0:Q.textValue,te=q.map(re=>re.textValue),J=hce(te,j,$),ne=(ce=q.find(re=>re.textValue===J))==null?void 0:ce.ref.current;(function re(le){U.current=le,window.clearTimeout(Y.current),le!==""&&(Y.current=window.setTimeout(()=>re(""),1e3))})(j),ne&&setTimeout(()=>ne.focus())};b.useEffect(()=>()=>window.clearTimeout(Y.current),[]),Eb();const F=b.useCallback(V=>{var q,K;return N.current===((q=I.current)==null?void 0:q.side)&&mce(V,(K=I.current)==null?void 0:K.area)},[]);return m.jsx(Qle,{scope:n,searchRef:U,onItemEnter:b.useCallback(V=>{F(V)&&V.preventDefault()},[F]),onItemLeave:b.useCallback(V=>{var j;F(V)||((j=P.current)==null||j.focus(),T(null))},[F]),onTriggerLeave:b.useCallback(V=>{F(V)&&V.preventDefault()},[F]),pointerGraceTimerRef:G,onPointerGraceIntentChange:b.useCallback(V=>{I.current=V},[]),children:m.jsx(B,{...O,children:m.jsx(mm,{asChild:!0,trapped:i,onMountAutoFocus:Wt(s,V=>{var j;V.preventDefault(),(j=P.current)==null||j.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:m.jsx(mf,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:d,onPointerDownOutside:f,onFocusOutside:h,onInteractOutside:y,onDismiss:g,children:m.jsx($le,{asChild:!0,...R,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:M,onCurrentTabStopIdChange:T,onEntryFocus:Wt(u,V=>{x.isUsingKeyboardRef.current||V.preventDefault()}),preventScrollOnEntryFocus:!0,children:m.jsx(Ib,{role:"menu","aria-orientation":"vertical","data-state":Q3(S.open),"data-radix-menu-content":"",dir:x.dir,...k,...w,ref:z,style:{outline:"none",...w.style},onKeyDown:Wt(w.onKeyDown,V=>{const q=V.target.closest("[data-radix-menu-content]")===V.currentTarget,K=V.ctrlKey||V.altKey||V.metaKey,$=V.key.length===1;q&&(V.key==="Tab"&&V.preventDefault(),!K&&$&&D(V.key));const te=P.current;if(V.target!==te||!Wle.includes(V.key))return;V.preventDefault();const ne=A().filter(Q=>!Q.disabled).map(Q=>Q.ref.current);R3.includes(V.key)&&ne.reverse(),dce(ne)}),onBlur:Wt(e.onBlur,V=>{V.currentTarget.contains(V.target)||(window.clearTimeout(Y.current),U.current="")}),onPointerMove:Wt(e.onPointerMove,Up(V=>{const j=V.target,q=L.current!==V.clientX;if(V.currentTarget.contains(j)&&q){const K=V.clientX>L.current?"right":"left";N.current=K,L.current=V.clientX}}))})})})})})})});L3.displayName=mo;var nce="MenuGroup",xk=b.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return m.jsx(yn.div,{role:"group",...r,ref:t})});xk.displayName=nce;var rce="MenuLabel",D3=b.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return m.jsx(yn.div,{...r,ref:t})});D3.displayName=rce;var Hy="MenuItem",iI="menu.itemSelect",Lb=b.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=b.useRef(null),o=Sm(Hy,e.__scopeMenu),l=_k(Hy,e.__scopeMenu),u=or(t,s),d=b.useRef(!1),f=()=>{const h=s.current;if(!n&&h){const y=new CustomEvent(iI,{bubbles:!0,cancelable:!0});h.addEventListener(iI,g=>r==null?void 0:r(g),{once:!0}),x5(h,y),y.defaultPrevented?d.current=!1:o.onClose()}};return m.jsx(B3,{...i,ref:u,disabled:n,onClick:Wt(e.onClick,f),onPointerDown:h=>{var y;(y=e.onPointerDown)==null||y.call(e,h),d.current=!0},onPointerUp:Wt(e.onPointerUp,h=>{var y;d.current||(y=h.currentTarget)==null||y.click()}),onKeyDown:Wt(e.onKeyDown,h=>{const y=l.searchRef.current!=="";n||y&&h.key===" "||y1.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});Lb.displayName=Hy;var B3=b.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=_k(Hy,n),l=N3(n),u=b.useRef(null),d=or(t,u),[f,h]=b.useState(!1),[y,g]=b.useState("");return b.useEffect(()=>{const _=u.current;_&&g((_.textContent??"").trim())},[s.children]),m.jsx(Hp.ItemSlot,{scope:n,disabled:r,textValue:i??y,children:m.jsx(Hle,{asChild:!0,...l,focusable:!r,children:m.jsx(yn.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:d,onPointerMove:Wt(e.onPointerMove,Up(_=>{r?o.onItemLeave(_):(o.onItemEnter(_),_.defaultPrevented||_.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Wt(e.onPointerLeave,Up(_=>o.onItemLeave(_))),onFocus:Wt(e.onFocus,()=>h(!0)),onBlur:Wt(e.onBlur,()=>h(!1))})})})}),ice="MenuCheckboxItem",z3=b.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return m.jsx(U3,{scope:e.__scopeMenu,checked:n,children:m.jsx(Lb,{role:"menuitemcheckbox","aria-checked":Uy(n)?"mixed":n,...i,ref:t,"data-state":Ck(n),onSelect:Wt(i.onSelect,()=>r==null?void 0:r(Uy(n)?!0:!n),{checkForDefaultPrevented:!1})})})});z3.displayName=ice;var j3="MenuRadioGroup",[sce,oce]=Su(j3,{value:void 0,onValueChange:()=>{}}),F3=b.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=Io(r);return m.jsx(sce,{scope:e.__scopeMenu,value:n,onValueChange:s,children:m.jsx(xk,{...i,ref:t})})});F3.displayName=j3;var $3="MenuRadioItem",H3=b.forwardRef((e,t)=>{const{value:n,...r}=e,i=oce($3,e.__scopeMenu),s=n===i.value;return m.jsx(U3,{scope:e.__scopeMenu,checked:s,children:m.jsx(Lb,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Ck(s),onSelect:Wt(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});H3.displayName=$3;var Sk="MenuItemIndicator",[U3,ace]=Su(Sk,{checked:!1}),W3=b.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=ace(Sk,n);return m.jsx(wo,{present:r||Uy(s.checked)||s.checked===!0,children:m.jsx(yn.span,{...i,ref:t,"data-state":Ck(s.checked)})})});W3.displayName=Sk;var lce="MenuSeparator",q3=b.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return m.jsx(yn.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});q3.displayName=lce;var cce="MenuArrow",V3=b.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=xm(n);return m.jsx(Ob,{...i,...r,ref:t})});V3.displayName=cce;var Ek="MenuSub",[uce,Y3]=Su(Ek),K3=e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,s=uc(Ek,t),o=xm(t),[l,u]=b.useState(null),[d,f]=b.useState(null),h=Io(i);return b.useEffect(()=>(s.open===!1&&h(!1),()=>h(!1)),[s.open,h]),m.jsx(ym,{...o,children:m.jsx(M3,{scope:t,open:r,onOpenChange:h,content:d,onContentChange:f,children:m.jsx(uce,{scope:t,contentId:vi(),triggerId:vi(),trigger:l,onTriggerChange:u,children:n})})})};K3.displayName=Ek;var op="MenuSubTrigger",G3=b.forwardRef((e,t)=>{const n=uc(op,e.__scopeMenu),r=Sm(op,e.__scopeMenu),i=Y3(op,e.__scopeMenu),s=_k(op,e.__scopeMenu),o=b.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:u}=s,d={__scopeMenu:e.__scopeMenu},f=b.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return b.useEffect(()=>f,[f]),b.useEffect(()=>{const h=l.current;return()=>{window.clearTimeout(h),u(null)}},[l,u]),m.jsx(yk,{asChild:!0,...d,children:m.jsx(B3,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":Q3(n.open),...e,ref:qa(t,i.onTriggerChange),onClick:h=>{var y;(y=e.onClick)==null||y.call(e,h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Wt(e.onPointerMove,Up(h=>{s.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(s.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),f()},100))})),onPointerLeave:Wt(e.onPointerLeave,Up(h=>{var g,_;f();const y=(g=n.content)==null?void 0:g.getBoundingClientRect();if(y){const w=(_=n.content)==null?void 0:_.dataset.side,S=w==="right",x=S?-5:5,k=y[S?"left":"right"],R=y[S?"right":"left"];s.onPointerGraceIntentChange({area:[{x:h.clientX+x,y:h.clientY},{x:k,y:y.top},{x:R,y:y.top},{x:R,y:y.bottom},{x:k,y:y.bottom}],side:w}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(h),h.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:Wt(e.onKeyDown,h=>{var g;const y=s.searchRef.current!=="";e.disabled||y&&h.key===" "||qle[r.dir].includes(h.key)&&(n.onOpenChange(!0),(g=n.content)==null||g.focus(),h.preventDefault())})})})});G3.displayName=op;var X3="MenuSubContent",Z3=b.forwardRef((e,t)=>{const n=I3(mo,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=uc(mo,e.__scopeMenu),o=Sm(mo,e.__scopeMenu),l=Y3(X3,e.__scopeMenu),u=b.useRef(null),d=or(t,u);return m.jsx(Hp.Provider,{scope:e.__scopeMenu,children:m.jsx(wo,{present:r||s.open,children:m.jsx(Hp.Slot,{scope:e.__scopeMenu,children:m.jsx(wk,{id:l.contentId,"aria-labelledby":l.triggerId,...i,ref:d,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:f=>{var h;o.isUsingKeyboardRef.current&&((h=u.current)==null||h.focus()),f.preventDefault()},onCloseAutoFocus:f=>f.preventDefault(),onFocusOutside:Wt(e.onFocusOutside,f=>{f.target!==l.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:Wt(e.onEscapeKeyDown,f=>{o.onClose(),f.preventDefault()}),onKeyDown:Wt(e.onKeyDown,f=>{var g;const h=f.currentTarget.contains(f.target),y=Vle[o.dir].includes(f.key);h&&y&&(s.onOpenChange(!1),(g=l.trigger)==null||g.focus(),f.preventDefault())})})})})})});Z3.displayName=X3;function Q3(e){return e?"open":"closed"}function Uy(e){return e==="indeterminate"}function Ck(e){return Uy(e)?"indeterminate":e?"checked":"unchecked"}function dce(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function fce(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function hce(e,t,n){const i=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let o=fce(e,Math.max(s,0));i.length===1&&(o=o.filter(d=>d!==n));const u=o.find(d=>d.toLowerCase().startsWith(i.toLowerCase()));return u!==n?u:void 0}function pce(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const l=t[s],u=t[o],d=l.x,f=l.y,h=u.x,y=u.y;f>r!=y>r&&n<(h-d)*(r-f)/(y-f)+d&&(i=!i)}return i}function mce(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return pce(n,t)}function Up(e){return t=>t.pointerType==="mouse"?e(t):void 0}var gce=P3,vce=yk,yce=O3,bce=L3,_ce=xk,wce=D3,xce=Lb,Sce=z3,Ece=F3,Cce=H3,kce=W3,Tce=q3,Rce=V3,Ace=K3,Nce=G3,Mce=Z3,Db="DropdownMenu",[Pce]=Xa(Db,[A3]),Ji=A3(),[Ice,J3]=Pce(Db),e4=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:l=!0}=e,u=Ji(t),d=b.useRef(null),[f,h]=Jl({prop:i,defaultProp:s??!1,onChange:o,caller:Db});return m.jsx(Ice,{scope:t,triggerId:vi(),triggerRef:d,contentId:vi(),open:f,onOpenChange:h,onOpenToggle:b.useCallback(()=>h(y=>!y),[h]),modal:l,children:m.jsx(gce,{...u,open:f,onOpenChange:h,dir:r,modal:l,children:n})})};e4.displayName=Db;var t4="DropdownMenuTrigger",n4=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,s=J3(t4,n),o=Ji(n);return m.jsx(vce,{asChild:!0,...o,children:m.jsx(yn.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...i,ref:qa(t,s.triggerRef),onPointerDown:Wt(e.onPointerDown,l=>{!r&&l.button===0&&l.ctrlKey===!1&&(s.onOpenToggle(),s.open||l.preventDefault())}),onKeyDown:Wt(e.onKeyDown,l=>{r||(["Enter"," "].includes(l.key)&&s.onOpenToggle(),l.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(l.key)&&l.preventDefault())})})})});n4.displayName=t4;var Oce="DropdownMenuPortal",r4=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Ji(t);return m.jsx(yce,{...r,...n})};r4.displayName=Oce;var i4="DropdownMenuContent",s4=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=J3(i4,n),s=Ji(n),o=b.useRef(!1);return m.jsx(bce,{id:i.contentId,"aria-labelledby":i.triggerId,...s,...r,ref:t,onCloseAutoFocus:Wt(e.onCloseAutoFocus,l=>{var u;o.current||(u=i.triggerRef.current)==null||u.focus(),o.current=!1,l.preventDefault()}),onInteractOutside:Wt(e.onInteractOutside,l=>{const u=l.detail.originalEvent,d=u.button===0&&u.ctrlKey===!0,f=u.button===2||d;(!i.modal||f)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});s4.displayName=i4;var Lce="DropdownMenuGroup",Dce=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Ji(n);return m.jsx(_ce,{...i,...r,ref:t})});Dce.displayName=Lce;var Bce="DropdownMenuLabel",o4=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Ji(n);return m.jsx(wce,{...i,...r,ref:t})});o4.displayName=Bce;var zce="DropdownMenuItem",a4=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Ji(n);return m.jsx(xce,{...i,...r,ref:t})});a4.displayName=zce;var jce="DropdownMenuCheckboxItem",l4=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Ji(n);return m.jsx(Sce,{...i,...r,ref:t})});l4.displayName=jce;var Fce="DropdownMenuRadioGroup",$ce=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Ji(n);return m.jsx(Ece,{...i,...r,ref:t})});$ce.displayName=Fce;var Hce="DropdownMenuRadioItem",Uce=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Ji(n);return m.jsx(Cce,{...i,...r,ref:t})});Uce.displayName=Hce;var Wce="DropdownMenuItemIndicator",c4=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Ji(n);return m.jsx(kce,{...i,...r,ref:t})});c4.displayName=Wce;var qce="DropdownMenuSeparator",u4=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Ji(n);return m.jsx(Tce,{...i,...r,ref:t})});u4.displayName=qce;var Vce="DropdownMenuArrow",Yce=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Ji(n);return m.jsx(Rce,{...i,...r,ref:t})});Yce.displayName=Vce;var Kce=e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:s}=e,o=Ji(t),[l,u]=Jl({prop:r,defaultProp:s??!1,onChange:i,caller:"DropdownMenuSub"});return m.jsx(Ace,{...o,open:l,onOpenChange:u,children:n})},Gce="DropdownMenuSubTrigger",d4=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Ji(n);return m.jsx(Nce,{...i,...r,ref:t})});d4.displayName=Gce;var Xce="DropdownMenuSubContent",f4=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Ji(n);return m.jsx(Mce,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});f4.displayName=Xce;var Zce=e4,Qce=n4,h4=r4,Jce=s4,eue=o4,tue=a4,nue=l4,rue=c4,iue=u4,sue=Kce,oue=d4,aue=f4;function sI(e,[t,n]){return Math.min(n,Math.max(t,e))}var Bb="Popover",[p4]=Xa(Bb,[cc]),Em=cc(),[lue,dc]=p4(Bb),m4=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:o=!1}=e,l=Em(t),u=b.useRef(null),[d,f]=b.useState(!1),[h,y]=Jl({prop:r,defaultProp:i??!1,onChange:s,caller:Bb});return m.jsx(ym,{...l,children:m.jsx(lue,{scope:t,contentId:vi(),triggerRef:u,open:h,onOpenChange:y,onOpenToggle:b.useCallback(()=>y(g=>!g),[y]),hasCustomAnchor:d,onCustomAnchorAdd:b.useCallback(()=>f(!0),[]),onCustomAnchorRemove:b.useCallback(()=>f(!1),[]),modal:o,children:n})})};m4.displayName=Bb;var g4="PopoverAnchor",cue=b.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=dc(g4,n),s=Em(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:l}=i;return b.useEffect(()=>(o(),()=>l()),[o,l]),m.jsx(bm,{...s,...r,ref:t})});cue.displayName=g4;var v4="PopoverTrigger",y4=b.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=dc(v4,n),s=Em(n),o=or(t,i.triggerRef),l=m.jsx(yn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":S4(i.open),...r,ref:o,onClick:Wt(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?l:m.jsx(bm,{asChild:!0,...s,children:l})});y4.displayName=v4;var kk="PopoverPortal",[uue,due]=p4(kk,{forceMount:void 0}),b4=e=>{const{__scopePopover:t,forceMount:n,children:r,container:i}=e,s=dc(kk,t);return m.jsx(uue,{scope:t,forceMount:n,children:m.jsx(wo,{present:n||s.open,children:m.jsx(gf,{asChild:!0,container:i,children:r})})})};b4.displayName=kk;var sf="PopoverContent",_4=b.forwardRef((e,t)=>{const n=due(sf,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,s=dc(sf,e.__scopePopover);return m.jsx(wo,{present:r||s.open,children:s.modal?m.jsx(hue,{...i,ref:t}):m.jsx(pue,{...i,ref:t})})});_4.displayName=sf;var fue=Ql("PopoverContent.RemoveScroll"),hue=b.forwardRef((e,t)=>{const n=dc(sf,e.__scopePopover),r=b.useRef(null),i=or(t,r),s=b.useRef(!1);return b.useEffect(()=>{const o=r.current;if(o)return kb(o)},[]),m.jsx(gm,{as:fue,allowPinchZoom:!0,children:m.jsx(w4,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Wt(e.onCloseAutoFocus,o=>{var l;o.preventDefault(),s.current||(l=n.triggerRef.current)==null||l.focus()}),onPointerDownOutside:Wt(e.onPointerDownOutside,o=>{const l=o.detail.originalEvent,u=l.button===0&&l.ctrlKey===!0,d=l.button===2||u;s.current=d},{checkForDefaultPrevented:!1}),onFocusOutside:Wt(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),pue=b.forwardRef((e,t)=>{const n=dc(sf,e.__scopePopover),r=b.useRef(!1),i=b.useRef(!1);return m.jsx(w4,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var o,l;(o=e.onCloseAutoFocus)==null||o.call(e,s),s.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),s.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:s=>{var u,d;(u=e.onInteractOutside)==null||u.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const o=s.target;((d=n.triggerRef.current)==null?void 0:d.contains(o))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}})}),w4=b.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:o,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,...h}=e,y=dc(sf,n),g=Em(n);return Eb(),m.jsx(mm,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:m.jsx(mf,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:f,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onDismiss:()=>y.onOpenChange(!1),children:m.jsx(Ib,{"data-state":S4(y.open),role:"dialog",id:y.contentId,...g,...h,ref:t,style:{...h.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),x4="PopoverClose",mue=b.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=dc(x4,n);return m.jsx(yn.button,{type:"button",...r,ref:t,onClick:Wt(e.onClick,()=>i.onOpenChange(!1))})});mue.displayName=x4;var gue="PopoverArrow",vue=b.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Em(n);return m.jsx(Ob,{...i,...r,ref:t})});vue.displayName=gue;function S4(e){return e?"open":"closed"}var yue=m4,bue=y4,_ue=b4,wue=_4,xue=[" ","Enter","ArrowUp","ArrowDown"],Sue=[" ","Enter"],uu="Select",[zb,jb,Eue]=tk(uu),[bf]=Xa(uu,[Eue,cc]),Fb=cc(),[Cue,fc]=bf(uu),[kue,Tue]=bf(uu),E4=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:s,value:o,defaultValue:l,onValueChange:u,dir:d,name:f,autoComplete:h,disabled:y,required:g,form:_}=e,w=Fb(t),[S,x]=b.useState(null),[k,R]=b.useState(null),[A,M]=b.useState(!1),T=nk(d),[P,z]=Jl({prop:r,defaultProp:i??!1,onChange:s,caller:uu}),[Y,U]=Jl({prop:o,defaultProp:l,onChange:u,caller:uu}),G=b.useRef(null),I=S?_||!!S.closest("form"):!0,[N,L]=b.useState(new Set),B=Array.from(N).map(O=>O.props.value).join(";");return m.jsx(ym,{...w,children:m.jsxs(Cue,{required:g,scope:t,trigger:S,onTriggerChange:x,valueNode:k,onValueNodeChange:R,valueNodeHasChildren:A,onValueNodeHasChildrenChange:M,contentId:vi(),value:Y,onValueChange:U,open:P,onOpenChange:z,dir:T,triggerPointerDownPosRef:G,disabled:y,children:[m.jsx(zb.Provider,{scope:t,children:m.jsx(kue,{scope:e.__scopeSelect,onNativeOptionAdd:b.useCallback(O=>{L(D=>new Set(D).add(O))},[]),onNativeOptionRemove:b.useCallback(O=>{L(D=>{const F=new Set(D);return F.delete(O),F})},[]),children:n})}),I?m.jsxs(V4,{"aria-hidden":!0,required:g,tabIndex:-1,name:f,autoComplete:h,value:Y,onChange:O=>U(O.target.value),disabled:y,form:_,children:[Y===void 0?m.jsx("option",{value:""}):null,Array.from(N)]},B):null]})})};E4.displayName=uu;var C4="SelectTrigger",k4=b.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...i}=e,s=Fb(n),o=fc(C4,n),l=o.disabled||r,u=or(t,o.onTriggerChange),d=jb(n),f=b.useRef("touch"),[h,y,g]=K4(w=>{const S=d().filter(R=>!R.disabled),x=S.find(R=>R.value===o.value),k=G4(S,w,x);k!==void 0&&o.onValueChange(k.value)}),_=w=>{l||(o.onOpenChange(!0),g()),w&&(o.triggerPointerDownPosRef.current={x:Math.round(w.pageX),y:Math.round(w.pageY)})};return m.jsx(bm,{asChild:!0,...s,children:m.jsx(yn.button,{type:"button",role:"combobox","aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":"none",dir:o.dir,"data-state":o.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":Y4(o.value)?"":void 0,...i,ref:u,onClick:Wt(i.onClick,w=>{w.currentTarget.focus(),f.current!=="mouse"&&_(w)}),onPointerDown:Wt(i.onPointerDown,w=>{f.current=w.pointerType;const S=w.target;S.hasPointerCapture(w.pointerId)&&S.releasePointerCapture(w.pointerId),w.button===0&&w.ctrlKey===!1&&w.pointerType==="mouse"&&(_(w),w.preventDefault())}),onKeyDown:Wt(i.onKeyDown,w=>{const S=h.current!=="";!(w.ctrlKey||w.altKey||w.metaKey)&&w.key.length===1&&y(w.key),!(S&&w.key===" ")&&xue.includes(w.key)&&(_(),w.preventDefault())})})})});k4.displayName=C4;var T4="SelectValue",R4=b.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:i,children:s,placeholder:o="",...l}=e,u=fc(T4,n),{onValueNodeHasChildrenChange:d}=u,f=s!==void 0,h=or(t,u.onValueNodeChange);return Qi(()=>{d(f)},[d,f]),m.jsx(yn.span,{...l,ref:h,style:{pointerEvents:"none"},children:Y4(u.value)?m.jsx(m.Fragment,{children:o}):s})});R4.displayName=T4;var Rue="SelectIcon",A4=b.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...i}=e;return m.jsx(yn.span,{"aria-hidden":!0,...i,ref:t,children:r||"▼"})});A4.displayName=Rue;var Aue="SelectPortal",N4=e=>m.jsx(gf,{asChild:!0,...e});N4.displayName=Aue;var du="SelectContent",M4=b.forwardRef((e,t)=>{const n=fc(du,e.__scopeSelect),[r,i]=b.useState();if(Qi(()=>{i(new DocumentFragment)},[]),!n.open){const s=r;return s?xu.createPortal(m.jsx(P4,{scope:e.__scopeSelect,children:m.jsx(zb.Slot,{scope:e.__scopeSelect,children:m.jsx("div",{children:e.children})})}),s):null}return m.jsx(I4,{...e,ref:t})});M4.displayName=du;var Ao=10,[P4,hc]=bf(du),Nue="SelectContentImpl",Mue=Ql("SelectContent.RemoveScroll"),I4=b.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:s,onPointerDownOutside:o,side:l,sideOffset:u,align:d,alignOffset:f,arrowPadding:h,collisionBoundary:y,collisionPadding:g,sticky:_,hideWhenDetached:w,avoidCollisions:S,...x}=e,k=fc(du,n),[R,A]=b.useState(null),[M,T]=b.useState(null),P=or(t,Q=>A(Q)),[z,Y]=b.useState(null),[U,G]=b.useState(null),I=jb(n),[N,L]=b.useState(!1),B=b.useRef(!1);b.useEffect(()=>{if(R)return kb(R)},[R]),Eb();const O=b.useCallback(Q=>{const[ce,...re]=I().map(Ce=>Ce.ref.current),[le]=re.slice(-1),we=document.activeElement;for(const Ce of Q)if(Ce===we||(Ce==null||Ce.scrollIntoView({block:"nearest"}),Ce===ce&&M&&(M.scrollTop=0),Ce===le&&M&&(M.scrollTop=M.scrollHeight),Ce==null||Ce.focus(),document.activeElement!==we))return},[I,M]),D=b.useCallback(()=>O([z,R]),[O,z,R]);b.useEffect(()=>{N&&D()},[N,D]);const{onOpenChange:F,triggerPointerDownPosRef:V}=k;b.useEffect(()=>{if(R){let Q={x:0,y:0};const ce=le=>{var we,Ce;Q={x:Math.abs(Math.round(le.pageX)-(((we=V.current)==null?void 0:we.x)??0)),y:Math.abs(Math.round(le.pageY)-(((Ce=V.current)==null?void 0:Ce.y)??0))}},re=le=>{Q.x<=10&&Q.y<=10?le.preventDefault():R.contains(le.target)||F(!1),document.removeEventListener("pointermove",ce),V.current=null};return V.current!==null&&(document.addEventListener("pointermove",ce),document.addEventListener("pointerup",re,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ce),document.removeEventListener("pointerup",re,{capture:!0})}}},[R,F,V]),b.useEffect(()=>{const Q=()=>F(!1);return window.addEventListener("blur",Q),window.addEventListener("resize",Q),()=>{window.removeEventListener("blur",Q),window.removeEventListener("resize",Q)}},[F]);const[j,q]=K4(Q=>{const ce=I().filter(we=>!we.disabled),re=ce.find(we=>we.ref.current===document.activeElement),le=G4(ce,Q,re);le&&setTimeout(()=>le.ref.current.focus())}),K=b.useCallback((Q,ce,re)=>{const le=!B.current&&!re;(k.value!==void 0&&k.value===ce||le)&&(Y(Q),le&&(B.current=!0))},[k.value]),$=b.useCallback(()=>R==null?void 0:R.focus(),[R]),te=b.useCallback((Q,ce,re)=>{const le=!B.current&&!re;(k.value!==void 0&&k.value===ce||le)&&G(Q)},[k.value]),J=r==="popper"?b1:O4,ne=J===b1?{side:l,sideOffset:u,align:d,alignOffset:f,arrowPadding:h,collisionBoundary:y,collisionPadding:g,sticky:_,hideWhenDetached:w,avoidCollisions:S}:{};return m.jsx(P4,{scope:n,content:R,viewport:M,onViewportChange:T,itemRefCallback:K,selectedItem:z,onItemLeave:$,itemTextRefCallback:te,focusSelectedItem:D,selectedItemText:U,position:r,isPositioned:N,searchRef:j,children:m.jsx(gm,{as:Mue,allowPinchZoom:!0,children:m.jsx(mm,{asChild:!0,trapped:k.open,onMountAutoFocus:Q=>{Q.preventDefault()},onUnmountAutoFocus:Wt(i,Q=>{var ce;(ce=k.trigger)==null||ce.focus({preventScroll:!0}),Q.preventDefault()}),children:m.jsx(mf,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:Q=>Q.preventDefault(),onDismiss:()=>k.onOpenChange(!1),children:m.jsx(J,{role:"listbox",id:k.contentId,"data-state":k.open?"open":"closed",dir:k.dir,onContextMenu:Q=>Q.preventDefault(),...x,...ne,onPlaced:()=>L(!0),ref:P,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:Wt(x.onKeyDown,Q=>{const ce=Q.ctrlKey||Q.altKey||Q.metaKey;if(Q.key==="Tab"&&Q.preventDefault(),!ce&&Q.key.length===1&&q(Q.key),["ArrowUp","ArrowDown","Home","End"].includes(Q.key)){let le=I().filter(we=>!we.disabled).map(we=>we.ref.current);if(["ArrowUp","End"].includes(Q.key)&&(le=le.slice().reverse()),["ArrowUp","ArrowDown"].includes(Q.key)){const we=Q.target,Ce=le.indexOf(we);le=le.slice(Ce+1)}setTimeout(()=>O(le)),Q.preventDefault()}})})})})})})});I4.displayName=Nue;var Pue="SelectItemAlignedPosition",O4=b.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...i}=e,s=fc(du,n),o=hc(du,n),[l,u]=b.useState(null),[d,f]=b.useState(null),h=or(t,P=>f(P)),y=jb(n),g=b.useRef(!1),_=b.useRef(!0),{viewport:w,selectedItem:S,selectedItemText:x,focusSelectedItem:k}=o,R=b.useCallback(()=>{if(s.trigger&&s.valueNode&&l&&d&&w&&S&&x){const P=s.trigger.getBoundingClientRect(),z=d.getBoundingClientRect(),Y=s.valueNode.getBoundingClientRect(),U=x.getBoundingClientRect();if(s.dir!=="rtl"){const we=U.left-z.left,Ce=Y.left-we,ye=P.left-Ce,Re=P.width+ye,Rt=Math.max(Re,z.width),Ke=window.innerWidth-Ao,et=sI(Ce,[Ao,Math.max(Ao,Ke-Rt)]);l.style.minWidth=Re+"px",l.style.left=et+"px"}else{const we=z.right-U.right,Ce=window.innerWidth-Y.right-we,ye=window.innerWidth-P.right-Ce,Re=P.width+ye,Rt=Math.max(Re,z.width),Ke=window.innerWidth-Ao,et=sI(Ce,[Ao,Math.max(Ao,Ke-Rt)]);l.style.minWidth=Re+"px",l.style.right=et+"px"}const G=y(),I=window.innerHeight-Ao*2,N=w.scrollHeight,L=window.getComputedStyle(d),B=parseInt(L.borderTopWidth,10),O=parseInt(L.paddingTop,10),D=parseInt(L.borderBottomWidth,10),F=parseInt(L.paddingBottom,10),V=B+O+N+F+D,j=Math.min(S.offsetHeight*5,V),q=window.getComputedStyle(w),K=parseInt(q.paddingTop,10),$=parseInt(q.paddingBottom,10),te=P.top+P.height/2-Ao,J=I-te,ne=S.offsetHeight/2,Q=S.offsetTop+ne,ce=B+O+Q,re=V-ce;if(ce<=te){const we=G.length>0&&S===G[G.length-1].ref.current;l.style.bottom="0px";const Ce=d.clientHeight-w.offsetTop-w.offsetHeight,ye=Math.max(J,ne+(we?$:0)+Ce+D),Re=ce+ye;l.style.height=Re+"px"}else{const we=G.length>0&&S===G[0].ref.current;l.style.top="0px";const ye=Math.max(te,B+w.offsetTop+(we?K:0)+ne)+re;l.style.height=ye+"px",w.scrollTop=ce-te+w.offsetTop}l.style.margin=`${Ao}px 0`,l.style.minHeight=j+"px",l.style.maxHeight=I+"px",r==null||r(),requestAnimationFrame(()=>g.current=!0)}},[y,s.trigger,s.valueNode,l,d,w,S,x,s.dir,r]);Qi(()=>R(),[R]);const[A,M]=b.useState();Qi(()=>{d&&M(window.getComputedStyle(d).zIndex)},[d]);const T=b.useCallback(P=>{P&&_.current===!0&&(R(),k==null||k(),_.current=!1)},[R,k]);return m.jsx(Oue,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:g,onScrollButtonChange:T,children:m.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:A},children:m.jsx(yn.div,{...i,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})});O4.displayName=Pue;var Iue="SelectPopperPosition",b1=b.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:i=Ao,...s}=e,o=Fb(n);return m.jsx(Ib,{...o,...s,ref:t,align:r,collisionPadding:i,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});b1.displayName=Iue;var[Oue,Tk]=bf(du,{}),_1="SelectViewport",L4=b.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...i}=e,s=hc(_1,n),o=Tk(_1,n),l=or(t,s.onViewportChange),u=b.useRef(0);return m.jsxs(m.Fragment,{children:[m.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),m.jsx(zb.Slot,{scope:n,children:m.jsx(yn.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:Wt(i.onScroll,d=>{const f=d.currentTarget,{contentWrapper:h,shouldExpandOnScrollRef:y}=o;if(y!=null&&y.current&&h){const g=Math.abs(u.current-f.scrollTop);if(g>0){const _=window.innerHeight-Ao*2,w=parseFloat(h.style.minHeight),S=parseFloat(h.style.height),x=Math.max(w,S);if(x<_){const k=x+g,R=Math.min(_,k),A=k-R;h.style.height=R+"px",h.style.bottom==="0px"&&(f.scrollTop=A>0?A:0,h.style.justifyContent="flex-end")}}}u.current=f.scrollTop})})})]})});L4.displayName=_1;var D4="SelectGroup",[Lue,Due]=bf(D4),Bue=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=vi();return m.jsx(Lue,{scope:n,id:i,children:m.jsx(yn.div,{role:"group","aria-labelledby":i,...r,ref:t})})});Bue.displayName=D4;var B4="SelectLabel",zue=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=Due(B4,n);return m.jsx(yn.div,{id:i.id,...r,ref:t})});zue.displayName=B4;var Wy="SelectItem",[jue,z4]=bf(Wy),j4=b.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:i=!1,textValue:s,...o}=e,l=fc(Wy,n),u=hc(Wy,n),d=l.value===r,[f,h]=b.useState(s??""),[y,g]=b.useState(!1),_=or(t,k=>{var R;return(R=u.itemRefCallback)==null?void 0:R.call(u,k,r,i)}),w=vi(),S=b.useRef("touch"),x=()=>{i||(l.onValueChange(r),l.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return m.jsx(jue,{scope:n,value:r,disabled:i,textId:w,isSelected:d,onItemTextChange:b.useCallback(k=>{h(R=>R||((k==null?void 0:k.textContent)??"").trim())},[]),children:m.jsx(zb.ItemSlot,{scope:n,value:r,disabled:i,textValue:f,children:m.jsx(yn.div,{role:"option","aria-labelledby":w,"data-highlighted":y?"":void 0,"aria-selected":d&&y,"data-state":d?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1,...o,ref:_,onFocus:Wt(o.onFocus,()=>g(!0)),onBlur:Wt(o.onBlur,()=>g(!1)),onClick:Wt(o.onClick,()=>{S.current!=="mouse"&&x()}),onPointerUp:Wt(o.onPointerUp,()=>{S.current==="mouse"&&x()}),onPointerDown:Wt(o.onPointerDown,k=>{S.current=k.pointerType}),onPointerMove:Wt(o.onPointerMove,k=>{var R;S.current=k.pointerType,i?(R=u.onItemLeave)==null||R.call(u):S.current==="mouse"&&k.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Wt(o.onPointerLeave,k=>{var R;k.currentTarget===document.activeElement&&((R=u.onItemLeave)==null||R.call(u))}),onKeyDown:Wt(o.onKeyDown,k=>{var A;((A=u.searchRef)==null?void 0:A.current)!==""&&k.key===" "||(Sue.includes(k.key)&&x(),k.key===" "&&k.preventDefault())})})})})});j4.displayName=Wy;var ap="SelectItemText",F4=b.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:i,...s}=e,o=fc(ap,n),l=hc(ap,n),u=z4(ap,n),d=Tue(ap,n),[f,h]=b.useState(null),y=or(t,x=>h(x),u.onItemTextChange,x=>{var k;return(k=l.itemTextRefCallback)==null?void 0:k.call(l,x,u.value,u.disabled)}),g=f==null?void 0:f.textContent,_=b.useMemo(()=>m.jsx("option",{value:u.value,disabled:u.disabled,children:g},u.value),[u.disabled,u.value,g]),{onNativeOptionAdd:w,onNativeOptionRemove:S}=d;return Qi(()=>(w(_),()=>S(_)),[w,S,_]),m.jsxs(m.Fragment,{children:[m.jsx(yn.span,{id:u.textId,...s,ref:y}),u.isSelected&&o.valueNode&&!o.valueNodeHasChildren?xu.createPortal(s.children,o.valueNode):null]})});F4.displayName=ap;var $4="SelectItemIndicator",H4=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return z4($4,n).isSelected?m.jsx(yn.span,{"aria-hidden":!0,...r,ref:t}):null});H4.displayName=$4;var w1="SelectScrollUpButton",U4=b.forwardRef((e,t)=>{const n=hc(w1,e.__scopeSelect),r=Tk(w1,e.__scopeSelect),[i,s]=b.useState(!1),o=or(t,r.onScrollButtonChange);return Qi(()=>{if(n.viewport&&n.isPositioned){let l=function(){const d=u.scrollTop>0;s(d)};const u=n.viewport;return l(),u.addEventListener("scroll",l),()=>u.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),i?m.jsx(q4,{...e,ref:o,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=n;l&&u&&(l.scrollTop=l.scrollTop-u.offsetHeight)}}):null});U4.displayName=w1;var x1="SelectScrollDownButton",W4=b.forwardRef((e,t)=>{const n=hc(x1,e.__scopeSelect),r=Tk(x1,e.__scopeSelect),[i,s]=b.useState(!1),o=or(t,r.onScrollButtonChange);return Qi(()=>{if(n.viewport&&n.isPositioned){let l=function(){const d=u.scrollHeight-u.clientHeight,f=Math.ceil(u.scrollTop)<d;s(f)};const u=n.viewport;return l(),u.addEventListener("scroll",l),()=>u.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),i?m.jsx(q4,{...e,ref:o,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=n;l&&u&&(l.scrollTop=l.scrollTop+u.offsetHeight)}}):null});W4.displayName=x1;var q4=b.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...i}=e,s=hc("SelectScrollButton",n),o=b.useRef(null),l=jb(n),u=b.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return b.useEffect(()=>()=>u(),[u]),Qi(()=>{var f;const d=l().find(h=>h.ref.current===document.activeElement);(f=d==null?void 0:d.ref.current)==null||f.scrollIntoView({block:"nearest"})},[l]),m.jsx(yn.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:Wt(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:Wt(i.onPointerMove,()=>{var d;(d=s.onItemLeave)==null||d.call(s),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:Wt(i.onPointerLeave,()=>{u()})})}),Fue="SelectSeparator",$ue=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return m.jsx(yn.div,{"aria-hidden":!0,...r,ref:t})});$ue.displayName=Fue;var S1="SelectArrow",Hue=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=Fb(n),s=fc(S1,n),o=hc(S1,n);return s.open&&o.position==="popper"?m.jsx(Ob,{...i,...r,ref:t}):null});Hue.displayName=S1;var Uue="SelectBubbleInput",V4=b.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const i=b.useRef(null),s=or(r,i),o=vae(t);return b.useEffect(()=>{const l=i.current;if(!l)return;const u=window.HTMLSelectElement.prototype,f=Object.getOwnPropertyDescriptor(u,"value").set;if(o!==t&&f){const h=new Event("change",{bubbles:!0});f.call(l,t),l.dispatchEvent(h)}},[o,t]),m.jsx(yn.select,{...n,style:{...S5,...n.style},ref:s,defaultValue:t})});V4.displayName=Uue;function Y4(e){return e===""||e===void 0}function K4(e){const t=Io(e),n=b.useRef(""),r=b.useRef(0),i=b.useCallback(o=>{const l=n.current+o;t(l),(function u(d){n.current=d,window.clearTimeout(r.current),d!==""&&(r.current=window.setTimeout(()=>u(""),1e3))})(l)},[t]),s=b.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return b.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,s]}function G4(e,t,n){const i=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let o=Wue(e,Math.max(s,0));i.length===1&&(o=o.filter(d=>d!==n));const u=o.find(d=>d.textValue.toLowerCase().startsWith(i.toLowerCase()));return u!==n?u:void 0}function Wue(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var que=E4,Vue=k4,Yue=R4,Kue=A4,Gue=N4,Xue=M4,Zue=L4,Que=j4,Jue=F4,ede=H4,tde=U4,nde=W4,[$b]=Xa("Tooltip",[cc]),Hb=cc(),X4="TooltipProvider",rde=700,E1="tooltip.open",[ide,Rk]=$b(X4),Z4=e=>{const{__scopeTooltip:t,delayDuration:n=rde,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,o=b.useRef(!0),l=b.useRef(!1),u=b.useRef(0);return b.useEffect(()=>{const d=u.current;return()=>window.clearTimeout(d)},[]),m.jsx(ide,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:b.useCallback(()=>{window.clearTimeout(u.current),o.current=!1},[]),onClose:b.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:b.useCallback(d=>{l.current=d},[]),disableHoverableContent:i,children:s})};Z4.displayName=X4;var Wp="Tooltip",[sde,Cm]=$b(Wp),Q4=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:l}=e,u=Rk(Wp,e.__scopeTooltip),d=Hb(t),[f,h]=b.useState(null),y=vi(),g=b.useRef(0),_=o??u.disableHoverableContent,w=l??u.delayDuration,S=b.useRef(!1),[x,k]=Jl({prop:r,defaultProp:i??!1,onChange:P=>{P?(u.onOpen(),document.dispatchEvent(new CustomEvent(E1))):u.onClose(),s==null||s(P)},caller:Wp}),R=b.useMemo(()=>x?S.current?"delayed-open":"instant-open":"closed",[x]),A=b.useCallback(()=>{window.clearTimeout(g.current),g.current=0,S.current=!1,k(!0)},[k]),M=b.useCallback(()=>{window.clearTimeout(g.current),g.current=0,k(!1)},[k]),T=b.useCallback(()=>{window.clearTimeout(g.current),g.current=window.setTimeout(()=>{S.current=!0,k(!0),g.current=0},w)},[w,k]);return b.useEffect(()=>()=>{g.current&&(window.clearTimeout(g.current),g.current=0)},[]),m.jsx(ym,{...d,children:m.jsx(sde,{scope:t,contentId:y,open:x,stateAttribute:R,trigger:f,onTriggerChange:h,onTriggerEnter:b.useCallback(()=>{u.isOpenDelayedRef.current?T():A()},[u.isOpenDelayedRef,T,A]),onTriggerLeave:b.useCallback(()=>{_?M():(window.clearTimeout(g.current),g.current=0)},[M,_]),onOpen:A,onClose:M,disableHoverableContent:_,children:n})})};Q4.displayName=Wp;var C1="TooltipTrigger",J4=b.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Cm(C1,n),s=Rk(C1,n),o=Hb(n),l=b.useRef(null),u=or(t,l,i.onTriggerChange),d=b.useRef(!1),f=b.useRef(!1),h=b.useCallback(()=>d.current=!1,[]);return b.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),m.jsx(bm,{asChild:!0,...o,children:m.jsx(yn.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:u,onPointerMove:Wt(e.onPointerMove,y=>{y.pointerType!=="touch"&&!f.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),f.current=!0)}),onPointerLeave:Wt(e.onPointerLeave,()=>{i.onTriggerLeave(),f.current=!1}),onPointerDown:Wt(e.onPointerDown,()=>{i.open&&i.onClose(),d.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Wt(e.onFocus,()=>{d.current||i.onOpen()}),onBlur:Wt(e.onBlur,i.onClose),onClick:Wt(e.onClick,i.onClose)})})});J4.displayName=C1;var Ak="TooltipPortal",[ode,ade]=$b(Ak,{forceMount:void 0}),eF=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,s=Cm(Ak,t);return m.jsx(ode,{scope:t,forceMount:n,children:m.jsx(wo,{present:n||s.open,children:m.jsx(gf,{asChild:!0,container:i,children:r})})})};eF.displayName=Ak;var of="TooltipContent",tF=b.forwardRef((e,t)=>{const n=ade(of,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,o=Cm(of,e.__scopeTooltip);return m.jsx(wo,{present:r||o.open,children:o.disableHoverableContent?m.jsx(nF,{side:i,...s,ref:t}):m.jsx(lde,{side:i,...s,ref:t})})}),lde=b.forwardRef((e,t)=>{const n=Cm(of,e.__scopeTooltip),r=Rk(of,e.__scopeTooltip),i=b.useRef(null),s=or(t,i),[o,l]=b.useState(null),{trigger:u,onClose:d}=n,f=i.current,{onPointerInTransitChange:h}=r,y=b.useCallback(()=>{l(null),h(!1)},[h]),g=b.useCallback((_,w)=>{const S=_.currentTarget,x={x:_.clientX,y:_.clientY},k=fde(x,S.getBoundingClientRect()),R=hde(x,k),A=pde(w.getBoundingClientRect()),M=gde([...R,...A]);l(M),h(!0)},[h]);return b.useEffect(()=>()=>y(),[y]),b.useEffect(()=>{if(u&&f){const _=S=>g(S,f),w=S=>g(S,u);return u.addEventListener("pointerleave",_),f.addEventListener("pointerleave",w),()=>{u.removeEventListener("pointerleave",_),f.removeEventListener("pointerleave",w)}}},[u,f,g,y]),b.useEffect(()=>{if(o){const _=w=>{const S=w.target,x={x:w.clientX,y:w.clientY},k=(u==null?void 0:u.contains(S))||(f==null?void 0:f.contains(S)),R=!mde(x,o);k?y():R&&(y(),d())};return document.addEventListener("pointermove",_),()=>document.removeEventListener("pointermove",_)}},[u,f,o,d,y]),m.jsx(nF,{...e,ref:s})}),[cde,ude]=$b(Wp,{isInside:!1}),dde=Use("TooltipContent"),nF=b.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...l}=e,u=Cm(of,n),d=Hb(n),{onClose:f}=u;return b.useEffect(()=>(document.addEventListener(E1,f),()=>document.removeEventListener(E1,f)),[f]),b.useEffect(()=>{if(u.trigger){const h=y=>{const g=y.target;g!=null&&g.contains(u.trigger)&&f()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[u.trigger,f]),m.jsx(mf,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:h=>h.preventDefault(),onDismiss:f,children:m.jsxs(Ib,{"data-state":u.stateAttribute,...d,...l,ref:t,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[m.jsx(dde,{children:r}),m.jsx(cde,{scope:n,isInside:!0,children:m.jsx(C5,{id:u.contentId,role:"tooltip",children:i||r})})]})})});tF.displayName=of;var rF="TooltipArrow",iF=b.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Hb(n);return ude(rF,n).isInside?null:m.jsx(Ob,{...i,...r,ref:t})});iF.displayName=rF;function fde(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function hde(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function pde(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function mde(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const l=t[s],u=t[o],d=l.x,f=l.y,h=u.x,y=u.y;f>r!=y>r&&n<(h-d)*(r-f)/(y-f)+d&&(i=!i)}return i}function gde(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),vde(t)}function vde(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const s=t[t.length-1],o=t[t.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],o=n[n.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var yde=Z4,bde=Q4,_de=J4,wde=eF,xde=tF,Sde=iF;const sF=b.createContext(!1);function Ede({blocked:e,children:t}){return m.jsx(sF.Provider,{value:e,children:t})}function km(){return b.useContext(sF)}function Ub({...e}){return m.jsx(yue,{"data-slot":"popover",...e})}function Wb({...e}){return m.jsx(bue,{"data-slot":"popover-trigger",...e})}function qb({className:e,align:t="center",sideOffset:n=4,inert:r,"aria-disabled":i,...s}){const o=km();return m.jsx(_ue,{children:m.jsx(wue,{"data-slot":"popover-content",align:t,sideOffset:n,className:qe("z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-hidden data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",e),inert:o||r?!0:void 0,"aria-disabled":o?!0:i,"data-relay-interaction-blocked":o?"true":void 0,...s})})}const oI=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,aI=Oz,Cde=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return aI(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:i,defaultVariants:s}=t,o=Object.keys(i).map(d=>{const f=n==null?void 0:n[d],h=s==null?void 0:s[d];if(f===null)return null;const y=oI(f)||oI(h);return i[d][y]}),l=n&&Object.entries(n).reduce((d,f)=>{let[h,y]=f;return y===void 0||(d[h]=y),d},{}),u=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((d,f)=>{let{class:h,className:y,...g}=f;return Object.entries(g).every(_=>{let[w,S]=_;return Array.isArray(S)?S.includes({...s,...l}[w]):{...s,...l}[w]===S})?[...d,h,y]:d},[]);return aI(e,o,u,n==null?void 0:n.class,n==null?void 0:n.className)},kde=Cde("inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-normal whitespace-nowrap transition-[color,background-color,border-color,box-shadow,opacity] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/75 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",xs:"h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-xs":"size-6 rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function vt({className:e,variant:t="default",size:n="default",asChild:r=!1,...i}){const s=r?$se:"button";return m.jsx(s,{"data-slot":"button","data-variant":t,"data-size":n,className:qe(kde({variant:t,size:n,className:e})),...i})}function _f({...e}){return m.jsx(Zce,{"data-slot":"dropdown-menu",...e})}function Tde({...e}){return m.jsx(h4,{"data-slot":"dropdown-menu-portal",...e})}function wf({...e}){return m.jsx(Qce,{"data-slot":"dropdown-menu-trigger",...e})}function xf({className:e,sideOffset:t=4,inert:n,"aria-disabled":r,...i}){const s=km();return m.jsx(h4,{children:m.jsx(Jce,{"data-slot":"dropdown-menu-content",sideOffset:t,className:qe("z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",e),inert:s||n?!0:void 0,"aria-disabled":s?!0:r,"data-relay-interaction-blocked":s?"true":void 0,...i})})}function Zr({className:e,inset:t,variant:n="default",...r}){return m.jsx(tue,{"data-slot":"dropdown-menu-item","data-inset":t,"data-variant":n,className:qe("relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:*:[svg]:text-destructive!",e),...r})}function v0({className:e,children:t,checked:n,...r}){return m.jsxs(nue,{"data-slot":"dropdown-menu-checkbox-item",className:qe("relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),checked:n,...r,children:[m.jsx("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:m.jsx(rue,{children:m.jsx(ua,{className:"size-4"})})}),t]})}function vv({className:e,inset:t,...n}){return m.jsx(eue,{"data-slot":"dropdown-menu-label","data-inset":t,className:qe("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",e),...n})}function Gc({className:e,...t}){return m.jsx(iue,{"data-slot":"dropdown-menu-separator",className:qe("-mx-1 my-1 h-px bg-border",e),...t})}function Rde({...e}){return m.jsx(sue,{"data-slot":"dropdown-menu-sub",...e})}function Ade({className:e,inset:t,children:n,...r}){return m.jsxs(oue,{"data-slot":"dropdown-menu-sub-trigger","data-inset":t,className:qe("flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[inset]:pl-8 data-[state=open]:bg-accent data-[state=open]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",e),...r,children:[n,m.jsx(Hd,{className:"ml-auto size-4"})]})}function Nde({className:e,...t}){return m.jsx(aue,{"data-slot":"dropdown-menu-sub-content",className:qe("z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",e),...t})}const Mde={"no-proxy":{heading:"还没有连接开发机",body:"在开发机上启动 DEV Anywhere,本页会显示可连接的开发机"},"client-token-missing":{heading:"需要 client token",body:"Relay 已启用客户端访问控制,请在设置中填写"},"client-token-invalid":{heading:"client token 无效",body:"client token 无效或已过期,请在设置中更新"},"no-session":{heading:"没有选中的会话",body:""},"no-messages":{heading:"开始对话",body:""}};function Jc({variant:e,action:t}){const{heading:n,body:r}=Mde[e];return e==="no-messages"?m.jsx("div",{className:"flex h-full w-full items-center justify-center animate-in fade-in-0 duration-200 motion-reduce:animate-none",children:m.jsx("p",{className:"text-sm text-muted-foreground",children:n})}):m.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-6 px-6 text-center animate-in fade-in-0 duration-200 motion-reduce:animate-none",children:[m.jsx("h2",{className:"text-2xl font-semibold",children:n}),r&&m.jsx("p",{className:"max-w-md text-sm text-muted-foreground",children:r}),t&&m.jsx("div",{children:t})]})}const Pde={online:"bg-[var(--color-status-success)]",offline:"bg-[var(--muted-foreground)]",connecting:"bg-[var(--color-status-working)] animate-pulse"},Ide={online:"开发机在线",offline:"开发机离线",connecting:"正在连接开发机"};function k1({status:e,className:t}){return m.jsx("span",{className:qe("inline-block w-2 h-2 rounded-full shrink-0",Pde[e],t),role:"status","aria-label":Ide[e]})}function Ep({name:e,osName:t,className:n,nameClassName:r}){return m.jsxs("span",{className:qe("min-w-0 flex-1",n),children:[m.jsx("span",{"data-slot":"proxy-name",className:qe("block truncate text-sm font-normal leading-5",r),children:e}),t&&m.jsx("span",{"data-slot":"proxy-os",className:"block truncate text-xs font-normal leading-4 text-muted-foreground",children:t})]})}function es({...e}){return m.jsx(ok,{"data-slot":"dialog",...e})}function Ode({...e}){return m.jsx(ak,{"data-slot":"dialog-portal",...e})}function Lde({...e}){return m.jsx(Rb,{"data-slot":"dialog-close",...e})}function Dde({className:e,...t}){return m.jsx(lk,{"data-slot":"dialog-overlay",className:qe("fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",e),...t})}function ts({className:e,children:t,showCloseButton:n=!0,focusSurfaceOnOpen:r=!1,onOpenAutoFocus:i,inert:s,"aria-disabled":o,...l}){const u=km();return m.jsxs(Ode,{"data-slot":"dialog-portal",children:[m.jsx(Dde,{}),m.jsxs(ck,{"data-slot":"dialog-content",className:qe("fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg",e),onOpenAutoFocus:d=>{i==null||i(d),!(!r||d.defaultPrevented)&&(d.preventDefault(),d.currentTarget.focus({preventScroll:!0}))},inert:u||s?!0:void 0,"aria-disabled":u?!0:o,"data-relay-interaction-blocked":u?"true":void 0,...l,children:[t,n&&m.jsxs(Rb,{"data-slot":"dialog-close",className:"absolute top-2 right-2 flex size-11 items-center justify-center rounded-md opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[m.jsx(bu,{}),m.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function ns({className:e,...t}){return m.jsx("div",{"data-slot":"dialog-header",className:qe("flex flex-col gap-2 text-center sm:text-left",e),...t})}function qs({className:e,showCloseButton:t=!1,children:n,...r}){return m.jsxs("div",{"data-slot":"dialog-footer",className:qe("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end max-sm:[&_button]:min-h-11",e),...r,children:[n,t&&m.jsx(Rb,{asChild:!0,children:m.jsx(vt,{variant:"outline",children:"Close"})})]})}function $i({className:e,...t}){return m.jsx(J5,{"data-slot":"dialog-title",className:qe("text-lg leading-none font-semibold",e),...t})}function Es({className:e,...t}){return m.jsx(e3,{"data-slot":"dialog-description",className:qe("text-sm text-muted-foreground",e),...t})}function Bde(e){return`“${(e==null?void 0:e.name)??(e==null?void 0:e.proxyId)??"这台开发机"}”只会从当前 Relay 的开发机列表中移除。不会删除机器上的文件或会话,也不会阻止它再次连接;以后重新运行时,它会重新出现在列表中。`}function zde({open:e,target:t,removing:n,onOpenChange:r,onConfirm:i}){return m.jsx(es,{open:e,onOpenChange:s=>{n||r(s)},children:m.jsxs(ts,{"data-slot":"proxy-removal-dialog",showCloseButton:!n,onEscapeKeyDown:s=>{n&&s.preventDefault()},onPointerDownOutside:s=>{n&&s.preventDefault()},children:[m.jsxs(ns,{children:[m.jsx($i,{children:"移除离线开发机?"}),m.jsx(Es,{children:Bde(t)})]}),m.jsxs(qs,{children:[m.jsx(vt,{type:"button",variant:"ghost",disabled:n,onClick:()=>r(!1),children:"取消"}),m.jsxs(vt,{type:"button",variant:"destructive",disabled:n||!t,"aria-busy":n||void 0,onClick:i,"data-slot":"proxy-removal-confirm",children:[n&&m.jsx(li,{className:"size-4 animate-spin","aria-hidden":"true"}),n?"正在移除":"移除"]})]})]})})}const ay=80,jde=8,Fde=1.2;function lI(e){return Math.max(0,Math.min(ay,e))}function $de({proxyId:e,name:t,osName:n,selected:r,revealed:i,disabled:s=!1,onRevealedChange:o,onRemove:l}){const u=t??e,d=b.useRef(null),f=b.useRef(!1),[h,y]=b.useState(null),g=h??(i?ay:0),_=h!==null;function w(R){var A,M;if(!(s||R.pointerType!=="touch"&&R.pointerType!=="pen")&&!R.target.closest("button")){d.current={pointerId:R.pointerId,startX:R.clientX,startY:R.clientY,startOffset:i?ay:0,axis:"pending"};try{(M=(A=R.currentTarget).setPointerCapture)==null||M.call(A,R.pointerId)}catch{}}}function S(R){const A=d.current;if(!A||A.pointerId!==R.pointerId)return;const M=R.clientX-A.startX,T=R.clientY-A.startY;if(A.axis==="pending"){if(Math.hypot(M,T)<jde)return;A.axis=Math.abs(M)>Math.abs(T)*Fde?"horizontal":"vertical"}A.axis!=="vertical"&&(R.preventDefault(),y(lI(A.startOffset-M)))}function x(R,A=!1){var P,z;const M=d.current;if(!M||M.pointerId!==R.pointerId)return;d.current=null;try{(z=(P=R.currentTarget).releasePointerCapture)==null||z.call(P,R.pointerId)}catch{}if(M.axis!=="horizontal"||A){y(null);return}R.preventDefault();const T=h??lI(M.startOffset-(R.clientX-M.startX));y(null),o(T>=ay/2),f.current=!0,window.setTimeout(()=>{f.current=!1},0)}function k(R){if(f.current){f.current=!1,R.preventDefault();return}i&&o(!1)}return m.jsxs("li",{className:`relative ${n?"h-14":"h-11"} overflow-hidden rounded-md border border-border bg-card`,"data-slot":"proxy-item","data-swipeable":"true","data-proxy-id":e,"data-online":"false","data-revealed":i||void 0,children:[m.jsxs("div",{className:"relative z-10 flex h-full w-full touch-pan-y select-none items-center gap-3 bg-card px-3 text-left text-muted-foreground transition-transform duration-200 ease-out motion-reduce:transition-none",style:{transform:`translateX(-${g}px)`,transitionDuration:_?"0ms":void 0},title:"这台开发机离线。向左滑动可移除。","data-slot":"proxy-swipe-foreground","data-offset":g,onPointerDown:w,onPointerMove:S,onPointerUp:R=>x(R),onPointerCancel:R=>x(R,!0),onClick:k,children:[m.jsx(k1,{status:"offline"}),m.jsx(Ep,{name:u,osName:n}),r&&m.jsx(ua,{className:"size-4 shrink-0 text-primary","aria-label":"已选"}),m.jsx("span",{className:"shrink-0 text-xs",children:"离线"})]}),m.jsx("button",{type:"button",className:`absolute inset-y-0 right-0 z-0 flex w-20 items-center justify-center bg-destructive text-sm font-medium text-white outline-none transition-colors hover:bg-destructive/90 focus-visible:z-20 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset disabled:pointer-events-none disabled:opacity-50 ${i?"":"pointer-events-none"}`,tabIndex:i?0:-1,disabled:s,"aria-label":`移除 ${u}`,"aria-hidden":i?void 0:!0,"data-slot":"proxy-mobile-remove",onClick:l,children:"移除"})]})}function oF({layout:e,variant:t="default"}){const n=Me(P=>P.proxies),r=Me(P=>P.proxyListLoaded),i=Me(P=>P.relayClientAuthIssue),s=Me(P=>P.selectedProxyId),o=Me(P=>P.proxySwitchTarget),l=ds(),u=Cs(),[d,f]=b.useState(!1),[h,y]=b.useState(null),[g,_]=b.useState(null),[w,S]=b.useState(null);async function x(P,z){if(o)return;const Y=$t;if(!Y){Ue.error("请先连接开发机");return}const U=z??P,G=s!==null&&s!==P;Me.getState().setProxySwitchTarget({proxyId:P,name:U});try{const I=await Y.selectProxy(P);if(!I.success){Ue.error(`无法连接 ${U}:${I.error??"未知错误"}`);return}const N=Y.getPreviewScope();if(!N||N.proxyId!==P||N.bindingId!==I.bindingId)throw Pt.dispose(),Y.clearBoundProxy(),new Error("开发机绑定状态无效,请重试");Pt.activate(Y,N),Pt.syncWebSnapshot(N).catch(L=>{L instanceof Error&&L.name==="AbortError"||console.error("[proxy-switcher] web preview snapshot failed",L)}),Pt.syncDeviceSnapshot(N).catch(L=>{L instanceof Error&&L.name==="AbortError"||console.error("[proxy-switcher] device preview snapshot failed",L)}),G&&(Ut.getState().prepareForProxySwitch(U),qr.getState().prepareForProxySwitch()),Rr("local",_n.proxyId,P),Me.getState().setProxy(P,z??null),Me.getState().setProxyOnline(!0),Me.getState().transitionToPhase("session_browsing"),Y.sendControl({type:"session_list_request"}),Y.requestProxyInfo().then(L=>{if(Me.getState().selectedProxyId!==P||!Pt.isActive(Y,N))return;const B=qr.getState();B.setHomePath(L.homePath),B.setAgentCli(L.agentCli),Me.getState().setTerminalShells(L.terminalShells)}).catch(L=>{Pt.isActive(Y,N)&&console.error("[proxy-switcher] post-bind proxy info fetch failed",L)}),Y.requestAgentStatuses().then(L=>{if(Me.getState().selectedProxyId!==P||!Pt.isActive(Y,N))return;const B=Ut.getState();for(const O of L)B.setAgentStatus(O.sessionId,O.payload)}).catch(L=>{Pt.isActive(Y,N)&&console.error("[proxy-switcher] post-bind data fetch failed",L)}),YC(Y).then(L=>{L.status==="failed"&&console.error("[proxy-switcher] post-bind data fetch failed",L.error)}),f(!1),(e==="page"||l.pathname.startsWith("/chat/")||l.pathname.startsWith("/preview/device/"))&&u("/sessions")}catch(I){const N=I instanceof Error?I.message:"未知错误";Ue.error(`无法连接 ${U}:${N}`)}finally{Me.getState().setProxySwitchTarget(null)}}function k(P){P.online||w||(y(null),_({proxyId:P.proxyId,...P.name?{name:P.name}:{}}))}async function R(){const P=g;if(!P||w)return;const z=$t;if(!z){Ue.error("Relay 连接不可用,请稍后重试");return}const Y=Me.getState().proxies.find(U=>U.proxyId===P.proxyId);if(!Y){if(!Me.getState().proxyListLoaded){Ue.info("正在重新连接 Relay,请稍后再试");return}Sp(P.proxyId,z)&&u("/"),Ue.info("这台开发机已经不在列表中"),_(null);return}if(Y.online){Ue.warning("这台开发机已重新上线,未移除"),_(null);return}S(P.proxyId),Nie(P.proxyId);try{const U=await z.removeOfflineProxy(P.proxyId);if(U.success){Id(P.proxyId),Sp(P.proxyId,z)&&u("/"),Ue.success(`已移除 ${P.name??P.proxyId}`),_(null);return}if(U.errorCode===Ar.PROXY_ONLINE){Id(P.proxyId),Ue.warning("这台开发机已重新上线,未移除"),_(null),z.listProxies();return}if(U.errorCode===Ar.PROXY_NOT_FOUND){Id(P.proxyId),Sp(P.proxyId,z)&&u("/"),Ue.info("这台开发机已经不在列表中"),_(null),z.listProxies();return}Id(P.proxyId),Ue.error(U.error??"无法移除开发机,请重试")}catch(U){Ue.error(U instanceof Error?U.message:"无法移除开发机,请重试"),z.listProxies()}finally{S(null)}}const A=m.jsx(zde,{open:g!==null,target:g,removing:w!==null,onOpenChange:P=>{P||_(null)},onConfirm:()=>void R()});if(e==="page")return i==="missing_client_token"?m.jsx(Jc,{variant:"client-token-missing"}):i==="invalid_client_token"?m.jsx(Jc,{variant:"client-token-invalid"}):r?n.length===0?m.jsx(Jc,{variant:"no-proxy"}):m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"flex h-full flex-col gap-3 overflow-auto p-4",children:[m.jsx("h3",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"开发机"}),m.jsx("ul",{role:"list",className:"flex flex-col gap-2",children:n.map(P=>{const z=(o==null?void 0:o.proxyId)===P.proxyId,Y=o!==null;return P.online?m.jsx("li",{children:m.jsxs("button",{type:"button","data-slot":"proxy-item","data-proxy-id":P.proxyId,"data-online":"true","data-selecting":z||void 0,disabled:Y||w!==null,"aria-busy":z||void 0,onClick:()=>x(P.proxyId,P.name),className:qe("flex min-h-[44px] w-full items-center gap-3 rounded-md border bg-card px-3 text-left transition-colors disabled:cursor-not-allowed disabled:hover:bg-card",P.osName?"h-14":"h-11",z?"border-primary/40 bg-accent text-accent-foreground":"border-border hover:bg-accent",Y&&!z||w!==null?"opacity-50":""),"aria-pressed":s===P.proxyId,children:[m.jsx(k1,{status:"online"}),m.jsx(Ep,{name:P.name??P.proxyId,osName:P.osName}),z?m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:"正在连接"}),m.jsx(li,{className:"size-4 shrink-0 animate-spin text-primary","aria-hidden":!0})]}):s===P.proxyId?m.jsx(ua,{className:"size-4 shrink-0 text-primary","aria-label":"已选"}):null]})},P.proxyId):m.jsx($de,{proxyId:P.proxyId,name:P.name,osName:P.osName,selected:s===P.proxyId,revealed:h===P.proxyId,disabled:Y||w!==null,onRevealedChange:U=>y(U?P.proxyId:null),onRemove:()=>k(P)},P.proxyId)})})]}),A]}):m.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 text-muted-foreground animate-in fade-in-0 duration-200 motion-reduce:animate-none",children:[m.jsx(li,{className:"h-5 w-5 animate-spin","aria-hidden":!0}),m.jsx("p",{className:"text-sm",children:"连接中..."})]});const M=n.find(P=>P.proxyId===s),T=(M==null?void 0:M.name)??(M==null?void 0:M.proxyId)??"未选择开发机";return m.jsxs(m.Fragment,{children:[m.jsxs(Ub,{open:d,onOpenChange:f,children:[m.jsx(Wb,{asChild:!0,children:m.jsxs("button",{type:"button","data-slot":"proxy-switcher-trigger",className:qe("group transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",t==="sidebarChrome"?"inline-flex min-h-9 min-w-0 max-w-full items-center justify-start gap-1.5 rounded-md text-left text-foreground hover:text-primary":"flex min-h-10 w-full items-center gap-2 rounded-md border border-border bg-background px-4 py-1.5 hover:bg-accent"),"aria-label":`当前连接:${T}`,children:[t==="default"&&m.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":!0}),m.jsx(Ep,{name:T,osName:M==null?void 0:M.osName,className:t==="sidebarChrome"?"flex-initial":"text-center",nameClassName:t==="sidebarChrome"?"text-base font-semibold":void 0}),m.jsx(sc,{className:"h-4 w-4 text-muted-foreground shrink-0 transition-transform group-data-[state=open]:rotate-180","aria-hidden":!0})]})}),m.jsx(qb,{align:"start",className:"w-[260px] p-1",children:n.length===0?m.jsx("div",{className:"text-xs text-muted-foreground p-2",children:"暂无可连接开发机"}):m.jsx("ul",{role:"list",className:"flex flex-col",children:n.map(P=>{const z=(o==null?void 0:o.proxyId)===P.proxyId,Y=o!==null;return m.jsxs("li",{className:"group flex min-w-0 items-center rounded-md",children:[m.jsxs("button",{type:"button","data-slot":"proxy-item","data-proxy-id":P.proxyId,"data-online":P.online,"data-selecting":z||void 0,disabled:!P.online||Y,"aria-busy":z||void 0,onClick:()=>x(P.proxyId,P.name),className:qe("flex min-w-0 flex-1 items-center gap-2 rounded-md px-2 text-left transition-colors disabled:cursor-not-allowed disabled:hover:bg-transparent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",P.osName?"h-12":"h-9",z?"bg-accent text-accent-foreground":"hover:bg-accent",Y&&!z?"opacity-50":"",P.online?"":"opacity-50"),"aria-pressed":s===P.proxyId,title:P.online?void 0:"这台开发机离线",children:[m.jsx(k1,{status:P.online?"online":"offline"}),m.jsx(Ep,{name:P.name??P.proxyId,osName:P.osName}),z?m.jsx(li,{className:"h-4 w-4 animate-spin text-primary shrink-0","aria-label":"正在连接"}):s===P.proxyId?m.jsx(ua,{className:"h-4 w-4 text-primary shrink-0","aria-label":"已选"}):null,!P.online&&!z&&m.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:"离线"})]}),!P.online&&m.jsxs(_f,{children:[m.jsx(wf,{asChild:!0,children:m.jsx(vt,{type:"button",variant:"ghost",size:"icon-xs",className:"mr-1 size-8 text-muted-foreground opacity-60 hover:opacity-100 focus-visible:opacity-100",disabled:Y||w!==null,"aria-label":`${P.name??P.proxyId} 操作`,"data-slot":"proxy-row-menu-trigger",children:m.jsx(hb,{"aria-hidden":"true"})})}),m.jsx(xf,{align:"end","data-slot":"proxy-row-menu",children:m.jsxs(Zr,{variant:"destructive","data-slot":"proxy-row-remove-item",onSelect:U=>{U.stopPropagation(),k(P)},children:[m.jsx(Mz,{"aria-hidden":"true"}),"移除开发机"]})})]})]},P.proxyId)})})})]}),A]})}function Hde({delayDuration:e=0,...t}){return m.jsx(yde,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function Sf({...e}){return m.jsx(bde,{"data-slot":"tooltip",...e})}function Ef({...e}){return m.jsx(_de,{"data-slot":"tooltip-trigger",...e})}function Cf({className:e,sideOffset:t=0,children:n,hideArrow:r=!1,...i}){return m.jsx(wde,{children:m.jsxs(xde,{"data-slot":"tooltip-content",sideOffset:t,className:qe("z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-md bg-foreground px-3 py-1.5 text-xs text-balance text-background fade-in-0 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 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",e),...i,children:[n,!r&&m.jsx(Sde,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})}function pc({...e}){return m.jsx(ok,{"data-slot":"sheet",...e})}function Ude({...e}){return m.jsx(gae,{"data-slot":"sheet-trigger",...e})}function Wde({...e}){return m.jsx(ak,{"data-slot":"sheet-portal",...e})}function qde({className:e,...t}){return m.jsx(lk,{"data-slot":"sheet-overlay",className:qe("fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",e),...t})}function mc({className:e,overlayClassName:t,children:n,side:r="right",showCloseButton:i=!0,focusSurfaceOnOpen:s=!1,onOpenAutoFocus:o,inert:l,"aria-disabled":u,...d}){const f=km();return m.jsxs(Wde,{children:[m.jsx(qde,{className:t}),m.jsxs(ck,{"data-slot":"sheet-content",className:qe("fixed z-50 flex flex-col gap-4 bg-background shadow-lg transition ease-in-out data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:animate-in data-[state=open]:duration-500",r==="right"&&"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm",r==="left"&&"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",r==="top"&&"inset-x-0 top-0 h-auto border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",r==="bottom"&&"inset-x-0 bottom-0 h-auto border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",e),onOpenAutoFocus:h=>{o==null||o(h),!(!s||h.defaultPrevented)&&(h.preventDefault(),h.currentTarget.focus({preventScroll:!0}))},inert:f||l?!0:void 0,"aria-disabled":f?!0:u,"data-relay-interaction-blocked":f?"true":void 0,...d,children:[n,i&&m.jsxs(Rb,{"data-slot":"sheet-close",className:"absolute top-2 right-2 flex size-11 items-center justify-center rounded-md opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:pointer-events-none data-[state=open]:bg-secondary",children:[m.jsx(bu,{className:"size-4"}),m.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Eu({className:e,...t}){return m.jsx("div",{"data-slot":"sheet-header",className:qe("flex flex-col gap-1.5 p-4",e),...t})}function gc({className:e,...t}){return m.jsx(J5,{"data-slot":"sheet-title",className:qe("font-semibold text-foreground",e),...t})}function Vb({className:e,...t}){return m.jsx(e3,{"data-slot":"sheet-description",className:qe("text-sm text-muted-foreground",e),...t})}const Vde={claude:"Claude Code",codex:"Codex",kimi:"Kimi Code"},cI=["claude","codex","kimi"];function Yb(e){return Vde[e]}function aF(e,t){return cI.indexOf(e)-cI.indexOf(t)}function qp(e){return e.provider}const T1=60*1e3,R1=60*T1,Yde=24*R1;function lF(e,t=Date.now()){const n=t-e;if(n<T1)return"刚刚";if(n<R1)return`${Math.floor(n/T1)} 分钟前`;if(n<Yde)return`${Math.floor(n/R1)} 小时前`;const r=new Date(e),i=r.getMonth()+1,s=r.getDate(),o=String(r.getHours()).padStart(2,"0"),l=String(r.getMinutes()).padStart(2,"0");return`${i} 月 ${s} 日 ${o}:${l}`}const uI={idle:{dot:"bg-[var(--color-status-success)]",text:"text-[var(--color-status-success)]",label:"空闲"},working:{dot:"bg-[var(--color-status-working)] animate-pulse",text:"text-[var(--color-status-working)]",label:"工作中"},compacting:{dot:"bg-[var(--color-status-compacting)] animate-pulse",text:"text-[var(--color-status-compacting)]",label:"压缩中"},waiting_approval:{dot:"bg-[var(--color-status-warning)]",text:"text-[var(--color-status-warning)]",label:"等待审批"},error:{dot:"bg-[var(--color-status-error)]",text:"text-[var(--color-status-error)]",label:"出错"},terminated:{dot:"bg-muted-foreground",text:"text-muted-foreground",label:"已终止"}};function A1(e){return e.kind!=="terminal"?uI[e.state]:e.state==="terminated"?uI.terminated:e.state==="error"?{dot:"bg-[var(--color-status-error)]",text:"text-[var(--color-status-error)]",label:"已断开"}:{dot:"bg-[var(--color-status-success)]",text:"text-[var(--color-status-success)]",label:"运行中"}}function Kde({session:e}){const t=A1(e);return m.jsx("span",{className:qe("inline-block size-2 rounded-full shrink-0",t.dot),"aria-label":`会话状态:${t.label}`,role:"status"})}function Gde({mode:e}){if(e!=="pty"&&e!=="json")return null;const t=e==="json"?"聊天视图":"终端视图",n=e==="json"?EC:kC;return m.jsx("span",{className:"inline-flex h-5 w-4 shrink-0 items-center justify-center text-muted-foreground",role:"img","aria-label":t,title:t,"data-slot":"session-mode-icon","data-mode":e,children:m.jsx(n,{className:"size-3.5","aria-hidden":"true"})})}function Xde({session:e,selected:t,now:n,onClick:r,onRename:i,onTerminate:s}){const o=qr(w=>w.homePath),l=e.lastActive,u=e.cwd,d=ZC(e.name,o),f=QC(e,o),h=e.nameLocked&&e.name?e.name:f||(d==="New Session"?e.sessionId.slice(0,8):d),y=lF(l,n),g=e.mode==="pty"&&e.ptyOwner==="local-terminal",_=e.kind==="terminal"?"终止终端":g?"断开远程连接":"终止会话";return m.jsxs("li",{className:qe("relative flex items-center gap-2 px-4 py-2 w-full min-w-0 transition-colors","min-h-[44px]","hover:bg-accent",t&&"dev-sidebar-active-row"),"data-slot":"session-row","data-session-id":e.sessionId,"data-selected":t,children:[t&&m.jsx("span",{className:"dev-sidebar-active-indicator absolute left-0 top-0 bottom-0 w-[2px]","aria-hidden":"true"}),m.jsxs("button",{type:"button","data-slot":"session-row-select",onClick:r,className:"flex min-h-11 flex-col justify-center gap-1 flex-1 min-w-0 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm md:min-h-0","aria-pressed":t,children:[m.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[m.jsx(Kde,{session:e}),m.jsx("span",{className:"text-sm font-normal truncate flex-1",title:u,children:h})]}),m.jsxs("span",{className:"flex items-center gap-1.5 text-xs leading-5 h-5",children:[m.jsx(Gde,{mode:e.mode}),m.jsx("span",{className:"text-muted-foreground/60 shrink-0","aria-hidden":"true",children:"·"}),e.kind!=="terminal"&&m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"font-mono text-muted-foreground shrink-0",children:Yb(e.provider)}),m.jsx("span",{className:"text-muted-foreground/60 shrink-0","aria-hidden":"true",children:"·"})]}),m.jsx("span",{className:qe("shrink-0",A1(e).text),children:A1(e).label}),y&&m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"text-muted-foreground/60 shrink-0","aria-hidden":"true",children:"·"}),m.jsx("span",{className:"text-muted-foreground shrink-0 tabular-nums",children:y})]})]})]}),(i||s)&&m.jsxs(_f,{children:[m.jsx(wf,{asChild:!0,children:m.jsx(vt,{variant:"ghost",size:"icon-xs",className:"size-11 md:size-6","aria-label":"会话操作","data-slot":"session-row-menu-trigger",onClick:w=>w.stopPropagation(),children:m.jsx(hb,{"aria-hidden":"true"})})}),m.jsxs(xf,{align:"end","data-slot":"session-row-menu",children:[i&&m.jsx(Zr,{"data-slot":"session-row-rename-item",onSelect:w=>{w.stopPropagation(),i()},children:"重命名"}),s&&m.jsx(Zr,{variant:"destructive","data-slot":"session-row-terminate-item",onSelect:w=>{w.stopPropagation(),s()},children:_})]})]})]})}function yo(e){const[t,n]=b.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(e).matches);return b.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const r=window.matchMedia(e),i=s=>n(s.matches);return n(r.matches),r.addEventListener("change",i),()=>r.removeEventListener("change",i)},[e]),t}function Zde({session:e,now:t,disabled:n,loading:r,onClick:i,modeTag:s}){const o=m.jsx(Qde,{title:e.title,modeTag:s}),l=m.jsx("span",{className:"text-xs text-muted-foreground tabular-nums",children:lF(e.updatedAt,t)}),u=m.jsxs("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[o,l]});return m.jsx("li",{"data-slot":"history-row","data-session-id":e.id,"data-loading":r?"true":void 0,className:"group w-full flex items-stretch",children:m.jsxs("button",{type:"button",onClick:i,disabled:n,"data-slot":"history-row-primary",className:qe("min-w-0 flex-1 flex items-start gap-2 pl-10 pr-4 py-2 min-h-[50px]","text-left transition-colors outline-none","hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring","disabled:opacity-50 disabled:cursor-wait disabled:hover:bg-transparent"),"aria-label":`恢复会话:${e.title}`,children:[u,m.jsx(CV,{className:qe("mt-0.5 size-3.5 shrink-0 text-muted-foreground transition-opacity",r?"animate-pulse opacity-100":"opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100"),"aria-hidden":"true"})]})})}function Qde({title:e,modeTag:t}){return m.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[m.jsx("span",{className:"text-sm font-normal truncate min-w-0",title:e,children:e}),t&&m.jsx(Jde,{mode:t})]})}function Jde({mode:e}){const t=e==="json"?"聊天视图":"终端视图",n=e==="json"?EC:kC;return m.jsx("span",{"data-slot":"history-mode-tag","data-mode":e,role:"img","aria-label":t,title:t,className:qe("inline-flex size-5 shrink-0 items-center justify-center rounded border","border-border bg-muted/50 text-muted-foreground"),children:m.jsx(n,{className:"size-3","aria-hidden":"true"})})}function cF({providerLabel:e}){return m.jsx("div",{className:"grid min-w-0 gap-4","data-slot":"bypass-permission-warning",role:"alert",children:m.jsxs("div",{className:"flex min-w-0 items-start gap-3 text-sm",children:[m.jsx(_K,{className:"mt-0.5 size-5 shrink-0 text-destructive","aria-hidden":"true"}),m.jsxs("div",{className:"grid min-w-0 gap-2",children:[m.jsxs("p",{className:"font-medium text-foreground",children:[e," 将不再请求工具审批。"]}),m.jsx("p",{className:"text-muted-foreground",children:"Agent 可以直接执行命令、修改或删除文件,并可能绕过部分沙箱保护。"})]})]})})}function efe({now:e}){const t=qr(I=>I.homePath),n=Ut(I=>I.historySessions),r=Ut(I=>I.historyLoadStatus),[i,s]=b.useState(null),[o,l]=b.useState(null),[u,d]=b.useState("json"),[f,h]=b.useState("default"),[y,g]=b.useState(!1),[_,w]=b.useState(new Set),[S,x]=b.useState(new Set),k=Cs(),R=b.useMemo(()=>{const I=new Map;for(const N of n){const L=qp(N);let B=I.get(L);B||(B=new Map,I.set(L,B));const O=uF(N.projectDir),D=B.get(O);D?D.sessions.push(N):B.set(O,{dir:O,sessions:[N]})}return Array.from(I.entries()).sort(([N],[L])=>aF(N,L)).map(([N,L])=>({provider:N,sessions:Array.from(L.values()).flatMap(B=>B.sessions),projects:Array.from(L.values()).map(B=>({dir:B.dir,shortDir:pm(B.dir,t,{compact:!0}),sessions:B.sessions}))}))},[n,t]);function A(I){l(I),d(tfe(I)),h(nfe(I))}async function M(I,N,L){if(i)return;const B=$t;if(!B){Ue.error("请先连接开发机");return}s(I.id);const O=qp(I);try{const D=await B.createSession({kind:"agent",cwd:I.projectDir,mode:N,provider:O,resumeSessionId:I.id,...L?{permissionMode:L}:{}});if(!D.success){if(D.errorCode===Ar.SESSION_ALREADY_ACTIVE){Ut.getState().setCodexActiveWriterConflict({...D.activeWriterPid?{activeWriterPid:D.activeWriterPid}:{}}),l(null);return}Ue.error(`恢复失败:${D.error}`);return}if(D.kind!=="agent"){Ue.error("恢复失败:开发机返回了错误的会话类型");return}const F={sessionId:D.sessionId,kind:"agent",...D.name!==void 0?{name:D.name}:{},...D.nameLocked!==void 0?{nameLocked:D.nameLocked}:{},state:"idle",cwd:D.cwd,lastActive:D.lastActive,provider:D.provider},V=D.mode==="pty"?{...F,mode:"pty",ptyOwner:D.ptyOwner}:{...F,mode:"json"};Ut.getState().addSession(V),k(`/chat/${D.sessionId}?mode=${D.mode}`),l(null)}catch(D){Ue.error(`恢复失败:${D instanceof Error?D.message:String(D)}`)}finally{s(null)}}function T(){const I=$t;!I||Ut.getState().historyLoadStatus==="loading"||YC(I).then(N=>{N.status==="failed"&&Ue.error(N.error instanceof Error?N.error.message:String(N.error))})}function P(I,N){const L=dI(I,N);x(B=>{const O=new Set(B);return O.has(L)?O.delete(L):O.add(L),O})}function z(I){w(N=>{const L=new Set(N);return L.has(I)?L.delete(I):L.add(I),L})}const Y=n.length>0,U=r==="loading",G=o?dF():[];return m.jsxs("div",{"data-slot":"history-list",className:"flex flex-col",children:[m.jsxs("div",{className:"flex min-h-11 w-full items-center gap-1.5 px-4 py-1.5 md:min-h-[36px]",children:[m.jsxs("button",{type:"button",onClick:()=>Y&&g(I=>!I),disabled:!Y,"aria-expanded":Y?y:void 0,"data-slot":"history-section-header","data-expanded":y,className:qe("flex min-w-0 flex-1 items-center gap-1.5 rounded-md py-0.5 text-left","transition-colors outline-none","hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring","disabled:cursor-default disabled:hover:text-inherit"),children:[m.jsxs("h3",{className:"min-w-0 text-sm font-semibold text-foreground",children:["全部会话",Y?m.jsxs("span",{className:"ml-1 text-muted-foreground/70 font-normal",children:["· ",n.length]}):null]}),Y?m.jsx(Hd,{className:qe("size-3.5 shrink-0 text-muted-foreground/80 transition-transform",y&&"rotate-90"),"aria-hidden":"true"}):null]}),m.jsx(vt,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"刷新全部会话","aria-busy":U,title:U?"正在加载":"刷新",onClick:T,disabled:U,"data-slot":"history-refresh",className:"size-11 md:size-8",children:m.jsx(um,{className:qe("size-3.5",U&&"animate-spin motion-reduce:animate-none"),"aria-hidden":"true"})})]}),!Y&&U&&m.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 text-sm text-muted-foreground/80","data-slot":"history-loading",role:"status","aria-live":"polite",children:[m.jsx(li,{className:"size-3.5 shrink-0 animate-spin motion-reduce:animate-none","aria-hidden":"true"}),m.jsx("span",{children:"正在加载会话记录..."})]}),!Y&&r==="idle"&&m.jsx("div",{className:"px-4 py-3 text-sm text-muted-foreground/80","data-slot":"history-idle",role:"status",children:"会话记录尚未加载"}),!Y&&r==="error"&&m.jsx("div",{className:"px-4 py-3 text-sm text-muted-foreground/80","data-slot":"history-error",role:"status",children:"会话记录加载失败,请点击刷新重试"}),Y&&r==="error"&&m.jsx("div",{className:"px-4 pb-2 text-xs text-muted-foreground/80","data-slot":"history-stale",role:"status",children:"刷新失败,当前显示上次加载的结果"}),!Y&&r==="loaded"&&m.jsx("div",{className:"px-4 py-3 text-sm text-muted-foreground/70","data-slot":"history-empty",children:"暂无会话记录"}),Y&&y&&m.jsx("ul",{role:"list",className:"flex flex-col",children:R.map(I=>{const N=_.has(I.provider);return m.jsxs("li",{children:[m.jsxs("button",{type:"button",onClick:()=>z(I.provider),"aria-expanded":!N,"data-slot":"history-provider-header","data-expanded":!N,className:qe("w-full flex items-center gap-2 px-4 pt-2 pb-1 min-h-[32px]","text-xs text-muted-foreground text-left transition-colors outline-none","hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring"),children:[m.jsx("span",{className:"font-mono",children:Yb(I.provider)}),m.jsx("span",{className:"h-px flex-1 bg-border/70","aria-hidden":"true"}),m.jsx("span",{className:"tabular-nums",children:I.sessions.length}),m.jsx(Hd,{className:qe("size-3.5 shrink-0 text-muted-foreground/80 transition-transform",!N&&"rotate-90"),"aria-hidden":"true"})]}),!N&&m.jsx("ul",{role:"list",className:"flex flex-col",children:I.projects.map(L=>{const B=dI(I.provider,L.dir),O=S.has(B);return m.jsxs("li",{children:[m.jsxs("button",{type:"button",onClick:()=>P(I.provider,L.dir),"aria-expanded":O,"data-slot":"history-group-header","data-expanded":O,className:qe("w-full flex items-center gap-1.5 pl-6 pr-4 py-2 min-h-[36px]","text-left transition-colors outline-none","hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring"),children:[m.jsx("span",{className:"text-sm font-mono truncate flex-1 min-w-0",title:L.dir,children:L.shortDir}),m.jsx("span",{className:"text-xs text-muted-foreground/80 tabular-nums shrink-0",children:L.sessions.length}),m.jsx(Hd,{className:qe("size-3.5 shrink-0 text-muted-foreground/80 transition-transform",O&&"rotate-90"),"aria-hidden":"true"})]}),O&&m.jsx("ul",{role:"list",className:"flex flex-col",children:L.sessions.map(D=>m.jsx(Zde,{session:D,now:e,disabled:i!==null,loading:i===D.id,onClick:()=>A(D),modeTag:D.preferredMode},D.id))})]},B)})})]},I.provider)})}),m.jsx(rfe,{session:o,open:o!==null,modes:G,mode:u,permissionMode:f,submitting:i!==null,onOpenChange:I=>{I||l(null)},onModeChange:d,onPermissionModeChange:h,onConfirm:()=>{o&&M(o,u,f)}})]})}function dI(e,t){return`${e}:${uF(t)}`}function uF(e){const t=e.trim();return!t||t==="/"?t||"/":t.replace(/\/+$/,"")||"/"}function dF(){return["json","pty"]}function tfe(e){const t=dF();return e.preferredMode&&t.includes(e.preferredMode)?e.preferredMode:t[0]??"json"}function nfe(e){return qp(e)==="codex"?"auto":"default"}function rfe({session:e,open:t,modes:n,mode:r,permissionMode:i,submitting:s,onOpenChange:o,onModeChange:l,onPermissionModeChange:u,onConfirm:d}){const[f,h]=b.useState(!1),y=i==="bypassPermissions",g=yo("(min-width: 768px)"),_=e?qp(e):null,w=_==="codex",S=_==="kimi";b.useEffect(()=>{t||h(!1)},[t]);const x=f?m.jsx(cF,{providerLabel:e?Yb(qp(e)):"Agent"}):m.jsxs("div",{className:"grid min-w-0 gap-4",children:[m.jsxs("div",{className:"grid min-w-0 gap-2",children:[m.jsx("span",{className:"text-sm font-medium",children:"模式"}),m.jsxs("div",{role:"radiogroup","aria-label":"恢复模式",className:"grid min-w-0 grid-cols-2 gap-2",children:[n.includes("json")&&m.jsx(fI,{checked:r==="json",label:"聊天",icon:m.jsx(EC,{className:"size-4","aria-hidden":"true"}),disabled:s,onClick:()=>l("json")}),n.includes("pty")&&m.jsx(fI,{checked:r==="pty",label:"终端",icon:m.jsx(kC,{className:"size-4","aria-hidden":"true"}),disabled:s,onClick:()=>l("pty")})]})]}),m.jsxs("div",{className:"grid min-w-0 gap-2",children:[m.jsx("span",{className:"text-sm font-medium",children:"权限模式"}),m.jsxs("div",{role:"radiogroup","aria-label":"权限模式",className:"grid min-w-0 gap-2",children:[!w&&m.jsx(yv,{checked:i==="default",label:S?"手工审批":"严格审批",description:S?"工具调用会在 Web 中请求确认。":"所有需要权限的操作都要确认。",disabled:s,onClick:()=>u("default")}),m.jsx(yv,{checked:i==="auto",label:w?"按需审批":S?"自动审批":"自动判定",description:w?"Codex 在需要时请求确认。":S?"Kimi Code 使用原生 yolo 模式自动审批。":"交给 Agent CLI 的原生策略判断。",disabled:s,onClick:()=>u("auto")}),S&&m.jsx(yv,{checked:i==="plan",label:"只读规划",description:"Kimi Code 使用只读规划模式。",disabled:s,onClick:()=>u("plan")}),m.jsx(yv,{checked:i==="bypassPermissions",label:S?"全自动":"跳过全部审批",description:S?"危险模式,Kimi Code 将全自动执行。":"危险模式,会跳过工具审批和部分沙箱保护。",destructive:!0,disabled:s,onClick:()=>u("bypassPermissions")})]})]})]}),k=m.jsxs(m.Fragment,{children:[m.jsx(vt,{type:"button",variant:"ghost",disabled:s,onClick:()=>{f?h(!1):o(!1)},children:f?"返回":"取消"}),m.jsx(vt,{type:"button",variant:f?"destructive":"default",disabled:s,onClick:()=>{if(y&&!f){h(!0);return}d()},"data-slot":f?"bypass-permission-confirm":void 0,children:s?"恢复中...":f?"确认":"恢复"})]});return g?m.jsx(es,{open:t,onOpenChange:o,children:m.jsxs(ts,{focusSurfaceOnOpen:!0,className:"min-w-0 sm:max-w-md","data-slot":"history-restore-dialog",children:[m.jsxs(ns,{className:"min-w-0",children:[m.jsx($i,{children:f?"跳过全部审批?":"恢复会话"}),m.jsx(Es,{className:"min-w-0 truncate pr-10 sm:pr-0",title:e==null?void 0:e.title,children:(e==null?void 0:e.title)??""})]}),x,m.jsx(qs,{children:k})]})}):m.jsx(pc,{open:t,onOpenChange:o,children:m.jsxs(mc,{side:"bottom",focusSurfaceOnOpen:!0,className:"inset-x-2 w-auto max-h-[calc(100dvh-0.75rem)] min-w-0 overflow-hidden rounded-t-xl border bg-background p-0","data-slot":"history-restore-dialog",children:[m.jsxs(Eu,{className:"min-w-0 shrink-0 px-4 pb-2 pt-4 text-left",children:[m.jsx(gc,{children:f?"跳过全部审批?":"恢复会话"}),m.jsx(Vb,{className:"min-w-0 truncate pr-10",title:e==null?void 0:e.title,children:(e==null?void 0:e.title)??""})]}),m.jsx("div",{className:"min-h-0 overflow-y-auto px-4 pb-3","data-slot":"history-restore-body",children:x}),m.jsx("div",{className:"shrink-0 border-t border-border/70 bg-background px-4 pb-[max(theme(spacing.4),env(safe-area-inset-bottom))] pt-3","data-slot":"history-restore-footer",children:m.jsx("div",{className:"flex flex-col-reverse gap-2 [&_button]:min-h-11 [&_button]:w-full",children:k})})]})})}function fI({checked:e,label:t,icon:n,disabled:r,onClick:i}){return m.jsxs("button",{type:"button",role:"radio","aria-label":t,"aria-checked":e,disabled:r,onClick:i,className:qe("grid min-h-11 w-full min-w-0 max-w-full grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2 rounded-md border px-3 text-sm outline-none transition-colors md:h-10 md:min-h-0","focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-wait disabled:opacity-60",e?"border-primary text-foreground":"border-border text-muted-foreground hover:bg-accent/60 hover:text-foreground"),children:[n,m.jsx("span",{className:"min-w-0 text-center",children:t}),m.jsx(ua,{className:qe("size-3.5 justify-self-end transition-opacity",e?"opacity-100":"opacity-0"),"aria-hidden":"true"})]})}function yv({checked:e,label:t,description:n,destructive:r,disabled:i,onClick:s}){return m.jsxs("button",{type:"button",role:"radio","aria-label":t,"aria-checked":e,disabled:i,onClick:s,className:qe("grid w-full min-w-0 max-w-full grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-3 rounded-md border p-3 text-left outline-none transition-colors","focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-wait disabled:opacity-60",e?r?"border-destructive/70":"border-primary":"border-border hover:bg-accent/60"),children:[m.jsx("span",{className:qe("mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full border",e?r?"border-destructive":"border-primary":"border-muted-foreground/50"),"aria-hidden":"true",children:e&&m.jsx("span",{className:qe("size-2 rounded-full",r?"bg-destructive":"bg-primary")})}),m.jsxs("span",{className:"grid min-w-0 gap-1",children:[m.jsx("span",{className:qe("text-sm font-medium",r?"text-destructive":"text-foreground"),children:t}),m.jsx("span",{className:"min-w-0 break-words text-xs leading-5 text-muted-foreground",children:n})]}),e&&m.jsx(ua,{className:qe("mt-0.5 size-4 shrink-0",r?"text-destructive":"text-primary"),"aria-hidden":"true"})]})}function Kb({...e}){return m.jsx(que,{"data-slot":"select",...e})}function Gb({...e}){return m.jsx(Yue,{"data-slot":"select-value",...e})}function Xb({className:e,size:t="default",children:n,...r}){return m.jsxs(Vue,{"data-slot":"select-trigger","data-size":t,className:qe("flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/75 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",e),...r,children:[n,m.jsx(Kue,{asChild:!0,children:m.jsx(sc,{className:"size-4 opacity-50"})})]})}function Zb({className:e,children:t,position:n="item-aligned",align:r="center",inert:i,"aria-disabled":s,...o}){const l=km();return m.jsx(Gue,{children:m.jsxs(Xue,{"data-slot":"select-content",className:qe("relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,align:r,inert:l||i?!0:void 0,"aria-disabled":l?!0:s,"data-relay-interaction-blocked":l?"true":void 0,...o,children:[m.jsx(ife,{}),m.jsx(Zue,{className:qe("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),m.jsx(sfe,{})]})})}function Qb({className:e,children:t,...n}){return m.jsxs(Que,{"data-slot":"select-item",className:qe("relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...n,children:[m.jsx("span",{"data-slot":"select-item-indicator",className:"absolute right-2 flex size-3.5 items-center justify-center",children:m.jsx(ede,{children:m.jsx(ua,{className:"size-4"})})}),m.jsx(Jue,{children:t})]})}function ife({className:e,...t}){return m.jsx(tde,{"data-slot":"select-scroll-up-button",className:qe("flex cursor-default items-center justify-center py-1",e),...t,children:m.jsx(wC,{className:"size-4"})})}function sfe({className:e,...t}){return m.jsx(nde,{"data-slot":"select-scroll-down-button",className:qe("flex cursor-default items-center justify-center py-1",e),...t,children:m.jsx(sc,{className:"size-4"})})}function ofe(e,t,n){var u;if(t==="insert"){const d=e.split("@").pop()??"",f=au((n==null?void 0:n.baseCwd)??d)==="\\",h=Math.max(d.lastIndexOf("/"),f?d.lastIndexOf("\\"):-1);return{currentPath:h>=0?d.slice(0,h+1):f?".\\":"./",query:d.slice(h+1).toLowerCase()}}const r=oa((n==null?void 0:n.baseCwd)??"");if(!e)return{currentPath:fo(r),query:""};const i=bb(r,e);if(!i)return{currentPath:"",query:""};const s=qC(i),o=au(i);return e.endsWith("/")||o==="\\"&&e.endsWith("\\")||i===s||i===r||((u=n==null?void 0:n.knownDirs)==null?void 0:u.has(i))?{currentPath:fo(i),query:""}:{currentPath:fo(s),query:i.slice(i.lastIndexOf(o)+1).toLowerCase()}}function y0(e,t){return bb(e,t)}const fF=b.forwardRef(function({filter:t,onSelect:n,onNavigate:r,onSelectCurrentDirectory:i,onCreateDirectory:s,mode:o="insert",placement:l="floating",dirsOnly:u=!1,fileExtensions:d,includeHidden:f=!1,autoHighlightFirst:h=!0,title:y},g){const _=qr(ye=>f?ye.treeWithHidden:ye.tree),w=qr(ye=>ye.cwd),S=qr(ye=>ye.homePath),x=o==="insert"?w:S||w,k=b.useMemo(()=>new Set(_.keys()),[_]),R=b.useMemo(()=>ofe(t,o,{baseCwd:x,knownDirs:k}),[t,o,x,k]),A=R.currentPath,M=b.useMemo(()=>y0(x,A),[x,A]),T=R.query,P=b.useRef(new Map),[z,Y]=b.useState(!1),[U,G]=b.useState(""),[I,N]=b.useState(!1),[L,B]=b.useState(null),[O,D]=b.useState(0);b.useEffect(()=>{if(!M)return;const ye=`${f?"hidden":"default"}\0${M}`;if(_.has(M))return;const Re=$t;if(!Re)return;let Rt=!1;B(et=>(et==null?void 0:et.path)===M?null:et);let Ke=P.current.get(ye);if(!Ke){Ke=Re.requestDirectoryList(M,{includeHidden:f}),P.current.set(ye,Ke);const et=()=>{P.current.get(ye)===Ke&&P.current.delete(ye)};Ke.then(et,et)}return Ke.then(et=>{if(!Rt){if(et.error!==void 0||et.errorCode!==void 0){B({path:M,message:et.error||"读取失败"});return}qr.getState().setDirEntries(et.path,et.entries,et.includeHidden)}},et=>{Rt||B({path:M,message:et instanceof Error?et.message:"读取失败"})}),()=>{Rt=!0}},[M,f,_,O]);const F=(L==null?void 0:L.path)===M?L:null,V=!_.has(M)&&!F,j=b.useMemo(()=>d==null?void 0:d.map(ye=>ye.startsWith(".")?ye.toLowerCase():`.${ye.toLowerCase()}`),[d]),q=b.useMemo(()=>{let ye=_.get(M)??[];return u?ye=ye.filter(Re=>Re.isDir):j!=null&&j.length&&(ye=ye.filter(Re=>Re.isDir||j.some(Rt=>Re.name.toLowerCase().endsWith(Rt)))),T&&(ye=ye.filter(Re=>Re.name.toLowerCase().includes(T))),ye},[_,M,T,u,j]),[K,$]=b.useState(h?0:-1);b.useEffect(()=>$(h?0:-1),[h,A,T]),b.useEffect(()=>{Y(!1),G("")},[M]),b.useEffect(()=>{K>=q.length&&q.length>0&&$(q.length-1)},[q.length,K]);const te=b.useRef(null),J=b.useRef(!1);b.useEffect(()=>{var Re;if(!J.current)return;J.current=!1;const ye=(Re=te.current)==null?void 0:Re.querySelector(`[data-entry-index="${K}"]`);ye==null||ye.scrollIntoView({block:"nearest"})},[K]);const ne=b.useCallback(ye=>{const Re=au(x),Rt=`${fo(A,x)}${ye.name}${ye.isDir?Re:""}`;if(o==="insert")return Rt.replace(Re==="\\"?/^\.[\\/]/:/^\.\//,"");const Ke=y0(x,Rt);return ye.isDir?fo(Ke):Ke},[x,A,o]),Q=b.useCallback(ye=>{const Re=y0(x,ye);if(!Re)return;const Rt=fo(Re);if(o==="select"){r(Rt);return}n(Rt)},[x,o,r,n]),ce=b.useCallback(ye=>{const Re=ne(ye);if(ye.isDir){Q(Re);return}n(Re)},[ne,Q,n]);async function re(){const ye=l2(M,U);if(!(!ye||!s)){N(!0);try{const Re=await s(ye);if(!Re)return;if(G(""),Y(!1),i){i(fo(Re));return}Q(Re)}finally{N(!1)}}}b.useImperativeHandle(g,()=>({handleKey(ye){return q.length===0?!1:ye.key==="ArrowDown"?(J.current=!0,$(Re=>Math.min(q.length-1,Re+1)),!0):ye.key==="ArrowUp"?(J.current=!0,$(Re=>Math.max(0,Re-1)),!0):ye.key==="Enter"&&K>=0&&!ye.nativeEvent.isComposing?(ce(q[K]),!0):!1}}),[q,K,ce]);const le=b.useMemo(()=>qC(M),[M]),we=l==="inline"?"relative w-full bg-popover border border-border rounded-md overflow-hidden":o==="insert"?"absolute bottom-full left-0 right-0 z-50 mb-2 bg-popover border border-border rounded-md shadow-lg overflow-hidden":"absolute left-0 right-0 top-full z-50 mt-2 bg-popover border border-border rounded-md shadow-lg overflow-hidden",Ce=l==="inline"?"max-h-[min(11rem,30dvh)] overflow-y-auto overscroll-contain":o==="select"?"max-h-44 overflow-y-auto overscroll-contain":"max-h-60 overflow-y-auto overscroll-contain";return m.jsxs("div",{className:we,"data-slot":"file-path-picker","data-mode":o,"data-placement":l,children:[o==="select"?m.jsxs("div",{className:"border-b border-border/70 px-3 py-2",children:[m.jsxs("div",{className:"min-w-0",children:[y?m.jsx("p",{className:"mb-2 truncate text-xs text-muted-foreground","data-slot":"file-path-picker-title",children:y}):null,m.jsx("p",{className:"truncate font-mono text-xs text-foreground","data-slot":"file-path-picker-current-directory",title:M,children:pm(M,S)||"正在读取路径"})]}),m.jsxs("div",{className:"mt-1 flex items-center justify-between gap-2",role:"toolbar","aria-label":"路径操作","data-slot":"file-path-picker-actions",children:[m.jsx("button",{type:"button","data-slot":"file-path-picker-parent",className:"inline-flex min-h-11 min-w-11 items-center justify-start px-0 text-xs font-medium text-primary hover:underline focus-visible:underline focus-visible:outline-none disabled:cursor-not-allowed disabled:text-muted-foreground disabled:no-underline md:min-h-8 md:min-w-0",disabled:!M||M===le,onClick:()=>Q(le),children:"上一级"}),i||s?m.jsxs("span",{className:"flex shrink-0 items-center gap-4",children:[s?m.jsx("button",{type:"button","data-slot":"file-path-picker-create-directory-toggle",className:"inline-flex min-h-11 min-w-11 items-center justify-center px-0 text-xs font-medium text-primary hover:underline focus-visible:underline focus-visible:outline-none disabled:cursor-not-allowed disabled:text-muted-foreground disabled:no-underline md:min-h-8 md:min-w-0",disabled:!M||I,onClick:()=>Y(ye=>!ye),children:"新建目录"}):null,i?m.jsx("button",{type:"button","data-slot":"select-current-directory",className:"inline-flex min-h-11 min-w-11 items-center justify-center px-0 text-xs font-medium text-primary hover:underline focus-visible:underline focus-visible:outline-none disabled:cursor-not-allowed disabled:text-muted-foreground disabled:no-underline md:min-h-8 md:min-w-0",disabled:!M,onClick:()=>i(fo(M)),children:"选定"}):null]}):null]}),z?m.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[m.jsx("input",{type:"text","data-slot":"file-path-picker-create-directory-name",value:U,onChange:ye=>G(ye.target.value),onKeyDown:ye=>{ye.key==="Enter"&&!ye.nativeEvent.isComposing&&(ye.preventDefault(),re()),ye.key==="Escape"&&(Y(!1),G(""))},placeholder:"目录名称",className:"min-h-11 min-w-0 flex-1 rounded-md border border-border bg-input px-2 text-base outline-none focus-visible:ring-2 focus-visible:ring-ring md:h-8 md:min-h-0 md:text-sm",autoComplete:"off",autoCorrect:"off",spellCheck:!1}),m.jsx("button",{type:"button","data-slot":"file-path-picker-create-directory-submit",className:"min-h-11 rounded-md bg-primary px-3 text-sm text-primary-foreground disabled:cursor-not-allowed disabled:opacity-50 md:h-8 md:min-h-0",disabled:!l2(M,U)||I,onClick:()=>void re(),children:I?"创建中...":"创建目录"})]}):null]}):null,m.jsx("div",{className:Ce,"data-slot":"file-path-picker-entries",children:F?m.jsxs("div",{"data-slot":"file-path-picker-error",className:"flex items-center justify-between gap-3 px-3 py-2",role:"alert",children:[m.jsx("span",{className:"min-w-0 text-xs text-destructive",title:F.message,children:"无法读取这个文件夹"}),m.jsx("button",{type:"button","data-slot":"file-path-picker-retry",className:"shrink-0 rounded px-2 py-1 text-xs text-primary hover:bg-primary/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>D(ye=>ye+1),children:"重试"})]}):q.length===0?m.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:V?"加载中...":"没有匹配的路径"}):m.jsx("ul",{ref:te,role:"list",className:"flex flex-col",children:q.map((ye,Re)=>m.jsx("li",{children:m.jsx("button",{type:"button",onClick:()=>ce(ye),onMouseEnter:()=>$(Re),className:qe("w-full flex min-h-11 items-center gap-2 px-3 py-2 text-sm text-left transition-colors md:h-9 md:min-h-0 md:py-0",Re===K&&"bg-[color-mix(in_srgb,var(--primary)_15%,transparent)]",ye.isDir&&"font-semibold"),"data-slot":"file-entry","data-entry-type":ye.isDir?"dir":"file","data-entry-name":ye.name,"data-entry-index":Re,children:m.jsxs("span",{className:"font-mono text-[13px]",children:[ye.name,ye.isDir?"/":""]})})},ye.name))})})]})});function hI(e,t,n){const r=ly(e,t);return r?n==="file"?fo(qC(r)):r:t}function ly(e,t){const n=oa(e,t);return n?e.endsWith("/")||au(n)==="\\"&&e.endsWith("\\")?fo(n):n:""}function Nk({value:e,onValueChange:t,selectionKind:n,fileExtensions:r,includeHidden:i=!1,onCreateDirectory:s,disabled:o=!1,placeholder:l="选择路径",label:u,labelActions:d,id:f,name:h,required:y,autoFocus:g,"aria-describedby":_,"aria-invalid":w,"data-slot":S,className:x,onKeyDown:k}){const R=b.useId(),A=f??`remote-path-${R}`,M=`${A}-label`,T=qr(J=>J.homePath),P=yo("(pointer: coarse), (hover: none)"),z=pf().deviceKind,Y=P||z==="phone"||z==="tablet",[U,G]=b.useState(!1),[I,N]=b.useState(()=>hI(e,T,n)),[L,B]=b.useState(e),O=b.useRef(null),D=b.useRef(null);b.useEffect(()=>{U||L===e||B(e)},[L,U,e]),b.useEffect(()=>{if(!U)return;function J(ne){const Q=O.current,ce=ne.target;Q&&(ne.composedPath().includes(Q)||ce instanceof Node&&Q.contains(ce))||(G(!1),B(e))}return document.addEventListener("click",J),()=>document.removeEventListener("click",J)},[U,e]),b.useEffect(()=>{o&&(G(!1),B(e))},[o,e]);const F=n!=="file";function V(){if(o)return;const J=hI(e,T,n);N(J),B(e),G(!0)}function j(){G(!1),B(e)}function q(J){const ne=ly(J,T);ne&&(N(ne),B(ne),t(ne),G(!1))}function K(J){const ne=ly(J,T);ne&&N(ne)}function $(J){var ne;if(U&&((ne=D.current)!=null&&ne.handleKey(J))){J.preventDefault();return}if(J.key==="Escape"&&U){J.preventDefault(),j();return}k==null||k(J)}const te=U?m.jsx("div",{className:qe(Y&&"mt-2"),"data-slot":"remote-path-browser",children:m.jsx(fF,{ref:D,mode:"select",placement:Y?"inline":"floating",filter:I,dirsOnly:n==="directory",fileExtensions:r,includeHidden:i,autoHighlightFirst:!Y,title:l,onNavigate:K,onSelect:q,onSelectCurrentDirectory:F?q:void 0,onCreateDirectory:s})}):null;return m.jsxs("div",{className:qe("flex min-w-0 flex-col gap-1",x),children:[m.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[m.jsx("span",{id:M,className:"min-w-0 text-sm",children:u}),d?m.jsx("div",{className:"flex shrink-0 items-center gap-4",children:d}):null]}),m.jsx("div",{ref:O,className:"relative min-w-0",onBlur:J=>{if(!U||Y)return;const ne=J.relatedTarget;ne instanceof Node&&J.currentTarget.contains(ne)||window.setTimeout(()=>{var Q;(Q=O.current)!=null&&Q.contains(document.activeElement)||j()},0)},children:Y?m.jsxs(m.Fragment,{children:[m.jsxs("button",{id:A,type:"button","aria-labelledby":M,"aria-describedby":_,"aria-invalid":w,"aria-expanded":U,"aria-controls":`${A}-browser`,disabled:o,"data-slot":S,"data-path-control":"button",onClick:()=>{U?j():V()},className:"flex min-h-11 w-full min-w-0 items-center gap-2 rounded-md border border-border bg-input px-3 text-left text-base outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60",children:[m.jsx(bY,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),m.jsx("span",{className:qe("min-w-0 flex-1 truncate font-mono",e?"text-foreground":"text-muted-foreground"),title:e||void 0,children:pm(e,T)||l})]}),h?m.jsx("input",{type:"hidden",name:h,value:e,required:y}):null,m.jsx("div",{id:`${A}-browser`,children:te})]}):m.jsxs(m.Fragment,{children:[m.jsx("input",{id:A,type:"text","aria-labelledby":M,"aria-describedby":_,"aria-invalid":w,name:h,required:y,autoFocus:g,autoComplete:"off",autoCorrect:"off",spellCheck:!1,disabled:o,value:L,"data-slot":S,"data-path-control":"input",onFocus:V,onChange:J=>{const ne=J.target.value,Q=ly(ne,T);B(ne),N(Q||T),t(Q||ne),G(!0)},onKeyDown:$,placeholder:l,className:"min-h-11 min-w-0 w-full rounded-md border border-border bg-input px-3 font-mono text-base outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60 md:h-9 md:min-h-0 md:text-sm"}),te]})})]})}const pI="工作目录不存在或不可访问:",afe=[{value:"default",label:"严格审批"},{value:"auto",label:"自动判定"},{value:"acceptEdits",label:"自动接受编辑"},{value:"plan",label:"只读规划"},{value:"bypassPermissions",label:"跳过全部审批"}],hF=[{value:"auto",label:"按需审批"},{value:"bypassPermissions",label:"跳过全部审批"}],pF=[{value:"default",label:"手工审批"},{value:"auto",label:"自动审批"},{value:"plan",label:"只读规划"},{value:"bypassPermissions",label:"全自动"}],Vp={claude:"Claude Code",codex:"Codex",kimi:"Kimi Code"};function lfe(e,t){return t!==Ar.PATH_NOT_FOUND||!e.startsWith(pI)?null:e.slice(pI.length).trim()||null}function mF(e,t){if(!t)return{label:"检测中",disabled:!0};const n=t[e];return n.available?{label:"可用",disabled:!1,title:n.command}:{label:"未找到",disabled:!0,title:n.error}}function cfe(e,t){return e==="codex"?hF.some(n=>n.value===t)?t:"auto":e==="kimi"?pF.some(n=>n.value===t)?t:"default":t}async function ufe({relay:e,agentCli:t,form:n,timeoutMs:r=UC}){var d,f;const i=n.cwd.trim();if(!i)return{type:"validation_error",message:"请输入工作目录"};if(!e)return{type:"relay_missing",message:"请先连接开发机"};if(mF(n.provider,t).disabled){const h=(d=t==null?void 0:t[n.provider])==null?void 0:d.error;return{type:"provider_unavailable",message:h?`${Vp[n.provider]} 不可用:${h}`:`${Vp[n.provider]} 暂不可用`}}const o=n.mode,l=n.provider,u=n.name.trim();try{const h=await e.createSession({kind:"agent",cwd:i,name:u||void 0,mode:o,provider:l,permissionMode:n.permissionMode},r);if(!h.success){const w=lfe(h.error,h.errorCode);return w?{type:"missing_cwd",path:w,message:"找不到这个工作目录"}:{type:"create_error",message:`创建失败:${h.error}`}}if(h.kind!=="agent")return{type:"create_error",message:"创建失败:开发机返回了错误的会话类型"};const y=((f=h.name)==null?void 0:f.trim())||void 0,g={sessionId:h.sessionId,kind:"agent",name:y,...h.nameLocked!==void 0?{nameLocked:h.nameLocked}:{},state:"idle",cwd:h.cwd,lastActive:h.lastActive,provider:h.provider};return{type:"success",session:h.mode==="pty"?{...g,mode:"pty",ptyOwner:h.ptyOwner}:{...g,mode:"json"},route:`/chat/${h.sessionId}?mode=${h.mode}`}}catch(h){return{type:"exception",message:h instanceof Error?h.message:String(h)}}}async function dfe({relay:e,shell:t,timeoutMs:n=UC}){var r;if(!e)return{type:"relay_missing",message:"请先连接开发机"};try{const i=await e.createSession({kind:"terminal",mode:"pty",...t?{shell:t}:{}},n);return i.success?i.kind!=="terminal"?{type:"create_error",message:"创建终端失败:开发机返回了错误的会话类型"}:{type:"success",session:{sessionId:i.sessionId,kind:"terminal",name:((r=i.name)==null?void 0:r.trim())||void 0,...i.shellFamily!==void 0?{shellFamily:i.shellFamily}:{},...i.nameLocked!==void 0?{nameLocked:i.nameLocked}:{},state:"idle",cwd:i.cwd,lastActive:i.lastActive,mode:"pty",provider:i.provider,ptyOwner:i.ptyOwner},route:`/chat/${i.sessionId}?mode=pty`}:{type:"create_error",message:`创建终端失败:${i.error}`}}catch(i){return{type:"exception",message:i instanceof Error?i.message:String(i)}}}const ffe=["claude","codex","kimi"];function hfe({agentCli:e,provider:t,cliPathDraftProvider:n,cliPathDraft:r,savingCliPath:i,onProviderChange:s,onCliPathDraftChange:o,onDiscardCliPathDraft:l,onSaveCliPath:u}){const d=e==null?void 0:e[t],f=(d==null?void 0:d.command)??"",h=n===t,y=h?r:f,g=h&&r.trim()!==f;return m.jsxs("section",{"aria-label":"Agent CLI",className:"flex min-w-0 flex-col gap-2",children:[m.jsx("span",{className:"text-sm",children:"Agent CLI"}),m.jsxs(Kb,{value:t,disabled:i,onValueChange:_=>s(_),children:[m.jsx(Xb,{className:"min-h-11 w-full md:min-h-0","aria-label":"Agent CLI","data-slot":"agent-cli-provider-select",children:m.jsx(Gb,{})}),m.jsx(Zb,{"data-slot":"agent-cli-provider-options",children:ffe.map(_=>m.jsx(Qb,{value:_,className:"min-h-11 md:min-h-0",children:Vp[_]},_))})]}),m.jsxs("div",{className:"relative min-w-0","data-slot":"agent-cli-path-card",children:[m.jsx(Nk,{id:`agent-cli-path-${t}`,"data-slot":"agent-cli-path",label:"CLI 路径",value:y,onValueChange:_=>o(t,_),selectionKind:"file",includeHidden:!0,disabled:i,placeholder:"选择 CLI 可执行文件",labelActions:g?m.jsxs("div",{className:"flex items-center gap-4","data-slot":"agent-cli-path-actions",children:[m.jsx("button",{type:"button",className:"inline-flex min-h-11 min-w-11 items-center justify-center px-0 text-xs font-medium text-muted-foreground hover:underline focus-visible:underline focus-visible:outline-none disabled:cursor-not-allowed disabled:no-underline md:min-h-8 md:min-w-0",onClick:l,disabled:i,children:"取消"}),m.jsx("button",{type:"button",className:"inline-flex min-h-11 min-w-11 items-center justify-center px-0 text-xs font-medium text-primary hover:underline focus-visible:underline focus-visible:outline-none disabled:cursor-not-allowed disabled:text-muted-foreground disabled:no-underline md:min-h-8 md:min-w-0",onClick:u,disabled:i||!r.trim(),children:i?"保存中...":"保存"})]}):void 0,onKeyDown:_=>{_.key==="Enter"&&g&&(_.preventDefault(),_.stopPropagation(),u()),_.key==="Escape"&&h&&(_.preventDefault(),_.stopPropagation(),l())}},t),d!=null&&d.error&&!g?m.jsx("p",{className:"mt-1 break-all text-xs text-destructive",children:d.error}):null]})]})}function lp({open:e,onOpenChange:t}){var Q;const[n,r]=b.useState(""),[i,s]=b.useState(""),[o,l]=b.useState("claude"),[u,d]=b.useState("pty"),[f,h]=b.useState("default"),[y,g]=b.useState(!1),[_,w]=b.useState(!1),[S,x]=b.useState(null),[k,R]=b.useState(null),[A,M]=b.useState(""),[T,P]=b.useState(!1),z=b.useRef(e);z.current=e;const Y=Cs(),U=qr(ce=>ce.homePath),G=qr(ce=>ce.agentCli),I=yo("(min-width: 768px)");b.useEffect(()=>{e&&!i&&U&&s(U)},[e,U,i]),b.useEffect(()=>{if(!e||U&&G)return;const ce=$t==null?void 0:$t.requestProxyInfo();ce&&ce.then(re=>{const le=qr.getState();le.setHomePath(re.homePath),le.setAgentCli(re.agentCli)}).catch(re=>{console.error("[create-session-dialog] requestProxyInfo failed",re)})},[e,U,G]);function N(){r(""),s(""),l("claude"),d("pty"),h("default"),g(!1),x(null),R(null),M(""),P(!1)}function L(){if(f==="bypassPermissions"){g(!0);return}q()}async function B(){await q(),z.current&&g(!1)}const O=o==="codex"?hF:o==="kimi"?pF:afe,D=mF(o,G),F=k===o&&A.trim()!==(((Q=G==null?void 0:G[o])==null?void 0:Q.command)??""),V=_||T||D.disabled||F;function j(ce){const re=cfe(ce,f);re!==f&&h(re)}async function q(ce){x(null),w(!0);try{const re=await ufe({relay:$t,agentCli:G,form:{cwd:ce??i,name:n,provider:o,permissionMode:f,mode:u}});if(re.type==="success"){if(Ut.getState().addSession(re.session),!z.current)return;t(!1),N(),Y(re.route);return}if(re.type==="missing_cwd"&&x(re.path),Ue.error(re.message),re.type==="validation_error"||re.type==="relay_missing")return}finally{w(!1)}}async function K(ce){const re=$t;if(!re)return Ue.error("请先连接开发机"),null;try{const le=await re.createDirectory(ce);return le.success?(x(null),Ue.success("目录已创建"),le.path):(Ue.error(`目录创建失败:${le.error??"未知错误"}`),null)}catch(le){return Ue.error(le instanceof Error?le.message:String(le)),null}}function $(ce,re){R(ce),M(re)}async function te(){if(!k)return;const ce=k,re=A.trim();if(!re){Ue.error("请选择 Agent CLI 可执行文件");return}const le=$t;if(!le){Ue.error("请先连接开发机");return}P(!0);try{const we=await le.updateAgentCliPath(ce,re);if(we.error||!we.agentCli){Ue.error(`路径保存失败:${we.error??"未知错误"}`);return}qr.getState().setAgentCli(we.agentCli),Ue.success(`${Vp[ce]} 路径已保存`),R(null),M("")}catch(we){Ue.error(we instanceof Error?we.message:String(we))}finally{P(!1)}}function J(ce){d(ce),j(o)}const ne=y?m.jsxs("div",{className:"grid min-w-0 gap-5","data-slot":"bypass-permission-confirmation",children:[m.jsx(cF,{providerLabel:Vp[o]}),m.jsxs(qs,{children:[m.jsx(vt,{type:"button",variant:"ghost",className:"min-h-11 md:min-h-0",onClick:()=>g(!1),disabled:_,children:"返回"}),m.jsx(vt,{type:"button",variant:"destructive",className:"min-h-11 md:min-h-0",onClick:()=>void B(),disabled:_,"data-slot":"bypass-permission-confirm",children:_?"创建中...":"确认"})]})]}):m.jsxs("form",{className:"flex min-w-0 flex-col gap-4","data-slot":"create-session-form",autoComplete:"off",onSubmit:ce=>{ce.preventDefault(),L()},children:[m.jsxs("label",{className:"flex min-w-0 flex-col gap-1",children:[m.jsx("span",{className:"text-sm",children:"名称(可选)"}),m.jsx("input",{type:"text",name:"dev-anywhere-session-name",autoComplete:"off",autoCorrect:"off",spellCheck:!1,value:n,onChange:ce=>r(ce.target.value),className:"min-h-11 min-w-0 rounded-md border border-border bg-input px-3 text-base outline-none focus-visible:ring-2 focus-visible:ring-ring md:h-9 md:min-h-0 md:text-sm",placeholder:"自动生成"})]}),m.jsx(Nk,{id:"create-session-cwd",name:"dev-anywhere-session-cwd","data-slot":"create-session-cwd",label:"工作目录",value:i,selectionKind:"directory",placeholder:"选择工作目录",onCreateDirectory:K,onValueChange:ce=>{s(ce),x(null)}}),S?m.jsxs("section",{role:"status","aria-live":"polite",className:"rounded-md border border-primary/50 bg-primary/10 p-3",children:[m.jsx("p",{className:"text-sm font-medium",children:"工作目录不存在"}),m.jsx("p",{className:"mt-1 break-all font-mono text-xs text-muted-foreground",children:S})]}):null,m.jsxs("section",{"aria-label":"交互方式",className:"flex min-w-0 flex-col gap-2",children:[m.jsx("span",{className:"text-sm",children:"交互方式"}),m.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-2 sm:grid-cols-2",children:[m.jsxs("button",{type:"button","aria-pressed":u==="pty",onClick:()=>J("pty"),className:qe("flex min-h-14 min-w-0 flex-col items-start justify-center gap-1 rounded-md border px-3 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",u==="pty"?"border-primary/70 bg-primary/10":"border-border bg-muted/20"),children:[m.jsx("span",{className:"text-sm font-medium",children:"终端模式"}),m.jsx("span",{className:"text-xs text-muted-foreground",children:"像本地终端一样操作"})]}),m.jsxs("button",{type:"button","aria-pressed":u==="json",onClick:()=>J("json"),className:qe("flex min-h-14 min-w-0 flex-col items-start justify-center gap-1 rounded-md border px-3 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",u==="json"?"border-primary/70 bg-primary/10":"border-border bg-muted/20"),children:[m.jsx("span",{className:"text-sm font-medium",children:"聊天模式"}),m.jsx("span",{className:"text-xs text-muted-foreground",children:"气泡式对话,支持 Voice Pilot"})]})]})]}),m.jsx(hfe,{agentCli:G,provider:o,cliPathDraftProvider:k,cliPathDraft:A,savingCliPath:T,onProviderChange:ce=>{l(ce),j(ce),R(null),M("")},onCliPathDraftChange:$,onDiscardCliPathDraft:()=>{R(null),M("")},onSaveCliPath:()=>void te()}),m.jsxs("label",{className:"flex min-w-0 flex-col gap-2",children:[m.jsx("span",{className:"text-sm",children:"权限模式"}),m.jsxs(Kb,{value:f,onValueChange:ce=>h(ce),children:[m.jsx(Xb,{className:"w-full",children:m.jsx(Gb,{})}),m.jsx(Zb,{children:O.map(ce=>m.jsx(Qb,{value:ce.value,children:ce.label},ce.value))})]})]}),m.jsxs(qs,{children:[m.jsx(vt,{type:"button",variant:"ghost",className:"min-h-11 md:min-h-0",onClick:()=>t(!1),disabled:_,children:"取消"}),m.jsx(vt,{type:"submit",className:"min-h-11 md:min-h-0",disabled:V,children:_?"创建中...":"创建"})]})]});return I?m.jsx(es,{open:e,onOpenChange:t,children:m.jsxs(ts,{className:"!w-[calc(100vw-2rem)] !max-w-none max-h-[calc(100dvh-2rem)] overflow-y-auto sm:!w-[44rem]","data-slot":"create-session-dialog",focusSurfaceOnOpen:!0,children:[m.jsx(ns,{children:m.jsx($i,{children:y?"跳过全部审批?":"新建会话"})}),ne]})}):m.jsx(pc,{open:e,onOpenChange:t,children:m.jsxs(mc,{side:"bottom",className:"inset-x-2 max-h-[calc(100dvh-0.75rem)] w-auto overflow-x-hidden overflow-y-auto rounded-t-xl border bg-background px-4 pb-[max(theme(spacing.4),env(safe-area-inset-bottom))] pt-3","data-slot":"create-session-dialog",focusSurfaceOnOpen:!0,children:[m.jsx(Eu,{className:"px-0 pb-1 pt-0 text-left",children:m.jsx(gc,{children:y?"跳过全部审批?":"新建会话"})}),ne]})})}function cp({open:e,sessionId:t,initialName:n,onOpenChange:r,onRename:i}){const s=b.useMemo(()=>(n==null?void 0:n.trim())??"",[n]),[o,l]=b.useState(s),[u,d]=b.useState(null),[f,h]=b.useState(!1);b.useEffect(()=>{e&&(l(s),d(null),h(!1))},[s,e]);async function y(g){g.preventDefault();const _=o.trim();if(!_){d("会话标题不能为空");return}if(t){h(!0);try{await i(t,_),r(!1)}catch(w){d(w instanceof Error?w.message:String(w))}finally{h(!1)}}}return m.jsx(es,{open:e,onOpenChange:r,children:m.jsx(ts,{className:"sm:max-w-md","data-slot":"session-rename-dialog",children:m.jsxs("form",{className:"grid gap-4",onSubmit:g=>void y(g),children:[m.jsxs(ns,{children:[m.jsx($i,{children:"重命名会话"}),m.jsx(Es,{children:"自定义名称会显示在会话列表和顶部标题中。"})]}),m.jsxs("div",{className:"grid gap-2",children:[m.jsx("label",{htmlFor:"session-rename-title",className:"text-sm font-medium",children:"会话标题"}),m.jsx("input",{id:"session-rename-title",value:o,autoFocus:!0,maxLength:100,"aria-invalid":!!u,"aria-describedby":u?"session-rename-error":void 0,className:qe("h-10 rounded-md border border-input bg-background px-3 text-sm shadow-xs outline-none transition-[border-color,box-shadow]","placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/75","disabled:cursor-not-allowed disabled:opacity-50",u&&"border-destructive focus-visible:ring-destructive/20"),disabled:f,onChange:g=>{l(g.target.value),u&&d(null)}}),u?m.jsx("p",{id:"session-rename-error",className:"text-sm text-destructive",children:u}):null]}),m.jsxs(qs,{children:[m.jsx(vt,{type:"button",variant:"outline",onClick:()=>r(!1),children:"取消"}),m.jsx(vt,{type:"submit",disabled:f,children:"保存"})]})]})})})}function pfe(e){return(e==null?void 0:e.kind)==="agent"&&e.mode==="pty"&&e.ptyOwner==="local-terminal"}function mfe(e){return(e==null?void 0:e.kind)==="terminal"}function gfe(e){return pfe(e)?{title:"断开远程连接?",description:"这只会断开当前页面和本地终端的连接,本地终端里的 Claude Code/Codex/Kimi Code 会继续运行。重新接入前,页面不能继续查看或输入这个会话。",confirmLabel:"断开远程连接",destructive:!1}:mfe(e)?{title:"终止终端?",description:"这会停止当前终端进程,并清理这个终端会话的运行状态。终止后不能继续输入,也无法恢复正在执行的命令。",confirmLabel:"终止终端",destructive:!0}:{title:"终止会话?",description:"这会停止当前 Agent 进程,并清理这个会话的运行状态。终止后不能继续输入,也无法恢复正在执行的任务。",confirmLabel:"终止会话",destructive:!0}}function bv({open:e,session:t,onOpenChange:n,onConfirm:r}){const i=gfe(t);function s(){t&&(r(t),n(!1))}return m.jsx(es,{open:e,onOpenChange:n,children:m.jsxs(ts,{"data-slot":"session-termination-dialog",children:[m.jsxs(ns,{children:[m.jsx($i,{children:i.title}),m.jsx(Es,{children:i.description})]}),m.jsxs(qs,{children:[m.jsx(vt,{type:"button",variant:"ghost",onClick:()=>n(!1),children:"取消"}),m.jsx(vt,{type:"button",variant:i.destructive?"destructive":"default",onClick:s,"data-slot":"session-termination-confirm",children:i.confirmLabel})]})]})})}function gF(e){var t,n,r,i,s,o,l,u,d,f,h,y;return e.connected===!1||e.proxyOnline===!1?"disconnected":e.routeSessionEnded||((t=e.session)==null?void 0:t.state)==="terminated"?"terminated":((n=e.session)==null?void 0:n.state)==="error"?"error":e.hasPendingApproval||((r=e.session)==null?void 0:r.state)==="waiting_approval"?"waiting_approval":((i=e.session)==null?void 0:i.state)==="compacting"?"compacting":((s=e.session)==null?void 0:s.state)==="working"?"working":((o=e.session)==null?void 0:o.state)==="idle"?"idle":((l=e.agentStatus)==null?void 0:l.phase)==="waiting_permission"||((u=e.ptyState)==null?void 0:u.state)==="approval_wait"?"waiting_approval":((d=e.agentStatus)==null?void 0:d.phase)==="thinking"||((f=e.agentStatus)==null?void 0:f.phase)==="tool_use"||((h=e.agentStatus)==null?void 0:h.phase)==="outputting"||((y=e.ptyState)==null?void 0:y.state)==="working"?"working":"idle"}function vfe(e){if(e.session.state==="error")return"error";const t=gF(e);return t==="disconnected"?e.session.state:t}const yfe=new Set(["localhost","127.0.0.1","[::1]"]),N1={cloudflare:{label:"Cloudflare Tunnel",executable:"cloudflared",installUrl:"https://developers.cloudflare.com/tunnel/downloads/"},cpolar:{label:"Cpolar",executable:"cpolar"}};function bfe(){return Ni("local",_n.webPreviewTunnelProvider)==="cpolar"?"cpolar":"cloudflare"}function vF(e,t){if(e)return t==="cloudflare"?e.cloudflared:e.cpolar}function b0(e,t){var n;return((n=vF(e,t))==null?void 0:n.available)===!0}function _fe(e){const t=e.trim();if(!t)return"请输入本机网站地址";let n;try{n=new URL(t)}catch{return"请输入完整的 http:// 本机网站地址"}return n.protocol!=="http:"||!yfe.has(n.hostname)||n.username!==""||n.password!==""?"只支持 localhost、127.0.0.1 或 [::1] 的 http:// 地址":null}function Mh(){return{status:"idle"}}function wfe({open:e,onOpenChange:t}){const[n,r]=b.useState(""),[i,s]=b.useState(bfe),[o,l]=b.useState("local"),[u,d]=b.useState(""),[f,h]=b.useState(""),[y,g]=b.useState(""),[_,w]=b.useState(Mh),[S,x]=b.useState(!1),k=b.useRef(null),R=b.useRef(null),A=b.useRef(null),M=b.useRef(null),T=b.useRef(i);T.current=i;const P=b.useRef(e);P.current=e;const z=yo("(min-width: 768px)"),Y=Me(ne=>ne.selectedProxyId),U=Hr(ne=>ne.capability),G=Hr(ne=>ne.capabilityStatus),I=Hr(ne=>ne.capabilityError),N=Hr(ne=>{var Q;return((Q=ne.authoritative)==null?void 0:Q.scope)??null}),L=N?`${N.proxyId}\0${N.bindingId}`:null,B=b.useCallback(ne=>{T.current=ne,s(ne),Rr("local",_n.webPreviewTunnelProvider,ne)},[]);function O(){var ne,Q;r(""),l("local"),d(""),h(""),g(""),w(Mh()),x(!1),(ne=k.current)==null||ne.abort(),k.current=null,(Q=R.current)==null||Q.abort(),R.current=null,A.current=null,M.current=null}const D=b.useCallback(async ne=>{var re;(re=k.current)==null||re.abort();const Q=new AbortController;k.current=Q;const ce=Pt.getActiveScope();if(!(!ce||ce.proxyId!==Y))try{const le=await Pt.requestWebPreviewCapability(ce,ne,{signal:Q.signal});if(!le||Q.signal.aborted||!P.current||!le.success)return;const we=T.current,Ce=we==="cloudflare"?"cpolar":"cloudflare";!b0(le.capability,we)&&b0(le.capability,Ce)&&B(Ce)}catch{}},[B,Y]);function F(ne){!ne&&S||t(ne)}b.useEffect(()=>{if(!e){O();return}return D(!1),()=>{var ne;(ne=k.current)==null||ne.abort(),k.current=null}},[D,e,L]),b.useEffect(()=>{var re;if(!e||o!=="static")return;(re=R.current)==null||re.abort(),R.current=null;const ne=f.trim();if(!ne){w(Mh()),g("");return}const Q=new AbortController;R.current=Q,w({status:"loading"}),g("");const ce=window.setTimeout(()=>{const le=$t,we=Pt.getActiveScope();if(!le||!we||we.proxyId!==Y){w({status:"error",message:"请先连接开发机"});return}Pt.inspectStaticWebPreview(we,ne,{signal:Q.signal}).then(Ce=>{if(!Ce||Q.signal.aborted||!P.current||!Pt.isActive(le,we))return;if(!Ce.success){w({status:"error",message:Ce.error});return}const ye=Ce.htmlEntries;if(ye.length===0&&!Ce.entryPath){w({status:"error",message:"这里没有可以预览的网页"});return}const Re={entryPath:Ce.entryPath,htmlEntries:ye};w({status:"ready",path:ne,result:Re}),g(Ce.entryPath??"")}).catch(Ce=>{Q.signal.aborted||!P.current||Ce instanceof Error&&Ce.name==="AbortError"||!Pt.isActive(le,we)||w({status:"error",message:Ce instanceof Error?Ce.message:"检查网页失败"})})},300);return()=>{window.clearTimeout(ce),Q.abort(),R.current===Q&&(R.current=null)}},[e,L,Y,o,f]);const V=o==="local"?_fe(u):null,j=o==="static"&&_.status==="ready"&&_.path===f.trim()&&!!(_.result.entryPath||y),q=G==="loaded"&&b0(U,i),$=S||!q||!(o==="local"?V===null:j);async function te(){var le,we,Ce;if($)return;const ne=$t;if(!ne){Ue.error("请先连接开发机");return}let Q;if(o==="local")Q={kind:"local",url:u.trim()};else{if(_.status!=="ready"||_.path!==f.trim())return;const ye=_.result.entryPath??y;if(!ye)return;Q={kind:"static",path:_.path,entryPath:ye}}x(!0);const ce=Pt.getActiveScope();if(!ce){x(!1),Ue.error("请先连接开发机");return}let re=null;try{const ye=n.trim(),Re=JSON.stringify({proxyId:ce.proxyId,tunnelProvider:i,source:Q,name:ye||void 0});((le=A.current)==null?void 0:le.sourceKey)!==Re&&(A.current={sourceKey:Re,operationId:hm(`preview-operation-${i}`)}),re=A.current.operationId,M.current=re;const Rt=await Pt.createWebPreview(ce,Q,{tunnelProvider:i,operationId:re,...ye?{name:ye}:{}});if(M.current!==re)return;if(!Rt.accepted){((we=A.current)==null?void 0:we.operationId)===re&&(A.current=null),Ue.error(Rt.error);return}if(((Ce=A.current)==null?void 0:Ce.operationId)===re&&(A.current=null),!P.current||!Pt.isActive(ne,ce))return;t(!1)}catch(ye){if(!re||M.current!==re||!P.current||!Pt.isActive(ne,ce))return;Ue.error(ye instanceof Error?ye.message:"无法创建网页预览")}finally{re&&M.current===re&&(M.current=null,P.current&&x(!1))}}const J=m.jsxs("form",{className:"flex min-w-0 flex-col gap-4","data-slot":"create-web-preview-form",autoComplete:"off",onSubmit:ne=>{ne.preventDefault(),te()},children:[m.jsxs("label",{className:"flex min-w-0 flex-col gap-1",children:[m.jsx("span",{className:"text-sm",children:"名称(可选)"}),m.jsx("input",{type:"text",name:"dev-anywhere-web-preview-name",value:n,maxLength:256,autoComplete:"off",autoCorrect:"off",spellCheck:!1,disabled:S,placeholder:"自动生成","data-slot":"web-preview-name",onChange:ne=>{r(ne.target.value)},className:"min-h-11 min-w-0 rounded-md border border-border bg-input px-3 text-base outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60 md:h-9 md:min-h-0 md:text-sm"})]}),m.jsxs("section",{className:"flex min-w-0 flex-col gap-1","data-slot":"web-preview-tunnel-provider-field","data-provider":i,children:[m.jsx("span",{className:"text-sm",children:"内网穿透服务"}),m.jsxs(Kb,{value:i,disabled:S,onValueChange:ne=>B(ne),children:[m.jsx(Xb,{"aria-label":"内网穿透服务","data-slot":"web-preview-tunnel-provider-select","data-provider":i,className:"min-h-11 w-full md:min-h-0",children:m.jsx(Gb,{})}),m.jsx(Zb,{"data-slot":"web-preview-tunnel-provider-options",children:Object.keys(N1).map(ne=>m.jsx(Qb,{value:ne,"data-slot":"web-preview-tunnel-provider-option","data-provider":ne,children:N1[ne].label},ne))})]})]}),m.jsx(xfe,{status:G,capability:U,provider:i,error:I,disabled:S,onRetry:()=>void D(!0)}),m.jsxs("section",{"aria-label":"网页来源",className:"flex min-w-0 flex-col gap-2",children:[m.jsx("span",{className:"text-sm",children:"网页来源"}),m.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-2 sm:grid-cols-2",children:[m.jsxs("button",{type:"button","data-slot":"web-preview-source-local",disabled:S,"aria-pressed":o==="local",onClick:()=>{var ne;(ne=R.current)==null||ne.abort(),R.current=null,w(Mh()),g(""),l("local")},className:qe("flex min-h-16 min-w-0 flex-col items-start justify-center gap-1 rounded-md border px-3 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60",o==="local"?"border-primary/70 bg-primary/10":"border-border bg-muted/20"),children:[m.jsx("span",{className:"text-sm font-medium",children:"本机网站"}),m.jsx("span",{className:"text-xs text-muted-foreground",children:"输入 localhost 地址"})]}),m.jsxs("button",{type:"button","data-slot":"web-preview-source-static",disabled:S,"aria-pressed":o==="static",onClick:()=>{var ne;(ne=R.current)==null||ne.abort(),R.current=null,w(Mh()),g(""),l("static")},className:qe("flex min-h-16 min-w-0 flex-col items-start justify-center gap-1 rounded-md border px-3 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60",o==="static"?"border-primary/70 bg-primary/10":"border-border bg-muted/20"),children:[m.jsx("span",{className:"text-sm font-medium",children:"网页文件"}),m.jsx("span",{className:"text-xs text-muted-foreground",children:"选择 HTML 网页文件或目录"})]})]})]}),o==="local"?m.jsxs("label",{className:"flex min-w-0 flex-col gap-1",children:[m.jsx("span",{className:"text-sm",children:"本机网站地址"}),m.jsx("input",{type:"url","data-slot":"web-preview-local-url","aria-label":"本机网站地址",inputMode:"url",name:"dev-anywhere-preview-local-url",autoComplete:"off",autoCorrect:"off",spellCheck:!1,disabled:S,value:u,onChange:ne=>{d(ne.target.value)},placeholder:"http://localhost:5173","aria-invalid":u.length>0&&V!==null,className:"min-h-11 min-w-0 rounded-md border border-border bg-input px-3 font-mono text-base outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60 md:h-9 md:min-h-0 md:text-sm"}),u.length>0&&V?m.jsx("span",{"data-slot":"web-preview-local-url-error",className:"text-xs text-destructive",role:"alert",children:V}):null]}):m.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[m.jsx(Nk,{id:"create-web-preview-path",name:"dev-anywhere-preview-static-path","data-slot":"web-preview-static-path",label:"网页位置",value:f,selectionKind:"file-or-directory",fileExtensions:[".html",".htm"],disabled:S,placeholder:"选择 HTML 网页文件或目录",onValueChange:h}),m.jsx(Sfe,{inspection:_,selectedEntryPath:y,disabled:S,onEntryPathChange:ne=>{g(ne)}})]}),m.jsxs(qs,{children:[m.jsx(vt,{type:"button",variant:"ghost","data-slot":"create-web-preview-cancel",className:"min-h-11 md:min-h-0",onClick:()=>F(!1),disabled:S,children:"取消"}),m.jsx(vt,{type:"submit",className:"min-h-11 md:min-h-0",disabled:$,"data-slot":"create-web-preview-submit",children:S?"正在创建...":"创建预览"})]})]});return z?m.jsx(es,{open:e,onOpenChange:F,children:m.jsxs(ts,{showCloseButton:!S,onEscapeKeyDown:ne=>{S&&ne.preventDefault()},onPointerDownOutside:ne=>{S&&ne.preventDefault()},className:"!w-[calc(100vw-2rem)] !max-w-none max-h-[calc(100dvh-2rem)] overflow-y-auto sm:!w-[40rem]","data-slot":"create-web-preview-dialog",focusSurfaceOnOpen:!0,children:[m.jsxs(ns,{children:[m.jsx($i,{children:"新建网页预览"}),m.jsx(Es,{children:"输入本机网站地址,或选择 HTML 网页文件或目录。"})]}),J]})}):m.jsx(pc,{open:e,onOpenChange:F,children:m.jsxs(mc,{side:"bottom",showCloseButton:!S,onEscapeKeyDown:ne=>{S&&ne.preventDefault()},onPointerDownOutside:ne=>{S&&ne.preventDefault()},className:"inset-x-2 max-h-[calc(100dvh-0.75rem)] w-auto overflow-x-hidden overflow-y-auto rounded-t-xl border bg-background px-4 pb-[max(theme(spacing.4),env(safe-area-inset-bottom))] pt-3","data-slot":"create-web-preview-dialog",focusSurfaceOnOpen:!0,children:[m.jsxs(Eu,{className:"px-0 pb-1 pt-0 text-left",children:[m.jsx(gc,{children:"新建网页预览"}),m.jsx(Vb,{children:"输入本机网站地址,或选择 HTML 网页文件或目录。"})]}),J]})})}function xfe({status:e,capability:t,provider:n,error:r,disabled:i,onRetry:s}){const o=N1[n];if(e==="loading"||e==="idle")return m.jsxs("div",{"data-slot":"web-preview-capability-status","data-status":"loading","data-provider":n,className:"flex items-center gap-2 rounded-md border border-border/70 bg-muted/20 px-3 py-2 text-sm text-muted-foreground",role:"status",children:[m.jsx(li,{className:"size-4 animate-spin","aria-hidden":"true"}),"正在检测 ",o.label,"..."]});if(e==="error")return m.jsx("div",{"data-slot":"web-preview-capability-status","data-status":"error","data-provider":n,className:"rounded-md border border-destructive/45 bg-destructive/5 p-3",role:"alert",children:m.jsxs("div",{className:"flex items-start gap-2",children:[m.jsx(wz,{className:"mt-0.5 size-4 shrink-0 text-destructive","aria-hidden":"true"}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsxs("p",{className:"text-sm font-medium",children:["无法检测 ",o.label]}),r?m.jsx("p",{className:"mt-1 break-words text-xs text-muted-foreground",children:r}):null]}),m.jsx(mI,{onClick:s,disabled:i})]})});const l=vF(t,n);if(!(l!=null&&l.available)){const u=(l==null?void 0:l.suggestions)??[],d=`未找到 ${o.label}`,f=(l==null?void 0:l.error)&&l.error!==d;return m.jsx("div",{"data-slot":"web-preview-capability-status","data-status":"missing","data-provider":n,className:"rounded-md border border-[var(--color-status-warning)]/45 bg-[var(--color-status-warning)]/5 p-3",role:"alert",children:m.jsxs("div",{className:"flex items-start gap-2",children:[m.jsx(YV,{className:"mt-0.5 size-4 shrink-0 text-[var(--color-status-warning)]","aria-hidden":"true"}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsx("p",{className:"text-sm font-medium",children:d}),m.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["请先安装 ",o.executable,",并确保它在用户 Shell 的 PATH 中,然后重新检测。"]}),u.length>0?m.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:[m.jsx("span",{children:"检测到的位置:"}),m.jsx("ul",{className:"mt-1 space-y-1",children:u.map(h=>m.jsx("li",{"data-slot":n==="cloudflare"?"web-preview-cloudflared-suggestion":"web-preview-cpolar-suggestion","data-provider":n,"data-path":h,children:m.jsx("code",{className:"break-all rounded bg-muted px-1 py-0.5",children:h})},h))})]}):null,o.installUrl?m.jsx("a",{"data-slot":"web-preview-cloudflared-install-link","data-provider":n,href:o.installUrl,target:"_blank",rel:"noopener noreferrer",className:"mt-2 inline-block text-xs text-primary underline-offset-4 hover:underline",children:"查看官方安装说明"}):null,f?m.jsx("p",{className:"mt-1 break-words text-xs text-muted-foreground/80",children:l.error}):null]}),m.jsx(mI,{onClick:s,disabled:i})]})})}return m.jsxs("div",{"data-slot":"web-preview-capability-status","data-status":"ready","data-provider":n,className:"flex items-center gap-2 rounded-md border border-[var(--color-status-success)]/35 bg-[var(--color-status-success)]/5 px-3 py-2 text-sm",role:"status",children:[m.jsx(jV,{className:"size-4 text-[var(--color-status-success)]","aria-hidden":"true"}),m.jsxs("span",{children:[o.label," 已安装"]}),l.version?m.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:["· ",l.version]}):null]})}function mI({onClick:e,disabled:t}){return m.jsxs(vt,{type:"button",variant:"outline",size:"sm","data-slot":"web-preview-capability-retry",className:"shrink-0",onClick:e,disabled:t,children:[m.jsx(um,{className:"size-3.5","aria-hidden":"true"}),"重新检测"]})}function Sfe({inspection:e,selectedEntryPath:t,disabled:n,onEntryPathChange:r}){if(e.status==="idle")return null;if(e.status==="loading")return m.jsxs("span",{"data-slot":"web-preview-static-inspection","data-status":"loading",className:"flex items-center gap-2 text-xs text-muted-foreground",role:"status",children:[m.jsx(li,{className:"size-3.5 animate-spin","aria-hidden":"true"}),"正在检查网页..."]});if(e.status==="error")return m.jsx("span",{"data-slot":"web-preview-static-inspection","data-status":"error",className:"text-xs text-destructive",role:"alert",children:e.message});if(!e.result.entryPath&&e.result.htmlEntries.length>1)return m.jsxs("label",{"data-slot":"web-preview-static-inspection","data-status":"choose-entry",className:"mt-1 flex min-w-0 flex-col gap-2",children:[m.jsx("span",{className:"text-sm",children:"这个文件夹里有多个网页,打开预览时先显示哪个?"}),m.jsxs(Kb,{value:t,onValueChange:r,disabled:n,children:[m.jsx(Xb,{"data-slot":"web-preview-entry-select",className:"w-full font-mono",children:m.jsx(Gb,{placeholder:"选择网页"})}),m.jsx(Zb,{children:e.result.htmlEntries.map(o=>m.jsx(Qb,{value:o,"data-entry-path":o,children:o},o))})]})]});const s=e.result.entryPath;return s?m.jsxs("span",{"data-slot":"web-preview-static-inspection","data-status":"ready","data-entry-path":s,className:"truncate text-xs text-muted-foreground",title:s,children:["打开时显示:",m.jsx("span",{className:"font-mono",children:s})]}):null}const M1={ios:"iOS Simulator",android:"Android Emulator"};function Efe({open:e,platform:t,onOpenChange:n}){const r=Cs(),i=yo("(min-width: 768px)"),s=Me(F=>F.selectedProxyId),o=fr(F=>F.capability),l=fr(F=>F.targets),u=fr(F=>F.targetsStatus),d=fr(F=>F.targetsError),f=fr(c5),h=fr(F=>{var V;return((V=F.authoritative)==null?void 0:V.scope)??null}),y=h?`${h.proxyId}\0${h.bindingId}`:null,[g,_]=b.useState(""),[w,S]=b.useState(null),[x,k]=b.useState(!1),R=b.useRef(null),A=b.useRef(e);A.current=e;const M=b.useRef(null),T=b.useRef(null),P=b.useMemo(()=>l.filter(F=>F.platform===t),[t,l]),z=b.useMemo(()=>new Set(f.map(F=>F.targetId)),[f]),Y=b.useMemo(()=>P.filter(F=>!z.has(F.targetId)),[z,P]),U=Y.find(F=>F.targetId===w),G=o==null?void 0:o[t],I=b.useCallback(async F=>{var K;(K=R.current)==null||K.abort();const V=new AbortController;R.current=V;const j=$t,q=Pt.getActiveScope();if(!(!j||!q||q.proxyId!==s))try{const $=await Pt.requestDevicePreviewCapability(q,F,{signal:V.signal});if(!$||V.signal.aborted||!A.current||!$.success)return;await Pt.requestDevicePreviewTargets(q,!0,{signal:V.signal})}catch{}},[s]);b.useEffect(()=>{var F;if(!e){(F=R.current)==null||F.abort(),R.current=null,_(""),S(null),k(!1),M.current=null,T.current=null;return}return I(!1),()=>{var V;(V=R.current)==null||V.abort(),R.current=null}},[I,e,t,y]),b.useEffect(()=>{if(e){if(w&&!U){S(null);return}!w&&Y.length===1&&S(Y[0].targetId)}},[e,Y,U,w]);async function N(){var K,$,te;const F=U;if(!F||x||(G==null?void 0:G.available)!==!0)return;const V=$t,j=Pt.getActiveScope();if(!V||!j||j.proxyId!==s){Ue.error("请先连接开发机");return}k(!0);let q=null;try{const J=g.trim(),ne=((K=M.current)==null?void 0:K.proxyId)===j.proxyId&&M.current.targetId===F.targetId&&M.current.name===J?M.current:{proxyId:j.proxyId,targetId:F.targetId,name:J,operationId:hm("device-preview-operation")};M.current=ne,q=ne.operationId,T.current=q;const Q=await Pt.createDevicePreview(j,F.targetId,{operationId:ne.operationId,...J?{name:J}:{}});if(T.current!==ne.operationId)return;if(!Q.accepted){if((($=M.current)==null?void 0:$.operationId)===ne.operationId&&(M.current=null),!A.current||!Pt.isActive(V,j))return;Ue.error(Q.error);return}if(((te=M.current)==null?void 0:te.operationId)===ne.operationId&&(M.current=null),!A.current||!Pt.isActive(V,j))return;n(!1),r(`/preview/device/${Q.previewId}`)}catch(J){if(!q||T.current!==q||!A.current||!Pt.isActive(V,j))return;Ue.error(J instanceof Error?J.message:"无法创建模拟器预览")}finally{q&&T.current===q&&(T.current=null,A.current&&k(!1))}}function L(F){var V;!F&&x||(F||((V=R.current)==null||V.abort(),R.current=null,M.current=null,T.current=null,_(""),S(null)),n(F))}const B=m.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-4",children:[m.jsxs("label",{className:"flex min-w-0 flex-col gap-1",children:[m.jsx("span",{className:"text-sm",children:"名称(可选)"}),m.jsx("input",{type:"text",name:"dev-anywhere-device-preview-name",value:g,maxLength:256,autoComplete:"off",autoCorrect:"off",spellCheck:!1,disabled:x,placeholder:"自动生成","data-slot":"device-preview-name",onChange:F=>{_(F.target.value)},className:"min-h-11 min-w-0 rounded-md border border-border bg-input px-3 text-base outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60 md:h-9 md:min-h-0 md:text-sm"})]}),m.jsx(Cfe,{platform:t,tool:G}),m.jsx("div",{className:"grid min-w-0 grid-cols-1 gap-2","data-slot":"device-preview-targets",children:u==="loading"?m.jsxs("div",{className:"flex min-h-28 items-center justify-center gap-2 text-sm text-muted-foreground",children:[m.jsx(li,{className:"size-4 animate-spin","aria-hidden":"true"}),"正在查找已启动的模拟器..."]}):u==="error"?m.jsx(gI,{message:d??"无法读取模拟器列表"}):P.length===0?m.jsx(gI,{message:`没有已启动的 ${M1[t]}`}):P.map(F=>{const V=F.targetId===w,j=z.has(F.targetId);return m.jsx(kfe,{target:F,selected:V,disabled:j||x,alreadyOpen:j,onClick:()=>{S(F.targetId)}},F.targetId)})}),m.jsxs(qs,{className:"gap-2 sm:gap-2",children:[m.jsxs(vt,{type:"button",variant:"outline",disabled:x||u==="loading",onClick:()=>void I(!0),"data-slot":"device-preview-refresh",children:[m.jsx(um,{className:"size-4","aria-hidden":"true"}),"重新检测"]}),m.jsx(vt,{type:"button",disabled:!U||x||(G==null?void 0:G.available)!==!0,onClick:()=>void N(),"data-slot":"create-device-preview-submit",children:x?"正在创建...":"创建预览"})]})]}),O=`新建 ${M1[t]} 预览`,D="选择开发机上已经启动的模拟器。";return i?m.jsx(es,{open:e,onOpenChange:L,children:m.jsxs(ts,{showCloseButton:!x,className:"sm:max-w-xl","data-slot":"create-device-preview-dialog","data-platform":t,focusSurfaceOnOpen:!0,children:[m.jsxs(ns,{children:[m.jsx($i,{children:O}),m.jsx(Es,{children:D})]}),B]})}):m.jsx(pc,{open:e,onOpenChange:L,children:m.jsxs(mc,{side:"bottom",showCloseButton:!x,className:"inset-x-2 max-h-[calc(100dvh-0.75rem)] w-auto min-w-0 max-w-[calc(100%-1rem)] overflow-x-hidden overflow-y-auto rounded-t-xl border bg-background px-4 pb-[max(theme(spacing.4),env(safe-area-inset-bottom))] pt-3","data-slot":"create-device-preview-dialog","data-platform":t,focusSurfaceOnOpen:!0,children:[m.jsxs(Eu,{className:"px-0 pb-1 pt-0 text-left",children:[m.jsx(gc,{children:O}),m.jsx(Vb,{children:D})]}),B]})})}function Cfe({platform:e,tool:t}){if(!t||t.available)return null;const n=e==="android"&&!!t.command,r=e==="ios"?"Baguette":"adb",i=t.supported?e==="ios"&&t.version?"outdated":t.command?"unavailable":"missing":"unsupported",s=n?"Android 模拟器预览不可用":i==="unsupported"?`${M1[e]} 不可用`:i==="outdated"?`需要更新 ${r}`:i==="unavailable"?`${r} 暂时不可用`:`未找到 ${r}`,o=t.error??(e==="ios"?"需要先在开发机上安装 Baguette 0.1.96 或更高版本。":"需要先在开发机上安装 adb。"),l=o.trim()!==s.trim();return m.jsx("div",{className:"rounded-lg border border-amber-500/45 bg-amber-500/5 p-3 text-sm","data-slot":"device-preview-tool-status","data-status":i,children:m.jsxs("div",{className:"flex gap-2",children:[m.jsx(wz,{className:"mt-0.5 size-4 shrink-0 text-amber-600","aria-hidden":"true"}),m.jsxs("div",{className:"min-w-0",children:[m.jsx("p",{className:"font-medium",children:s}),l?m.jsx("p",{className:"mt-1 text-muted-foreground","data-slot":"device-preview-tool-description",children:o}):null,i!=="unsupported"&&!n?m.jsx("a",{href:e==="ios"?"https://github.com/tddworks/baguette#install":"https://developer.android.com/tools/releases/platform-tools",target:"_blank",rel:"noreferrer",className:"mt-1 inline-block text-primary underline underline-offset-4",children:"查看安装方法"}):null]})]})})}function gI({message:e}){return m.jsx("div",{className:"flex min-h-28 items-center justify-center rounded-lg border border-dashed px-4 text-center text-sm text-muted-foreground",children:e})}function kfe({target:e,selected:t,disabled:n,alreadyOpen:r,onClick:i}){const s=e.platform==="ios"?"iOS":"Android",o=`${e.model} · ${s} ${e.osVersion}`;return m.jsxs("button",{type:"button",className:qe("flex min-h-16 w-full min-w-0 max-w-full items-center gap-3 overflow-hidden rounded-lg border px-3 py-2 text-left outline-none transition-colors",t?"border-primary bg-primary/5":"border-border hover:bg-accent",n&&"cursor-not-allowed opacity-55"),disabled:n,"aria-pressed":t,onClick:i,"data-slot":"device-preview-target","data-target-id":e.targetId,"data-already-open":r?"true":"false","data-interactive":e.interactive?"true":"false",children:[m.jsx(Ty,{className:"size-5 shrink-0 text-muted-foreground","aria-hidden":"true"}),m.jsxs("span",{className:"min-w-0 flex-1",children:[m.jsx("span",{className:"block truncate text-sm font-medium",children:e.name}),m.jsx("span",{className:"mt-0.5 block truncate text-xs text-muted-foreground","data-slot":"device-preview-target-device","data-device-model":e.model,"data-os-version":e.osVersion,children:o})]}),r?m.jsx("span",{className:"text-xs text-muted-foreground",children:"已在预览"}):t?m.jsx(ua,{className:"size-4 text-primary","aria-hidden":"true"}):null]})}function yF({open:e,onOpenChange:t}){const[n,r]=b.useState(()=>e?"chooser":"closed"),i=b.useRef(null),s=yo("(min-width: 768px)");b.useLayoutEffect(()=>{if(e){n==="closed"&&r("chooser");return}n!=="closed"&&(i.current=n,r("closed"))},[e,n]);function o(){t(!1)}const l=m.jsxs("div",{className:"grid gap-2 pt-2","data-slot":"frontend-preview-options",children:[m.jsx(_0,{icon:m.jsx(Ez,{className:"size-5","aria-hidden":"true"}),title:"网页",description:"通过临时链接访问或分享本机网页",slot:"frontend-preview-web",onClick:()=>r("web")}),m.jsx(_0,{icon:m.jsx(Ty,{className:"size-5","aria-hidden":"true"}),title:"iOS Simulator",description:"查看和操控开发机上已启动的 iPhone 或 iPad 模拟器",slot:"frontend-preview-ios",onClick:()=>r("ios")}),m.jsx(_0,{icon:m.jsx(Ty,{className:"size-5","aria-hidden":"true"}),title:"Android Emulator",description:"查看和操控开发机上已启动的 Android 模拟器",slot:"frontend-preview-android",onClick:()=>r("android")})]}),u=n==="closed"?i.current:n,d=e&&n!=="closed";switch(u){case"chooser":return s?m.jsx(es,{open:d,onOpenChange:f=>!f&&o(),children:m.jsxs(ts,{className:"sm:max-w-lg","data-slot":"create-frontend-preview-dialog",children:[m.jsxs(ns,{children:[m.jsx($i,{children:"新建预览"}),m.jsx(Es,{children:"选择预览类型。"})]}),l]})},"chooser"):m.jsx(pc,{open:d,onOpenChange:f=>!f&&o(),children:m.jsxs(mc,{side:"bottom",className:"inset-x-2 w-auto rounded-t-xl border bg-background px-4 pb-[max(theme(spacing.4),env(safe-area-inset-bottom))] pt-3","data-slot":"create-frontend-preview-dialog",focusSurfaceOnOpen:!0,children:[m.jsxs(Eu,{className:"px-0 pb-1 pt-0 text-left",children:[m.jsx(gc,{children:"新建预览"}),m.jsx(Vb,{children:"选择预览类型。"})]}),l]})},"chooser");case"web":return m.jsx(wfe,{open:d,onOpenChange:f=>!f&&o()},"web");case"ios":case"android":return m.jsx(Efe,{open:d,platform:u,onOpenChange:f=>!f&&o()},u);case null:return null}}function _0({icon:e,title:t,description:n,slot:r,onClick:i}){return m.jsxs(vt,{type:"button",variant:"outline",className:"h-auto min-h-[4.5rem] justify-start gap-3 px-4 py-3 text-left","data-slot":r,onClick:i,children:[m.jsx("span",{className:"text-muted-foreground",children:e}),m.jsxs("span",{className:"min-w-0",children:[m.jsx("span",{className:"block font-medium text-foreground",children:t}),m.jsx("span",{className:"mt-0.5 block whitespace-normal text-xs leading-5 text-muted-foreground",children:n})]})]})}function Tfe({preview:e,closing:t,onOpenChange:n,onConfirm:r}){return m.jsx(es,{open:e!==null,onOpenChange:n,children:m.jsxs(ts,{"data-slot":"device-preview-close-dialog",children:[m.jsxs(ns,{children:[m.jsx($i,{children:"停止预览?"}),m.jsx(Es,{children:"模拟器会继续在开发机上运行。"})]}),m.jsxs(qs,{children:[m.jsx(vt,{type:"button",variant:"ghost",disabled:t,onClick:()=>n(!1),children:"取消"}),m.jsx(vt,{type:"button",variant:"destructive",disabled:!e||t,onClick:()=>e&&r(e),"data-slot":"device-preview-close-confirm",children:t?"正在停止...":"停止预览"})]})]})})}const Rfe={ready:{dot:"bg-[var(--color-status-success)]",text:"text-[var(--color-status-success)]",label:"已连接"},disconnected:{dot:"bg-muted-foreground",text:"text-muted-foreground",label:"已断开"}};function Afe({preview:e,selected:t,pendingOperation:n,onRename:r,onReconnect:i,onClose:s}){const o=Rfe[e.state],l=n==="reconnect"?{dot:"bg-[var(--color-status-working)] animate-pulse",text:"text-[var(--color-status-working)]",label:"正在重新连接",busy:!0}:n==="close"?{dot:"bg-muted-foreground animate-pulse",text:"text-muted-foreground",label:"正在停止",busy:!0}:o,u=e.state==="ready",d=e.state==="disconnected",f=e.platform==="ios"?"iOS":"Android",h=m.jsxs(m.Fragment,{children:[m.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[m.jsx("span",{className:qe("inline-block size-2 shrink-0 rounded-full",l.dot),role:"status","aria-label":`预览状态:${l.label}`}),m.jsx("span",{className:"flex-1 truncate text-sm font-normal",title:e.name,children:e.name})]}),m.jsxs("span",{className:"flex h-5 min-w-0 items-center gap-1.5 text-xs leading-5",children:[m.jsx(Ty,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),m.jsxs("span",{className:"min-w-0 flex-1 truncate text-muted-foreground","data-slot":"device-preview-row-device","data-device-model":e.model,"data-os-version":e.osVersion,children:[e.model," · ",f," ",e.osVersion]}),m.jsx("span",{className:qe("shrink-0",l.text),children:l.label})]})]});return m.jsxs("li",{className:qe("relative flex min-h-[44px] w-full min-w-0 items-center gap-2 px-4 py-2 transition-colors hover:bg-accent",t&&"bg-accent"),"data-slot":"device-preview-row","data-preview-id":e.previewId,"data-preview-state":e.state,"data-preview-operation":n,children:[u?m.jsx(_C,{to:`/preview/device/${e.previewId}`,className:"flex min-h-11 min-w-0 flex-1 flex-col justify-center gap-1 rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring md:min-h-0","data-slot":"device-preview-row-open",children:h}):m.jsx("div",{className:"flex min-h-11 min-w-0 flex-1 flex-col justify-center gap-1 md:min-h-0",children:h}),m.jsxs(_f,{children:[m.jsx(wf,{asChild:!0,children:m.jsx(vt,{variant:"ghost",size:"icon-xs",className:"size-11 md:size-6","aria-label":"模拟器预览操作",disabled:n!==void 0,"data-slot":"device-preview-row-menu-trigger",children:l.busy||n==="rename"?m.jsx(li,{className:"animate-spin","aria-hidden":"true"}):m.jsx(hb,{"aria-hidden":"true"})})}),m.jsxs(xf,{align:"end","data-slot":"device-preview-row-menu",children:[m.jsx(Zr,{"data-slot":"device-preview-row-rename-item",onSelect:r,children:"重命名"}),d?m.jsx(Zr,{"data-slot":"device-preview-row-reconnect-item",onSelect:i,children:"重新连接"}):null,m.jsx(Gc,{}),m.jsx(Zr,{variant:"destructive","data-slot":"device-preview-row-close-item",onSelect:s,children:"停止预览"})]})]})]})}function Nfe({preview:e,closing:t,onOpenChange:n,onConfirm:r}){return m.jsx(es,{open:e!==null,onOpenChange:n,children:m.jsxs(ts,{"data-slot":"preview-close-dialog",children:[m.jsxs(ns,{children:[m.jsx($i,{children:"关闭预览?"}),m.jsx(Es,{children:"关闭后,当前预览链接将立即失效。"})]}),m.jsxs(qs,{children:[m.jsx(vt,{type:"button",variant:"ghost",disabled:t,onClick:()=>n(!1),children:"取消"}),m.jsx(vt,{type:"button",variant:"destructive",disabled:!e||t,onClick:()=>e&&r(e),"data-slot":"preview-close-confirm",children:t?"正在关闭...":"关闭预览"})]})]})})}function Mfe({target:e,onOpenChange:t,onRename:n}){return m.jsx(Pfe,{target:e,onOpenChange:t,onRename:n},(e==null?void 0:e.targetKey)??"closed")}function Pfe({target:e,onOpenChange:t,onRename:n}){const[r,i]=b.useState(()=>(e==null?void 0:e.name.trim())??""),[s,o]=b.useState(null),[l,u]=b.useState(!1),d=b.useRef((e==null?void 0:e.targetKey)??null);b.useLayoutEffect(()=>()=>{d.current=null},[]);function f(y){!y&&l||t(y)}async function h(y){y.preventDefault();const g=r.trim();if(!g){o("名称不能为空");return}if(!e||l)return;const _=e.targetKey;u(!0);try{if(await n(g),d.current!==_)return;t(!1)}catch(w){if(d.current!==_)return;o(w instanceof Error?w.message:String(w))}finally{d.current===_&&u(!1)}}return m.jsx(es,{open:e!==null,onOpenChange:f,children:m.jsx(ts,{showCloseButton:!l,className:"sm:max-w-md","data-slot":"preview-rename-dialog",children:m.jsxs("form",{className:"grid gap-4",onSubmit:y=>void h(y),children:[m.jsx(ns,{children:m.jsx($i,{children:"重命名预览"})}),m.jsxs("div",{className:"grid gap-2",children:[m.jsx("label",{htmlFor:"preview-rename-name",className:"text-sm font-medium",children:"预览名称"}),m.jsx("input",{id:"preview-rename-name",value:r,autoFocus:!0,maxLength:256,autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-invalid":!!s,"aria-describedby":s?"preview-rename-error":void 0,"data-slot":"preview-rename-input",className:qe("h-10 rounded-md border border-input bg-background px-3 text-sm shadow-xs outline-none transition-[border-color,box-shadow]","placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/75","disabled:cursor-not-allowed disabled:opacity-50",s&&"border-destructive focus-visible:ring-destructive/20"),disabled:l,onChange:y=>{i(y.target.value),s&&o(null)}}),s?m.jsx("p",{id:"preview-rename-error",className:"text-sm text-destructive",role:"alert",children:s}):null]}),m.jsxs(qs,{children:[m.jsx(vt,{type:"button",variant:"outline",disabled:l,onClick:()=>f(!1),children:"取消"}),m.jsx(vt,{type:"submit",disabled:l,"data-slot":"preview-rename-submit",children:"保存"})]})]})})})}const Ife={starting:{dot:"bg-[var(--color-status-working)] animate-pulse",text:"text-[var(--color-status-working)]",label:"正在创建",busy:!0},ready:{dot:"bg-[var(--color-status-success)]",text:"text-[var(--color-status-success)]",label:"可访问"},failed:{dot:"bg-[var(--color-status-error)]",text:"text-[var(--color-status-error)]",label:"连接失败"},disconnected:{dot:"bg-muted-foreground",text:"text-muted-foreground",label:"已断开"},stopping:{dot:"bg-muted-foreground animate-pulse",text:"text-muted-foreground",label:"正在关闭",busy:!0}};function Ofe(e){return e.source.kind==="local"?e.source.url:bb(e.source.rootPath,e.source.entryPath)}async function Lfe(e){if(await Fp(e,{allowUserGestureFallback:!0})==="failed"){Ue.error("复制失败,请稍后重试");return}Ue.success("链接已复制")}async function Dfe(e,t){if(typeof navigator.share=="function")try{await navigator.share({title:e,url:t})}catch(n){if(n instanceof DOMException&&n.name==="AbortError")return;Ue.error("无法打开系统分享面板")}}function Bfe({preview:e,pendingOperation:t,onRename:n,onReconnect:r,onClose:i}){const s=qr(w=>w.homePath),o=Ife[e.state],l=t==="reconnect"?{dot:"bg-[var(--color-status-working)] animate-pulse",text:"text-[var(--color-status-working)]",label:"正在重新连接",busy:!0}:t==="close"?{dot:"bg-muted-foreground animate-pulse",text:"text-muted-foreground",label:"正在关闭",busy:!0}:o,u=e.state==="ready"?e.publicUrl:null,d=u!==null,f=e.state==="failed"||e.state==="disconnected",h=d&&typeof navigator<"u"&&typeof navigator.share=="function",y=Ofe(e),g=e.source.kind==="static"?pm(y,s):y,_=m.jsxs(m.Fragment,{children:[m.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[m.jsx("span",{className:qe("inline-block size-2 shrink-0 rounded-full",l.dot),role:"status","aria-label":`预览状态:${l.label}`}),m.jsx("span",{className:"flex-1 truncate text-sm font-normal",title:e.name,children:e.name})]}),m.jsxs("span",{className:"flex h-5 min-w-0 items-center gap-1.5 text-xs leading-5",children:[m.jsx(Ez,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),m.jsx("span",{className:"min-w-0 truncate font-mono text-muted-foreground",title:y,children:g}),m.jsx("span",{className:"shrink-0 text-muted-foreground/60","aria-hidden":"true",children:"·"}),m.jsx("span",{className:qe("shrink-0",l.text),children:l.label})]}),e.state==="failed"?m.jsx("span",{"data-slot":"preview-row-error",className:"truncate text-xs text-destructive/90",title:e.error,children:e.error}):null]});return m.jsxs("li",{className:"relative flex min-h-[44px] w-full min-w-0 items-center gap-2 px-4 py-2 transition-colors hover:bg-accent","data-slot":"preview-row","data-preview-id":e.previewId,"data-preview-state":e.state,"data-preview-operation":t,children:[d?m.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer","data-slot":"preview-row-open",className:"flex min-h-11 min-w-0 flex-1 flex-col justify-center gap-1 rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring md:min-h-0",children:_}):m.jsx("div",{"data-slot":"preview-row-inactive","aria-disabled":"true",className:"flex min-h-11 min-w-0 flex-1 flex-col justify-center gap-1 md:min-h-0",children:_}),m.jsxs(_f,{children:[m.jsx(wf,{asChild:!0,children:m.jsx(vt,{variant:"ghost",size:"icon-xs",className:"size-11 md:size-6","aria-label":"预览操作","data-slot":"preview-row-menu-trigger",disabled:e.state==="stopping"||t!==void 0,children:l.busy||t==="rename"?m.jsx(li,{className:"animate-spin","aria-hidden":"true"}):m.jsx(hb,{"aria-hidden":"true"})})}),m.jsxs(xf,{align:"end","data-slot":"preview-row-menu",children:[m.jsx(Zr,{"data-slot":"preview-row-rename-item",onSelect:n,children:"重命名"}),d?m.jsx(Zr,{"data-slot":"preview-row-copy-item",onSelect:()=>void Lfe(u),children:"复制链接"}):null,h?m.jsx(Zr,{"data-slot":"preview-row-share-item",onSelect:()=>void Dfe(e.name,u),children:"分享…"}):null,f?m.jsx(Zr,{"data-slot":"preview-row-reconnect-item",onSelect:r,children:"重新连接"}):null,m.jsx(Gc,{}),m.jsx(Zr,{variant:"destructive","data-slot":"preview-row-close-item",onSelect:i,children:"关闭预览"})]})]})]})}const zfe=Object.freeze([]),jfe=Object.freeze([]);function ud(e,t,n){return Object.freeze({kind:e,previewId:t,scope:Object.freeze({proxyId:n.proxyId,bindingId:n.bindingId})})}function jc(e,t){return e!==null&&e.kind===t.kind&&e.previewId===t.previewId&&Jt(e.scope,t.scope)}function up(e,t,n){return t!==null&&n!==void 0&&Jt(e.scope,t)&&Jt(e.scope,n)}function Ph(e){const t=Pt.getActiveScope(),n=e.kind==="web"?Hr.getState().authoritative:fr.getState().authoritative;return!n||!up(e,t,n.scope)?!1:n.previews.some(r=>r.previewId===e.previewId)}function Uo(e){const t=Pt.getActiveScope();return t!==null&&Jt(t,e)}function vI(){const e=Hr(N=>N.authoritative),t=fr(N=>N.authoritative),n=Zo(N=>N.registry),r=Pt.getActiveScope(),i=r&&e&&Jt(r,e.scope)?e.scope:null,s=r&&t&&Jt(r,t.scope)?t.scope:null,o=i&&e?e.previews:zfe,l=s&&t?t.previews:jfe,u=lz("/preview/device/:id"),d=Cs(),[f,h]=b.useState(null),[y,g]=b.useState(null),_=(y==null?void 0:y.kind)==="web"&&up(y,r,e==null?void 0:e.scope)?o.find(N=>N.previewId===y.previewId)??null:null,w=(y==null?void 0:y.kind)==="device"&&up(y,r,t==null?void 0:t.scope)?l.find(N=>N.previewId===y.previewId)??null:null,S=_??w,x=(f==null?void 0:f.kind)==="web"&&up(f,r,e==null?void 0:e.scope)?o.find(N=>N.previewId===f.previewId)??null:null,k=(f==null?void 0:f.kind)==="device"&&up(f,r,t==null?void 0:t.scope)?l.find(N=>N.previewId===f.previewId)??null:null;b.useEffect(()=>{y&&!S&&g(N=>jc(N,y)?null:N),f&&!x&&!k&&h(N=>jc(N,f)?null:N)},[f,k,y,S,x]);function R(N,L,B){var O;return(O=s5(n,N,L,B)[0])==null?void 0:O.kind}if(o.length===0&&l.length===0)return null;async function A(N){if(Ph(N))try{const L=await Pt.reconnectWebPreview(N.scope,N.previewId);if(!Uo(N.scope))return;L.success||Ue.error(L.error)}catch(L){if(!Uo(N.scope))return;Ue.error(L instanceof Error?L.message:"无法重新连接网页预览")}}async function M(N,L){if(!Ph(N))return;let B;try{B=N.kind==="web"?await Pt.renameWebPreview(N.scope,N.previewId,L):await Pt.renameDevicePreview(N.scope,N.previewId,L)}catch(O){if(!Uo(N.scope))return;throw O}if(Uo(N.scope)&&!B.success)throw new Error(B.error)}async function T(N){if(Ph(N))try{const L=await Pt.closeWebPreview(N.scope,N.previewId);if(!Uo(N.scope))return;if(!L.success){Ue.error(L.error);return}h(B=>jc(B,N)?null:B)}catch(L){if(!Uo(N.scope))return;Ue.error(L instanceof Error?L.message:"无法关闭网页预览")}}async function P(N){if(Ph(N))try{const L=await Pt.reconnectDevicePreview(N.scope,N.previewId);if(!Uo(N.scope))return;L.success||Ue.error(L.error)}catch(L){if(!Uo(N.scope))return;Ue.error(L instanceof Error?L.message:"无法重新连接模拟器预览")}}async function z(N){if(Ph(N))try{const L=await Pt.closeDevicePreview(N.scope,N.previewId);if(!Uo(N.scope))return;if(!L.success){Ue.error(L.error);return}h(B=>jc(B,N)?null:B),(u==null?void 0:u.params.id)===N.previewId&&d("/sessions")}catch(L){if(!Uo(N.scope))return;Ue.error(L instanceof Error?L.message:"无法停止模拟器预览")}}const Y=(f==null?void 0:f.kind)==="web"&&R(f.scope,"web",f.previewId)==="close",U=(f==null?void 0:f.kind)==="device"&&R(f.scope,"device",f.previewId)==="close",G=y,I=f;return m.jsxs("section",{"data-slot":"preview-section","aria-labelledby":"preview-section-title",children:[m.jsxs("h3",{id:"preview-section-title",className:"px-4 pb-2 pt-3 text-sm font-semibold text-foreground",children:["预览",m.jsxs("span",{className:"ml-1 font-normal text-muted-foreground/70",children:["· ",o.length+l.length]})]}),m.jsxs("ul",{role:"list",className:"flex w-full min-w-0 flex-col",children:[o.map(N=>m.jsx(Bfe,{preview:N,pendingOperation:i?R(i,"web",N.previewId):void 0,onRename:()=>i&&g(ud("web",N.previewId,i)),onReconnect:()=>i&&void A(ud("web",N.previewId,i)),onClose:()=>i&&h(ud("web",N.previewId,i))},N.previewId)),l.map(N=>m.jsx(Afe,{preview:N,selected:(u==null?void 0:u.params.id)===N.previewId,pendingOperation:s?R(s,"device",N.previewId):void 0,onRename:()=>s&&g(ud("device",N.previewId,s)),onReconnect:()=>s&&void P(ud("device",N.previewId,s)),onClose:()=>s&&h(ud("device",N.previewId,s))},N.previewId))]}),m.jsx(Mfe,{target:G&&S?{targetKey:`${G.kind}\0${G.scope.proxyId}\0${G.scope.bindingId}\0${G.previewId}`,name:S.name}:null,onOpenChange:N=>{!N&&G&&g(L=>jc(L,G)?null:L)},onRename:N=>G?M(G,N):Promise.resolve()}),m.jsx(Nfe,{preview:x,closing:Y,onOpenChange:N=>{!N&&!Y&&I&&h(L=>jc(L,I)?null:L)},onConfirm:()=>I&&void T(I)}),m.jsx(Tfe,{preview:k,closing:U,onOpenChange:N=>{!N&&!U&&I&&h(L=>jc(L,I)?null:L)},onConfirm:()=>I&&void z(I)})]})}function bF({layout:e}){const t=Ut(re=>re.sessions),n=Ut(re=>re.sessionListLoaded),r=Ut(re=>re.agentStatusBySessionId),i=Ut(re=>re.ptyStateBySessionId),s=Ut(re=>re.renameSession),o=fn(re=>re.bySessionId),l=lz("/chat/:id"),u=(l==null?void 0:l.params.id)??null,d=Me(re=>!!re.selectedProxyId),f=Me(re=>re.proxyListLoaded),h=Me(re=>re.proxySwitchTarget),y=Ut(re=>re.loadingProxyName),g=h!==null||!f||d&&!n,_=(h==null?void 0:h.name)??y,w=_?`正在连接 ${_}...`:"连接中...",S=Cs(),[x,k]=b.useState(!1),[R,A]=b.useState(!1),[M,T]=b.useState(!1),[P,z]=b.useState(!1),[Y,U]=b.useState(null),[G,I]=b.useState(null),{creatingTerminal:N,creatingShell:L,createTerminal:B}=_F(),[O,D]=b.useState(new Set),[F,V]=b.useState(()=>Date.now());b.useEffect(()=>{const re=setInterval(()=>V(Date.now()),6e4);return()=>clearInterval(re)},[]);function j(re,le){S(`/chat/${re}?mode=${le}`,{replace:!1})}function q(re){const le=re.sessionId,we=$t;if(!we){Ue.error("请先连接开发机");return}we.sendControl({type:"session_terminate",sessionId:le}),Ut.getState().removeSession(le),fn.getState().clearSession(le),le===u&&S("/sessions"),(re==null?void 0:re.kind)==="agent"&&re.mode==="pty"&&re.ptyOwner==="local-terminal"?Ue.info("已断开页面连接,本地终端仍在运行"):Ue.info("正在终止会话",{duration:1500})}async function K(re,le){const we=$t;if(!we)throw new Error("请先连接开发机");const Ce=await we.renameSession(re,le);if(!Ce.success)throw new Error(Ce.error??"重命名失败");s(re,Ce.name??le),Ue.success("已重命名会话")}function $(re){D(le=>{const we=new Set(le);return we.has(re)?we.delete(re):we.add(re),we})}function te(re){var Ce;const le=re.mode==="json"&&(((Ce=o[re.sessionId])==null?void 0:Ce.pendingApprovals.some(ye=>ye.status==="pending"))??!1),we=vfe({session:re,agentStatus:r[re.sessionId],ptyState:i[re.sessionId],hasPendingApproval:le});return we===re.state?re:{...re,state:we}}const J=t.length>0;if(e==="sidebar"&&(g||!d))return m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"px-4 py-3 text-sm text-muted-foreground/70","data-slot":g?"session-list-loading":void 0,role:g?"status":void 0,"aria-live":g?"polite":void 0,children:g?w:"请先连接开发机"}),m.jsx(lp,{open:x,onOpenChange:k}),m.jsx(bv,{open:G!==null,session:G,onOpenChange:re=>{re||I(null)},onConfirm:q}),m.jsx(cp,{open:Y!==null,sessionId:(Y==null?void 0:Y.sessionId)??null,initialName:Y==null?void 0:Y.name,onOpenChange:re=>{re||U(null)},onRename:K})]});if(e==="page"&&g)return m.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 text-muted-foreground animate-in fade-in-0 duration-200 motion-reduce:animate-none","data-slot":"session-list-loading",role:"status","aria-live":"polite",children:[m.jsx(li,{className:"h-5 w-5 animate-spin","aria-hidden":!0}),m.jsx("p",{className:"max-w-[min(24rem,calc(100%-2rem))] truncate text-sm",children:w})]});if(e==="page"&&!d)return m.jsxs("div",{className:"flex flex-col h-full",children:[m.jsx("div",{className:"flex-1",children:m.jsx(Jc,{variant:"no-proxy"})}),m.jsx(lp,{open:x,onOpenChange:k}),m.jsx(bv,{open:G!==null,session:G,onOpenChange:re=>{re||I(null)},onConfirm:q}),m.jsx(cp,{open:Y!==null,sessionId:(Y==null?void 0:Y.sessionId)??null,initialName:Y==null?void 0:Y.name,onOpenChange:re=>{re||U(null)},onRename:K})]});const ne=m.jsxs("h3",{className:"px-4 pt-3 pb-2 text-sm font-semibold text-foreground","data-slot":"active-section-header",children:["活跃会话",J?m.jsxs("span",{className:"ml-1 text-muted-foreground/70 font-normal",children:["· ",t.length]}):null]}),Q=J?m.jsx("ul",{role:"list",className:"flex flex-col w-full min-w-0",children:Ffe(t).map(re=>m.jsxs("li",{children:[m.jsxs("button",{type:"button",onClick:()=>$(re.provider),"aria-expanded":!O.has(re.provider),className:qe("flex w-full items-center gap-2 px-4 pt-2 pb-1 min-h-[32px]","text-xs text-muted-foreground","text-left outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring"),children:[m.jsx("span",{className:"font-mono",children:$fe(re.provider)}),m.jsx("span",{className:"h-px flex-1 bg-border/70","aria-hidden":"true"}),m.jsx("span",{className:"tabular-nums",children:re.sessions.length}),m.jsx(Hd,{className:qe("size-3.5 shrink-0 text-muted-foreground/80 transition-transform",!O.has(re.provider)&&"rotate-90"),"aria-hidden":"true"})]}),O.has(re.provider)?null:m.jsx("ul",{role:"list",className:"flex flex-col",children:re.sessions.map(le=>m.jsx(Xde,{session:te(le),selected:le.sessionId===u,now:F,onClick:()=>j(le.sessionId,le.mode),onRename:()=>U(le),onTerminate:()=>I(le)},le.sessionId))})]},re.provider))}):m.jsx("div",{className:"px-4 py-3 text-sm text-muted-foreground/70","data-slot":"active-empty",children:"暂无活跃会话"}),ce=m.jsx(efe,{now:F});return e==="page"?m.jsxs("div",{className:"flex flex-col h-full",children:[m.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto overscroll-contain",children:[ne,Q,m.jsx(vI,{}),ce]}),m.jsx("div",{className:"px-4 pt-4 pb-[calc(env(safe-area-inset-bottom)+1rem)] border-t border-border",children:m.jsxs(vt,{className:"min-h-11 w-full md:min-h-0","data-slot":"create-session-mobile-trigger",onClick:()=>A(!0),children:[m.jsx(xz,{"aria-hidden":"true"}),"新建"]})}),m.jsx(Vfe,{open:R,creatingTerminal:N,onOpenChange:A,onCreateAgent:()=>{A(!1),k(!0)},onCreateTerminal:()=>{wF()?(A(!1),T(!0)):B(void 0,()=>A(!1))},onCreatePreview:()=>{A(!1),z(!0)}}),m.jsx(xF,{layout:"mobile",open:M,creatingTerminal:N,creatingShell:L,onOpenChange:T,onBack:()=>{T(!1),A(!0)},onCreate:re=>void B(re,()=>T(!1))}),m.jsx(lp,{open:x,onOpenChange:k}),m.jsx(yF,{open:P,onOpenChange:z}),m.jsx(bv,{open:G!==null,session:G,onOpenChange:re=>{re||I(null)},onConfirm:q}),m.jsx(cp,{open:Y!==null,sessionId:(Y==null?void 0:Y.sessionId)??null,initialName:Y==null?void 0:Y.name,onOpenChange:re=>{re||U(null)},onRename:K})]}):m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"dev-sidebar-scroll h-full overflow-y-auto overscroll-contain",children:[ne,Q,m.jsx(vI,{}),ce]}),m.jsx(lp,{open:x,onOpenChange:k}),m.jsx(bv,{open:G!==null,session:G,onOpenChange:re=>{re||I(null)},onConfirm:q}),m.jsx(cp,{open:Y!==null,sessionId:(Y==null?void 0:Y.sessionId)??null,initialName:Y==null?void 0:Y.name,onOpenChange:re=>{re||U(null)},onRename:K})]})}function Ffe(e){const t=new Map;for(const n of e){const r=n.kind==="terminal"?"terminal":n.provider,i=t.get(r);i?i.push(n):t.set(r,[n])}return Array.from(t.entries()).sort(([n],[r])=>Hfe(n,r)).map(([n,r])=>({provider:n,sessions:r}))}function $fe(e){return e==="terminal"?"终端":Yb(e)}function Hfe(e,t){return e===t?0:e==="terminal"?-1:t==="terminal"?1:aF(e,t)}function _F(){const e=Cs(),[t,n]=b.useState(null),r=t!==null;async function i(s,o){var u;const l=Me.getState();if(!(r||!l.connected||!l.proxyOnline||!l.selectedProxyId||l.proxySwitchTarget)&&!Mk(l)&&!(s&&!((u=l.terminalShells)!=null&&u.some(d=>d.id===s)))){n(s??"default");try{const d=await dfe({relay:$t,shell:s});if(d.type!=="success"){Ue.error(d.message);return}Ut.getState().addSession(d.session),o==null||o(),e(d.route)}finally{n(null)}}}return{creatingTerminal:r,creatingShell:t,createTerminal:i}}function Mk(e){var t;return!e.terminalShellsLoaded&&((t=e.proxies.find(n=>n.proxyId===e.selectedProxyId))==null?void 0:t.osName)==="Windows"}function Ufe(e){const t=Me(u=>u.terminalShells),n=Me(Mk),r=Me(u=>u.selectedProxyId),[i,s]=b.useState(!1),[o,l]=b.useState(0);return b.useEffect(()=>{if(!e||!n)return;let u=!1;const d=$t,f=d==null?void 0:d.getPreviewScope();if(s(!1),!d||!f||f.proxyId!==r){s(!0);return}return d.requestProxyInfo().then(h=>{const y=Me.getState(),g=d.getPreviewScope();u||!y.connected||!y.proxyOnline||y.selectedProxyId!==r||!g||!Jt(f,g)||y.setTerminalShells(h.terminalShells)},()=>{u||s(!0)}),()=>{u=!0}},[e,n,r,o]),{terminalShells:t,needsDetection:n,failed:i,retry:()=>l(u=>u+1)}}const Wfe=[{label:"启动 Shell"}];function qfe(e){return e!=null&&e.length?e:Wfe}function wF(){var t;const e=Me.getState();return Mk(e)||!!((t=e.terminalShells)!=null&&t.length)}function yI({compact:e=!1}){const[t,n]=b.useState(!1),[r,i]=b.useState(!1),[s,o]=b.useState(!1),[l,u]=b.useState(!1),[d,f]=b.useState(!1),h=b.useRef(!1),y=Me(Y=>!!Y.selectedProxyId),g=Me(Y=>Y.proxySwitchTarget!==null),_=y&&!g,{creatingTerminal:w,creatingShell:S,createTerminal:x}=_F();function k(){f(!0),window.setTimeout(()=>f(!1),2e3)}function R(){if(!_){k();return}h.current=!0,o(!0)}function A(){if(!_){k();return}h.current=!0,wF()?i(!0):x()}function M(){if(!_){k();return}h.current=!0,u(!0)}function T(Y){Y.preventDefault(),k()}const P=m.jsxs(vt,{variant:"outline","data-slot":"create-session-trigger",className:qe(e?"h-11 w-11 justify-center border-border px-0":"h-[46px] w-full justify-center gap-2 border-border px-3",!_&&"opacity-50 hover:bg-background"),"aria-label":"新建","aria-disabled":!_,onClick:_?void 0:T,children:[m.jsx(xz,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),!e&&m.jsx("span",{className:"truncate",children:"新建"})]}),z=_?m.jsxs(_f,{open:t,onOpenChange:n,children:[m.jsx(wf,{asChild:!0,children:P}),m.jsxs(xf,{align:e?"end":"start",className:"w-80","data-slot":"create-session-type-menu",onCloseAutoFocus:Y=>{h.current&&(h.current=!1,Y.preventDefault())},children:[m.jsxs(Zr,{className:"min-h-9 gap-2.5","data-slot":"create-agent-session-item",onSelect:R,children:[m.jsx(_z,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),"Agent 会话"]}),m.jsxs(Zr,{className:"min-h-9 gap-2.5","data-slot":"create-terminal-session-item",disabled:w,onSelect:A,children:[m.jsx(ru,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),w?"正在创建 Shell 会话...":"Shell 会话"]}),m.jsx(Gc,{}),m.jsxs(Zr,{className:"min-h-[3.75rem] items-start gap-2.5 py-2","data-slot":"create-frontend-preview-item",onSelect:M,children:[m.jsx(CC,{className:"mt-0.5 size-4 text-muted-foreground","aria-hidden":"true"}),m.jsxs("span",{className:"min-w-0 flex-1",children:[m.jsx("span",{className:"flex items-center gap-1.5 font-medium",children:"预览"}),m.jsx("span",{className:"mt-0.5 block text-xs leading-4 text-muted-foreground",children:"在浏览器中预览网页或设备模拟器"})]})]})]})]}):P;return m.jsxs(m.Fragment,{children:[_?z:m.jsxs(Sf,{open:_?void 0:d,onOpenChange:_?void 0:f,children:[m.jsx(Ef,{asChild:!0,children:z}),m.jsx(Cf,{side:"top",children:g?"正在切换开发机":"请先连接开发机"})]}),m.jsx(xF,{layout:"desktop",open:r,creatingTerminal:w,creatingShell:S,onOpenChange:i,onBack:()=>{i(!1),n(!0)},onCreate:Y=>void x(Y,()=>i(!1))}),m.jsx(lp,{open:s,onOpenChange:o}),m.jsx(yF,{open:l,onOpenChange:u})]})}function Vfe({open:e,creatingTerminal:t,onOpenChange:n,onCreateAgent:r,onCreateTerminal:i,onCreatePreview:s}){const o=b.useRef(!1);function l(u){o.current=!0,u()}return m.jsx(pc,{open:e,onOpenChange:n,children:m.jsxs(mc,{side:"bottom",overlayClassName:"bg-black/10 dark:bg-black/30",className:"inset-x-2 w-auto rounded-t-xl border border-border/80 bg-background px-3 pb-[max(theme(spacing.4),env(safe-area-inset-bottom))] pt-3 shadow-2xl","data-slot":"create-session-type-sheet",focusSurfaceOnOpen:!0,onCloseAutoFocus:u=>{o.current&&(o.current=!1,u.preventDefault())},children:[m.jsx(Eu,{className:"px-1 pb-1 pt-0 text-left",children:m.jsx(gc,{children:"新建"})}),m.jsxs("div",{className:"grid gap-2 pb-1","data-slot":"create-session-type-options",children:[m.jsxs(vt,{type:"button",variant:"ghost",className:"min-h-12 justify-start gap-3 rounded-md px-3 text-left","data-slot":"create-agent-session-sheet-item",onClick:()=>l(r),children:[m.jsx(_z,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),"Agent 会话"]}),m.jsxs(vt,{type:"button",variant:"ghost",className:"min-h-12 justify-start gap-3 rounded-md px-3 text-left","data-slot":"create-terminal-session-sheet-item",disabled:t,onClick:()=>l(i),children:[m.jsx(ru,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),t?"正在创建 Shell 会话...":"Shell 会话"]}),m.jsx("div",{className:"mx-1 h-px bg-border","aria-hidden":"true"}),m.jsxs(vt,{type:"button",variant:"ghost",className:"min-h-16 justify-start gap-3 rounded-md px-3 text-left","data-slot":"create-frontend-preview-sheet-item",onClick:()=>l(s),children:[m.jsx(CC,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),m.jsxs("span",{className:"min-w-0",children:[m.jsx("span",{className:"flex items-center gap-1.5 font-medium",children:"预览"}),m.jsx("span",{className:"mt-0.5 block text-xs leading-4 text-muted-foreground",children:"在浏览器中预览网页或设备模拟器"})]})]})]})]})})}function xF({layout:e,open:t,creatingTerminal:n,creatingShell:r,onOpenChange:i,onBack:s,onCreate:o}){const{terminalShells:l,needsDetection:u,failed:d,retry:f}=Ufe(t),h=b.useRef(!1),y=Me(w=>w.connected&&w.proxyOnline&&!!w.selectedProxyId&&!w.proxySwitchTarget),g=m.jsxs("div",{className:"grid gap-2","data-slot":"terminal-shell-options",children:[u?m.jsxs(vt,{type:"button",variant:"ghost",className:"min-h-12 justify-start gap-3 rounded-md px-3 text-left","data-slot":"terminal-shell-detection",disabled:!d,onClick:f,children:[m.jsx(ru,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),d?"终端检测失败,点击重试":"正在检测终端..."]}):qfe(l).map(w=>m.jsxs(vt,{type:"button",variant:"ghost",className:"min-h-12 justify-start gap-3 rounded-md px-3 text-left","data-slot":"terminal-shell-option","data-shell":w.id,disabled:n||!y,onClick:()=>o(w.id),children:[m.jsx(ru,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),r===(w.id??"default")?"正在创建 Shell 会话...":w.label]},w.id??"default")),m.jsx("div",{className:"mx-1 h-px bg-border","aria-hidden":"true"}),m.jsxs(vt,{type:"button",variant:"ghost",className:"min-h-11 justify-start gap-3 px-3 text-muted-foreground",disabled:n,onClick:()=>{h.current=!0,s()},children:[m.jsx(ff,{className:"size-4","aria-hidden":"true"}),"返回"]})]});function _(w){h.current&&(h.current=!1,w.preventDefault())}return e==="mobile"?m.jsx(pc,{open:t,onOpenChange:i,children:m.jsxs(mc,{side:"bottom",overlayClassName:"bg-black/10 dark:bg-black/30",className:"inset-x-2 w-auto rounded-t-xl border border-border/80 bg-background px-3 pb-[max(theme(spacing.4),env(safe-area-inset-bottom))] pt-3 shadow-2xl","data-slot":"create-terminal-shell-dialog",focusSurfaceOnOpen:!0,onCloseAutoFocus:_,children:[m.jsx(Eu,{className:"px-1 pb-1 pt-0 text-left",children:m.jsx(gc,{children:"Shell 会话"})}),g]})}):m.jsx(es,{open:t,onOpenChange:i,children:m.jsxs(ts,{className:"sm:max-w-sm","data-slot":"create-terminal-shell-dialog",focusSurfaceOnOpen:!0,onCloseAutoFocus:_,children:[m.jsx(ns,{children:m.jsx($i,{children:"Shell 会话"})}),g]})})}const Yfe="0.9.13",Kfe={version:Yfe},Gfe={playback:"playback",capture:"play-and-record"};function Xfe(){return typeof navigator>"u"?null:navigator.audioSession??null}function Zfe(){return{setMode:()=>{},release:()=>{}}}class Qfe{constructor(t=Xfe){je(this,"leases",new Map);je(this,"session",null);je(this,"baselineType",null);je(this,"nextLeaseId",1);je(this,"nextOrder",1);this.getAudioSession=t}acquire(t){const n=this.getAudioSession();if(!n)return Zfe();this.leases.size===0&&(this.session=n,this.baselineType=n.type);const r=this.nextLeaseId++;this.leases.set(r,{mode:t,order:this.nextOrder++});try{this.applyActiveMode()}catch(s){throw this.leases.delete(r),this.leases.size===0?this.restoreWhenUnused():this.applyActiveModeBestEffort(),s}let i=!1;return{setMode:s=>{if(i)return;const o=this.leases.get(r);if(!o)return;const l={...o};o.mode=s,o.order=this.nextOrder++;try{this.applyActiveMode()}catch(u){throw this.leases.set(r,l),this.applyActiveModeBestEffort(),u}},release:()=>{if(!i){if(i=!0,this.leases.delete(r),this.leases.size===0){this.restoreWhenUnused();return}this.applyActiveModeBestEffort()}}}}applyActiveMode(){const t=[...this.leases.values()].reduce((n,r)=>!n||r.order>n.order?r:n,null);!t||!this.session||this.setNativeType(Gfe[t.mode])}applyActiveModeBestEffort(){try{this.applyActiveMode()}catch{}}restoreWhenUnused(){const t=this.session,n=this.baselineType;if(this.session=null,this.baselineType=null,!(!t||n===null))try{t.type=n}catch{}}setNativeType(t){if(!(!this.session||this.session.type===t)){try{this.session.type=t}catch{throw new Error("浏览器无法切换语音音频模式")}if(this.session.type!==t)throw new Error("浏览器无法切换语音音频模式")}}}const Pk=new Qfe,P1=64,bI=-60,SF=32;function _I(e){if(!Number.isFinite(e)||e===0)return 0;const t=Math.min(1,Math.abs(e)),n=20*Math.log10(t),r=Math.max(0,Math.min(1,(n-bI)/-bI));return e<0?-r:r}function wI(e,t=8){const n=Math.floor(e.byteLength/2);if(n===0||!Number.isFinite(t)||t<=0)return[];const r=Math.min(n,Math.max(1,Math.floor(t))),i=new DataView(e.buffer,e.byteOffset,e.byteLength),s=[];for(let o=0;o<r;o+=1){const l=Math.floor(o*n/r),u=Math.max(l+1,Math.floor((o+1)*n/r));let d=1,f=-1;for(let h=l;h<u;h+=1){const y=i.getInt16(h*2,!0)/32768;d=Math.min(d,y),f=Math.max(f,y)}s.push({min:d,max:f})}return s}function Jfe(e){const t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=Math.floor(e.byteLength/2),r=new Float32Array(n);for(let i=0;i<n;i+=1)r[i]=t.getInt16(i*2,!0)/32768;return r}function ehe(e){if(e.length===0)return 0;const t=Math.max(1,Math.floor(e.length/512));let n=0,r=0;for(let i=0;i<e.length;i+=t){const s=e[i]??0;n+=s*s,r+=1}return r===0?0:Math.min(1,Math.sqrt(n/r)*10)}class EF{constructor(t,n=24e3,r={}){je(this,"nextStartTime",0);je(this,"activityEndToken",0);je(this,"timelineTimers",new Set);this.context=t,this.sampleRate=n,this.options=r}async resume(){this.emitPlaybackEvent("resume-start");try{if(this.context.state!=="running"&&this.context.state!=="closed"&&await this.context.resume(),this.context.state!=="running")throw new Error("浏览器未允许播放 Voice Pilot 提示音");this.emitPlaybackEvent("resume-finished")}catch(t){throw this.emitPlaybackEvent("resume-failed",{error:t instanceof Error?t.message:String(t)}),t}}enqueue(t){this.context.state==="suspended"&&this.resume().catch(()=>{});const n=Jfe(t),r=this.context.createBuffer(1,n.length,this.sampleRate);r.getChannelData(0).set(n);const i=this.context.createBufferSource();i.buffer=r,i.connect(this.context.destination);const s=Math.max(this.context.currentTime,this.nextStartTime);i.start(s);const o=s+r.duration;this.nextStartTime=o,this.schedulePlaybackFrames(t,n,s,o);const l=Math.max(0,(o-this.context.currentTime)*1e3);return this.emitPlaybackEvent("pcm-scheduled",{bytes:t.byteLength,durationMs:r.duration*1e3}),typeof i.addEventListener=="function"&&i.addEventListener("ended",()=>{this.emitPlaybackEvent("source-ended",{bytes:t.byteLength,durationMs:r.duration*1e3})},{once:!0}),l}stop(){var t,n;this.nextStartTime=this.context.currentTime,this.activityEndToken+=1;for(const r of this.timelineTimers)clearTimeout(r);this.timelineTimers.clear(),(n=(t=this.options).onActivityLevel)==null||n.call(t,0),this.emitPlaybackEvent("stopped")}snapshot(){const t=this.context.currentTime;return{contextState:String(this.context.state??"unknown"),contextTime:t,nextStartTime:this.nextStartTime,queuedMs:Math.max(0,(this.nextStartTime-t)*1e3)}}schedulePlaybackFrames(t,n,r,i){if(!this.options.onActivityLevel&&!this.options.onPlaybackChunk)return;const s=Math.max(1,Math.round(this.sampleRate*SF/1e3)),o=this.activityEndToken+=1;for(let l=0;l<n.length;l+=s){const u=Math.min(n.length,l+s),d=r+l/this.sampleRate,f=Math.max(0,(d-this.context.currentTime)*1e3),h=t.slice(l*Int16Array.BYTES_PER_ELEMENT,u*Int16Array.BYTES_PER_ELEMENT),y=ehe(n.subarray(l,u));this.scheduleTimer(()=>{var g,_,w,S;(_=(g=this.options).onActivityLevel)==null||_.call(g,y),(S=(w=this.options).onPlaybackChunk)==null||S.call(w,h)},f)}if(this.options.onActivityLevel){const l=Math.max(0,(i-this.context.currentTime)*1e3);this.scheduleTimer(()=>{var u,d;o===this.activityEndToken&&((d=(u=this.options).onActivityLevel)==null||d.call(u,0))},l)}}scheduleTimer(t,n){const r=setTimeout(()=>{this.timelineTimers.delete(r),t()},n);this.timelineTimers.add(r)}emitPlaybackEvent(t,n={}){var r,i;(i=(r=this.options).onPlaybackEvent)==null||i.call(r,{event:t,...this.snapshot(),...n})}}const w0={provider:"aliyun-bailian",configured:!1,region:"cn",asrModel:"qwen3-asr-flash-realtime",ttsModel:"cosyvoice-v3-flash",ttsVoice:"longanyang",turnIdleSeconds:3},xI="min-h-11 min-w-0 rounded-md border border-border bg-input px-3 text-base outline-none transition-colors placeholder:text-muted-foreground/65 focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring md:h-9 md:min-h-0 md:text-sm",the=800,SI=300,nhe=1600;function I1(e,t){return e.filter(n=>!n.model||n.model===t)}function EI({label:e,children:t,help:n}){return m.jsxs("div",{className:"block min-w-0 rounded-lg border border-border/75 bg-card/55 p-3.5 transition-colors focus-within:border-ring/55 focus-within:bg-card/75 sm:p-3",children:[m.jsx("span",{className:"block text-[13px] font-medium leading-none text-muted-foreground",children:e}),m.jsx("div",{className:"mt-2 min-w-0",children:t}),n?m.jsx("span",{className:"mt-2 block text-xs leading-relaxed text-muted-foreground",children:n}):null]})}function _v({label:e,value:t,options:n,onChange:r,placeholder:i="请选择",help:s}){const[o,l]=b.useState(!1),u=b.useId(),d=n.find(g=>g.value===t),f=(d==null?void 0:d.label)??(t||i),h=n.filter(g=>!g.disabled),y=!!CF(f).detail;return m.jsxs("div",{className:"min-w-0 rounded-lg border border-border/75 bg-card/55 p-3.5 sm:p-3",onBlur:g=>{g.currentTarget.contains(g.relatedTarget)||l(!1)},children:[m.jsx("div",{id:u,className:"text-[13px] font-medium leading-none text-muted-foreground",children:e}),m.jsxs("button",{type:"button","aria-labelledby":u,"aria-haspopup":"listbox","aria-expanded":o,disabled:h.length===0,className:`mt-2 flex w-full min-w-0 items-center justify-between gap-3 rounded-md border border-border bg-input px-3 text-left outline-none transition-colors hover:border-primary/40 focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-60 ${y?"min-h-[60px] py-2":"min-h-11"}`,onClick:()=>l(g=>!g),"data-slot":"voice-settings-choice-trigger",children:[m.jsx(CI,{label:f,muted:!d&&!t}),m.jsx(sc,{className:`size-4 shrink-0 text-muted-foreground transition-transform ${o?"rotate-180":""}`,"aria-hidden":"true"})]}),o?m.jsx("div",{role:"listbox","aria-labelledby":u,className:"mt-2 max-h-64 overflow-y-auto rounded-md border border-border/80 bg-popover p-1 shadow-sm",children:n.map(g=>{const _=g.value===t;return m.jsxs("button",{type:"button",role:"option","aria-label":g.label,"aria-selected":_,disabled:g.disabled,className:"flex w-full min-w-0 items-center gap-2 rounded-sm px-2.5 py-2.5 text-left text-sm outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>{g.disabled||(r(g.value),l(!1))},children:[m.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center text-primary",children:_?m.jsx(ua,{className:"size-4","aria-hidden":"true"}):null}),m.jsx(CI,{label:g.label})]},g.value)})}):null,s?m.jsx("div",{className:"mt-2 text-xs leading-relaxed text-muted-foreground",children:s}):null]})}function CI({label:e,muted:t=!1}){const n=CF(e);return m.jsxs("span",{className:"min-w-0 flex-1",children:[m.jsx("span",{className:`block truncate text-base leading-6 md:text-sm ${t?"text-muted-foreground":"text-foreground"}`,children:n.title}),n.detail?m.jsx("span",{className:"mt-0.5 block truncate text-xs leading-4 text-muted-foreground",children:n.detail}):null]})}function rhe({scrollRef:e}={}){const[t,n]=b.useState(w0),[r,i]=b.useState(String(w0.turnIdleSeconds)),[s,o]=b.useState(()=>sv()),[l,u]=b.useState(""),[d,f]=b.useState(!1),[h,y]=b.useState(!1),[g,_]=b.useState({kind:"idle"}),w=b.useRef(null),S=b.useRef(null),x=b.useRef(null),k=b.useRef(null),R=b.useRef(null),A=b.useRef(!1);b.useEffect(()=>{const Q=$t;if(!Q){_({kind:"error",message:"请先连接 Relay 服务器"});return}let ce=!1;return _({kind:"loading"}),Q.requestVoiceConfig().then(re=>{if(!ce){if(re.error||!re.config){_({kind:"error",message:re.error??"读取语音设置失败"});return}n(re.config),i(String(re.config.turnIdleSeconds)),u(""),f(!1),y(!0),_({kind:"idle"})}}).catch(re=>{ce||_({kind:"error",message:re instanceof Error?re.message:"读取语音设置失败"})}),()=>{ce=!0}},[]),b.useEffect(()=>{const Q=$t;if(!Q||!h)return;let ce=!1;return Q.requestVoiceCapabilities({region:t.region}).then(re=>{if(!ce){if(re.error||!re.capabilities){o(sv());return}o(re.capabilities)}}).catch(()=>{ce||o(sv())}),()=>{ce=!0}},[t.region,h]),b.useEffect(()=>(A.current=!0,()=>{A.current=!1,$(),te()}),[]);const M=b.useMemo(()=>g.kind==="loading"?"读取中...":g.kind==="saving"?"保存中...":g.kind==="testing"?"正在测试语音合成":g.kind==="playingTest"?"正在播放测试音频":g.kind==="testPassed"?"测试通过":g.kind==="saved"?"已保存":g.kind==="error"?g.message:null,[g]),T=g.kind==="saving"||g.kind==="loading"||g.kind==="testing"||g.kind==="playingTest",P=b.useMemo(()=>I1(s.ttsVoices,t.ttsModel),[s.ttsVoices,t.ttsModel]),Y=P.some(Q=>Q.value===t.ttsVoice)?t.ttsVoice:"",U=P.length===0?"当前模型暂无可用音色":Y?null:"请选择可用音色",G=b.useMemo(()=>ahe(r),[r]),I=G?null:"请输入正整数秒数",N=U??I,L=T||!!N,B=b.useMemo(()=>[{value:"cn",label:"中国大陆"},{value:"intl",label:"国际"}],[]),O=b.useMemo(()=>RI(s.asrModels,t.asrModel),[s.asrModels,t.asrModel]),D=b.useMemo(()=>lhe(s.ttsModels,s.ttsVoices,t.ttsModel),[s.ttsModels,s.ttsVoices,t.ttsModel]),F=b.useMemo(()=>RI(P,Y),[P,Y]);function V(){return{...d?{clearApiKey:!0}:{},...!d&&l.trim()?{apiKey:l.trim()}:{},region:t.region,asrModel:t.asrModel.trim(),ttsModel:t.ttsModel.trim(),ttsVoice:t.ttsVoice.trim(),turnIdleSeconds:G??w0.turnIdleSeconds}}async function j(){if(T)return;if(N){_({kind:"error",message:N});return}const Q=$t;if(!Q){_({kind:"error",message:"请先连接 Relay 服务器"});return}const ce=V();te(),_({kind:"saving"});const re=performance.now();try{const le=await Q.updateVoiceConfig(ce);if(!A.current)return;const we=performance.now()-re;if(we<SI&&await ohe(SI-we),!A.current)return;if(!le.success||le.error||!le.config){_({kind:"error",message:le.error??"保存语音设置失败"});return}n(le.config),i(String(le.config.turnIdleSeconds)),u(""),f(!1),_({kind:"saved"}),R.current=setTimeout(()=>{R.current=null,_(Ce=>Ce.kind==="saved"?{kind:"idle"}:Ce)},nhe),Q.requestVoiceCapabilities({region:le.config.region}).then(Ce=>{A.current&&Ce.capabilities&&o(Ce.capabilities)}).catch(()=>{A.current&&o(sv())})}catch(le){if(!A.current)return;_({kind:"error",message:le instanceof Error?le.message:"保存语音设置失败"})}}async function q(){if(T)return;if(N){_({kind:"error",message:N});return}const Q=$t;if(!Q){_({kind:"error",message:"请先连接 Relay 服务器"});return}let ce;try{ce=K()}catch(re){_({kind:"error",message:TI(re)});return}_({kind:"testing"});try{const[re]=await Promise.all([Q.testVoiceConfig(V()),ce.ready]);if(!re.success||re.error){$(),_({kind:"error",message:re.error??"语音配置测试失败"});return}const le=await J(re,ce.context);_({kind:"playingTest",transcript:re.transcript}),k.current=setTimeout(()=>{k.current=null,$(),_({kind:"testPassed",transcript:re.transcript})},le)}catch(re){$(),_({kind:"error",message:TI(re)})}}function K(){$();const Q=Pk.acquire("playback");S.current=Q;try{const ce=she();return w.current=ce,{context:ce,ready:kI(ce)}}catch(ce){throw Q.release(),S.current=null,ce}}function $(){var Q,ce,re;k.current&&(clearTimeout(k.current),k.current=null),(Q=x.current)==null||Q.stop(),x.current=null,(ce=w.current)==null||ce.close(),w.current=null,(re=S.current)==null||re.release(),S.current=null}function te(){R.current&&(clearTimeout(R.current),R.current=null)}async function J(Q,ce){if(!Q.audioBase64)throw new Error("语音测试未返回可播放音频");if(Q.audioEncoding&&Q.audioEncoding!=="pcm_s16le")throw new Error("测试音频格式暂不支持");const re=Q.audioSampleRate??24e3,le=ihe(Q.audioBase64);if(le.byteLength===0||le.byteLength%2!==0)throw new Error("测试音频数据无效");await kI(ce);const we=new EF(ce,re);x.current=we,we.enqueue(le);const Ce=Math.ceil(le.byteLength/2/re*1e3);return Math.max(the,Ce)}function ne(Q){var ce;return((ce=I1(s.ttsVoices,Q)[0])==null?void 0:ce.value)??""}return m.jsxs("form",{className:"flex min-h-0 min-w-0 flex-1 flex-col","data-slot":"voice-settings-panel",autoComplete:"off",onSubmit:Q=>{Q.preventDefault(),j()},children:[m.jsx("div",{className:"flex min-h-0 flex-1 flex-col px-4 py-3 sm:px-5 sm:py-3.5","data-slot":"voice-settings-body-frame",children:m.jsx("div",{className:"dev-render-scroll min-h-0 flex-1 overflow-y-auto overscroll-contain pr-4 sm:pr-1","data-slot":"voice-settings-scroll",ref:e,children:m.jsxs("div",{className:"space-y-3","data-slot":"voice-settings-fields",children:[m.jsx("div",{className:"grid gap-2 rounded-lg border border-border/75 bg-card/55 p-3.5 sm:p-3",children:m.jsxs("div",{className:"flex items-center justify-between gap-3",children:[m.jsxs("div",{className:"min-w-0",children:[m.jsx("div",{className:"text-[13px] font-medium leading-none text-muted-foreground",children:"服务商"}),m.jsx("div",{className:"mt-2 truncate text-base font-medium text-foreground md:text-sm",children:"阿里云百炼"})]}),m.jsx("span",{className:"shrink-0 rounded-full border border-primary/35 bg-primary/10 px-2.5 py-1 text-xs font-medium text-primary",children:"Bailian"})]})}),m.jsx(EI,{label:"阿里云百炼 API Key",help:d?"保存后会清空已保存的 key":null,children:m.jsxs("div",{className:"flex min-w-0 gap-2",children:[m.jsxs("div",{className:"relative min-w-0 flex-1",children:[m.jsx(kz,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground","aria-hidden":"true"}),m.jsx("input",{"aria-label":"阿里云百炼 API Key",type:"password",name:"dev-anywhere-bailian-api-key",autoComplete:"off",value:l,onChange:Q=>{u(Q.target.value),f(!1)},placeholder:d?"保存后清空":t.configured?"••••••••••••••••":"输入 API Key",className:`${xI} w-full pl-9`})]}),t.configured&&m.jsxs(vt,{type:"button",variant:"outline",className:"min-h-11 shrink-0 px-3 md:h-9 md:min-h-0",onClick:()=>{u(""),f(!0)},children:[m.jsx(Mz,{className:"size-4","aria-hidden":"true"}),"清空"]})]})}),m.jsx(_v,{label:"地域",value:t.region,options:B,onChange:Q=>n(ce=>({...ce,region:Q==="intl"?"intl":"cn"}))}),m.jsx(_v,{label:"语音识别模型",value:t.asrModel,options:O,onChange:Q=>n(ce=>({...ce,asrModel:Q}))}),m.jsx(_v,{label:"语音合成模型",value:t.ttsModel,options:D,onChange:Q=>n(ce=>({...ce,ttsModel:Q,ttsVoice:ne(Q)}))}),m.jsx(_v,{label:"语音音色",value:Y,options:F,placeholder:P.length===0?"暂无可用音色":"请选择音色",onChange:Q=>n(ce=>({...ce,ttsVoice:Q})),help:U}),m.jsx(EI,{label:"结束停顿时间(秒)",help:I,children:m.jsx("input",{"aria-label":"结束停顿时间(秒)",type:"number",min:1,step:1,inputMode:"numeric",value:r,onChange:Q=>i(Q.target.value),className:`${xI} w-full`})})]})})}),m.jsxs("div",{className:"bg-background/95 px-4 pb-3.5 pt-0 backdrop-blur sm:px-5","data-slot":"voice-settings-footer",children:[m.jsx("div",{className:"mr-4 border-t border-border/70","data-slot":"voice-settings-footer-divider"}),m.jsxs("div",{className:"mt-3.5 flex items-center justify-end gap-2",children:[M?m.jsx("div",{role:g.kind==="error"?"alert":"status","aria-live":"polite",className:g.kind==="error"?"min-w-0 flex-1 text-sm text-destructive":"min-w-0 flex-1 text-sm text-muted-foreground",children:M}):null,m.jsxs(vt,{type:"button",variant:"outline",disabled:L,onClick:()=>void q(),children:[m.jsx(Rz,{className:"size-4","aria-hidden":"true"}),"测试"]}),m.jsxs(vt,{type:"submit",disabled:L,children:[m.jsx(sK,{className:"size-4","aria-hidden":"true"}),g.kind==="saving"?"保存中...":"保存"]})]})]})]})}function ihe(e){const t=window.atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r+=1)n[r]=t.charCodeAt(r);return n}function she(){const e=window,t=e.AudioContext??e.webkitAudioContext;if(!t)throw new Error("当前浏览器不支持音频播放");return new t}async function kI(e){if(e.state!=="running")try{await e.resume()}catch{throw new Error("浏览器阻止了测试音频播放,请再次点击测试")}if(e.state!=="running")throw new Error("浏览器阻止了测试音频播放,请再次点击测试")}function TI(e){return e instanceof Error?e.message:"语音配置测试失败"}function ohe(e){return new Promise(t=>setTimeout(t,e))}function ahe(e){const t=e.trim();if(!/^[1-9]\d*$/.test(t))return null;const n=Number(t);return Number.isSafeInteger(n)?n:null}function RI(e,t){const n=e.map(r=>({value:r.value,label:kF(r)}));return!t||n.some(r=>r.value===t)?n:[{value:t,label:t},...n]}function lhe(e,t,n){const r=e.map(i=>{const s=I1(t,i.value).length===0;return{value:i.value,label:`${kF(i)}${s?" · 暂无音色":""}`,disabled:s}});return!n||r.some(i=>i.value===n)?r:[{value:n,label:`${n} · 暂无音色`,disabled:!0},...r]}function CF(e){const t=e.split(" · ").map(n=>n.trim()).filter(Boolean);return t.length<=1?{title:e,detail:null}:{title:t[0],detail:t.slice(1).join(" · ")}}function kF(e){if(!e.age)return e.label;const t=`年龄 ${e.age}`;if(e.label.includes(t))return e.label;const n=` · ${e.age}`;return e.label.endsWith(n)?`${e.label.slice(0,-n.length)} · ${t}`:`${e.label} · ${t}`}const che=[{value:"auto",label:"跟随系统"},{value:"light",label:"浅色"},{value:"dark",label:"深色"}],uhe=[{value:"auto",label:"自动"},{value:"touch",label:"触控优先"},{value:"hardware",label:"实体键盘优先"}],Ik="dev-render-scroll min-h-0 space-y-3 overflow-y-auto overscroll-contain pr-4 sm:pr-1";function TF(e){if(!Number.isFinite(e)||e<0)return"未知";if(e<60)return`${Math.floor(e)} 秒`;const t=Math.floor(e/60);if(t<60)return`${t} 分钟`;const n=Math.floor(t/60),r=t%60;if(n<24)return r>0?`${n} 小时 ${r} 分钟`:`${n} 小时`;const i=Math.floor(n/24),s=n%24;return s>0?`${i} 天 ${s} 小时`:`${i} 天`}function dhe(e){const t=e||window.location.origin;return new URL("/health",t).toString()}function fhe(e){return e==="version"?"版本":e==="relay-token"?"Relay Token":e==="clients"?"客户端管理":"设置 Voice Pilot"}function hhe(e){return e==="version"?"Web 与 Relay 服务器版本。":e==="relay-token"?"连接受保护的 Relay 服务器,保存后立即重连。":e==="clients"?"管理当前连接的 Web 客户端。":"连接语音服务后,即可以语音交互的形式驱动会话。"}function O1({open:e,onOpenChange:t}){const n=Me(G=>G.relayUrl),r=Me(G=>G.latencyMonitorEnabled),i=Me(G=>G.setLatencyMonitorEnabled),s=Me(G=>G.sessionIdleNotificationsEnabled),o=Me(G=>G.setSessionIdleNotificationsEnabled),l=Me(G=>G.inputModePreference),u=Me(G=>G.setInputModePreference),d=Me(G=>G.themePreference),f=Me(G=>G.setThemePreference),h=Me(G=>G.ptyScrollTraceEnabled),y=Me(G=>G.setPtyScrollTraceEnabled),[g,_]=b.useState("menu"),[w,S]=b.useState(e),[x,k]=b.useState({kind:"idle"}),R=b.useRef(null),A=b.useRef(null),M=Ose(),T=b.useMemo(()=>pf().osName==="iPad",[]);e!==w&&(S(e),e&&_("menu"));const P=b.useCallback(async G=>{if(!G){o(!1);return}const I=await sse();if(I==="granted"){o(!0);return}if(I==="denied"){Ue.error("浏览器未授予通知权限,请在浏览器设置中允许通知");return}if(I==="default"){Ue.info("未授予通知权限,会话通知保持关闭");return}Ue.error("当前浏览器不支持系统通知")},[o]),z=b.useCallback(async G=>{k({kind:"loading"});try{const I=await fetch(dhe(n),{cache:"no-store",signal:G});if(!I.ok)throw new Error(`HTTP ${I.status}`);const N=await I.json();if(N.status!=="ok")throw new Error("状态异常");k({kind:"ready",version:N.version??"未知",uptime:N.uptime??0})}catch(I){if(I instanceof DOMException&&I.name==="AbortError")return;k({kind:"error",message:I instanceof Error?"当前 Relay 服务器无法读取版本":"读取失败"})}},[n]);b.useEffect(()=>{if(!e||g!=="version")return;const G=new AbortController;return z(G.signal),()=>G.abort()},[z,e,g]),b.useEffect(()=>{if(!e||g!=="voice")return;const G=window.requestAnimationFrame(()=>{var I;(I=R.current)==null||I.focus({preventScroll:!0}),A.current&&(A.current.scrollTop=0)});return()=>window.cancelAnimationFrame(G)},[e,g]);const Y=x.kind==="ready"?x.version:x.kind==="loading"?"读取中...":x.kind==="error"?"读取失败":"未读取",U=x.kind==="ready"?`运行 ${TF(x.uptime)}`:x.kind==="error"?x.message:"从当前 Relay 服务器 /health 读取";return m.jsx(es,{open:e,onOpenChange:t,children:m.jsxs(ts,{className:qe("grid max-h-[calc(100dvh-1rem)] grid-rows-[auto_minmax(0,1fr)] overflow-hidden p-4 sm:max-w-[440px] sm:p-6",g==="voice"&&"max-h-[min(760px,calc(100dvh-1rem))] !gap-0 !p-0 sm:max-w-[480px]",g==="voice"&&"max-sm:top-auto max-sm:bottom-0 max-sm:left-2 max-sm:right-2 max-sm:h-[calc(100dvh-1rem)] max-sm:w-auto max-sm:max-h-none max-sm:max-w-none max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-b-none max-sm:rounded-t-2xl max-sm:border-x max-sm:border-b-0"),"data-slot":"settings-dialog","data-view":g,focusSurfaceOnOpen:!0,ref:R,showCloseButton:g==="menu",children:[m.jsx(ns,{className:qe(g==="menu"&&"pr-12 text-left",g!=="menu"&&"text-left",g==="voice"&&"gap-0 px-4 pb-0 pt-3.5 text-left sm:px-5 sm:pt-4"),children:g!=="menu"?m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"flex items-start gap-2",children:[m.jsx(vt,{type:"button",variant:"ghost",size:"icon",className:"-ml-2 mt-0.5 size-11 sm:size-9","aria-label":"返回设置","data-slot":"voice-settings-back",onClick:()=>_("menu"),children:m.jsx(ff,{className:"size-4","aria-hidden":"true"})}),m.jsxs("div",{className:"min-w-0 space-y-1.5 pt-0.5 text-left",children:[m.jsx($i,{children:fhe(g)}),m.jsx(Es,{className:"max-w-[28rem] leading-5",children:hhe(g)})]})]}),g==="voice"?m.jsx("div",{className:"mr-4 mt-3.5 border-t border-border/70","data-slot":"voice-settings-header-divider"}):null]}):m.jsxs(m.Fragment,{children:[m.jsx($i,{children:"设置"}),m.jsx(Es,{children:"连接、外观、通知和高级诊断选项。"})]})}),g==="version"?m.jsx(phe,{relayVersion:Y,relayDetail:U,relayMuted:x.kind==="error"}):g==="relay-token"?m.jsx(ghe,{saved:M}):g==="clients"?m.jsx(whe,{}):g==="voice"?m.jsx(rhe,{scrollRef:A}):m.jsx(mhe,{relayTokenSaved:M,themePreference:d,onThemePreferenceChange:f,inputModePreference:l,onInputModePreferenceChange:u,showInputModeSetting:T,sessionIdleNotificationsEnabled:s,onSessionIdleNotificationsEnabledChange:P,ptyScrollTraceEnabled:h,onPtyScrollTraceEnabledChange:y,latencyMonitorEnabled:r,onLatencyMonitorEnabledChange:i,onOpenVoice:()=>_("voice"),onOpenRelayToken:()=>_("relay-token"),onOpenClients:()=>_("clients"),onOpenVersion:()=>_("version")})]})})}function phe({relayVersion:e,relayDetail:t,relayMuted:n}){return m.jsxs("div",{className:Ik,"data-slot":"settings-dialog-body",children:[m.jsx(NI,{icon:m.jsx(Tz,{className:"size-4","aria-hidden":"true"}),label:"Web",value:Kfe.version,detail:"当前浏览器加载的版本"}),m.jsx(NI,{icon:m.jsx(Az,{className:"size-4","aria-hidden":"true"}),label:"Relay 服务器",value:e,detail:t,muted:n})]})}function mhe({relayTokenSaved:e,themePreference:t,onThemePreferenceChange:n,inputModePreference:r,onInputModePreferenceChange:i,showInputModeSetting:s,sessionIdleNotificationsEnabled:o,onSessionIdleNotificationsEnabledChange:l,ptyScrollTraceEnabled:u,onPtyScrollTraceEnabledChange:d,latencyMonitorEnabled:f,onLatencyMonitorEnabledChange:h,onOpenVoice:y,onOpenRelayToken:g,onOpenClients:_,onOpenVersion:w}){return m.jsxs("div",{className:"dev-render-scroll min-h-0 space-y-4 overflow-y-auto overscroll-contain pr-4 sm:pr-1","data-slot":"settings-dialog-body",children:[m.jsxs(dd,{title:"服务",children:[m.jsx(wv,{icon:m.jsx(AV,{className:"size-4","aria-hidden":"true"}),label:"Voice Pilot",detail:"用语音输入、听取回复和处理审批",onClick:y}),m.jsx(wv,{icon:m.jsx(kz,{className:"size-4","aria-hidden":"true"}),label:"Relay Token",detail:`${e?"已保存":"未设置"} · 受保护的 Relay 服务器`,onClick:g}),m.jsx(wv,{icon:m.jsx(TK,{className:"size-4","aria-hidden":"true"}),label:"客户端管理",detail:"已连接的浏览器页面和设备",onClick:_})]}),m.jsx(dd,{title:"外观",children:m.jsx(AI,{icon:m.jsx(gK,{className:"size-4","aria-hidden":"true"}),label:"主题",value:t,options:che,onValueChange:n})}),m.jsx(dd,{title:"通知",children:m.jsx(S0,{icon:m.jsx(MV,{className:"size-4","aria-hidden":"true"}),label:"会话空闲通知",detail:"会话从工作中转为空闲时发送浏览器通知",checked:o,onCheckedChange:l})}),s?m.jsx(dd,{title:"交互",children:m.jsx(AI,{icon:m.jsx(SC,{className:"size-4","aria-hidden":"true"}),label:"输入方式",detail:"默认自动识别软键盘和实体键盘;必要时可强制一种方式",value:r,options:uhe,onValueChange:i})}):null,m.jsxs(dd,{title:"高级诊断",children:[m.jsx(S0,{icon:m.jsx(ru,{className:"size-4","aria-hidden":"true"}),label:"PTY 滚动追踪",detail:"记录终端滚动和视口同步现场,方便复制诊断报告",checked:u,onCheckedChange:d}),m.jsx(S0,{icon:m.jsx(yz,{className:"size-4","aria-hidden":"true"}),label:"延迟监控",detail:"显示可拖动的连接延迟浮窗",checked:f,onCheckedChange:h})]}),m.jsx(dd,{title:"关于",children:m.jsx(wv,{icon:m.jsx(Az,{className:"size-4","aria-hidden":"true"}),label:"版本",onClick:w})})]})}function dd({title:e,children:t}){return m.jsxs("section",{className:"space-y-2","data-slot":"settings-section",children:[m.jsx("h3",{className:"px-1 text-xs font-medium text-muted-foreground",children:e}),m.jsx("div",{className:"overflow-hidden rounded-lg border border-border bg-card/55 divide-y divide-border/70",children:t})]})}function AI({icon:e,label:t,detail:n,value:r,options:i,onValueChange:s}){const o=b.useId(),l=b.useId();return m.jsxs("div",{className:"flex w-full items-start gap-3 px-3 py-3 text-left","data-slot":"settings-choice-item",children:[m.jsx("div",{className:"flex size-8 shrink-0 items-center justify-center rounded-md bg-background/55 text-muted-foreground",children:e}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsx("div",{id:o,className:"text-sm font-medium text-foreground",children:t}),n?m.jsx("div",{id:l,className:"mt-1 text-xs text-muted-foreground",children:n}):null,m.jsx("div",{role:"radiogroup","aria-labelledby":o,"aria-describedby":n?l:void 0,className:"mt-3 grid grid-cols-3 gap-1 rounded-md border border-border bg-muted/70 p-1","data-slot":"settings-segmented-choice",children:i.map(u=>{const d=u.value===r;return m.jsx("button",{type:"button",role:"radio","aria-checked":d,className:qe("min-w-0 whitespace-nowrap rounded px-2 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",d?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:bg-background/55 hover:text-foreground"),onClick:()=>s(u.value),children:u.label},u.value)})})]})]})}function ghe({saved:e}){const t=b.useId(),n=b.useId(),[r,i]=b.useState(""),[s,o]=b.useState(null),l=()=>{_5().catch(f=>{o(f instanceof Error?f.message:"Relay 重连失败。")})},u=()=>{const f=r.trim();if(!f){o("请输入 token。");return}if(!y5(f)){const h="Relay Token 保存失败,请检查浏览器存储权限。";o(h),Ue.error(h);return}o(null),Ue.success("Relay Token 已保存,正在重新连接"),l()},d=()=>{b5(),l()};return m.jsxs("form",{className:Ik,"data-slot":"settings-dialog-body",onSubmit:f=>{f.preventDefault(),u()},children:[m.jsxs("div",{className:"rounded-md border border-border bg-card/70 p-3","data-slot":"relay-token-card",children:[m.jsx("label",{htmlFor:t,className:"text-sm font-medium text-foreground",children:"Token"}),m.jsx("input",{id:t,type:"password",value:r,onChange:f=>{i(f.currentTarget.value),s&&o(null)},autoComplete:"off",spellCheck:!1,"aria-describedby":s?n:void 0,className:"mt-2 h-10 w-full rounded-md border border-border bg-background px-3 font-mono text-sm text-foreground outline-none transition-colors placeholder:text-muted-foreground focus:border-ring focus:ring-2 focus:ring-ring/75",placeholder:"粘贴 token"}),s?m.jsx("p",{id:n,className:"mt-2 text-xs text-destructive",children:s}):null]}),m.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[e?m.jsx(vt,{type:"button",variant:"outline",onClick:d,children:"清空"}):null,m.jsx(vt,{type:"submit",disabled:!r.trim(),children:"保存"})]})]})}function vhe(e){return e.length<=16?e:`${e.slice(0,8)}...${e.slice(-4)}`}function yhe(e,t){var r;return((r=t.get(e))==null?void 0:r.trim())||vhe(e)}function bhe(e){return Xne(e)}function _he(e){const t=Math.max(0,Math.floor((Date.now()-e)/1e3));return TF(t)}function x0({label:e,value:t,title:n}){return m.jsxs("div",{className:"grid grid-cols-[3.75rem_minmax(0,1fr)] items-baseline gap-2 text-xs leading-5",children:[m.jsx("span",{className:"shrink-0 text-muted-foreground/80",children:e}),m.jsx("span",{className:"min-w-0 truncate text-muted-foreground",title:n??t,children:t})]})}function whe(){const e=Me(y=>y.proxies),[t,n]=b.useState([]),[r,i]=b.useState(!0),[s,o]=b.useState(null),[l,u]=b.useState(null),d=b.useMemo(()=>new Map(e.map(y=>[y.proxyId,y.name]).filter(y=>typeof y[1]=="string")),[e]),f=b.useCallback(async()=>{const y=$t;if(!y){n([]),o("Relay 未连接。"),i(!1);return}i(!0),o(null);try{n(await y.requestRelayClients())}catch(g){o(g instanceof Error?g.message:"读取客户端列表失败。")}finally{i(!1)}},[]);b.useEffect(()=>{f()},[f]);const h=b.useCallback(async y=>{const g=$t;if(!g){o("Relay 未连接。");return}u(y),o(null);try{const _=await g.kickRelayClient(y);if(!_.success){o(_.error??"断开客户端失败。");return}n(w=>w.filter(S=>S.clientId!==y))}catch(_){o(_ instanceof Error?_.message:"断开客户端失败。")}finally{u(null)}},[]);return m.jsxs("div",{className:Ik,"data-slot":"settings-dialog-body",children:[m.jsxs("div",{className:"flex min-h-9 items-center gap-2","data-slot":"relay-clients-toolbar",children:[m.jsx("div",{className:"text-sm font-medium text-foreground",children:r?"正在读取客户端":`${t.length} 个在线客户端`}),m.jsx(vt,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"刷新客户端列表",title:"刷新",onClick:()=>void f(),disabled:r,"data-slot":"relay-clients-refresh",children:m.jsx(um,{className:qe("size-3.5",r&&"animate-spin"),"aria-hidden":"true"})})]}),s?m.jsx("div",{className:"rounded-md border border-destructive/35 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:s}):null,!r&&t.length===0?m.jsx("div",{className:"rounded-md border border-border bg-card/70 px-3 py-6 text-center text-sm text-muted-foreground",children:"当前没有在线客户端"}):null,t.map(y=>{const g=y.current===!0,_=l===y.clientId;return m.jsx("div",{className:"rounded-md border border-border bg-card/70 p-3","data-slot":"relay-client-row","data-client-id":y.clientId,title:`客户端 ${y.clientId}`,children:m.jsxs("div",{className:"grid gap-3 sm:grid-cols-[minmax(0,1fr)_7.5rem] sm:items-start",children:[m.jsxs("div",{className:"min-w-0 space-y-1.5",children:[m.jsx("div",{className:"min-w-0",children:m.jsx("div",{className:"truncate text-sm font-medium leading-5 text-foreground",children:bhe(y)})}),m.jsxs("div",{className:"space-y-1",children:[m.jsx(x0,{label:"已连接",value:_he(y.connectedAt)}),y.proxyId?m.jsx(x0,{label:"连接到",value:yhe(y.proxyId,d),title:y.proxyId}):null,y.remoteAddress?m.jsx(x0,{label:"来源 IP",value:y.remoteAddress}):null]})]}),g?m.jsx("div",{className:"inline-flex h-9 w-full items-center justify-center rounded-md border border-primary/30 bg-primary/10 px-3 text-sm font-normal text-primary","aria-label":"当前设备","data-slot":"relay-client-current-indicator",children:"当前设备"}):m.jsxs(vt,{type:"button",variant:"outline",size:"sm",className:"h-9 w-full justify-center",disabled:_,onClick:()=>void h(y.clientId),"data-slot":"relay-client-action",children:[m.jsx(PY,{className:"size-3.5","aria-hidden":"true"}),_?"断开中...":"断开"]})]})},y.clientId)})]})}function S0({icon:e,label:t,detail:n,checked:r,onCheckedChange:i}){const s=b.useId(),o=b.useId();return m.jsxs("button",{type:"button",role:"switch",className:"group flex w-full items-center gap-3 px-3 py-3 text-left transition-colors hover:bg-accent/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>i(!r),"aria-checked":r,"aria-labelledby":s,"aria-describedby":o,"data-slot":"settings-toggle-item",children:[m.jsx("div",{className:qe("flex size-8 shrink-0 items-center justify-center rounded-md bg-background/55 transition-colors",r?"text-primary":"text-muted-foreground"),children:e}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsx("div",{id:s,className:"text-sm font-medium text-foreground",children:t}),m.jsx("div",{id:o,className:"mt-1 text-xs text-muted-foreground",children:n})]}),m.jsx("span",{className:qe("relative h-6 w-11 shrink-0 rounded-full border transition-colors",r?"border-primary/65 bg-primary/70":"border-border bg-muted/50"),"aria-hidden":"true","data-slot":"settings-toggle-switch",children:m.jsx("span",{className:qe("absolute top-1/2 size-4 -translate-y-1/2 rounded-full bg-background shadow-sm transition-transform",r?"translate-x-[1.35rem]":"translate-x-1")})})]})}function wv({icon:e,label:t,detail:n,onClick:r}){const i=b.useId(),s=b.useId();return m.jsxs("button",{type:"button",className:"group flex w-full items-center gap-3 px-3 py-3 text-left transition-colors hover:bg-accent/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:r,"aria-labelledby":i,"aria-describedby":n?s:void 0,"data-slot":"settings-menu-item",children:[m.jsx("div",{className:"flex size-8 shrink-0 items-center justify-center rounded-md bg-background/55 text-muted-foreground transition-colors group-hover:text-foreground",children:e}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsx("div",{id:i,className:"text-sm font-medium text-foreground",children:t}),n?m.jsx("div",{id:s,className:"mt-1 text-xs text-muted-foreground",children:n}):null]}),m.jsx(Hd,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"})]})}function NI({icon:e,label:t,value:n,detail:r,muted:i=!1}){return m.jsxs("div",{className:"flex gap-3 rounded-md border border-border bg-card/70 p-3",children:[m.jsx("div",{className:qe("mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-md border",i?"border-border text-muted-foreground":"border-primary/35 bg-primary/10 text-primary"),children:e}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[m.jsx("div",{className:"text-sm text-muted-foreground",children:t}),m.jsx("div",{className:"min-w-0 truncate font-mono text-sm text-foreground",children:n})]}),m.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:r})]})]})}const xhe="xterm-helper-textarea";function She(e=document.activeElement){return!(e instanceof HTMLElement)||!e.classList.contains(xhe)?!1:(e.blur(),!0)}function MI(e,t,n){if(!e||Math.abs(n)<1)return!1;let r=e instanceof Element?e:null;for(;r&&t.contains(r);){if(r instanceof HTMLElement&&Ehe(r,n))return!0;if(r===t)break;r=r.parentElement}return!1}function Ehe(e,t){if(e.scrollHeight<=e.clientHeight+1)return!1;const n=window.getComputedStyle(e).overflowY;return n!=="auto"&&n!=="scroll"&&n!=="overlay"?!1:t<0?e.scrollTop>0:e.scrollTop+e.clientHeight<e.scrollHeight-1}function Che({releasePtyFocus:e=!0,containVerticalScroll:t=!0}={}){const n=b.useRef(null),r=b.useCallback(()=>{e&&She()},[e]),i=b.useCallback(l=>{var u;n.current=((u=l.touches[0])==null?void 0:u.clientY)??null,r()},[r]),s=b.useCallback(l=>{if(!t)return;const u=l.touches[0];if(!u)return;const f=(n.current??u.clientY)-u.clientY;n.current=u.clientY,MI(l.target,l.currentTarget,f)||l.preventDefault()},[t]),o=b.useCallback(l=>{r(),t&&(MI(l.target,l.currentTarget,l.deltaY)||l.preventDefault())},[t,r]);return{onPointerDownCapture:r,onTouchStartCapture:i,onTouchMoveCapture:s,onWheelCapture:o}}function khe({className:e}){const t=Me(o=>o.sidebarCollapsed),n=Me(o=>o.toggleSidebarCollapsed),[r,i]=b.useState(!1),s=Che();return t?m.jsxs(m.Fragment,{children:[m.jsxs("nav",{className:qe("dev-sidebar-shell dev-sidebar-rail relative flex-col items-center w-12 shrink-0 bg-card border-r border-border overflow-hidden px-1.5 pb-[calc(var(--dev-safe-area-bottom,env(safe-area-inset-bottom))+0.5rem)] pt-[max(0.5rem,env(safe-area-inset-top))]",e),"aria-label":"侧边栏","data-slot":"sidebar-rail","data-collapsed":"true",...s,children:[m.jsx(II,{collapsed:!0,onClick:n}),m.jsx("div",{className:"mt-3 h-px w-5 bg-border/70","aria-hidden":"true"}),m.jsxs("div",{className:"mt-auto flex flex-col gap-2",children:[m.jsx(PI,{compact:!0,tooltipSide:"right",onClick:()=>i(!0)}),m.jsx(yI,{compact:!0})]})]}),m.jsx(O1,{open:r,onOpenChange:i})]}):m.jsxs(m.Fragment,{children:[m.jsxs("nav",{className:qe("dev-sidebar-shell group/sidebar relative flex-col w-[280px] shrink-0 bg-card border-r border-border overflow-visible pt-[env(safe-area-inset-top)]",e),"aria-label":"侧边栏","data-slot":"sidebar","data-collapsed":"false",...s,children:[m.jsx("div",{className:"dev-sidebar-fade p-2.5","data-slot":"sidebar-proxy-switcher",children:m.jsxs("div",{className:"dev-sidebar-chrome rounded-lg border p-3",children:[m.jsxs("div",{className:"flex items-center justify-between gap-3",children:[m.jsx(Gz,{className:"text-[13px]",slot:"sidebar-brand"}),m.jsx(II,{collapsed:!1,onClick:n})]}),m.jsx("div",{className:"mt-2.5",children:m.jsx(oF,{layout:"dropdown",variant:"sidebarChrome"})})]})}),m.jsx("div",{className:"dev-sidebar-fade flex min-h-0 flex-1 flex-col overflow-hidden","data-slot":"sidebar-session-list",children:m.jsx("div",{className:"flex-1 min-h-0",children:m.jsx(bF,{layout:"sidebar"})})}),m.jsxs("div",{className:"dev-sidebar-fade flex shrink-0 gap-2 px-2 pb-[calc(var(--dev-safe-area-bottom,env(safe-area-inset-bottom))+0.5rem)] pt-2","data-slot":"sidebar-new-session",children:[m.jsx("div",{className:"min-w-0 flex-1",children:m.jsx(yI,{})}),m.jsx("div",{className:"min-w-0 flex-1",children:m.jsx(PI,{onClick:()=>i(!0)})})]})]}),m.jsx(O1,{open:r,onOpenChange:i})]})}function PI({compact:e=!1,tooltipSide:t="top",onClick:n}){return m.jsxs(Sf,{delayDuration:500,children:[m.jsx(Ef,{asChild:!0,children:m.jsxs("button",{type:"button","aria-label":"设置","data-slot":"sidebar-settings-trigger",onClick:n,className:qe("inline-flex items-center justify-center shrink-0 border text-muted-foreground outline-none transition-[color,background-color,border-color,box-shadow]","focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",e?"h-11 w-11 rounded-md border-border bg-card/70 hover:border-primary/60 hover:bg-accent hover:text-foreground":"h-[46px] w-full gap-2 rounded-md border-border bg-background hover:border-primary/50 hover:bg-accent hover:text-foreground"),children:[m.jsx(Nz,{className:"size-4","aria-hidden":"true"}),!e&&m.jsx("span",{className:"truncate text-sm font-medium",children:"设置"})]})}),m.jsx(Cf,{side:t,sideOffset:10,hideArrow:!0,className:"border border-border/80 bg-card/95 px-2.5 py-1 text-muted-foreground shadow-sm backdrop-blur",children:"设置"})]})}function II({collapsed:e,onClick:t}){const n=e?"展开侧边栏":"收起侧边栏",r=e?WY:HY;return m.jsxs(Sf,{delayDuration:500,children:[m.jsx(Ef,{asChild:!0,children:m.jsx("button",{type:"button","aria-label":n,"data-slot":e?"sidebar-expand-trigger":"sidebar-collapse-trigger",onClick:t,className:qe("group inline-flex items-center justify-center text-muted-foreground outline-none transition-[opacity,color,background-color,border-color,box-shadow,transform]","outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",e?"h-9 w-9 rounded-md border border-border/80 bg-card/70 hover:border-primary/60 hover:bg-accent hover:text-foreground":"h-9 w-9 rounded-full border border-primary/25 bg-primary/10 hover:border-primary/60 hover:bg-primary/15 hover:text-foreground"),children:m.jsx(r,{className:qe("size-3.5 transition-transform",e&&"group-hover:translate-x-0.5",!e&&"group-hover:-translate-x-0.5"),"aria-hidden":"true"})})}),m.jsx(Cf,{side:e?"right":"top",sideOffset:10,hideArrow:!0,className:"border border-border/80 bg-card/95 px-2.5 py-1 text-muted-foreground shadow-sm backdrop-blur",children:n})]})}const The=1500,Rhe=300,OI=70,LI=35;function RF({texts:e,className:t}){const[n,r]=b.useState(""),[i,s]=b.useState(!0),o=b.useRef("typing"),l=b.useRef(0),u=b.useRef(0);b.useEffect(()=>{const f=setInterval(()=>s(h=>!h),530);return()=>clearInterval(f)},[]),b.useEffect(()=>{let f;const h=()=>e[u.current%e.length],y=()=>{const g=o.current;if(g==="typing"){const _=h();l.current<_.length?(l.current+=1,r(_.slice(0,l.current)),f=setTimeout(y,OI)):(o.current="paused",f=setTimeout(y,The))}else g==="paused"?(o.current="deleting",f=setTimeout(y,LI)):g==="deleting"?l.current>0?(l.current-=1,r(h().slice(0,l.current)),f=setTimeout(y,LI)):(u.current+=1,o.current="waiting",f=setTimeout(y,Rhe)):(o.current="typing",f=setTimeout(y,OI))};return f=setTimeout(y,500),()=>clearTimeout(f)},[e]);const d=n.startsWith("DEV")?3:n.length<=3&&"DEV".startsWith(n)?n.length:0;return m.jsxs("div",{className:`font-mono leading-tight select-none ${t??""}`,"data-slot":"brand-typewriter",children:[m.jsx("span",{className:"text-green-500",children:"> "}),m.jsx("span",{className:"text-primary","data-slot":"brand-typewriter-dev",children:n.slice(0,d)}),m.jsx("span",{className:"text-foreground/90",children:n.slice(d)}),m.jsx("span",{className:`text-primary ${i?"opacity-100":"opacity-0"}`,children:"_"})]})}const AF=["DEV Anywhere","/unlimited @anytime"];function Ahe({subtitle:e,action:t}){return m.jsx("section",{className:"dev-mobile-brand-hero border-b border-border/80 px-4 pb-5 pt-[calc(env(safe-area-inset-top)+1.25rem)] md:hidden","data-slot":"mobile-brand-hero","aria-label":"DEV Anywhere",children:m.jsxs("div",{className:"dev-mobile-brand-content min-w-0 space-y-3 pr-12",children:[m.jsx(RF,{texts:AF,className:"dev-mobile-brand-typewriter max-w-full overflow-hidden text-ellipsis whitespace-nowrap font-bold tracking-normal"}),e?m.jsx("p",{className:"dev-mobile-brand-subtitle max-w-[34rem] text-sm leading-5 text-muted-foreground",children:e}):null,t?m.jsx("div",{className:"dev-mobile-brand-action flex max-w-full min-w-0 pt-1",children:t}):null]})})}const Nhe=3e3,Mhe=1e4,xv=12,Phe=4,DI={webRelay:"浏览器 ↔ Relay 服务器",relayProxy:"Relay 服务器 ↔ 开发机",webProxy:"浏览器 ↔ 开发机"},Ihe={webRelay:{state:"idle"},relayProxy:{state:"idle"},webProxy:{state:"idle"}};function E0(e){if(!e.success||e.rttMs===void 0)return{state:"unavailable",error:e.error??"不可用",updatedAt:Date.now()};const t=e.rttMs;return{state:t<=120?"ok":t<=300?"warn":"bad",rttMs:t,updatedAt:Date.now()}}function fd(e){return{state:"unavailable",error:e,updatedAt:Date.now()}}function dp(e){return e===void 0||!Number.isFinite(e)?"--":`${Math.max(0,Math.round(e))}ms`}function BI(e){switch(e){case"bad":return 4;case"unavailable":return 3;case"warn":return 2;case"measuring":return 1;default:return 0}}function NF(e){return e==="bad"||e==="unavailable"?"bad":e==="warn"?"warn":e==="ok"?"ok":"neutral"}function Ohe(e){switch(e){case"ok":return"border-emerald-500/35 bg-emerald-500/10 text-emerald-300";case"warn":return"border-amber-500/40 bg-amber-500/10 text-amber-300";case"bad":return"border-destructive/55 bg-destructive/10 text-destructive";default:return"border-border bg-card/90 text-muted-foreground"}}function Lhe(e){return e.state==="measuring"?"检测中":e.state==="unavailable"?e.error??"不可用":e.rttMs!==void 0?dp(e.rttMs):"等待检测"}function Dhe(){const e=Ni("local",_n.latencyMonitorPosition);if(!e)return null;try{const t=JSON.parse(e);return!Number.isFinite(t.x)||!Number.isFinite(t.y)?null:{x:Number(t.x),y:Number(t.y)}}catch{return null}}function zI(e){Rr("local",_n.latencyMonitorPosition,JSON.stringify(e))}function Bhe(){var e,t;return{width:((e=window.visualViewport)==null?void 0:e.width)??window.innerWidth??document.documentElement.clientWidth??0,height:((t=window.visualViewport)==null?void 0:t.height)??window.innerHeight??document.documentElement.clientHeight??0}}function C0(e,t){const n=Bhe(),r=xv,i=xv,s=Math.max(r,n.width-t.width-xv),o=Math.max(i,n.height-t.height-xv);return{x:Math.min(s,Math.max(r,Math.round(e.x))),y:Math.min(o,Math.max(i,Math.round(e.y)))}}function zhe(){const e=Me(T=>T.latencyMonitorEnabled),t=Me(T=>T.connected),n=Me(T=>T.proxyOnline),r=Me(T=>T.selectedProxyId),[i,s]=b.useState(Ihe),[o,l]=b.useState(()=>Dhe()),u=b.useRef(!1),d=b.useRef(null),f=b.useRef(null),h=b.useRef(!1),y=b.useMemo(()=>(Object.values(i).sort((T,P)=>BI(P.state)-BI(T.state))[0]??{state:"idle"}).state,[i]),g=NF(y);async function _(){if(u.current)return;const T=$t;if(!T||!t){const U=fd("Relay 服务器未连接");s({webRelay:U,relayProxy:U,webProxy:U});return}u.current=!0,s(U=>({webRelay:{...U.webRelay,state:"measuring"},relayProxy:n?{...U.relayProxy,state:"measuring"}:fd("未连接开发机"),webProxy:n?{...U.webProxy,state:"measuring"}:fd("未连接开发机")}));const[P,z,Y]=await Promise.allSettled([T.measureWebRelayLatency(),n?T.measureRelayProxyLatency():Promise.resolve({success:!1}),n?T.measureWebProxyLatency():Promise.resolve({success:!1})]);s({webRelay:P.status==="fulfilled"?E0(P.value):fd(P.reason instanceof Error?P.reason.message:"测速失败"),relayProxy:z.status==="fulfilled"?E0(z.value):fd(z.reason instanceof Error?z.reason.message:"测速失败"),webProxy:Y.status==="fulfilled"?E0(Y.value):fd(Y.reason instanceof Error?Y.reason.message:"测速失败")}),u.current=!1}if(b.useEffect(()=>{if(!e)return;let T=!1,P=null;const z=async()=>{await _(),!T&&(P=setTimeout(z,document.hidden?Mhe:Nhe))};return z(),()=>{T=!0,u.current=!1,P&&clearTimeout(P)}},[e,t,n,r]),b.useEffect(()=>{if(!e||!o)return;const T=d.current;if(!T)return;const P=T.getBoundingClientRect(),z=C0(o,{width:P.width,height:P.height});z.x===o.x&&z.y===o.y||(l(z),zI(z))},[e,o]),!e)return null;const w=i.webProxy.rttMs!==void 0?i.webProxy:i.relayProxy,S=o!==null?{left:`${o.x}px`,top:`${o.y}px`}:void 0;function x(T){var z,Y;if(T.button!==0)return;const P=T.currentTarget.getBoundingClientRect();f.current={pointerId:T.pointerId,startX:T.clientX,startY:T.clientY,originX:P.left,originY:P.top,width:P.width,height:P.height,dragging:!1},(Y=(z=T.currentTarget).setPointerCapture)==null||Y.call(z,T.pointerId)}function k(T){const P=f.current;if(!P||P.pointerId!==T.pointerId)return;const z=T.clientX-P.startX,Y=T.clientY-P.startY;if(!P.dragging&&Math.hypot(z,Y)<Phe)return;P.dragging=!0,T.preventDefault();const U=C0({x:P.originX+z,y:P.originY+Y},{width:P.width,height:P.height});l(U)}function R(T){var G,I;const P=f.current;if(!P||P.pointerId!==T.pointerId||(f.current=null,(I=(G=T.currentTarget).releasePointerCapture)==null||I.call(G,T.pointerId),!P.dragging))return;T.preventDefault(),h.current=!0,window.setTimeout(()=>{h.current=!1},200);const z=T.clientX-P.startX,Y=T.clientY-P.startY,U=C0({x:P.originX+z,y:P.originY+Y},{width:P.width,height:P.height});l(U),zI(U)}function A(T){var z,Y;const P=f.current;!P||P.pointerId!==T.pointerId||(f.current=null,(Y=(z=T.currentTarget).releasePointerCapture)==null||Y.call(z,T.pointerId))}function M(T){h.current&&(h.current=!1,T.preventDefault(),T.stopPropagation())}return m.jsxs(Ub,{children:[m.jsx(Wb,{asChild:!0,children:m.jsxs("button",{ref:d,type:"button",className:qe("fixed z-40 flex max-w-[calc(100vw-1.5rem)] touch-none cursor-move select-none items-center gap-2 rounded-md border px-2.5 py-1.5 text-xs shadow-lg backdrop-blur transition-colors",o===null&&"right-[calc(env(safe-area-inset-right)+0.75rem)] top-[calc(env(safe-area-inset-top)+3.75rem)] md:right-4 md:top-4",Ohe(g)),style:S,"data-slot":"latency-monitor-trigger","aria-label":`延迟监控,Relay 服务器 ${dp(i.webRelay.rttMs)},开发机 ${dp(w.rttMs)}`,onPointerDown:x,onPointerMove:k,onPointerUp:R,onPointerCancel:A,onClickCapture:M,children:[m.jsx(yz,{className:"size-3.5","aria-hidden":"true"}),m.jsx("span",{className:"font-medium text-foreground",children:"延迟"}),m.jsxs("span",{className:"hidden text-muted-foreground sm:inline",children:["Relay ",dp(i.webRelay.rttMs)]}),m.jsxs("span",{className:"text-muted-foreground",children:["开发机 ",dp(w.rttMs)]}),m.jsx(sc,{className:"size-3 text-muted-foreground","aria-hidden":"true"})]})}),m.jsxs(qb,{align:"end",className:"w-[320px] p-3","data-slot":"latency-monitor-popover",children:[m.jsxs("div",{className:"flex items-start justify-between gap-3",children:[m.jsxs("div",{children:[m.jsx("div",{className:"text-sm font-medium text-foreground",children:"连接延迟"}),m.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:"数值越低,操作响应通常越快。"})]}),m.jsx(vt,{type:"button",variant:"ghost",size:"icon-xs","aria-label":"立即测速",onClick:()=>void _(),children:m.jsx(um,{className:"size-3","aria-hidden":"true"})})]}),m.jsx("div",{className:"mt-3 space-y-2",children:Object.keys(DI).map(T=>m.jsx(jhe,{label:DI[T],measurement:i[T]},T))})]})]})}function jhe({label:e,measurement:t}){const n=NF(t.state);return m.jsxs("div",{className:"flex min-h-10 items-center justify-between gap-3 rounded-md border border-border/70 bg-card/60 px-3 py-2",children:[m.jsx("div",{className:"min-w-0 truncate text-xs font-medium text-foreground",children:e}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("span",{className:qe("size-1.5 rounded-full",n==="ok"?"bg-emerald-400":n==="warn"?"bg-amber-400":n==="bad"?"bg-destructive":"bg-muted-foreground/60"),"aria-hidden":"true"}),m.jsx("span",{className:"min-w-[4rem] text-right font-mono text-xs text-foreground",children:Lhe(t)})]})]})}const MF="/__dev_anywhere_debug/browser-state-dumps",Fhe=1500,$he=10,k0=80,Ok=500,Hhe=["id","class","data-slot","data-state","data-testid","role","aria-label","aria-hidden","name","type","autocomplete","autocorrect","autocapitalize","inputmode","enterkeyhint","virtualkeyboardpolicy","contenteditable","placeholder","href","src"],Uhe=["display","position","visibility","opacity","pointer-events","z-index","overflow","overflow-x","overflow-y","touch-action","transform","translate","color-scheme","background-color","color","font-size","line-height","padding-top","padding-right","padding-bottom","padding-left","margin-top","margin-right","margin-bottom","margin-left"];function jI(){if(typeof window>"u")return"off";const e=jF("debugDump");return e==="auto"?"auto":e!==null||Qhe("debugInput")?"manual":"off"}function Whe(e="manual"){const t={count:0,truncated:!1},n=window,r={schemaVersion:1,createdAt:new Date().toISOString(),trigger:e,url:{href:window.location.href,origin:window.location.origin,pathname:window.location.pathname,search:window.location.search,hash:window.location.hash},browser:{userAgent:navigator.userAgent,language:navigator.language,languages:Array.from(navigator.languages??[]),platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints??0,cookieEnabled:navigator.cookieEnabled,onLine:navigator.onLine},viewport:Khe(),document:{title:document.title,readyState:document.readyState,visibilityState:document.visibilityState,activeElement:FI(document.activeElement),selection:Ghe(),focusedInputs:Array.from(document.querySelectorAll("input, textarea, select, [contenteditable]")).filter(i=>i===document.activeElement||i.matches(":focus")).map(i=>FI(i)).filter(i=>!!i),root:PF(document.documentElement,0,t),truncated:t.truncated,nodeCount:t.count},devAnywhere:{ptyDebug:hd(()=>{var i;return((i=n.__devAnywherePtyDebug)==null?void 0:i.call(n))??null}),ptyInputDebugSnapshot:hd(()=>n.__devAnywherePtyInputDebugSnapshot??null),ptyInputDebugText:n.__devAnywherePtyInputDebugText??null,ptyInputDebugEvents:hd(()=>n.__devAnywherePtyInputDebugEvents??null),ptyScrollTraceTail:hd(()=>$I(n.__devAnywherePtyScrollTrace)),jsonScrollTraceTail:hd(()=>$I(n.__devAnywhereJsonScrollTrace)),voicePilotDiagnostics:hd(()=>{var i;return((i=n.__devAnywhereVoicePilotDiagnostics)==null?void 0:i.snapshot())??null})}};return window.__devAnywhereLastBrowserStateDump=r,r}async function qhe(e="manual"){const t=Whe(e);return Vhe(t)}async function Vhe(e){const t=JSON.stringify(e,null,2),n=new Blob([t]).size;try{const r=await Yhe(t);return{status:"saved",path:r.path,bytes:r.bytes,endpoint:MF}}catch(r){const i=FF(r),s=Xhe(e.createdAt);return Zhe(s,t,"application/json")?{status:"downloaded",filename:s,bytes:n,endpointError:i}:{status:"failed",error:"无法保存或下载诊断包",endpointError:i}}}async function Yhe(e){const t=await fetch(MF,{method:"POST",headers:{"content-type":"application/json"},body:e});if(!t.ok)throw new Error(`${t.status} ${await t.text()}`);const n=await t.json();if(!n.ok||!n.path||typeof n.bytes!="number")throw new Error("debug endpoint returned an invalid response");return{path:n.path,bytes:n.bytes}}function PF(e,t,n){if(n.count>=Fhe||t>$he)return n.truncated=!0,{kind:"truncated"};if(n.count+=1,e.nodeType===Node.TEXT_NODE){const u=HI(e.textContent??"");return u?{kind:"text",text:Jb(u,Ok)}:{kind:"text",text:""}}if(!(e instanceof HTMLElement))return{kind:"truncated"};const r=[];let i=0;const s=Array.from(e.childNodes);for(const u of s.slice(0,k0))u.nodeType===Node.TEXT_NODE&&!HI(u.textContent??"")||r.push(PF(u,t+1,n));s.length>k0&&(i=s.length-k0,n.truncated=!0);const o={kind:"element",tag:e.tagName.toLowerCase(),path:zF(e),attrs:IF(e),rect:OF(e),scroll:LF(e),style:DF(e)},l=BF(e);return l&&(o.value=l),r.length>0&&(o.children=r),i>0&&(o.omittedChildren=i),o}function FI(e){if(!(e instanceof HTMLElement))return null;const t=BF(e);return{path:zF(e),tag:e.tagName.toLowerCase(),id:e.id||null,className:e.className||null,attrs:IF(e),rect:OF(e),scroll:LF(e),style:DF(e),...t?{value:t}:{}}}function Khe(){var n;const e=window.visualViewport,t=((n=screen.orientation)==null?void 0:n.type)??null;return{window:{innerWidth:window.innerWidth,innerHeight:window.innerHeight,outerWidth:window.outerWidth,outerHeight:window.outerHeight,devicePixelRatio:window.devicePixelRatio,scrollX:window.scrollX,scrollY:window.scrollY},visualViewport:e?{width:e.width,height:e.height,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,pageLeft:e.pageLeft,pageTop:e.pageTop,scale:e.scale}:null,screen:{width:screen.width,height:screen.height,availWidth:screen.availWidth,availHeight:screen.availHeight,orientation:t}}}function IF(e){const t={};for(const n of Hhe){const r=e.getAttribute(n);r!==null&&(t[n]=Jb(r,500))}return t}function OF(e){const t=e.getBoundingClientRect();return{x:Ss(t.x),y:Ss(t.y),width:Ss(t.width),height:Ss(t.height),top:Ss(t.top),right:Ss(t.right),bottom:Ss(t.bottom),left:Ss(t.left)}}function LF(e){return{top:Ss(e.scrollTop),left:Ss(e.scrollLeft),height:Ss(e.scrollHeight),width:Ss(e.scrollWidth),clientHeight:Ss(e.clientHeight),clientWidth:Ss(e.clientWidth)}}function DF(e){const t=window.getComputedStyle(e),n={};for(const r of Uhe)n[r]=t.getPropertyValue(r);return n}function BF(e){if(!(!(e instanceof HTMLInputElement)&&!(e instanceof HTMLTextAreaElement)))return{length:e.value.length,preview:Jb(e.value,Ok),selectionStart:e.selectionStart,selectionEnd:e.selectionEnd}}function Ghe(){var e;try{return Jb(((e=window.getSelection())==null?void 0:e.toString())??"",Ok)}catch{return null}}function zF(e){const t=[];let n=e;for(;n&&n!==document.documentElement;){let r=n.tagName.toLowerCase();if(n.id){r+=`#${n.id}`,t.unshift(r);break}const i=n.getAttribute("data-slot");i?r+=`[data-slot="${i}"]`:n.classList.length>0&&(r+=`.${Array.from(n.classList).slice(0,3).join(".")}`);const s=n.parentElement;if(s){const o=n.tagName,l=Array.from(s.children).filter(u=>u instanceof HTMLElement&&u.tagName===o);l.length>1&&(r+=`:nth-of-type(${l.indexOf(n)+1})`)}t.unshift(r),n=s}return`html>${t.join(">")}`}function Xhe(e){return`dev-anywhere-browser-state-${e.replace(/[:.]/g,"-")}.json`}function Zhe(e,t,n){if(typeof document>"u")return!1;const r=new Blob([t],{type:n}),i=URL.createObjectURL(r),s=document.createElement("a");return s.href=i,s.download=e,s.rel="noopener",document.body.append(s),s.click(),s.remove(),window.setTimeout(()=>URL.revokeObjectURL(i),1e3),!0}function Qhe(e){return jF(e)!==null}function jF(e){const t=new URLSearchParams(window.location.search);if(t.has(e))return t.get(e)??"";const[,n=""]=window.location.hash.split("?"),r=new URLSearchParams(n);return r.has(e)?r.get(e)??"":null}function $I(e){return e?qy(e.slice(-200)):null}function hd(e){try{return qy(e())}catch(t){return{error:FF(t)}}}function qy(e){if(e===null||typeof e=="string"||typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)?e:String(e);if(Array.isArray(e))return e.map(qy);if(typeof e=="object"){const t={};for(const[n,r]of Object.entries(e))t[n]=qy(r);return t}return String(e)}function HI(e){return e.replace(/\s+/g," ").trim()}function Jb(e,t){return e.length>t?`${e.slice(0,t)}...`:e}function Ss(e){return Math.round(e*100)/100}function FF(e){return e instanceof Error?e.message:String(e)}const Jhe=500,epe=1e3,tpe=60;function npe(){const[e,t]=b.useState(()=>jI()),[n,r]=b.useState(!1),[i,s]=b.useState(null),o=b.useRef(null),l=b.useRef(!1),u=b.useRef(0),d=b.useRef(0),f=b.useRef(null);b.useEffect(()=>{const _=()=>t(jI());return window.addEventListener("hashchange",_),window.addEventListener("popstate",_),()=>{window.removeEventListener("hashchange",_),window.removeEventListener("popstate",_)}},[]);const h=b.useCallback(async(_="manual")=>{if(l.current)return o.current??{status:"failed",error:"dump already running"};l.current=!0,r(!0);try{const w=await qhe(_);return o.current=w,s(w),(_==="manual"||w.status==="failed")&&rpe(w),w}finally{l.current=!1,r(!1)}},[]);if(b.useEffect(()=>(window.__devAnywhereDumpBrowserState=h,()=>{window.__devAnywhereDumpBrowserState===h&&delete window.__devAnywhereDumpBrowserState}),[h]),b.useEffect(()=>{var k,R;if(e!=="auto")return;const _=()=>{f.current!==null&&(window.clearTimeout(f.current),f.current=null)},w=A=>{d.current>=tpe||(_(),f.current=window.setTimeout(()=>{f.current=null;const M=Date.now(),T=epe-(M-u.current);if(T>0){f.current=window.setTimeout(()=>w(A),T);return}u.current=Date.now(),d.current+=1,h(`auto:${d.current}:${A}`)},Jhe))};w("initial");const S=["focusin","focusout","beforeinput","input","compositionstart","compositionupdate","compositionend","keydown","keyup","pointerdown","pointerup","resize","visibilitychange"],x=A=>w(A.type);return S.forEach(A=>window.addEventListener(A,x,!0)),(k=window.visualViewport)==null||k.addEventListener("resize",x),(R=window.visualViewport)==null||R.addEventListener("scroll",x),()=>{var A,M;_(),S.forEach(T=>window.removeEventListener(T,x,!0)),(A=window.visualViewport)==null||A.removeEventListener("resize",x),(M=window.visualViewport)==null||M.removeEventListener("scroll",x)}},[h,e]),e==="off")return null;const y=e==="auto"?"自动诊断中":"保存诊断",g=ipe(i);return m.jsxs("div",{className:"fixed bottom-3 right-3 z-[90] flex max-w-[min(360px,calc(100vw-24px))] flex-col items-end gap-1",children:[g?m.jsx("div",{className:"max-w-full truncate rounded-md border border-border/70 bg-popover/95 px-2 py-1 text-[10px] text-muted-foreground shadow",children:g}):null,m.jsxs(vt,{type:"button",size:"sm",variant:e==="auto"?"secondary":"outline",className:"h-9 rounded-md px-3 text-xs shadow-lg",onClick:()=>void h("manual"),disabled:n,"data-slot":"browser-state-dump",children:[n?m.jsx(li,{className:"size-3.5 animate-spin","aria-hidden":"true"}):m.jsx(pY,{className:"size-3.5","aria-hidden":"true"}),m.jsx("span",{children:y})]})]})}function rpe(e){if(e.status==="saved"){Ue.success(`诊断已保存: ${e.path}`);return}if(e.status==="downloaded"){Ue.info(`诊断已下载: ${e.filename}`);return}Ue.error(e.endpointError?`${e.error}: ${e.endpointError}`:e.error)}function ipe(e){return e?e.status==="saved"?`已保存 ${e.path}`:e.status==="downloaded"?`已下载 ${e.filename}`:`失败 ${e.endpointError??e.error}`:null}function spe({issue:e}){const t=e==="unreachable"?"暂时无法连接":e==="page_outdated"?"当前页面版本较旧,请刷新后重试":e==="service_outdated"?"服务端版本较旧,请更新服务后重试":e==="protocol_mismatch"?"页面与服务端版本不一致,请刷新后重试":"连接已断开",n=e==="page_outdated"||e==="protocol_mismatch"?"刷新页面":e==="service_outdated"?"重新检测":null;return m.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 px-6 text-center text-muted-foreground","data-slot":"relay-connection-state","data-state":"unavailable","data-issue":e,role:"status","aria-live":"polite",children:[e==="unreachable"?m.jsx(li,{className:"size-5 animate-spin","aria-hidden":"true"}):null,m.jsx("p",{className:"text-sm",children:t}),n?m.jsx(vt,{type:"button",size:"sm",onClick:()=>window.location.reload(),children:n}):null]})}function ope(e){if(typeof window>"u")return null;try{const t=window.localStorage;return!t||typeof t.getItem!="function"?null:t.getItem(e)}catch{return null}}function Lk(e){const{windowKey:t,storageKey:n,maxEntries:r=5e3,dedupeKey:i}=e,s=new Map,o=()=>typeof window>"u"?!1:ope(n)==="1",l=()=>typeof window>"u"?[]:window[t]??[],u=d=>{typeof window>"u"||(window[t]=d)};return{isEnabled:o,append(d){if(typeof window>"u")return;const f=l();if(i){const h=i(d);if(h!==null){const y=s.get(d.event);if(y&&i(y)===h&&f.includes(y)){y.t=d.t,y.repeat=(y.repeat??0)+1;const g=f.indexOf(y);g>=0&&g!==f.length-1&&(f.splice(g,1),f.push(y)),u(f);return}}}if(f.push(d),i&&s.set(d.event,d),f.length>r){const h=f.splice(0,f.length-r);if(i)for(const y of h)s.get(y.event)===y&&s.delete(y.event)}u(f)},getAll:l}}function Kn(e){return Math.round(e*10)/10}function Bl(e){return e.length===0?"":`${Kn(Math.min(...e))}..${Kn(Math.max(...e))}`}function Od(e){return[...new Set(e.filter(t=>t!==void 0).map(Kn))]}function $F(e){let t=0,n=0;for(let r=1;r<e.length;r+=1){const i=e[r]-e[r-1];if(Math.abs(i)<1)continue;const s=Math.sign(i);t!==0&&s!==t&&(n+=1),t=s}return n}const ape="dev_anywhere_pty_input_latency_trace",UI=80,lpe=1e4,cpe=new TextDecoder;let upe=0;const af=new Map,Cu=Lk({windowKey:"__devAnywherePtyInputLatencyTrace",storageKey:ape,dedupeKey:e=>e.event.startsWith("input")?null:`${e.event}|${e.sessionId}|${e.outputSeq??""}|${e.pendingInputs??""}`});function dpe(){typeof window>"u"||(window.__devAnywherePtyInputLatencyReport=mpe)}function fpe(e,t){if(!Cu.isEnabled())return null;const n=`pty-in-${Date.now().toString(36)}-${++upe}`,r=performance.now(),i={inputId:n,sessionId:e,data:t,kind:ype(t),dataLength:t.length,startedAt:r,sentAt:null,firstOutputAt:null,echoMatchedAt:null,xtermWriteAt:null,paintAt:null},s=af.get(e)??[];return s.push(i),Bk(s,r),af.set(e,s),Tm({t:r,event:"input:start",sessionId:e,inputId:n,inputKind:i.kind,dataLength:i.dataLength,pendingInputs:s.length}),{inputId:n,sessionId:e}}function WI(e,t){if(!e||!Cu.isEnabled())return;const n=performance.now(),r=gpe(e.sessionId,e.inputId);r&&(r.sentAt=n),Tm({t:n,event:"input:ws-send",sessionId:e.sessionId,inputId:e.inputId,inputKind:r==null?void 0:r.kind,dataLength:r==null?void 0:r.dataLength,sent:t.sent,queueWhenDisconnected:t.queueWhenDisconnected,deltaFromInputMs:r?n-r.startedAt:null,details:t.details})}function hpe(e,t,n){if(!Cu.isEnabled())return;const r=performance.now(),i=Dk(e,r),s=wpe(t),o=[],l=[];for(const u of i)u.firstOutputAt===null&&(u.firstOutputAt=r,o.push(u.inputId)),u.echoMatchedAt===null&&_pe(u)&&s.includes(u.data)&&(u.echoMatchedAt=r,l.push(u.inputId));Tm({t:r,event:"output:received",sessionId:e,outputSeq:n,bytes:t.byteLength,pendingInputs:i.length,deltaFromInputMs:zk(i,r),details:xpe([o.length>0?`first=${o.length}`:"",l.length>0?`echo=${l.length}`:""])})}function ppe(e,t,n=1){if(!Cu.isEnabled())return;const r=performance.now(),i=Dk(e,r),s=[];for(const o of i)o.xtermWriteAt===null&&(o.xtermWriteAt=r,s.push(o.inputId));Tm({t:r,event:"output:xterm-write",sessionId:e,bytes:t,chunkCount:n,pendingInputs:i.length,deltaFromInputMs:zk(i,r),details:s.length>0?`firstWrite=${s.length}`:""}),typeof requestAnimationFrame=="function"&&s.length>0&&requestAnimationFrame(()=>vpe(e,s))}function mpe(){const e=Cu.getAll(),t=e.slice(-200),n=[...af.values()].flat(),r=n.slice(-80).map(s=>[s.inputId,s.sessionId,s.kind,s.dataLength,s.sentAt===null?"":Kn(s.sentAt-s.startedAt),s.firstOutputAt===null?"":Kn(s.firstOutputAt-s.startedAt),s.echoMatchedAt===null?"":Kn(s.echoMatchedAt-s.startedAt),s.xtermWriteAt===null?"":Kn(s.xtermWriteAt-s.startedAt),s.paintAt===null?"":Kn(s.paintAt-s.startedAt)].join(" ")),i=t.map(s=>[Kn(s.t),s.repeat&&s.repeat>0?`${s.event} +${s.repeat}`:s.event,s.sessionId,s.inputId??"",s.inputKind??"",s.dataLength??"",s.sent===void 0?"":s.sent?"sent":"not-sent",s.queueWhenDisconnected?"queue-ok":"",s.outputSeq??"",s.bytes??"",s.chunkCount??"",s.pendingInputs??"",s.deltaFromInputMs===void 0||s.deltaFromInputMs===null?"":Kn(s.deltaFromInputMs),s.details??""].join(" "));return["DEV Anywhere PTY input latency trace",`events=${e.length}, included=${t.length}, pendingInputs=${n.length}`,"pending input summary:","inputId sessionId kind len wsSendMs firstOutputMs echoMatchMs xtermWriteMs paintMs",...r,"events:","t event sessionId inputId kind len sent queue outputSeq bytes chunks pending deltaMs details",...i].join(`
600
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return b.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},pae="DialogDescriptionWarning",mae=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Q5(pae).contentName}}.`;return b.useEffect(()=>{var s;const i=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&i&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},ok=z5,gae=F5,ak=H5,lk=U5,ck=W5,J5=V5,e3=K5,Rb=X5;function vae(e){const t=b.useRef({value:e,previous:e});return b.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}function yae(e){const[t,n]=b.useState(void 0);return Qi(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let o,l;if("borderBoxSize"in s){const u=s.borderBoxSize,d=Array.isArray(u)?u[0]:u;o=d.inlineSize,l=d.blockSize}else o=e.offsetWidth,l=e.offsetHeight;n({width:o,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}const bae=["top","right","bottom","left"],ec=Math.min,$s=Math.max,zy=Math.round,gv=Math.floor,aa=e=>({x:e,y:e}),_ae={left:"right",right:"left",bottom:"top",top:"bottom"};function p1(e,t,n){return $s(e,ec(t,n))}function Va(e,t){return typeof e=="function"?e(t):e}function Ya(e){return e.split("-")[0]}function vf(e){return e.split("-")[1]}function uk(e){return e==="x"?"y":"x"}function dk(e){return e==="y"?"height":"width"}function ra(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function fk(e){return uk(ra(e))}function wae(e,t,n){n===void 0&&(n=!1);const r=vf(e),i=fk(e),s=dk(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(o=jy(o)),[o,jy(o)]}function xae(e){const t=jy(e);return[m1(e),t,m1(t)]}function m1(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Y2=["left","right"],K2=["right","left"],Sae=["top","bottom"],Eae=["bottom","top"];function Cae(e,t,n){switch(e){case"top":case"bottom":return n?t?K2:Y2:t?Y2:K2;case"left":case"right":return t?Sae:Eae;default:return[]}}function kae(e,t,n,r){const i=vf(e);let s=Cae(Ya(e),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),t&&(s=s.concat(s.map(m1)))),s}function jy(e){const t=Ya(e);return _ae[t]+e.slice(t.length)}function Tae(e){return{top:0,right:0,bottom:0,left:0,...e}}function t3(e){return typeof e!="number"?Tae(e):{top:e,right:e,bottom:e,left:e}}function Fy(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function G2(e,t,n){let{reference:r,floating:i}=e;const s=ra(t),o=fk(t),l=dk(o),u=Ya(t),d=s==="y",f=r.x+r.width/2-i.width/2,h=r.y+r.height/2-i.height/2,y=r[l]/2-i[l]/2;let g;switch(u){case"top":g={x:f,y:r.y-i.height};break;case"bottom":g={x:f,y:r.y+r.height};break;case"right":g={x:r.x+r.width,y:h};break;case"left":g={x:r.x-i.width,y:h};break;default:g={x:r.x,y:r.y}}switch(vf(t)){case"start":g[o]-=y*(n&&d?-1:1);break;case"end":g[o]+=y*(n&&d?-1:1);break}return g}async function Rae(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:s,rects:o,elements:l,strategy:u}=e,{boundary:d="clippingAncestors",rootBoundary:f="viewport",elementContext:h="floating",altBoundary:y=!1,padding:g=0}=Va(t,e),_=t3(g),S=l[y?h==="floating"?"reference":"floating":h],x=Fy(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(S)))==null||n?S:S.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:d,rootBoundary:f,strategy:u})),k=h==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,R=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),A=await(s.isElement==null?void 0:s.isElement(R))?await(s.getScale==null?void 0:s.getScale(R))||{x:1,y:1}:{x:1,y:1},M=Fy(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:k,offsetParent:R,strategy:u}):k);return{top:(x.top-M.top+_.top)/A.y,bottom:(M.bottom-x.bottom+_.bottom)/A.y,left:(x.left-M.left+_.left)/A.x,right:(M.right-x.right+_.right)/A.x}}const Aae=50,Nae=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,l=o.detectOverflow?o:{...o,detectOverflow:Rae},u=await(o.isRTL==null?void 0:o.isRTL(t));let d=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:f,y:h}=G2(d,r,u),y=r,g=0;const _={};for(let w=0;w<s.length;w++){const S=s[w];if(!S)continue;const{name:x,fn:k}=S,{x:R,y:A,data:M,reset:T}=await k({x:f,y:h,initialPlacement:r,placement:y,strategy:i,middlewareData:_,rects:d,platform:l,elements:{reference:e,floating:t}});f=R??f,h=A??h,_[x]={..._[x],...M},T&&g<Aae&&(g++,typeof T=="object"&&(T.placement&&(y=T.placement),T.rects&&(d=T.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):T.rects),{x:f,y:h}=G2(d,y,u)),w=-1)}return{x:f,y:h,placement:y,strategy:i,middlewareData:_}},Mae=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:s,platform:o,elements:l,middlewareData:u}=t,{element:d,padding:f=0}=Va(e,t)||{};if(d==null)return{};const h=t3(f),y={x:n,y:r},g=fk(i),_=dk(g),w=await o.getDimensions(d),S=g==="y",x=S?"top":"left",k=S?"bottom":"right",R=S?"clientHeight":"clientWidth",A=s.reference[_]+s.reference[g]-y[g]-s.floating[_],M=y[g]-s.reference[g],T=await(o.getOffsetParent==null?void 0:o.getOffsetParent(d));let P=T?T[R]:0;(!P||!await(o.isElement==null?void 0:o.isElement(T)))&&(P=l.floating[R]||s.floating[_]);const z=A/2-M/2,Y=P/2-w[_]/2-1,U=ec(h[x],Y),G=ec(h[k],Y),I=U,N=P-w[_]-G,L=P/2-w[_]/2+z,B=p1(I,L,N),O=!u.arrow&&vf(i)!=null&&L!==B&&s.reference[_]/2-(L<I?U:G)-w[_]/2<0,D=O?L<I?L-I:L-N:0;return{[g]:y[g]+D,data:{[g]:B,centerOffset:L-B-D,...O&&{alignmentOffset:D}},reset:O}}}),Pae=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:s,rects:o,initialPlacement:l,platform:u,elements:d}=t,{mainAxis:f=!0,crossAxis:h=!0,fallbackPlacements:y,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:_="none",flipAlignment:w=!0,...S}=Va(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=Ya(i),k=ra(l),R=Ya(l)===l,A=await(u.isRTL==null?void 0:u.isRTL(d.floating)),M=y||(R||!w?[jy(l)]:xae(l)),T=_!=="none";!y&&T&&M.push(...kae(l,w,_,A));const P=[l,...M],z=await u.detectOverflow(t,S),Y=[];let U=((r=s.flip)==null?void 0:r.overflows)||[];if(f&&Y.push(z[x]),h){const L=wae(i,o,A);Y.push(z[L[0]],z[L[1]])}if(U=[...U,{placement:i,overflows:Y}],!Y.every(L=>L<=0)){var G,I;const L=(((G=s.flip)==null?void 0:G.index)||0)+1,B=P[L];if(B&&(!(h==="alignment"?k!==ra(B):!1)||U.every(F=>ra(F.placement)===k?F.overflows[0]>0:!0)))return{data:{index:L,overflows:U},reset:{placement:B}};let O=(I=U.filter(D=>D.overflows[0]<=0).sort((D,F)=>D.overflows[1]-F.overflows[1])[0])==null?void 0:I.placement;if(!O)switch(g){case"bestFit":{var N;const D=(N=U.filter(F=>{if(T){const V=ra(F.placement);return V===k||V==="y"}return!0}).map(F=>[F.placement,F.overflows.filter(V=>V>0).reduce((V,j)=>V+j,0)]).sort((F,V)=>F[1]-V[1])[0])==null?void 0:N[0];D&&(O=D);break}case"initialPlacement":O=l;break}if(i!==O)return{reset:{placement:O}}}return{}}}};function X2(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Z2(e){return bae.some(t=>e[t]>=0)}const Iae=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...s}=Va(e,t);switch(i){case"referenceHidden":{const o=await r.detectOverflow(t,{...s,elementContext:"reference"}),l=X2(o,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:Z2(l)}}}case"escaped":{const o=await r.detectOverflow(t,{...s,altBoundary:!0}),l=X2(o,n.floating);return{data:{escapedOffsets:l,escaped:Z2(l)}}}default:return{}}}}},n3=new Set(["left","top"]);async function Oae(e,t){const{placement:n,platform:r,elements:i}=e,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Ya(n),l=vf(n),u=ra(n)==="y",d=n3.has(o)?-1:1,f=s&&u?-1:1,h=Va(t,e);let{mainAxis:y,crossAxis:g,alignmentAxis:_}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return l&&typeof _=="number"&&(g=l==="end"?_*-1:_),u?{x:g*f,y:y*d}:{x:y*d,y:g*f}}const Lae=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:s,placement:o,middlewareData:l}=t,u=await Oae(t,e);return o===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:i+u.x,y:s+u.y,data:{...u,placement:o}}}}},Dae=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:s}=t,{mainAxis:o=!0,crossAxis:l=!1,limiter:u={fn:x=>{let{x:k,y:R}=x;return{x:k,y:R}}},...d}=Va(e,t),f={x:n,y:r},h=await s.detectOverflow(t,d),y=ra(Ya(i)),g=uk(y);let _=f[g],w=f[y];if(o){const x=g==="y"?"top":"left",k=g==="y"?"bottom":"right",R=_+h[x],A=_-h[k];_=p1(R,_,A)}if(l){const x=y==="y"?"top":"left",k=y==="y"?"bottom":"right",R=w+h[x],A=w-h[k];w=p1(R,w,A)}const S=u.fn({...t,[g]:_,[y]:w});return{...S,data:{x:S.x-n,y:S.y-r,enabled:{[g]:o,[y]:l}}}}}},Bae=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:s,middlewareData:o}=t,{offset:l=0,mainAxis:u=!0,crossAxis:d=!0}=Va(e,t),f={x:n,y:r},h=ra(i),y=uk(h);let g=f[y],_=f[h];const w=Va(l,t),S=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(u){const R=y==="y"?"height":"width",A=s.reference[y]-s.floating[R]+S.mainAxis,M=s.reference[y]+s.reference[R]-S.mainAxis;g<A?g=A:g>M&&(g=M)}if(d){var x,k;const R=y==="y"?"width":"height",A=n3.has(Ya(i)),M=s.reference[h]-s.floating[R]+(A&&((x=o.offset)==null?void 0:x[h])||0)+(A?0:S.crossAxis),T=s.reference[h]+s.reference[R]+(A?0:((k=o.offset)==null?void 0:k[h])||0)-(A?S.crossAxis:0);_<M?_=M:_>T&&(_=T)}return{[y]:g,[h]:_}}}},zae=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:i,rects:s,platform:o,elements:l}=t,{apply:u=()=>{},...d}=Va(e,t),f=await o.detectOverflow(t,d),h=Ya(i),y=vf(i),g=ra(i)==="y",{width:_,height:w}=s.floating;let S,x;h==="top"||h==="bottom"?(S=h,x=y===(await(o.isRTL==null?void 0:o.isRTL(l.floating))?"start":"end")?"left":"right"):(x=h,S=y==="end"?"top":"bottom");const k=w-f.top-f.bottom,R=_-f.left-f.right,A=ec(w-f[S],k),M=ec(_-f[x],R),T=!t.middlewareData.shift;let P=A,z=M;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(z=R),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(P=k),T&&!y){const U=$s(f.left,0),G=$s(f.right,0),I=$s(f.top,0),N=$s(f.bottom,0);g?z=_-2*(U!==0||G!==0?U+G:$s(f.left,f.right)):P=w-2*(I!==0||N!==0?I+N:$s(f.top,f.bottom))}await u({...t,availableWidth:z,availableHeight:P});const Y=await o.getDimensions(l.floating);return _!==Y.width||w!==Y.height?{reset:{rects:!0}}:{}}}};function Ab(){return typeof window<"u"}function yf(e){return r3(e)?(e.nodeName||"").toLowerCase():"#document"}function Us(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function pa(e){var t;return(t=(r3(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function r3(e){return Ab()?e instanceof Node||e instanceof Us(e).Node:!1}function Oo(e){return Ab()?e instanceof Element||e instanceof Us(e).Element:!1}function Za(e){return Ab()?e instanceof HTMLElement||e instanceof Us(e).HTMLElement:!1}function Q2(e){return!Ab()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Us(e).ShadowRoot}function vm(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=Lo(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function jae(e){return/^(table|td|th)$/.test(yf(e))}function Nb(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Fae=/transform|translate|scale|rotate|perspective|filter/,$ae=/paint|layout|strict|content/,zc=e=>!!e&&e!=="none";let h0;function hk(e){const t=Oo(e)?Lo(e):e;return zc(t.transform)||zc(t.translate)||zc(t.scale)||zc(t.rotate)||zc(t.perspective)||!pk()&&(zc(t.backdropFilter)||zc(t.filter))||Fae.test(t.willChange||"")||$ae.test(t.contain||"")}function Hae(e){let t=tc(e);for(;Za(t)&&!rf(t);){if(hk(t))return t;if(Nb(t))return null;t=tc(t)}return null}function pk(){return h0==null&&(h0=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),h0}function rf(e){return/^(html|body|#document)$/.test(yf(e))}function Lo(e){return Us(e).getComputedStyle(e)}function Mb(e){return Oo(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function tc(e){if(yf(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Q2(e)&&e.host||pa(e);return Q2(t)?t.host:t}function i3(e){const t=tc(e);return rf(t)?e.ownerDocument?e.ownerDocument.body:e.body:Za(t)&&vm(t)?t:i3(t)}function $p(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=i3(e),s=i===((r=e.ownerDocument)==null?void 0:r.body),o=Us(i);if(s){const l=g1(o);return t.concat(o,o.visualViewport||[],vm(i)?i:[],l&&n?$p(l):[])}else return t.concat(i,$p(i,[],n))}function g1(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function s3(e){const t=Lo(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Za(e),s=i?e.offsetWidth:n,o=i?e.offsetHeight:r,l=zy(n)!==s||zy(r)!==o;return l&&(n=s,r=o),{width:n,height:r,$:l}}function mk(e){return Oo(e)?e:e.contextElement}function qd(e){const t=mk(e);if(!Za(t))return aa(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:s}=s3(t);let o=(s?zy(n.width):n.width)/r,l=(s?zy(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const Uae=aa(0);function o3(e){const t=Us(e);return!pk()||!t.visualViewport?Uae:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Wae(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Us(e)?!1:t}function cu(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),s=mk(e);let o=aa(1);t&&(r?Oo(r)&&(o=qd(r)):o=qd(e));const l=Wae(s,n,r)?o3(s):aa(0);let u=(i.left+l.x)/o.x,d=(i.top+l.y)/o.y,f=i.width/o.x,h=i.height/o.y;if(s){const y=Us(s),g=r&&Oo(r)?Us(r):r;let _=y,w=g1(_);for(;w&&r&&g!==_;){const S=qd(w),x=w.getBoundingClientRect(),k=Lo(w),R=x.left+(w.clientLeft+parseFloat(k.paddingLeft))*S.x,A=x.top+(w.clientTop+parseFloat(k.paddingTop))*S.y;u*=S.x,d*=S.y,f*=S.x,h*=S.y,u+=R,d+=A,_=Us(w),w=g1(_)}}return Fy({width:f,height:h,x:u,y:d})}function Pb(e,t){const n=Mb(e).scrollLeft;return t?t.left+n:cu(pa(e)).left+n}function a3(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Pb(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function qae(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const s=i==="fixed",o=pa(r),l=t?Nb(t.floating):!1;if(r===o||l&&s)return n;let u={scrollLeft:0,scrollTop:0},d=aa(1);const f=aa(0),h=Za(r);if((h||!h&&!s)&&((yf(r)!=="body"||vm(o))&&(u=Mb(r)),h)){const g=cu(r);d=qd(r),f.x=g.x+r.clientLeft,f.y=g.y+r.clientTop}const y=o&&!h&&!s?a3(o,u):aa(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-u.scrollLeft*d.x+f.x+y.x,y:n.y*d.y-u.scrollTop*d.y+f.y+y.y}}function Vae(e){return Array.from(e.getClientRects())}function Yae(e){const t=pa(e),n=Mb(e),r=e.ownerDocument.body,i=$s(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=$s(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+Pb(e);const l=-n.scrollTop;return Lo(r).direction==="rtl"&&(o+=$s(t.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:l}}const J2=25;function Kae(e,t){const n=Us(e),r=pa(e),i=n.visualViewport;let s=r.clientWidth,o=r.clientHeight,l=0,u=0;if(i){s=i.width,o=i.height;const f=pk();(!f||f&&t==="fixed")&&(l=i.offsetLeft,u=i.offsetTop)}const d=Pb(r);if(d<=0){const f=r.ownerDocument,h=f.body,y=getComputedStyle(h),g=f.compatMode==="CSS1Compat"&&parseFloat(y.marginLeft)+parseFloat(y.marginRight)||0,_=Math.abs(r.clientWidth-h.clientWidth-g);_<=J2&&(s-=_)}else d<=J2&&(s+=d);return{width:s,height:o,x:l,y:u}}function Gae(e,t){const n=cu(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=Za(e)?qd(e):aa(1),o=e.clientWidth*s.x,l=e.clientHeight*s.y,u=i*s.x,d=r*s.y;return{width:o,height:l,x:u,y:d}}function eI(e,t,n){let r;if(t==="viewport")r=Kae(e,n);else if(t==="document")r=Yae(pa(e));else if(Oo(t))r=Gae(t,n);else{const i=o3(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Fy(r)}function l3(e,t){const n=tc(e);return n===t||!Oo(n)||rf(n)?!1:Lo(n).position==="fixed"||l3(n,t)}function Xae(e,t){const n=t.get(e);if(n)return n;let r=$p(e,[],!1).filter(l=>Oo(l)&&yf(l)!=="body"),i=null;const s=Lo(e).position==="fixed";let o=s?tc(e):e;for(;Oo(o)&&!rf(o);){const l=Lo(o),u=hk(o);!u&&l.position==="fixed"&&(i=null),(s?!u&&!i:!u&&l.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||vm(o)&&!u&&l3(e,o))?r=r.filter(f=>f!==o):i=l,o=tc(o)}return t.set(e,r),r}function Zae(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[...n==="clippingAncestors"?Nb(t)?[]:Xae(t,this._c):[].concat(n),r],l=eI(t,o[0],i);let u=l.top,d=l.right,f=l.bottom,h=l.left;for(let y=1;y<o.length;y++){const g=eI(t,o[y],i);u=$s(g.top,u),d=ec(g.right,d),f=ec(g.bottom,f),h=$s(g.left,h)}return{width:d-h,height:f-u,x:h,y:u}}function Qae(e){const{width:t,height:n}=s3(e);return{width:t,height:n}}function Jae(e,t,n){const r=Za(t),i=pa(t),s=n==="fixed",o=cu(e,!0,s,t);let l={scrollLeft:0,scrollTop:0};const u=aa(0);function d(){u.x=Pb(i)}if(r||!r&&!s)if((yf(t)!=="body"||vm(i))&&(l=Mb(t)),r){const g=cu(t,!0,s,t);u.x=g.x+t.clientLeft,u.y=g.y+t.clientTop}else i&&d();s&&!r&&i&&d();const f=i&&!r&&!s?a3(i,l):aa(0),h=o.left+l.scrollLeft-u.x-f.x,y=o.top+l.scrollTop-u.y-f.y;return{x:h,y,width:o.width,height:o.height}}function p0(e){return Lo(e).position==="static"}function tI(e,t){if(!Za(e)||Lo(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return pa(e)===n&&(n=n.ownerDocument.body),n}function c3(e,t){const n=Us(e);if(Nb(e))return n;if(!Za(e)){let i=tc(e);for(;i&&!rf(i);){if(Oo(i)&&!p0(i))return i;i=tc(i)}return n}let r=tI(e,t);for(;r&&jae(r)&&p0(r);)r=tI(r,t);return r&&rf(r)&&p0(r)&&!hk(r)?n:r||Hae(e)||n}const ele=async function(e){const t=this.getOffsetParent||c3,n=this.getDimensions,r=await n(e.floating);return{reference:Jae(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function tle(e){return Lo(e).direction==="rtl"}const nle={convertOffsetParentRelativeRectToViewportRelativeRect:qae,getDocumentElement:pa,getClippingRect:Zae,getOffsetParent:c3,getElementRects:ele,getClientRects:Vae,getDimensions:Qae,getScale:qd,isElement:Oo,isRTL:tle};function u3(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function rle(e,t){let n=null,r;const i=pa(e);function s(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function o(l,u){l===void 0&&(l=!1),u===void 0&&(u=1),s();const d=e.getBoundingClientRect(),{left:f,top:h,width:y,height:g}=d;if(l||t(),!y||!g)return;const _=gv(h),w=gv(i.clientWidth-(f+y)),S=gv(i.clientHeight-(h+g)),x=gv(f),R={rootMargin:-_+"px "+-w+"px "+-S+"px "+-x+"px",threshold:$s(0,ec(1,u))||1};let A=!0;function M(T){const P=T[0].intersectionRatio;if(P!==u){if(!A)return o();P?o(!1,P):r=setTimeout(()=>{o(!1,1e-7)},1e3)}P===1&&!u3(d,e.getBoundingClientRect())&&o(),A=!1}try{n=new IntersectionObserver(M,{...R,root:i.ownerDocument})}catch{n=new IntersectionObserver(M,R)}n.observe(e)}return o(!0),s}function ile(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,d=mk(e),f=i||s?[...d?$p(d):[],...t?$p(t):[]]:[];f.forEach(x=>{i&&x.addEventListener("scroll",n,{passive:!0}),s&&x.addEventListener("resize",n)});const h=d&&l?rle(d,n):null;let y=-1,g=null;o&&(g=new ResizeObserver(x=>{let[k]=x;k&&k.target===d&&g&&t&&(g.unobserve(t),cancelAnimationFrame(y),y=requestAnimationFrame(()=>{var R;(R=g)==null||R.observe(t)})),n()}),d&&!u&&g.observe(d),t&&g.observe(t));let _,w=u?cu(e):null;u&&S();function S(){const x=cu(e);w&&!u3(w,x)&&n(),w=x,_=requestAnimationFrame(S)}return n(),()=>{var x;f.forEach(k=>{i&&k.removeEventListener("scroll",n),s&&k.removeEventListener("resize",n)}),h==null||h(),(x=g)==null||x.disconnect(),g=null,u&&cancelAnimationFrame(_)}}const sle=Lae,ole=Dae,ale=Pae,lle=zae,cle=Iae,nI=Mae,ule=Bae,dle=(e,t,n)=>{const r=new Map,i={platform:nle,...n},s={...i.platform,_c:r};return Nae(e,t,{...i,platform:s})};var fle=typeof document<"u",hle=function(){},oy=fle?b.useLayoutEffect:hle;function $y(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!$y(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&e.$$typeof)&&!$y(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function d3(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function rI(e,t){const n=d3(e);return Math.round(t*n)/n}function m0(e){const t=b.useRef(e);return oy(()=>{t.current=e}),t}function ple(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:o}={},transform:l=!0,whileElementsMounted:u,open:d}=e,[f,h]=b.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[y,g]=b.useState(r);$y(y,r)||g(r);const[_,w]=b.useState(null),[S,x]=b.useState(null),k=b.useCallback(F=>{F!==T.current&&(T.current=F,w(F))},[]),R=b.useCallback(F=>{F!==P.current&&(P.current=F,x(F))},[]),A=s||_,M=o||S,T=b.useRef(null),P=b.useRef(null),z=b.useRef(f),Y=u!=null,U=m0(u),G=m0(i),I=m0(d),N=b.useCallback(()=>{if(!T.current||!P.current)return;const F={placement:t,strategy:n,middleware:y};G.current&&(F.platform=G.current),dle(T.current,P.current,F).then(V=>{const j={...V,isPositioned:I.current!==!1};L.current&&!$y(z.current,j)&&(z.current=j,xu.flushSync(()=>{h(j)}))})},[y,t,n,G,I]);oy(()=>{d===!1&&z.current.isPositioned&&(z.current.isPositioned=!1,h(F=>({...F,isPositioned:!1})))},[d]);const L=b.useRef(!1);oy(()=>(L.current=!0,()=>{L.current=!1}),[]),oy(()=>{if(A&&(T.current=A),M&&(P.current=M),A&&M){if(U.current)return U.current(A,M,N);N()}},[A,M,N,U,Y]);const B=b.useMemo(()=>({reference:T,floating:P,setReference:k,setFloating:R}),[k,R]),O=b.useMemo(()=>({reference:A,floating:M}),[A,M]),D=b.useMemo(()=>{const F={position:n,left:0,top:0};if(!O.floating)return F;const V=rI(O.floating,f.x),j=rI(O.floating,f.y);return l?{...F,transform:"translate("+V+"px, "+j+"px)",...d3(O.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:V,top:j}},[n,l,O.floating,f.x,f.y]);return b.useMemo(()=>({...f,update:N,refs:B,elements:O,floatingStyles:D}),[f,N,B,O,D])}const mle=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?nI({element:r.current,padding:i}).fn(n):{}:r?nI({element:r,padding:i}).fn(n):{}}}},gle=(e,t)=>{const n=sle(e);return{name:n.name,fn:n.fn,options:[e,t]}},vle=(e,t)=>{const n=ole(e);return{name:n.name,fn:n.fn,options:[e,t]}},yle=(e,t)=>({fn:ule(e).fn,options:[e,t]}),ble=(e,t)=>{const n=ale(e);return{name:n.name,fn:n.fn,options:[e,t]}},_le=(e,t)=>{const n=lle(e);return{name:n.name,fn:n.fn,options:[e,t]}},wle=(e,t)=>{const n=cle(e);return{name:n.name,fn:n.fn,options:[e,t]}},xle=(e,t)=>{const n=mle(e);return{name:n.name,fn:n.fn,options:[e,t]}};var Sle="Arrow",f3=b.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...s}=e;return m.jsx(yn.svg,{...s,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:m.jsx("polygon",{points:"0,0 30,0 15,10"})})});f3.displayName=Sle;var Ele=f3,gk="Popper",[h3,cc]=Xa(gk),[Cle,p3]=h3(gk),m3=e=>{const{__scopePopper:t,children:n}=e,[r,i]=b.useState(null);return m.jsx(Cle,{scope:t,anchor:r,onAnchorChange:i,children:n})};m3.displayName=gk;var g3="PopperAnchor",v3=b.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...i}=e,s=p3(g3,n),o=b.useRef(null),l=or(t,o),u=b.useRef(null);return b.useEffect(()=>{const d=u.current;u.current=(r==null?void 0:r.current)||o.current,d!==u.current&&s.onAnchorChange(u.current)}),r?null:m.jsx(yn.div,{...i,ref:l})});v3.displayName=g3;var vk="PopperContent",[kle,Tle]=h3(vk),y3=b.forwardRef((e,t)=>{var Q,ce,re,le,we,Ce;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:s="center",alignOffset:o=0,arrowPadding:l=0,avoidCollisions:u=!0,collisionBoundary:d=[],collisionPadding:f=0,sticky:h="partial",hideWhenDetached:y=!1,updatePositionStrategy:g="optimized",onPlaced:_,...w}=e,S=p3(vk,n),[x,k]=b.useState(null),R=or(t,ye=>k(ye)),[A,M]=b.useState(null),T=yae(A),P=(T==null?void 0:T.width)??0,z=(T==null?void 0:T.height)??0,Y=r+(s!=="center"?"-"+s:""),U=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},G=Array.isArray(d)?d:[d],I=G.length>0,N={padding:U,boundary:G.filter(Ale),altBoundary:I},{refs:L,floatingStyles:B,placement:O,isPositioned:D,middlewareData:F}=ple({strategy:"fixed",placement:Y,whileElementsMounted:(...ye)=>ile(...ye,{animationFrame:g==="always"}),elements:{reference:S.anchor},middleware:[gle({mainAxis:i+z,alignmentAxis:o}),u&&vle({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?yle():void 0,...N}),u&&ble({...N}),_le({...N,apply:({elements:ye,rects:Re,availableWidth:Rt,availableHeight:Ke})=>{const{width:et,height:$e}=Re.reference,Fe=ye.floating.style;Fe.setProperty("--radix-popper-available-width",`${Rt}px`),Fe.setProperty("--radix-popper-available-height",`${Ke}px`),Fe.setProperty("--radix-popper-anchor-width",`${et}px`),Fe.setProperty("--radix-popper-anchor-height",`${$e}px`)}}),A&&xle({element:A,padding:l}),Nle({arrowWidth:P,arrowHeight:z}),y&&wle({strategy:"referenceHidden",...N})]}),[V,j]=w3(O),q=Io(_);Qi(()=>{D&&(q==null||q())},[D,q]);const K=(Q=F.arrow)==null?void 0:Q.x,$=(ce=F.arrow)==null?void 0:ce.y,te=((re=F.arrow)==null?void 0:re.centerOffset)!==0,[J,ne]=b.useState();return Qi(()=>{x&&ne(window.getComputedStyle(x).zIndex)},[x]),m.jsx("div",{ref:L.setFloating,"data-radix-popper-content-wrapper":"",style:{...B,transform:D?B.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:J,"--radix-popper-transform-origin":[(le=F.transformOrigin)==null?void 0:le.x,(we=F.transformOrigin)==null?void 0:we.y].join(" "),...((Ce=F.hide)==null?void 0:Ce.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:m.jsx(kle,{scope:n,placedSide:V,onArrowChange:M,arrowX:K,arrowY:$,shouldHideArrow:te,children:m.jsx(yn.div,{"data-side":V,"data-align":j,...w,ref:R,style:{...w.style,animation:D?void 0:"none"}})})})});y3.displayName=vk;var b3="PopperArrow",Rle={top:"bottom",right:"left",bottom:"top",left:"right"},_3=b.forwardRef(function(t,n){const{__scopePopper:r,...i}=t,s=Tle(b3,r),o=Rle[s.placedSide];return m.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:m.jsx(Ele,{...i,ref:n,style:{...i.style,display:"block"}})})});_3.displayName=b3;function Ale(e){return e!==null}var Nle=e=>({name:"transformOrigin",options:e,fn(t){var S,x,k;const{placement:n,rects:r,middlewareData:i}=t,o=((S=i.arrow)==null?void 0:S.centerOffset)!==0,l=o?0:e.arrowWidth,u=o?0:e.arrowHeight,[d,f]=w3(n),h={start:"0%",center:"50%",end:"100%"}[f],y=(((x=i.arrow)==null?void 0:x.x)??0)+l/2,g=(((k=i.arrow)==null?void 0:k.y)??0)+u/2;let _="",w="";return d==="bottom"?(_=o?h:`${y}px`,w=`${-u}px`):d==="top"?(_=o?h:`${y}px`,w=`${r.floating.height+u}px`):d==="right"?(_=`${-u}px`,w=o?h:`${g}px`):d==="left"&&(_=`${r.floating.width+u}px`,w=o?h:`${g}px`),{data:{x:_,y:w}}}});function w3(e){const[t,n="center"]=e.split("-");return[t,n]}var ym=m3,bm=v3,Ib=y3,Ob=_3,g0="rovingFocusGroup.onEntryFocus",Mle={bubbles:!1,cancelable:!0},_m="RovingFocusGroup",[v1,x3,Ple]=tk(_m),[Ile,S3]=Xa(_m,[Ple]),[Ole,Lle]=Ile(_m),E3=b.forwardRef((e,t)=>m.jsx(v1.Provider,{scope:e.__scopeRovingFocusGroup,children:m.jsx(v1.Slot,{scope:e.__scopeRovingFocusGroup,children:m.jsx(Dle,{...e,ref:t})})}));E3.displayName=_m;var Dle=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:s,currentTabStopId:o,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:u,onEntryFocus:d,preventScrollOnEntryFocus:f=!1,...h}=e,y=b.useRef(null),g=or(t,y),_=nk(s),[w,S]=Jl({prop:o,defaultProp:l??null,onChange:u,caller:_m}),[x,k]=b.useState(!1),R=Io(d),A=x3(n),M=b.useRef(!1),[T,P]=b.useState(0);return b.useEffect(()=>{const z=y.current;if(z)return z.addEventListener(g0,R),()=>z.removeEventListener(g0,R)},[R]),m.jsx(Ole,{scope:n,orientation:r,dir:_,loop:i,currentTabStopId:w,onItemFocus:b.useCallback(z=>S(z),[S]),onItemShiftTab:b.useCallback(()=>k(!0),[]),onFocusableItemAdd:b.useCallback(()=>P(z=>z+1),[]),onFocusableItemRemove:b.useCallback(()=>P(z=>z-1),[]),children:m.jsx(yn.div,{tabIndex:x||T===0?-1:0,"data-orientation":r,...h,ref:g,style:{outline:"none",...e.style},onMouseDown:Wt(e.onMouseDown,()=>{M.current=!0}),onFocus:Wt(e.onFocus,z=>{const Y=!M.current;if(z.target===z.currentTarget&&Y&&!x){const U=new CustomEvent(g0,Mle);if(z.currentTarget.dispatchEvent(U),!U.defaultPrevented){const G=A().filter(O=>O.focusable),I=G.find(O=>O.active),N=G.find(O=>O.id===w),B=[I,N,...G].filter(Boolean).map(O=>O.ref.current);T3(B,f)}}M.current=!1}),onBlur:Wt(e.onBlur,()=>k(!1))})})}),C3="RovingFocusGroupItem",k3=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:s,children:o,...l}=e,u=vi(),d=s||u,f=Lle(C3,n),h=f.currentTabStopId===d,y=x3(n),{onFocusableItemAdd:g,onFocusableItemRemove:_,currentTabStopId:w}=f;return b.useEffect(()=>{if(r)return g(),()=>_()},[r,g,_]),m.jsx(v1.ItemSlot,{scope:n,id:d,focusable:r,active:i,children:m.jsx(yn.span,{tabIndex:h?0:-1,"data-orientation":f.orientation,...l,ref:t,onMouseDown:Wt(e.onMouseDown,S=>{r?f.onItemFocus(d):S.preventDefault()}),onFocus:Wt(e.onFocus,()=>f.onItemFocus(d)),onKeyDown:Wt(e.onKeyDown,S=>{if(S.key==="Tab"&&S.shiftKey){f.onItemShiftTab();return}if(S.target!==S.currentTarget)return;const x=jle(S,f.orientation,f.dir);if(x!==void 0){if(S.metaKey||S.ctrlKey||S.altKey||S.shiftKey)return;S.preventDefault();let R=y().filter(A=>A.focusable).map(A=>A.ref.current);if(x==="last")R.reverse();else if(x==="prev"||x==="next"){x==="prev"&&R.reverse();const A=R.indexOf(S.currentTarget);R=f.loop?Fle(R,A+1):R.slice(A+1)}setTimeout(()=>T3(R))}}),children:typeof o=="function"?o({isCurrentTabStop:h,hasTabStop:w!=null}):o})})});k3.displayName=C3;var Ble={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function zle(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function jle(e,t,n){const r=zle(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Ble[r]}function T3(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Fle(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var $le=E3,Hle=k3,y1=["Enter"," "],Ule=["ArrowDown","PageUp","Home"],R3=["ArrowUp","PageDown","End"],Wle=[...Ule,...R3],qle={ltr:[...y1,"ArrowRight"],rtl:[...y1,"ArrowLeft"]},Vle={ltr:["ArrowLeft"],rtl:["ArrowRight"]},wm="Menu",[Hp,Yle,Kle]=tk(wm),[Su,A3]=Xa(wm,[Kle,cc,S3]),xm=cc(),N3=S3(),[M3,uc]=Su(wm),[Gle,Sm]=Su(wm),P3=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,l=xm(t),[u,d]=b.useState(null),f=b.useRef(!1),h=Io(s),y=nk(i);return b.useEffect(()=>{const g=()=>{f.current=!0,document.addEventListener("pointerdown",_,{capture:!0,once:!0}),document.addEventListener("pointermove",_,{capture:!0,once:!0})},_=()=>f.current=!1;return document.addEventListener("keydown",g,{capture:!0}),()=>{document.removeEventListener("keydown",g,{capture:!0}),document.removeEventListener("pointerdown",_,{capture:!0}),document.removeEventListener("pointermove",_,{capture:!0})}},[]),m.jsx(ym,{...l,children:m.jsx(M3,{scope:t,open:n,onOpenChange:h,content:u,onContentChange:d,children:m.jsx(Gle,{scope:t,onClose:b.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:f,dir:y,modal:o,children:r})})})};P3.displayName=wm;var Xle="MenuAnchor",yk=b.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=xm(n);return m.jsx(bm,{...i,...r,ref:t})});yk.displayName=Xle;var bk="MenuPortal",[Zle,I3]=Su(bk,{forceMount:void 0}),O3=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=uc(bk,t);return m.jsx(Zle,{scope:t,forceMount:n,children:m.jsx(wo,{present:n||s.open,children:m.jsx(gf,{asChild:!0,container:i,children:r})})})};O3.displayName=bk;var mo="MenuContent",[Qle,_k]=Su(mo),L3=b.forwardRef((e,t)=>{const n=I3(mo,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=uc(mo,e.__scopeMenu),o=Sm(mo,e.__scopeMenu);return m.jsx(Hp.Provider,{scope:e.__scopeMenu,children:m.jsx(wo,{present:r||s.open,children:m.jsx(Hp.Slot,{scope:e.__scopeMenu,children:o.modal?m.jsx(Jle,{...i,ref:t}):m.jsx(ece,{...i,ref:t})})})})}),Jle=b.forwardRef((e,t)=>{const n=uc(mo,e.__scopeMenu),r=b.useRef(null),i=or(t,r);return b.useEffect(()=>{const s=r.current;if(s)return kb(s)},[]),m.jsx(wk,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Wt(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),ece=b.forwardRef((e,t)=>{const n=uc(mo,e.__scopeMenu);return m.jsx(wk,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),tce=Ql("MenuContent.ScrollLock"),wk=b.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEntryFocus:u,onEscapeKeyDown:d,onPointerDownOutside:f,onFocusOutside:h,onInteractOutside:y,onDismiss:g,disableOutsideScroll:_,...w}=e,S=uc(mo,n),x=Sm(mo,n),k=xm(n),R=N3(n),A=Yle(n),[M,T]=b.useState(null),P=b.useRef(null),z=or(t,P,S.onContentChange),Y=b.useRef(0),U=b.useRef(""),G=b.useRef(0),I=b.useRef(null),N=b.useRef("right"),L=b.useRef(0),B=_?gm:b.Fragment,O=_?{as:tce,allowPinchZoom:!0}:void 0,D=V=>{var Q,ce;const j=U.current+V,q=A().filter(re=>!re.disabled),K=document.activeElement,$=(Q=q.find(re=>re.ref.current===K))==null?void 0:Q.textValue,te=q.map(re=>re.textValue),J=hce(te,j,$),ne=(ce=q.find(re=>re.textValue===J))==null?void 0:ce.ref.current;(function re(le){U.current=le,window.clearTimeout(Y.current),le!==""&&(Y.current=window.setTimeout(()=>re(""),1e3))})(j),ne&&setTimeout(()=>ne.focus())};b.useEffect(()=>()=>window.clearTimeout(Y.current),[]),Eb();const F=b.useCallback(V=>{var q,K;return N.current===((q=I.current)==null?void 0:q.side)&&mce(V,(K=I.current)==null?void 0:K.area)},[]);return m.jsx(Qle,{scope:n,searchRef:U,onItemEnter:b.useCallback(V=>{F(V)&&V.preventDefault()},[F]),onItemLeave:b.useCallback(V=>{var j;F(V)||((j=P.current)==null||j.focus(),T(null))},[F]),onTriggerLeave:b.useCallback(V=>{F(V)&&V.preventDefault()},[F]),pointerGraceTimerRef:G,onPointerGraceIntentChange:b.useCallback(V=>{I.current=V},[]),children:m.jsx(B,{...O,children:m.jsx(mm,{asChild:!0,trapped:i,onMountAutoFocus:Wt(s,V=>{var j;V.preventDefault(),(j=P.current)==null||j.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:m.jsx(mf,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:d,onPointerDownOutside:f,onFocusOutside:h,onInteractOutside:y,onDismiss:g,children:m.jsx($le,{asChild:!0,...R,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:M,onCurrentTabStopIdChange:T,onEntryFocus:Wt(u,V=>{x.isUsingKeyboardRef.current||V.preventDefault()}),preventScrollOnEntryFocus:!0,children:m.jsx(Ib,{role:"menu","aria-orientation":"vertical","data-state":Q3(S.open),"data-radix-menu-content":"",dir:x.dir,...k,...w,ref:z,style:{outline:"none",...w.style},onKeyDown:Wt(w.onKeyDown,V=>{const q=V.target.closest("[data-radix-menu-content]")===V.currentTarget,K=V.ctrlKey||V.altKey||V.metaKey,$=V.key.length===1;q&&(V.key==="Tab"&&V.preventDefault(),!K&&$&&D(V.key));const te=P.current;if(V.target!==te||!Wle.includes(V.key))return;V.preventDefault();const ne=A().filter(Q=>!Q.disabled).map(Q=>Q.ref.current);R3.includes(V.key)&&ne.reverse(),dce(ne)}),onBlur:Wt(e.onBlur,V=>{V.currentTarget.contains(V.target)||(window.clearTimeout(Y.current),U.current="")}),onPointerMove:Wt(e.onPointerMove,Up(V=>{const j=V.target,q=L.current!==V.clientX;if(V.currentTarget.contains(j)&&q){const K=V.clientX>L.current?"right":"left";N.current=K,L.current=V.clientX}}))})})})})})})});L3.displayName=mo;var nce="MenuGroup",xk=b.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return m.jsx(yn.div,{role:"group",...r,ref:t})});xk.displayName=nce;var rce="MenuLabel",D3=b.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return m.jsx(yn.div,{...r,ref:t})});D3.displayName=rce;var Hy="MenuItem",iI="menu.itemSelect",Lb=b.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=b.useRef(null),o=Sm(Hy,e.__scopeMenu),l=_k(Hy,e.__scopeMenu),u=or(t,s),d=b.useRef(!1),f=()=>{const h=s.current;if(!n&&h){const y=new CustomEvent(iI,{bubbles:!0,cancelable:!0});h.addEventListener(iI,g=>r==null?void 0:r(g),{once:!0}),x5(h,y),y.defaultPrevented?d.current=!1:o.onClose()}};return m.jsx(B3,{...i,ref:u,disabled:n,onClick:Wt(e.onClick,f),onPointerDown:h=>{var y;(y=e.onPointerDown)==null||y.call(e,h),d.current=!0},onPointerUp:Wt(e.onPointerUp,h=>{var y;d.current||(y=h.currentTarget)==null||y.click()}),onKeyDown:Wt(e.onKeyDown,h=>{const y=l.searchRef.current!=="";n||y&&h.key===" "||y1.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});Lb.displayName=Hy;var B3=b.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=_k(Hy,n),l=N3(n),u=b.useRef(null),d=or(t,u),[f,h]=b.useState(!1),[y,g]=b.useState("");return b.useEffect(()=>{const _=u.current;_&&g((_.textContent??"").trim())},[s.children]),m.jsx(Hp.ItemSlot,{scope:n,disabled:r,textValue:i??y,children:m.jsx(Hle,{asChild:!0,...l,focusable:!r,children:m.jsx(yn.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:d,onPointerMove:Wt(e.onPointerMove,Up(_=>{r?o.onItemLeave(_):(o.onItemEnter(_),_.defaultPrevented||_.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Wt(e.onPointerLeave,Up(_=>o.onItemLeave(_))),onFocus:Wt(e.onFocus,()=>h(!0)),onBlur:Wt(e.onBlur,()=>h(!1))})})})}),ice="MenuCheckboxItem",z3=b.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return m.jsx(U3,{scope:e.__scopeMenu,checked:n,children:m.jsx(Lb,{role:"menuitemcheckbox","aria-checked":Uy(n)?"mixed":n,...i,ref:t,"data-state":Ck(n),onSelect:Wt(i.onSelect,()=>r==null?void 0:r(Uy(n)?!0:!n),{checkForDefaultPrevented:!1})})})});z3.displayName=ice;var j3="MenuRadioGroup",[sce,oce]=Su(j3,{value:void 0,onValueChange:()=>{}}),F3=b.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=Io(r);return m.jsx(sce,{scope:e.__scopeMenu,value:n,onValueChange:s,children:m.jsx(xk,{...i,ref:t})})});F3.displayName=j3;var $3="MenuRadioItem",H3=b.forwardRef((e,t)=>{const{value:n,...r}=e,i=oce($3,e.__scopeMenu),s=n===i.value;return m.jsx(U3,{scope:e.__scopeMenu,checked:s,children:m.jsx(Lb,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Ck(s),onSelect:Wt(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});H3.displayName=$3;var Sk="MenuItemIndicator",[U3,ace]=Su(Sk,{checked:!1}),W3=b.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=ace(Sk,n);return m.jsx(wo,{present:r||Uy(s.checked)||s.checked===!0,children:m.jsx(yn.span,{...i,ref:t,"data-state":Ck(s.checked)})})});W3.displayName=Sk;var lce="MenuSeparator",q3=b.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return m.jsx(yn.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});q3.displayName=lce;var cce="MenuArrow",V3=b.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=xm(n);return m.jsx(Ob,{...i,...r,ref:t})});V3.displayName=cce;var Ek="MenuSub",[uce,Y3]=Su(Ek),K3=e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,s=uc(Ek,t),o=xm(t),[l,u]=b.useState(null),[d,f]=b.useState(null),h=Io(i);return b.useEffect(()=>(s.open===!1&&h(!1),()=>h(!1)),[s.open,h]),m.jsx(ym,{...o,children:m.jsx(M3,{scope:t,open:r,onOpenChange:h,content:d,onContentChange:f,children:m.jsx(uce,{scope:t,contentId:vi(),triggerId:vi(),trigger:l,onTriggerChange:u,children:n})})})};K3.displayName=Ek;var op="MenuSubTrigger",G3=b.forwardRef((e,t)=>{const n=uc(op,e.__scopeMenu),r=Sm(op,e.__scopeMenu),i=Y3(op,e.__scopeMenu),s=_k(op,e.__scopeMenu),o=b.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:u}=s,d={__scopeMenu:e.__scopeMenu},f=b.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return b.useEffect(()=>f,[f]),b.useEffect(()=>{const h=l.current;return()=>{window.clearTimeout(h),u(null)}},[l,u]),m.jsx(yk,{asChild:!0,...d,children:m.jsx(B3,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":Q3(n.open),...e,ref:qa(t,i.onTriggerChange),onClick:h=>{var y;(y=e.onClick)==null||y.call(e,h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Wt(e.onPointerMove,Up(h=>{s.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(s.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),f()},100))})),onPointerLeave:Wt(e.onPointerLeave,Up(h=>{var g,_;f();const y=(g=n.content)==null?void 0:g.getBoundingClientRect();if(y){const w=(_=n.content)==null?void 0:_.dataset.side,S=w==="right",x=S?-5:5,k=y[S?"left":"right"],R=y[S?"right":"left"];s.onPointerGraceIntentChange({area:[{x:h.clientX+x,y:h.clientY},{x:k,y:y.top},{x:R,y:y.top},{x:R,y:y.bottom},{x:k,y:y.bottom}],side:w}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(h),h.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:Wt(e.onKeyDown,h=>{var g;const y=s.searchRef.current!=="";e.disabled||y&&h.key===" "||qle[r.dir].includes(h.key)&&(n.onOpenChange(!0),(g=n.content)==null||g.focus(),h.preventDefault())})})})});G3.displayName=op;var X3="MenuSubContent",Z3=b.forwardRef((e,t)=>{const n=I3(mo,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=uc(mo,e.__scopeMenu),o=Sm(mo,e.__scopeMenu),l=Y3(X3,e.__scopeMenu),u=b.useRef(null),d=or(t,u);return m.jsx(Hp.Provider,{scope:e.__scopeMenu,children:m.jsx(wo,{present:r||s.open,children:m.jsx(Hp.Slot,{scope:e.__scopeMenu,children:m.jsx(wk,{id:l.contentId,"aria-labelledby":l.triggerId,...i,ref:d,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:f=>{var h;o.isUsingKeyboardRef.current&&((h=u.current)==null||h.focus()),f.preventDefault()},onCloseAutoFocus:f=>f.preventDefault(),onFocusOutside:Wt(e.onFocusOutside,f=>{f.target!==l.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:Wt(e.onEscapeKeyDown,f=>{o.onClose(),f.preventDefault()}),onKeyDown:Wt(e.onKeyDown,f=>{var g;const h=f.currentTarget.contains(f.target),y=Vle[o.dir].includes(f.key);h&&y&&(s.onOpenChange(!1),(g=l.trigger)==null||g.focus(),f.preventDefault())})})})})})});Z3.displayName=X3;function Q3(e){return e?"open":"closed"}function Uy(e){return e==="indeterminate"}function Ck(e){return Uy(e)?"indeterminate":e?"checked":"unchecked"}function dce(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function fce(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function hce(e,t,n){const i=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let o=fce(e,Math.max(s,0));i.length===1&&(o=o.filter(d=>d!==n));const u=o.find(d=>d.toLowerCase().startsWith(i.toLowerCase()));return u!==n?u:void 0}function pce(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const l=t[s],u=t[o],d=l.x,f=l.y,h=u.x,y=u.y;f>r!=y>r&&n<(h-d)*(r-f)/(y-f)+d&&(i=!i)}return i}function mce(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return pce(n,t)}function Up(e){return t=>t.pointerType==="mouse"?e(t):void 0}var gce=P3,vce=yk,yce=O3,bce=L3,_ce=xk,wce=D3,xce=Lb,Sce=z3,Ece=F3,Cce=H3,kce=W3,Tce=q3,Rce=V3,Ace=K3,Nce=G3,Mce=Z3,Db="DropdownMenu",[Pce]=Xa(Db,[A3]),Ji=A3(),[Ice,J3]=Pce(Db),e4=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:l=!0}=e,u=Ji(t),d=b.useRef(null),[f,h]=Jl({prop:i,defaultProp:s??!1,onChange:o,caller:Db});return m.jsx(Ice,{scope:t,triggerId:vi(),triggerRef:d,contentId:vi(),open:f,onOpenChange:h,onOpenToggle:b.useCallback(()=>h(y=>!y),[h]),modal:l,children:m.jsx(gce,{...u,open:f,onOpenChange:h,dir:r,modal:l,children:n})})};e4.displayName=Db;var t4="DropdownMenuTrigger",n4=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,s=J3(t4,n),o=Ji(n);return m.jsx(vce,{asChild:!0,...o,children:m.jsx(yn.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...i,ref:qa(t,s.triggerRef),onPointerDown:Wt(e.onPointerDown,l=>{!r&&l.button===0&&l.ctrlKey===!1&&(s.onOpenToggle(),s.open||l.preventDefault())}),onKeyDown:Wt(e.onKeyDown,l=>{r||(["Enter"," "].includes(l.key)&&s.onOpenToggle(),l.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(l.key)&&l.preventDefault())})})})});n4.displayName=t4;var Oce="DropdownMenuPortal",r4=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Ji(t);return m.jsx(yce,{...r,...n})};r4.displayName=Oce;var i4="DropdownMenuContent",s4=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=J3(i4,n),s=Ji(n),o=b.useRef(!1);return m.jsx(bce,{id:i.contentId,"aria-labelledby":i.triggerId,...s,...r,ref:t,onCloseAutoFocus:Wt(e.onCloseAutoFocus,l=>{var u;o.current||(u=i.triggerRef.current)==null||u.focus(),o.current=!1,l.preventDefault()}),onInteractOutside:Wt(e.onInteractOutside,l=>{const u=l.detail.originalEvent,d=u.button===0&&u.ctrlKey===!0,f=u.button===2||d;(!i.modal||f)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});s4.displayName=i4;var Lce="DropdownMenuGroup",Dce=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Ji(n);return m.jsx(_ce,{...i,...r,ref:t})});Dce.displayName=Lce;var Bce="DropdownMenuLabel",o4=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Ji(n);return m.jsx(wce,{...i,...r,ref:t})});o4.displayName=Bce;var zce="DropdownMenuItem",a4=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Ji(n);return m.jsx(xce,{...i,...r,ref:t})});a4.displayName=zce;var jce="DropdownMenuCheckboxItem",l4=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Ji(n);return m.jsx(Sce,{...i,...r,ref:t})});l4.displayName=jce;var Fce="DropdownMenuRadioGroup",$ce=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Ji(n);return m.jsx(Ece,{...i,...r,ref:t})});$ce.displayName=Fce;var Hce="DropdownMenuRadioItem",Uce=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Ji(n);return m.jsx(Cce,{...i,...r,ref:t})});Uce.displayName=Hce;var Wce="DropdownMenuItemIndicator",c4=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Ji(n);return m.jsx(kce,{...i,...r,ref:t})});c4.displayName=Wce;var qce="DropdownMenuSeparator",u4=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Ji(n);return m.jsx(Tce,{...i,...r,ref:t})});u4.displayName=qce;var Vce="DropdownMenuArrow",Yce=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Ji(n);return m.jsx(Rce,{...i,...r,ref:t})});Yce.displayName=Vce;var Kce=e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:s}=e,o=Ji(t),[l,u]=Jl({prop:r,defaultProp:s??!1,onChange:i,caller:"DropdownMenuSub"});return m.jsx(Ace,{...o,open:l,onOpenChange:u,children:n})},Gce="DropdownMenuSubTrigger",d4=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Ji(n);return m.jsx(Nce,{...i,...r,ref:t})});d4.displayName=Gce;var Xce="DropdownMenuSubContent",f4=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Ji(n);return m.jsx(Mce,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});f4.displayName=Xce;var Zce=e4,Qce=n4,h4=r4,Jce=s4,eue=o4,tue=a4,nue=l4,rue=c4,iue=u4,sue=Kce,oue=d4,aue=f4;function sI(e,[t,n]){return Math.min(n,Math.max(t,e))}var Bb="Popover",[p4]=Xa(Bb,[cc]),Em=cc(),[lue,dc]=p4(Bb),m4=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:o=!1}=e,l=Em(t),u=b.useRef(null),[d,f]=b.useState(!1),[h,y]=Jl({prop:r,defaultProp:i??!1,onChange:s,caller:Bb});return m.jsx(ym,{...l,children:m.jsx(lue,{scope:t,contentId:vi(),triggerRef:u,open:h,onOpenChange:y,onOpenToggle:b.useCallback(()=>y(g=>!g),[y]),hasCustomAnchor:d,onCustomAnchorAdd:b.useCallback(()=>f(!0),[]),onCustomAnchorRemove:b.useCallback(()=>f(!1),[]),modal:o,children:n})})};m4.displayName=Bb;var g4="PopoverAnchor",cue=b.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=dc(g4,n),s=Em(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:l}=i;return b.useEffect(()=>(o(),()=>l()),[o,l]),m.jsx(bm,{...s,...r,ref:t})});cue.displayName=g4;var v4="PopoverTrigger",y4=b.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=dc(v4,n),s=Em(n),o=or(t,i.triggerRef),l=m.jsx(yn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":S4(i.open),...r,ref:o,onClick:Wt(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?l:m.jsx(bm,{asChild:!0,...s,children:l})});y4.displayName=v4;var kk="PopoverPortal",[uue,due]=p4(kk,{forceMount:void 0}),b4=e=>{const{__scopePopover:t,forceMount:n,children:r,container:i}=e,s=dc(kk,t);return m.jsx(uue,{scope:t,forceMount:n,children:m.jsx(wo,{present:n||s.open,children:m.jsx(gf,{asChild:!0,container:i,children:r})})})};b4.displayName=kk;var sf="PopoverContent",_4=b.forwardRef((e,t)=>{const n=due(sf,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,s=dc(sf,e.__scopePopover);return m.jsx(wo,{present:r||s.open,children:s.modal?m.jsx(hue,{...i,ref:t}):m.jsx(pue,{...i,ref:t})})});_4.displayName=sf;var fue=Ql("PopoverContent.RemoveScroll"),hue=b.forwardRef((e,t)=>{const n=dc(sf,e.__scopePopover),r=b.useRef(null),i=or(t,r),s=b.useRef(!1);return b.useEffect(()=>{const o=r.current;if(o)return kb(o)},[]),m.jsx(gm,{as:fue,allowPinchZoom:!0,children:m.jsx(w4,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Wt(e.onCloseAutoFocus,o=>{var l;o.preventDefault(),s.current||(l=n.triggerRef.current)==null||l.focus()}),onPointerDownOutside:Wt(e.onPointerDownOutside,o=>{const l=o.detail.originalEvent,u=l.button===0&&l.ctrlKey===!0,d=l.button===2||u;s.current=d},{checkForDefaultPrevented:!1}),onFocusOutside:Wt(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),pue=b.forwardRef((e,t)=>{const n=dc(sf,e.__scopePopover),r=b.useRef(!1),i=b.useRef(!1);return m.jsx(w4,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var o,l;(o=e.onCloseAutoFocus)==null||o.call(e,s),s.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),s.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:s=>{var u,d;(u=e.onInteractOutside)==null||u.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const o=s.target;((d=n.triggerRef.current)==null?void 0:d.contains(o))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}})}),w4=b.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:o,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,...h}=e,y=dc(sf,n),g=Em(n);return Eb(),m.jsx(mm,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:m.jsx(mf,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:f,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onDismiss:()=>y.onOpenChange(!1),children:m.jsx(Ib,{"data-state":S4(y.open),role:"dialog",id:y.contentId,...g,...h,ref:t,style:{...h.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),x4="PopoverClose",mue=b.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=dc(x4,n);return m.jsx(yn.button,{type:"button",...r,ref:t,onClick:Wt(e.onClick,()=>i.onOpenChange(!1))})});mue.displayName=x4;var gue="PopoverArrow",vue=b.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Em(n);return m.jsx(Ob,{...i,...r,ref:t})});vue.displayName=gue;function S4(e){return e?"open":"closed"}var yue=m4,bue=y4,_ue=b4,wue=_4,xue=[" ","Enter","ArrowUp","ArrowDown"],Sue=[" ","Enter"],uu="Select",[zb,jb,Eue]=tk(uu),[bf]=Xa(uu,[Eue,cc]),Fb=cc(),[Cue,fc]=bf(uu),[kue,Tue]=bf(uu),E4=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:s,value:o,defaultValue:l,onValueChange:u,dir:d,name:f,autoComplete:h,disabled:y,required:g,form:_}=e,w=Fb(t),[S,x]=b.useState(null),[k,R]=b.useState(null),[A,M]=b.useState(!1),T=nk(d),[P,z]=Jl({prop:r,defaultProp:i??!1,onChange:s,caller:uu}),[Y,U]=Jl({prop:o,defaultProp:l,onChange:u,caller:uu}),G=b.useRef(null),I=S?_||!!S.closest("form"):!0,[N,L]=b.useState(new Set),B=Array.from(N).map(O=>O.props.value).join(";");return m.jsx(ym,{...w,children:m.jsxs(Cue,{required:g,scope:t,trigger:S,onTriggerChange:x,valueNode:k,onValueNodeChange:R,valueNodeHasChildren:A,onValueNodeHasChildrenChange:M,contentId:vi(),value:Y,onValueChange:U,open:P,onOpenChange:z,dir:T,triggerPointerDownPosRef:G,disabled:y,children:[m.jsx(zb.Provider,{scope:t,children:m.jsx(kue,{scope:e.__scopeSelect,onNativeOptionAdd:b.useCallback(O=>{L(D=>new Set(D).add(O))},[]),onNativeOptionRemove:b.useCallback(O=>{L(D=>{const F=new Set(D);return F.delete(O),F})},[]),children:n})}),I?m.jsxs(V4,{"aria-hidden":!0,required:g,tabIndex:-1,name:f,autoComplete:h,value:Y,onChange:O=>U(O.target.value),disabled:y,form:_,children:[Y===void 0?m.jsx("option",{value:""}):null,Array.from(N)]},B):null]})})};E4.displayName=uu;var C4="SelectTrigger",k4=b.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...i}=e,s=Fb(n),o=fc(C4,n),l=o.disabled||r,u=or(t,o.onTriggerChange),d=jb(n),f=b.useRef("touch"),[h,y,g]=K4(w=>{const S=d().filter(R=>!R.disabled),x=S.find(R=>R.value===o.value),k=G4(S,w,x);k!==void 0&&o.onValueChange(k.value)}),_=w=>{l||(o.onOpenChange(!0),g()),w&&(o.triggerPointerDownPosRef.current={x:Math.round(w.pageX),y:Math.round(w.pageY)})};return m.jsx(bm,{asChild:!0,...s,children:m.jsx(yn.button,{type:"button",role:"combobox","aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":"none",dir:o.dir,"data-state":o.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":Y4(o.value)?"":void 0,...i,ref:u,onClick:Wt(i.onClick,w=>{w.currentTarget.focus(),f.current!=="mouse"&&_(w)}),onPointerDown:Wt(i.onPointerDown,w=>{f.current=w.pointerType;const S=w.target;S.hasPointerCapture(w.pointerId)&&S.releasePointerCapture(w.pointerId),w.button===0&&w.ctrlKey===!1&&w.pointerType==="mouse"&&(_(w),w.preventDefault())}),onKeyDown:Wt(i.onKeyDown,w=>{const S=h.current!=="";!(w.ctrlKey||w.altKey||w.metaKey)&&w.key.length===1&&y(w.key),!(S&&w.key===" ")&&xue.includes(w.key)&&(_(),w.preventDefault())})})})});k4.displayName=C4;var T4="SelectValue",R4=b.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:i,children:s,placeholder:o="",...l}=e,u=fc(T4,n),{onValueNodeHasChildrenChange:d}=u,f=s!==void 0,h=or(t,u.onValueNodeChange);return Qi(()=>{d(f)},[d,f]),m.jsx(yn.span,{...l,ref:h,style:{pointerEvents:"none"},children:Y4(u.value)?m.jsx(m.Fragment,{children:o}):s})});R4.displayName=T4;var Rue="SelectIcon",A4=b.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...i}=e;return m.jsx(yn.span,{"aria-hidden":!0,...i,ref:t,children:r||"▼"})});A4.displayName=Rue;var Aue="SelectPortal",N4=e=>m.jsx(gf,{asChild:!0,...e});N4.displayName=Aue;var du="SelectContent",M4=b.forwardRef((e,t)=>{const n=fc(du,e.__scopeSelect),[r,i]=b.useState();if(Qi(()=>{i(new DocumentFragment)},[]),!n.open){const s=r;return s?xu.createPortal(m.jsx(P4,{scope:e.__scopeSelect,children:m.jsx(zb.Slot,{scope:e.__scopeSelect,children:m.jsx("div",{children:e.children})})}),s):null}return m.jsx(I4,{...e,ref:t})});M4.displayName=du;var Ao=10,[P4,hc]=bf(du),Nue="SelectContentImpl",Mue=Ql("SelectContent.RemoveScroll"),I4=b.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:s,onPointerDownOutside:o,side:l,sideOffset:u,align:d,alignOffset:f,arrowPadding:h,collisionBoundary:y,collisionPadding:g,sticky:_,hideWhenDetached:w,avoidCollisions:S,...x}=e,k=fc(du,n),[R,A]=b.useState(null),[M,T]=b.useState(null),P=or(t,Q=>A(Q)),[z,Y]=b.useState(null),[U,G]=b.useState(null),I=jb(n),[N,L]=b.useState(!1),B=b.useRef(!1);b.useEffect(()=>{if(R)return kb(R)},[R]),Eb();const O=b.useCallback(Q=>{const[ce,...re]=I().map(Ce=>Ce.ref.current),[le]=re.slice(-1),we=document.activeElement;for(const Ce of Q)if(Ce===we||(Ce==null||Ce.scrollIntoView({block:"nearest"}),Ce===ce&&M&&(M.scrollTop=0),Ce===le&&M&&(M.scrollTop=M.scrollHeight),Ce==null||Ce.focus(),document.activeElement!==we))return},[I,M]),D=b.useCallback(()=>O([z,R]),[O,z,R]);b.useEffect(()=>{N&&D()},[N,D]);const{onOpenChange:F,triggerPointerDownPosRef:V}=k;b.useEffect(()=>{if(R){let Q={x:0,y:0};const ce=le=>{var we,Ce;Q={x:Math.abs(Math.round(le.pageX)-(((we=V.current)==null?void 0:we.x)??0)),y:Math.abs(Math.round(le.pageY)-(((Ce=V.current)==null?void 0:Ce.y)??0))}},re=le=>{Q.x<=10&&Q.y<=10?le.preventDefault():R.contains(le.target)||F(!1),document.removeEventListener("pointermove",ce),V.current=null};return V.current!==null&&(document.addEventListener("pointermove",ce),document.addEventListener("pointerup",re,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ce),document.removeEventListener("pointerup",re,{capture:!0})}}},[R,F,V]),b.useEffect(()=>{const Q=()=>F(!1);return window.addEventListener("blur",Q),window.addEventListener("resize",Q),()=>{window.removeEventListener("blur",Q),window.removeEventListener("resize",Q)}},[F]);const[j,q]=K4(Q=>{const ce=I().filter(we=>!we.disabled),re=ce.find(we=>we.ref.current===document.activeElement),le=G4(ce,Q,re);le&&setTimeout(()=>le.ref.current.focus())}),K=b.useCallback((Q,ce,re)=>{const le=!B.current&&!re;(k.value!==void 0&&k.value===ce||le)&&(Y(Q),le&&(B.current=!0))},[k.value]),$=b.useCallback(()=>R==null?void 0:R.focus(),[R]),te=b.useCallback((Q,ce,re)=>{const le=!B.current&&!re;(k.value!==void 0&&k.value===ce||le)&&G(Q)},[k.value]),J=r==="popper"?b1:O4,ne=J===b1?{side:l,sideOffset:u,align:d,alignOffset:f,arrowPadding:h,collisionBoundary:y,collisionPadding:g,sticky:_,hideWhenDetached:w,avoidCollisions:S}:{};return m.jsx(P4,{scope:n,content:R,viewport:M,onViewportChange:T,itemRefCallback:K,selectedItem:z,onItemLeave:$,itemTextRefCallback:te,focusSelectedItem:D,selectedItemText:U,position:r,isPositioned:N,searchRef:j,children:m.jsx(gm,{as:Mue,allowPinchZoom:!0,children:m.jsx(mm,{asChild:!0,trapped:k.open,onMountAutoFocus:Q=>{Q.preventDefault()},onUnmountAutoFocus:Wt(i,Q=>{var ce;(ce=k.trigger)==null||ce.focus({preventScroll:!0}),Q.preventDefault()}),children:m.jsx(mf,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:Q=>Q.preventDefault(),onDismiss:()=>k.onOpenChange(!1),children:m.jsx(J,{role:"listbox",id:k.contentId,"data-state":k.open?"open":"closed",dir:k.dir,onContextMenu:Q=>Q.preventDefault(),...x,...ne,onPlaced:()=>L(!0),ref:P,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:Wt(x.onKeyDown,Q=>{const ce=Q.ctrlKey||Q.altKey||Q.metaKey;if(Q.key==="Tab"&&Q.preventDefault(),!ce&&Q.key.length===1&&q(Q.key),["ArrowUp","ArrowDown","Home","End"].includes(Q.key)){let le=I().filter(we=>!we.disabled).map(we=>we.ref.current);if(["ArrowUp","End"].includes(Q.key)&&(le=le.slice().reverse()),["ArrowUp","ArrowDown"].includes(Q.key)){const we=Q.target,Ce=le.indexOf(we);le=le.slice(Ce+1)}setTimeout(()=>O(le)),Q.preventDefault()}})})})})})})});I4.displayName=Nue;var Pue="SelectItemAlignedPosition",O4=b.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...i}=e,s=fc(du,n),o=hc(du,n),[l,u]=b.useState(null),[d,f]=b.useState(null),h=or(t,P=>f(P)),y=jb(n),g=b.useRef(!1),_=b.useRef(!0),{viewport:w,selectedItem:S,selectedItemText:x,focusSelectedItem:k}=o,R=b.useCallback(()=>{if(s.trigger&&s.valueNode&&l&&d&&w&&S&&x){const P=s.trigger.getBoundingClientRect(),z=d.getBoundingClientRect(),Y=s.valueNode.getBoundingClientRect(),U=x.getBoundingClientRect();if(s.dir!=="rtl"){const we=U.left-z.left,Ce=Y.left-we,ye=P.left-Ce,Re=P.width+ye,Rt=Math.max(Re,z.width),Ke=window.innerWidth-Ao,et=sI(Ce,[Ao,Math.max(Ao,Ke-Rt)]);l.style.minWidth=Re+"px",l.style.left=et+"px"}else{const we=z.right-U.right,Ce=window.innerWidth-Y.right-we,ye=window.innerWidth-P.right-Ce,Re=P.width+ye,Rt=Math.max(Re,z.width),Ke=window.innerWidth-Ao,et=sI(Ce,[Ao,Math.max(Ao,Ke-Rt)]);l.style.minWidth=Re+"px",l.style.right=et+"px"}const G=y(),I=window.innerHeight-Ao*2,N=w.scrollHeight,L=window.getComputedStyle(d),B=parseInt(L.borderTopWidth,10),O=parseInt(L.paddingTop,10),D=parseInt(L.borderBottomWidth,10),F=parseInt(L.paddingBottom,10),V=B+O+N+F+D,j=Math.min(S.offsetHeight*5,V),q=window.getComputedStyle(w),K=parseInt(q.paddingTop,10),$=parseInt(q.paddingBottom,10),te=P.top+P.height/2-Ao,J=I-te,ne=S.offsetHeight/2,Q=S.offsetTop+ne,ce=B+O+Q,re=V-ce;if(ce<=te){const we=G.length>0&&S===G[G.length-1].ref.current;l.style.bottom="0px";const Ce=d.clientHeight-w.offsetTop-w.offsetHeight,ye=Math.max(J,ne+(we?$:0)+Ce+D),Re=ce+ye;l.style.height=Re+"px"}else{const we=G.length>0&&S===G[0].ref.current;l.style.top="0px";const ye=Math.max(te,B+w.offsetTop+(we?K:0)+ne)+re;l.style.height=ye+"px",w.scrollTop=ce-te+w.offsetTop}l.style.margin=`${Ao}px 0`,l.style.minHeight=j+"px",l.style.maxHeight=I+"px",r==null||r(),requestAnimationFrame(()=>g.current=!0)}},[y,s.trigger,s.valueNode,l,d,w,S,x,s.dir,r]);Qi(()=>R(),[R]);const[A,M]=b.useState();Qi(()=>{d&&M(window.getComputedStyle(d).zIndex)},[d]);const T=b.useCallback(P=>{P&&_.current===!0&&(R(),k==null||k(),_.current=!1)},[R,k]);return m.jsx(Oue,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:g,onScrollButtonChange:T,children:m.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:A},children:m.jsx(yn.div,{...i,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})});O4.displayName=Pue;var Iue="SelectPopperPosition",b1=b.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:i=Ao,...s}=e,o=Fb(n);return m.jsx(Ib,{...o,...s,ref:t,align:r,collisionPadding:i,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});b1.displayName=Iue;var[Oue,Tk]=bf(du,{}),_1="SelectViewport",L4=b.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...i}=e,s=hc(_1,n),o=Tk(_1,n),l=or(t,s.onViewportChange),u=b.useRef(0);return m.jsxs(m.Fragment,{children:[m.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),m.jsx(zb.Slot,{scope:n,children:m.jsx(yn.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:Wt(i.onScroll,d=>{const f=d.currentTarget,{contentWrapper:h,shouldExpandOnScrollRef:y}=o;if(y!=null&&y.current&&h){const g=Math.abs(u.current-f.scrollTop);if(g>0){const _=window.innerHeight-Ao*2,w=parseFloat(h.style.minHeight),S=parseFloat(h.style.height),x=Math.max(w,S);if(x<_){const k=x+g,R=Math.min(_,k),A=k-R;h.style.height=R+"px",h.style.bottom==="0px"&&(f.scrollTop=A>0?A:0,h.style.justifyContent="flex-end")}}}u.current=f.scrollTop})})})]})});L4.displayName=_1;var D4="SelectGroup",[Lue,Due]=bf(D4),Bue=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=vi();return m.jsx(Lue,{scope:n,id:i,children:m.jsx(yn.div,{role:"group","aria-labelledby":i,...r,ref:t})})});Bue.displayName=D4;var B4="SelectLabel",zue=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=Due(B4,n);return m.jsx(yn.div,{id:i.id,...r,ref:t})});zue.displayName=B4;var Wy="SelectItem",[jue,z4]=bf(Wy),j4=b.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:i=!1,textValue:s,...o}=e,l=fc(Wy,n),u=hc(Wy,n),d=l.value===r,[f,h]=b.useState(s??""),[y,g]=b.useState(!1),_=or(t,k=>{var R;return(R=u.itemRefCallback)==null?void 0:R.call(u,k,r,i)}),w=vi(),S=b.useRef("touch"),x=()=>{i||(l.onValueChange(r),l.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return m.jsx(jue,{scope:n,value:r,disabled:i,textId:w,isSelected:d,onItemTextChange:b.useCallback(k=>{h(R=>R||((k==null?void 0:k.textContent)??"").trim())},[]),children:m.jsx(zb.ItemSlot,{scope:n,value:r,disabled:i,textValue:f,children:m.jsx(yn.div,{role:"option","aria-labelledby":w,"data-highlighted":y?"":void 0,"aria-selected":d&&y,"data-state":d?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1,...o,ref:_,onFocus:Wt(o.onFocus,()=>g(!0)),onBlur:Wt(o.onBlur,()=>g(!1)),onClick:Wt(o.onClick,()=>{S.current!=="mouse"&&x()}),onPointerUp:Wt(o.onPointerUp,()=>{S.current==="mouse"&&x()}),onPointerDown:Wt(o.onPointerDown,k=>{S.current=k.pointerType}),onPointerMove:Wt(o.onPointerMove,k=>{var R;S.current=k.pointerType,i?(R=u.onItemLeave)==null||R.call(u):S.current==="mouse"&&k.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Wt(o.onPointerLeave,k=>{var R;k.currentTarget===document.activeElement&&((R=u.onItemLeave)==null||R.call(u))}),onKeyDown:Wt(o.onKeyDown,k=>{var A;((A=u.searchRef)==null?void 0:A.current)!==""&&k.key===" "||(Sue.includes(k.key)&&x(),k.key===" "&&k.preventDefault())})})})})});j4.displayName=Wy;var ap="SelectItemText",F4=b.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:i,...s}=e,o=fc(ap,n),l=hc(ap,n),u=z4(ap,n),d=Tue(ap,n),[f,h]=b.useState(null),y=or(t,x=>h(x),u.onItemTextChange,x=>{var k;return(k=l.itemTextRefCallback)==null?void 0:k.call(l,x,u.value,u.disabled)}),g=f==null?void 0:f.textContent,_=b.useMemo(()=>m.jsx("option",{value:u.value,disabled:u.disabled,children:g},u.value),[u.disabled,u.value,g]),{onNativeOptionAdd:w,onNativeOptionRemove:S}=d;return Qi(()=>(w(_),()=>S(_)),[w,S,_]),m.jsxs(m.Fragment,{children:[m.jsx(yn.span,{id:u.textId,...s,ref:y}),u.isSelected&&o.valueNode&&!o.valueNodeHasChildren?xu.createPortal(s.children,o.valueNode):null]})});F4.displayName=ap;var $4="SelectItemIndicator",H4=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return z4($4,n).isSelected?m.jsx(yn.span,{"aria-hidden":!0,...r,ref:t}):null});H4.displayName=$4;var w1="SelectScrollUpButton",U4=b.forwardRef((e,t)=>{const n=hc(w1,e.__scopeSelect),r=Tk(w1,e.__scopeSelect),[i,s]=b.useState(!1),o=or(t,r.onScrollButtonChange);return Qi(()=>{if(n.viewport&&n.isPositioned){let l=function(){const d=u.scrollTop>0;s(d)};const u=n.viewport;return l(),u.addEventListener("scroll",l),()=>u.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),i?m.jsx(q4,{...e,ref:o,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=n;l&&u&&(l.scrollTop=l.scrollTop-u.offsetHeight)}}):null});U4.displayName=w1;var x1="SelectScrollDownButton",W4=b.forwardRef((e,t)=>{const n=hc(x1,e.__scopeSelect),r=Tk(x1,e.__scopeSelect),[i,s]=b.useState(!1),o=or(t,r.onScrollButtonChange);return Qi(()=>{if(n.viewport&&n.isPositioned){let l=function(){const d=u.scrollHeight-u.clientHeight,f=Math.ceil(u.scrollTop)<d;s(f)};const u=n.viewport;return l(),u.addEventListener("scroll",l),()=>u.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),i?m.jsx(q4,{...e,ref:o,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=n;l&&u&&(l.scrollTop=l.scrollTop+u.offsetHeight)}}):null});W4.displayName=x1;var q4=b.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...i}=e,s=hc("SelectScrollButton",n),o=b.useRef(null),l=jb(n),u=b.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return b.useEffect(()=>()=>u(),[u]),Qi(()=>{var f;const d=l().find(h=>h.ref.current===document.activeElement);(f=d==null?void 0:d.ref.current)==null||f.scrollIntoView({block:"nearest"})},[l]),m.jsx(yn.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:Wt(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:Wt(i.onPointerMove,()=>{var d;(d=s.onItemLeave)==null||d.call(s),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:Wt(i.onPointerLeave,()=>{u()})})}),Fue="SelectSeparator",$ue=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return m.jsx(yn.div,{"aria-hidden":!0,...r,ref:t})});$ue.displayName=Fue;var S1="SelectArrow",Hue=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=Fb(n),s=fc(S1,n),o=hc(S1,n);return s.open&&o.position==="popper"?m.jsx(Ob,{...i,...r,ref:t}):null});Hue.displayName=S1;var Uue="SelectBubbleInput",V4=b.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const i=b.useRef(null),s=or(r,i),o=vae(t);return b.useEffect(()=>{const l=i.current;if(!l)return;const u=window.HTMLSelectElement.prototype,f=Object.getOwnPropertyDescriptor(u,"value").set;if(o!==t&&f){const h=new Event("change",{bubbles:!0});f.call(l,t),l.dispatchEvent(h)}},[o,t]),m.jsx(yn.select,{...n,style:{...S5,...n.style},ref:s,defaultValue:t})});V4.displayName=Uue;function Y4(e){return e===""||e===void 0}function K4(e){const t=Io(e),n=b.useRef(""),r=b.useRef(0),i=b.useCallback(o=>{const l=n.current+o;t(l),(function u(d){n.current=d,window.clearTimeout(r.current),d!==""&&(r.current=window.setTimeout(()=>u(""),1e3))})(l)},[t]),s=b.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return b.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,s]}function G4(e,t,n){const i=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let o=Wue(e,Math.max(s,0));i.length===1&&(o=o.filter(d=>d!==n));const u=o.find(d=>d.textValue.toLowerCase().startsWith(i.toLowerCase()));return u!==n?u:void 0}function Wue(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var que=E4,Vue=k4,Yue=R4,Kue=A4,Gue=N4,Xue=M4,Zue=L4,Que=j4,Jue=F4,ede=H4,tde=U4,nde=W4,[$b]=Xa("Tooltip",[cc]),Hb=cc(),X4="TooltipProvider",rde=700,E1="tooltip.open",[ide,Rk]=$b(X4),Z4=e=>{const{__scopeTooltip:t,delayDuration:n=rde,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,o=b.useRef(!0),l=b.useRef(!1),u=b.useRef(0);return b.useEffect(()=>{const d=u.current;return()=>window.clearTimeout(d)},[]),m.jsx(ide,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:b.useCallback(()=>{window.clearTimeout(u.current),o.current=!1},[]),onClose:b.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:b.useCallback(d=>{l.current=d},[]),disableHoverableContent:i,children:s})};Z4.displayName=X4;var Wp="Tooltip",[sde,Cm]=$b(Wp),Q4=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:l}=e,u=Rk(Wp,e.__scopeTooltip),d=Hb(t),[f,h]=b.useState(null),y=vi(),g=b.useRef(0),_=o??u.disableHoverableContent,w=l??u.delayDuration,S=b.useRef(!1),[x,k]=Jl({prop:r,defaultProp:i??!1,onChange:P=>{P?(u.onOpen(),document.dispatchEvent(new CustomEvent(E1))):u.onClose(),s==null||s(P)},caller:Wp}),R=b.useMemo(()=>x?S.current?"delayed-open":"instant-open":"closed",[x]),A=b.useCallback(()=>{window.clearTimeout(g.current),g.current=0,S.current=!1,k(!0)},[k]),M=b.useCallback(()=>{window.clearTimeout(g.current),g.current=0,k(!1)},[k]),T=b.useCallback(()=>{window.clearTimeout(g.current),g.current=window.setTimeout(()=>{S.current=!0,k(!0),g.current=0},w)},[w,k]);return b.useEffect(()=>()=>{g.current&&(window.clearTimeout(g.current),g.current=0)},[]),m.jsx(ym,{...d,children:m.jsx(sde,{scope:t,contentId:y,open:x,stateAttribute:R,trigger:f,onTriggerChange:h,onTriggerEnter:b.useCallback(()=>{u.isOpenDelayedRef.current?T():A()},[u.isOpenDelayedRef,T,A]),onTriggerLeave:b.useCallback(()=>{_?M():(window.clearTimeout(g.current),g.current=0)},[M,_]),onOpen:A,onClose:M,disableHoverableContent:_,children:n})})};Q4.displayName=Wp;var C1="TooltipTrigger",J4=b.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Cm(C1,n),s=Rk(C1,n),o=Hb(n),l=b.useRef(null),u=or(t,l,i.onTriggerChange),d=b.useRef(!1),f=b.useRef(!1),h=b.useCallback(()=>d.current=!1,[]);return b.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),m.jsx(bm,{asChild:!0,...o,children:m.jsx(yn.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:u,onPointerMove:Wt(e.onPointerMove,y=>{y.pointerType!=="touch"&&!f.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),f.current=!0)}),onPointerLeave:Wt(e.onPointerLeave,()=>{i.onTriggerLeave(),f.current=!1}),onPointerDown:Wt(e.onPointerDown,()=>{i.open&&i.onClose(),d.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Wt(e.onFocus,()=>{d.current||i.onOpen()}),onBlur:Wt(e.onBlur,i.onClose),onClick:Wt(e.onClick,i.onClose)})})});J4.displayName=C1;var Ak="TooltipPortal",[ode,ade]=$b(Ak,{forceMount:void 0}),eF=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,s=Cm(Ak,t);return m.jsx(ode,{scope:t,forceMount:n,children:m.jsx(wo,{present:n||s.open,children:m.jsx(gf,{asChild:!0,container:i,children:r})})})};eF.displayName=Ak;var of="TooltipContent",tF=b.forwardRef((e,t)=>{const n=ade(of,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,o=Cm(of,e.__scopeTooltip);return m.jsx(wo,{present:r||o.open,children:o.disableHoverableContent?m.jsx(nF,{side:i,...s,ref:t}):m.jsx(lde,{side:i,...s,ref:t})})}),lde=b.forwardRef((e,t)=>{const n=Cm(of,e.__scopeTooltip),r=Rk(of,e.__scopeTooltip),i=b.useRef(null),s=or(t,i),[o,l]=b.useState(null),{trigger:u,onClose:d}=n,f=i.current,{onPointerInTransitChange:h}=r,y=b.useCallback(()=>{l(null),h(!1)},[h]),g=b.useCallback((_,w)=>{const S=_.currentTarget,x={x:_.clientX,y:_.clientY},k=fde(x,S.getBoundingClientRect()),R=hde(x,k),A=pde(w.getBoundingClientRect()),M=gde([...R,...A]);l(M),h(!0)},[h]);return b.useEffect(()=>()=>y(),[y]),b.useEffect(()=>{if(u&&f){const _=S=>g(S,f),w=S=>g(S,u);return u.addEventListener("pointerleave",_),f.addEventListener("pointerleave",w),()=>{u.removeEventListener("pointerleave",_),f.removeEventListener("pointerleave",w)}}},[u,f,g,y]),b.useEffect(()=>{if(o){const _=w=>{const S=w.target,x={x:w.clientX,y:w.clientY},k=(u==null?void 0:u.contains(S))||(f==null?void 0:f.contains(S)),R=!mde(x,o);k?y():R&&(y(),d())};return document.addEventListener("pointermove",_),()=>document.removeEventListener("pointermove",_)}},[u,f,o,d,y]),m.jsx(nF,{...e,ref:s})}),[cde,ude]=$b(Wp,{isInside:!1}),dde=Use("TooltipContent"),nF=b.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...l}=e,u=Cm(of,n),d=Hb(n),{onClose:f}=u;return b.useEffect(()=>(document.addEventListener(E1,f),()=>document.removeEventListener(E1,f)),[f]),b.useEffect(()=>{if(u.trigger){const h=y=>{const g=y.target;g!=null&&g.contains(u.trigger)&&f()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[u.trigger,f]),m.jsx(mf,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:h=>h.preventDefault(),onDismiss:f,children:m.jsxs(Ib,{"data-state":u.stateAttribute,...d,...l,ref:t,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[m.jsx(dde,{children:r}),m.jsx(cde,{scope:n,isInside:!0,children:m.jsx(C5,{id:u.contentId,role:"tooltip",children:i||r})})]})})});tF.displayName=of;var rF="TooltipArrow",iF=b.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Hb(n);return ude(rF,n).isInside?null:m.jsx(Ob,{...i,...r,ref:t})});iF.displayName=rF;function fde(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function hde(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function pde(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function mde(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const l=t[s],u=t[o],d=l.x,f=l.y,h=u.x,y=u.y;f>r!=y>r&&n<(h-d)*(r-f)/(y-f)+d&&(i=!i)}return i}function gde(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),vde(t)}function vde(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const s=t[t.length-1],o=t[t.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],o=n[n.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var yde=Z4,bde=Q4,_de=J4,wde=eF,xde=tF,Sde=iF;const sF=b.createContext(!1);function Ede({blocked:e,children:t}){return m.jsx(sF.Provider,{value:e,children:t})}function km(){return b.useContext(sF)}function Ub({...e}){return m.jsx(yue,{"data-slot":"popover",...e})}function Wb({...e}){return m.jsx(bue,{"data-slot":"popover-trigger",...e})}function qb({className:e,align:t="center",sideOffset:n=4,inert:r,"aria-disabled":i,...s}){const o=km();return m.jsx(_ue,{children:m.jsx(wue,{"data-slot":"popover-content",align:t,sideOffset:n,className:qe("z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-hidden data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",e),inert:o||r?!0:void 0,"aria-disabled":o?!0:i,"data-relay-interaction-blocked":o?"true":void 0,...s})})}const oI=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,aI=Oz,Cde=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return aI(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:i,defaultVariants:s}=t,o=Object.keys(i).map(d=>{const f=n==null?void 0:n[d],h=s==null?void 0:s[d];if(f===null)return null;const y=oI(f)||oI(h);return i[d][y]}),l=n&&Object.entries(n).reduce((d,f)=>{let[h,y]=f;return y===void 0||(d[h]=y),d},{}),u=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((d,f)=>{let{class:h,className:y,...g}=f;return Object.entries(g).every(_=>{let[w,S]=_;return Array.isArray(S)?S.includes({...s,...l}[w]):{...s,...l}[w]===S})?[...d,h,y]:d},[]);return aI(e,o,u,n==null?void 0:n.class,n==null?void 0:n.className)},kde=Cde("inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-normal whitespace-nowrap transition-[color,background-color,border-color,box-shadow,opacity] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/75 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",xs:"h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-xs":"size-6 rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function vt({className:e,variant:t="default",size:n="default",asChild:r=!1,...i}){const s=r?$se:"button";return m.jsx(s,{"data-slot":"button","data-variant":t,"data-size":n,className:qe(kde({variant:t,size:n,className:e})),...i})}function _f({...e}){return m.jsx(Zce,{"data-slot":"dropdown-menu",...e})}function Tde({...e}){return m.jsx(h4,{"data-slot":"dropdown-menu-portal",...e})}function wf({...e}){return m.jsx(Qce,{"data-slot":"dropdown-menu-trigger",...e})}function xf({className:e,sideOffset:t=4,inert:n,"aria-disabled":r,...i}){const s=km();return m.jsx(h4,{children:m.jsx(Jce,{"data-slot":"dropdown-menu-content",sideOffset:t,className:qe("z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",e),inert:s||n?!0:void 0,"aria-disabled":s?!0:r,"data-relay-interaction-blocked":s?"true":void 0,...i})})}function Zr({className:e,inset:t,variant:n="default",...r}){return m.jsx(tue,{"data-slot":"dropdown-menu-item","data-inset":t,"data-variant":n,className:qe("relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:*:[svg]:text-destructive!",e),...r})}function v0({className:e,children:t,checked:n,...r}){return m.jsxs(nue,{"data-slot":"dropdown-menu-checkbox-item",className:qe("relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),checked:n,...r,children:[m.jsx("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:m.jsx(rue,{children:m.jsx(ua,{className:"size-4"})})}),t]})}function vv({className:e,inset:t,...n}){return m.jsx(eue,{"data-slot":"dropdown-menu-label","data-inset":t,className:qe("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",e),...n})}function Gc({className:e,...t}){return m.jsx(iue,{"data-slot":"dropdown-menu-separator",className:qe("-mx-1 my-1 h-px bg-border",e),...t})}function Rde({...e}){return m.jsx(sue,{"data-slot":"dropdown-menu-sub",...e})}function Ade({className:e,inset:t,children:n,...r}){return m.jsxs(oue,{"data-slot":"dropdown-menu-sub-trigger","data-inset":t,className:qe("flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[inset]:pl-8 data-[state=open]:bg-accent data-[state=open]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",e),...r,children:[n,m.jsx(Hd,{className:"ml-auto size-4"})]})}function Nde({className:e,...t}){return m.jsx(aue,{"data-slot":"dropdown-menu-sub-content",className:qe("z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",e),...t})}const Mde={"no-proxy":{heading:"还没有连接开发机",body:"在开发机上启动 DEV Anywhere,本页会显示可连接的开发机"},"client-token-missing":{heading:"需要 client token",body:"Relay 已启用客户端访问控制,请在设置中填写"},"client-token-invalid":{heading:"client token 无效",body:"client token 无效或已过期,请在设置中更新"},"no-session":{heading:"没有选中的会话",body:""},"no-messages":{heading:"开始对话",body:""}};function Jc({variant:e,action:t}){const{heading:n,body:r}=Mde[e];return e==="no-messages"?m.jsx("div",{className:"flex h-full w-full items-center justify-center animate-in fade-in-0 duration-200 motion-reduce:animate-none",children:m.jsx("p",{className:"text-sm text-muted-foreground",children:n})}):m.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-6 px-6 text-center animate-in fade-in-0 duration-200 motion-reduce:animate-none",children:[m.jsx("h2",{className:"text-2xl font-semibold",children:n}),r&&m.jsx("p",{className:"max-w-md text-sm text-muted-foreground",children:r}),t&&m.jsx("div",{children:t})]})}const Pde={online:"bg-[var(--color-status-success)]",offline:"bg-[var(--muted-foreground)]",connecting:"bg-[var(--color-status-working)] animate-pulse"},Ide={online:"开发机在线",offline:"开发机离线",connecting:"正在连接开发机"};function k1({status:e,className:t}){return m.jsx("span",{className:qe("inline-block w-2 h-2 rounded-full shrink-0",Pde[e],t),role:"status","aria-label":Ide[e]})}function Ep({name:e,osName:t,className:n,nameClassName:r}){return m.jsxs("span",{className:qe("min-w-0 flex-1",n),children:[m.jsx("span",{"data-slot":"proxy-name",className:qe("block truncate text-sm font-normal leading-5",r),children:e}),t&&m.jsx("span",{"data-slot":"proxy-os",className:"block truncate text-xs font-normal leading-4 text-muted-foreground",children:t})]})}function es({...e}){return m.jsx(ok,{"data-slot":"dialog",...e})}function Ode({...e}){return m.jsx(ak,{"data-slot":"dialog-portal",...e})}function Lde({...e}){return m.jsx(Rb,{"data-slot":"dialog-close",...e})}function Dde({className:e,...t}){return m.jsx(lk,{"data-slot":"dialog-overlay",className:qe("fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",e),...t})}function ts({className:e,children:t,showCloseButton:n=!0,focusSurfaceOnOpen:r=!1,onOpenAutoFocus:i,inert:s,"aria-disabled":o,...l}){const u=km();return m.jsxs(Ode,{"data-slot":"dialog-portal",children:[m.jsx(Dde,{}),m.jsxs(ck,{"data-slot":"dialog-content",className:qe("fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg",e),onOpenAutoFocus:d=>{i==null||i(d),!(!r||d.defaultPrevented)&&(d.preventDefault(),d.currentTarget.focus({preventScroll:!0}))},inert:u||s?!0:void 0,"aria-disabled":u?!0:o,"data-relay-interaction-blocked":u?"true":void 0,...l,children:[t,n&&m.jsxs(Rb,{"data-slot":"dialog-close",className:"absolute top-2 right-2 flex size-11 items-center justify-center rounded-md opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[m.jsx(bu,{}),m.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function ns({className:e,...t}){return m.jsx("div",{"data-slot":"dialog-header",className:qe("flex flex-col gap-2 text-center sm:text-left",e),...t})}function qs({className:e,showCloseButton:t=!1,children:n,...r}){return m.jsxs("div",{"data-slot":"dialog-footer",className:qe("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end max-sm:[&_button]:min-h-11",e),...r,children:[n,t&&m.jsx(Rb,{asChild:!0,children:m.jsx(vt,{variant:"outline",children:"Close"})})]})}function $i({className:e,...t}){return m.jsx(J5,{"data-slot":"dialog-title",className:qe("text-lg leading-none font-semibold",e),...t})}function Es({className:e,...t}){return m.jsx(e3,{"data-slot":"dialog-description",className:qe("text-sm text-muted-foreground",e),...t})}function Bde(e){return`“${(e==null?void 0:e.name)??(e==null?void 0:e.proxyId)??"这台开发机"}”只会从当前 Relay 的开发机列表中移除。不会删除机器上的文件或会话,也不会阻止它再次连接;以后重新运行时,它会重新出现在列表中。`}function zde({open:e,target:t,removing:n,onOpenChange:r,onConfirm:i}){return m.jsx(es,{open:e,onOpenChange:s=>{n||r(s)},children:m.jsxs(ts,{"data-slot":"proxy-removal-dialog",showCloseButton:!n,onEscapeKeyDown:s=>{n&&s.preventDefault()},onPointerDownOutside:s=>{n&&s.preventDefault()},children:[m.jsxs(ns,{children:[m.jsx($i,{children:"移除离线开发机?"}),m.jsx(Es,{children:Bde(t)})]}),m.jsxs(qs,{children:[m.jsx(vt,{type:"button",variant:"ghost",disabled:n,onClick:()=>r(!1),children:"取消"}),m.jsxs(vt,{type:"button",variant:"destructive",disabled:n||!t,"aria-busy":n||void 0,onClick:i,"data-slot":"proxy-removal-confirm",children:[n&&m.jsx(li,{className:"size-4 animate-spin","aria-hidden":"true"}),n?"正在移除":"移除"]})]})]})})}const ay=80,jde=8,Fde=1.2;function lI(e){return Math.max(0,Math.min(ay,e))}function $de({proxyId:e,name:t,osName:n,selected:r,revealed:i,disabled:s=!1,onRevealedChange:o,onRemove:l}){const u=t??e,d=b.useRef(null),f=b.useRef(!1),[h,y]=b.useState(null),g=h??(i?ay:0),_=h!==null;function w(R){var A,M;if(!(s||R.pointerType!=="touch"&&R.pointerType!=="pen")&&!R.target.closest("button")){d.current={pointerId:R.pointerId,startX:R.clientX,startY:R.clientY,startOffset:i?ay:0,axis:"pending"};try{(M=(A=R.currentTarget).setPointerCapture)==null||M.call(A,R.pointerId)}catch{}}}function S(R){const A=d.current;if(!A||A.pointerId!==R.pointerId)return;const M=R.clientX-A.startX,T=R.clientY-A.startY;if(A.axis==="pending"){if(Math.hypot(M,T)<jde)return;A.axis=Math.abs(M)>Math.abs(T)*Fde?"horizontal":"vertical"}A.axis!=="vertical"&&(R.preventDefault(),y(lI(A.startOffset-M)))}function x(R,A=!1){var P,z;const M=d.current;if(!M||M.pointerId!==R.pointerId)return;d.current=null;try{(z=(P=R.currentTarget).releasePointerCapture)==null||z.call(P,R.pointerId)}catch{}if(M.axis!=="horizontal"||A){y(null);return}R.preventDefault();const T=h??lI(M.startOffset-(R.clientX-M.startX));y(null),o(T>=ay/2),f.current=!0,window.setTimeout(()=>{f.current=!1},0)}function k(R){if(f.current){f.current=!1,R.preventDefault();return}i&&o(!1)}return m.jsxs("li",{className:`relative ${n?"h-14":"h-11"} overflow-hidden rounded-md border border-border bg-card`,"data-slot":"proxy-item","data-swipeable":"true","data-proxy-id":e,"data-online":"false","data-revealed":i||void 0,children:[m.jsxs("div",{className:"relative z-10 flex h-full w-full touch-pan-y select-none items-center gap-3 bg-card px-3 text-left text-muted-foreground transition-transform duration-200 ease-out motion-reduce:transition-none",style:{transform:`translateX(-${g}px)`,transitionDuration:_?"0ms":void 0},title:"这台开发机离线。向左滑动可移除。","data-slot":"proxy-swipe-foreground","data-offset":g,onPointerDown:w,onPointerMove:S,onPointerUp:R=>x(R),onPointerCancel:R=>x(R,!0),onClick:k,children:[m.jsx(k1,{status:"offline"}),m.jsx(Ep,{name:u,osName:n}),r&&m.jsx(ua,{className:"size-4 shrink-0 text-primary","aria-label":"已选"}),m.jsx("span",{className:"shrink-0 text-xs",children:"离线"})]}),m.jsx("button",{type:"button",className:`absolute inset-y-0 right-0 z-0 flex w-20 items-center justify-center bg-destructive text-sm font-medium text-white outline-none transition-colors hover:bg-destructive/90 focus-visible:z-20 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset disabled:pointer-events-none disabled:opacity-50 ${i?"":"pointer-events-none"}`,tabIndex:i?0:-1,disabled:s,"aria-label":`移除 ${u}`,"aria-hidden":i?void 0:!0,"data-slot":"proxy-mobile-remove",onClick:l,children:"移除"})]})}function oF({layout:e,variant:t="default"}){const n=Me(P=>P.proxies),r=Me(P=>P.proxyListLoaded),i=Me(P=>P.relayClientAuthIssue),s=Me(P=>P.selectedProxyId),o=Me(P=>P.proxySwitchTarget),l=ds(),u=Cs(),[d,f]=b.useState(!1),[h,y]=b.useState(null),[g,_]=b.useState(null),[w,S]=b.useState(null);async function x(P,z){if(o)return;const Y=$t;if(!Y){Ue.error("请先连接开发机");return}const U=z??P,G=s!==null&&s!==P;Me.getState().setProxySwitchTarget({proxyId:P,name:U});try{const I=await Y.selectProxy(P);if(!I.success){Ue.error(`无法连接 ${U}:${I.error??"未知错误"}`);return}const N=Y.getPreviewScope();if(!N||N.proxyId!==P||N.bindingId!==I.bindingId)throw Pt.dispose(),Y.clearBoundProxy(),new Error("开发机绑定状态无效,请重试");Pt.activate(Y,N),Pt.syncWebSnapshot(N).catch(L=>{L instanceof Error&&L.name==="AbortError"||console.error("[proxy-switcher] web preview snapshot failed",L)}),Pt.syncDeviceSnapshot(N).catch(L=>{L instanceof Error&&L.name==="AbortError"||console.error("[proxy-switcher] device preview snapshot failed",L)}),G&&(Ut.getState().prepareForProxySwitch(U),qr.getState().prepareForProxySwitch()),Rr("local",_n.proxyId,P),Me.getState().setProxy(P,z??null),Me.getState().setProxyOnline(!0),Me.getState().transitionToPhase("session_browsing"),Y.sendControl({type:"session_list_request"}),Y.requestProxyInfo().then(L=>{if(Me.getState().selectedProxyId!==P||!Pt.isActive(Y,N))return;const B=qr.getState();B.setHomePath(L.homePath),B.setAgentCli(L.agentCli),Me.getState().setTerminalShells(L.terminalShells)}).catch(L=>{Pt.isActive(Y,N)&&console.error("[proxy-switcher] post-bind proxy info fetch failed",L)}),Y.requestAgentStatuses().then(L=>{if(Me.getState().selectedProxyId!==P||!Pt.isActive(Y,N))return;const B=Ut.getState();for(const O of L)B.setAgentStatus(O.sessionId,O.payload)}).catch(L=>{Pt.isActive(Y,N)&&console.error("[proxy-switcher] post-bind data fetch failed",L)}),YC(Y).then(L=>{L.status==="failed"&&console.error("[proxy-switcher] post-bind data fetch failed",L.error)}),f(!1),(e==="page"||l.pathname.startsWith("/chat/")||l.pathname.startsWith("/preview/device/"))&&u("/sessions")}catch(I){const N=I instanceof Error?I.message:"未知错误";Ue.error(`无法连接 ${U}:${N}`)}finally{Me.getState().setProxySwitchTarget(null)}}function k(P){P.online||w||(y(null),_({proxyId:P.proxyId,...P.name?{name:P.name}:{}}))}async function R(){const P=g;if(!P||w)return;const z=$t;if(!z){Ue.error("Relay 连接不可用,请稍后重试");return}const Y=Me.getState().proxies.find(U=>U.proxyId===P.proxyId);if(!Y){if(!Me.getState().proxyListLoaded){Ue.info("正在重新连接 Relay,请稍后再试");return}Sp(P.proxyId,z)&&u("/"),Ue.info("这台开发机已经不在列表中"),_(null);return}if(Y.online){Ue.warning("这台开发机已重新上线,未移除"),_(null);return}S(P.proxyId),Nie(P.proxyId);try{const U=await z.removeOfflineProxy(P.proxyId);if(U.success){Id(P.proxyId),Sp(P.proxyId,z)&&u("/"),Ue.success(`已移除 ${P.name??P.proxyId}`),_(null);return}if(U.errorCode===Ar.PROXY_ONLINE){Id(P.proxyId),Ue.warning("这台开发机已重新上线,未移除"),_(null),z.listProxies();return}if(U.errorCode===Ar.PROXY_NOT_FOUND){Id(P.proxyId),Sp(P.proxyId,z)&&u("/"),Ue.info("这台开发机已经不在列表中"),_(null),z.listProxies();return}Id(P.proxyId),Ue.error(U.error??"无法移除开发机,请重试")}catch(U){Ue.error(U instanceof Error?U.message:"无法移除开发机,请重试"),z.listProxies()}finally{S(null)}}const A=m.jsx(zde,{open:g!==null,target:g,removing:w!==null,onOpenChange:P=>{P||_(null)},onConfirm:()=>void R()});if(e==="page")return i==="missing_client_token"?m.jsx(Jc,{variant:"client-token-missing"}):i==="invalid_client_token"?m.jsx(Jc,{variant:"client-token-invalid"}):r?n.length===0?m.jsx(Jc,{variant:"no-proxy"}):m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"flex h-full flex-col gap-3 overflow-auto p-4",children:[m.jsx("h3",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"开发机"}),m.jsx("ul",{role:"list",className:"flex flex-col gap-2",children:n.map(P=>{const z=(o==null?void 0:o.proxyId)===P.proxyId,Y=o!==null;return P.online?m.jsx("li",{children:m.jsxs("button",{type:"button","data-slot":"proxy-item","data-proxy-id":P.proxyId,"data-online":"true","data-selecting":z||void 0,disabled:Y||w!==null,"aria-busy":z||void 0,onClick:()=>x(P.proxyId,P.name),className:qe("flex min-h-[44px] w-full items-center gap-3 rounded-md border bg-card px-3 text-left transition-colors disabled:cursor-not-allowed disabled:hover:bg-card",P.osName?"h-14":"h-11",z?"border-primary/40 bg-accent text-accent-foreground":"border-border hover:bg-accent",Y&&!z||w!==null?"opacity-50":""),"aria-pressed":s===P.proxyId,children:[m.jsx(k1,{status:"online"}),m.jsx(Ep,{name:P.name??P.proxyId,osName:P.osName}),z?m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:"正在连接"}),m.jsx(li,{className:"size-4 shrink-0 animate-spin text-primary","aria-hidden":!0})]}):s===P.proxyId?m.jsx(ua,{className:"size-4 shrink-0 text-primary","aria-label":"已选"}):null]})},P.proxyId):m.jsx($de,{proxyId:P.proxyId,name:P.name,osName:P.osName,selected:s===P.proxyId,revealed:h===P.proxyId,disabled:Y||w!==null,onRevealedChange:U=>y(U?P.proxyId:null),onRemove:()=>k(P)},P.proxyId)})})]}),A]}):m.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 text-muted-foreground animate-in fade-in-0 duration-200 motion-reduce:animate-none",children:[m.jsx(li,{className:"h-5 w-5 animate-spin","aria-hidden":!0}),m.jsx("p",{className:"text-sm",children:"连接中..."})]});const M=n.find(P=>P.proxyId===s),T=(M==null?void 0:M.name)??(M==null?void 0:M.proxyId)??"未选择开发机";return m.jsxs(m.Fragment,{children:[m.jsxs(Ub,{open:d,onOpenChange:f,children:[m.jsx(Wb,{asChild:!0,children:m.jsxs("button",{type:"button","data-slot":"proxy-switcher-trigger",className:qe("group transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",t==="sidebarChrome"?"inline-flex min-h-9 min-w-0 max-w-full items-center justify-start gap-1.5 rounded-md text-left text-foreground hover:text-primary":"flex min-h-10 w-full items-center gap-2 rounded-md border border-border bg-background px-4 py-1.5 hover:bg-accent"),"aria-label":`当前连接:${T}`,children:[t==="default"&&m.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":!0}),m.jsx(Ep,{name:T,osName:M==null?void 0:M.osName,className:t==="sidebarChrome"?"flex-initial":"text-center",nameClassName:t==="sidebarChrome"?"text-base font-semibold":void 0}),m.jsx(sc,{className:"h-4 w-4 text-muted-foreground shrink-0 transition-transform group-data-[state=open]:rotate-180","aria-hidden":!0})]})}),m.jsx(qb,{align:"start",className:"w-[260px] p-1",children:n.length===0?m.jsx("div",{className:"text-xs text-muted-foreground p-2",children:"暂无可连接开发机"}):m.jsx("ul",{role:"list",className:"flex flex-col",children:n.map(P=>{const z=(o==null?void 0:o.proxyId)===P.proxyId,Y=o!==null;return m.jsxs("li",{className:"group flex min-w-0 items-center rounded-md",children:[m.jsxs("button",{type:"button","data-slot":"proxy-item","data-proxy-id":P.proxyId,"data-online":P.online,"data-selecting":z||void 0,disabled:!P.online||Y,"aria-busy":z||void 0,onClick:()=>x(P.proxyId,P.name),className:qe("flex min-w-0 flex-1 items-center gap-2 rounded-md px-2 text-left transition-colors disabled:cursor-not-allowed disabled:hover:bg-transparent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",P.osName?"h-12":"h-9",z?"bg-accent text-accent-foreground":"hover:bg-accent",Y&&!z?"opacity-50":"",P.online?"":"opacity-50"),"aria-pressed":s===P.proxyId,title:P.online?void 0:"这台开发机离线",children:[m.jsx(k1,{status:P.online?"online":"offline"}),m.jsx(Ep,{name:P.name??P.proxyId,osName:P.osName}),z?m.jsx(li,{className:"h-4 w-4 animate-spin text-primary shrink-0","aria-label":"正在连接"}):s===P.proxyId?m.jsx(ua,{className:"h-4 w-4 text-primary shrink-0","aria-label":"已选"}):null,!P.online&&!z&&m.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:"离线"})]}),!P.online&&m.jsxs(_f,{children:[m.jsx(wf,{asChild:!0,children:m.jsx(vt,{type:"button",variant:"ghost",size:"icon-xs",className:"mr-1 size-8 text-muted-foreground opacity-60 hover:opacity-100 focus-visible:opacity-100",disabled:Y||w!==null,"aria-label":`${P.name??P.proxyId} 操作`,"data-slot":"proxy-row-menu-trigger",children:m.jsx(hb,{"aria-hidden":"true"})})}),m.jsx(xf,{align:"end","data-slot":"proxy-row-menu",children:m.jsxs(Zr,{variant:"destructive","data-slot":"proxy-row-remove-item",onSelect:U=>{U.stopPropagation(),k(P)},children:[m.jsx(Mz,{"aria-hidden":"true"}),"移除开发机"]})})]})]},P.proxyId)})})})]}),A]})}function Hde({delayDuration:e=0,...t}){return m.jsx(yde,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function Sf({...e}){return m.jsx(bde,{"data-slot":"tooltip",...e})}function Ef({...e}){return m.jsx(_de,{"data-slot":"tooltip-trigger",...e})}function Cf({className:e,sideOffset:t=0,children:n,hideArrow:r=!1,...i}){return m.jsx(wde,{children:m.jsxs(xde,{"data-slot":"tooltip-content",sideOffset:t,className:qe("z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-md bg-foreground px-3 py-1.5 text-xs text-balance text-background fade-in-0 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 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",e),...i,children:[n,!r&&m.jsx(Sde,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})}function pc({...e}){return m.jsx(ok,{"data-slot":"sheet",...e})}function Ude({...e}){return m.jsx(gae,{"data-slot":"sheet-trigger",...e})}function Wde({...e}){return m.jsx(ak,{"data-slot":"sheet-portal",...e})}function qde({className:e,...t}){return m.jsx(lk,{"data-slot":"sheet-overlay",className:qe("fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",e),...t})}function mc({className:e,overlayClassName:t,children:n,side:r="right",showCloseButton:i=!0,focusSurfaceOnOpen:s=!1,onOpenAutoFocus:o,inert:l,"aria-disabled":u,...d}){const f=km();return m.jsxs(Wde,{children:[m.jsx(qde,{className:t}),m.jsxs(ck,{"data-slot":"sheet-content",className:qe("fixed z-50 flex flex-col gap-4 bg-background shadow-lg transition ease-in-out data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:animate-in data-[state=open]:duration-500",r==="right"&&"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm",r==="left"&&"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",r==="top"&&"inset-x-0 top-0 h-auto border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",r==="bottom"&&"inset-x-0 bottom-0 h-auto border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",e),onOpenAutoFocus:h=>{o==null||o(h),!(!s||h.defaultPrevented)&&(h.preventDefault(),h.currentTarget.focus({preventScroll:!0}))},inert:f||l?!0:void 0,"aria-disabled":f?!0:u,"data-relay-interaction-blocked":f?"true":void 0,...d,children:[n,i&&m.jsxs(Rb,{"data-slot":"sheet-close",className:"absolute top-2 right-2 flex size-11 items-center justify-center rounded-md opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:pointer-events-none data-[state=open]:bg-secondary",children:[m.jsx(bu,{className:"size-4"}),m.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Eu({className:e,...t}){return m.jsx("div",{"data-slot":"sheet-header",className:qe("flex flex-col gap-1.5 p-4",e),...t})}function gc({className:e,...t}){return m.jsx(J5,{"data-slot":"sheet-title",className:qe("font-semibold text-foreground",e),...t})}function Vb({className:e,...t}){return m.jsx(e3,{"data-slot":"sheet-description",className:qe("text-sm text-muted-foreground",e),...t})}const Vde={claude:"Claude Code",codex:"Codex",kimi:"Kimi Code"},cI=["claude","codex","kimi"];function Yb(e){return Vde[e]}function aF(e,t){return cI.indexOf(e)-cI.indexOf(t)}function qp(e){return e.provider}const T1=60*1e3,R1=60*T1,Yde=24*R1;function lF(e,t=Date.now()){const n=t-e;if(n<T1)return"刚刚";if(n<R1)return`${Math.floor(n/T1)} 分钟前`;if(n<Yde)return`${Math.floor(n/R1)} 小时前`;const r=new Date(e),i=r.getMonth()+1,s=r.getDate(),o=String(r.getHours()).padStart(2,"0"),l=String(r.getMinutes()).padStart(2,"0");return`${i} 月 ${s} 日 ${o}:${l}`}const uI={idle:{dot:"bg-[var(--color-status-success)]",text:"text-[var(--color-status-success)]",label:"空闲"},working:{dot:"bg-[var(--color-status-working)] animate-pulse",text:"text-[var(--color-status-working)]",label:"工作中"},compacting:{dot:"bg-[var(--color-status-compacting)] animate-pulse",text:"text-[var(--color-status-compacting)]",label:"压缩中"},waiting_approval:{dot:"bg-[var(--color-status-warning)]",text:"text-[var(--color-status-warning)]",label:"等待审批"},error:{dot:"bg-[var(--color-status-error)]",text:"text-[var(--color-status-error)]",label:"出错"},terminated:{dot:"bg-muted-foreground",text:"text-muted-foreground",label:"已终止"}};function A1(e){return e.kind!=="terminal"?uI[e.state]:e.state==="terminated"?uI.terminated:e.state==="error"?{dot:"bg-[var(--color-status-error)]",text:"text-[var(--color-status-error)]",label:"已断开"}:{dot:"bg-[var(--color-status-success)]",text:"text-[var(--color-status-success)]",label:"运行中"}}function Kde({session:e}){const t=A1(e);return m.jsx("span",{className:qe("inline-block size-2 rounded-full shrink-0",t.dot),"aria-label":`会话状态:${t.label}`,role:"status"})}function Gde({mode:e}){if(e!=="pty"&&e!=="json")return null;const t=e==="json"?"聊天视图":"终端视图",n=e==="json"?EC:kC;return m.jsx("span",{className:"inline-flex h-5 w-4 shrink-0 items-center justify-center text-muted-foreground",role:"img","aria-label":t,title:t,"data-slot":"session-mode-icon","data-mode":e,children:m.jsx(n,{className:"size-3.5","aria-hidden":"true"})})}function Xde({session:e,selected:t,now:n,onClick:r,onRename:i,onTerminate:s}){const o=qr(w=>w.homePath),l=e.lastActive,u=e.cwd,d=ZC(e.name,o),f=QC(e,o),h=e.nameLocked&&e.name?e.name:f||(d==="New Session"?e.sessionId.slice(0,8):d),y=lF(l,n),g=e.mode==="pty"&&e.ptyOwner==="local-terminal",_=e.kind==="terminal"?"终止终端":g?"断开远程连接":"终止会话";return m.jsxs("li",{className:qe("relative flex items-center gap-2 px-4 py-2 w-full min-w-0 transition-colors","min-h-[44px]","hover:bg-accent",t&&"dev-sidebar-active-row"),"data-slot":"session-row","data-session-id":e.sessionId,"data-selected":t,children:[t&&m.jsx("span",{className:"dev-sidebar-active-indicator absolute left-0 top-0 bottom-0 w-[2px]","aria-hidden":"true"}),m.jsxs("button",{type:"button","data-slot":"session-row-select",onClick:r,className:"flex min-h-11 flex-col justify-center gap-1 flex-1 min-w-0 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm md:min-h-0","aria-pressed":t,children:[m.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[m.jsx(Kde,{session:e}),m.jsx("span",{className:"text-sm font-normal truncate flex-1",title:u,children:h})]}),m.jsxs("span",{className:"flex items-center gap-1.5 text-xs leading-5 h-5",children:[m.jsx(Gde,{mode:e.mode}),m.jsx("span",{className:"text-muted-foreground/60 shrink-0","aria-hidden":"true",children:"·"}),e.kind!=="terminal"&&m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"font-mono text-muted-foreground shrink-0",children:Yb(e.provider)}),m.jsx("span",{className:"text-muted-foreground/60 shrink-0","aria-hidden":"true",children:"·"})]}),m.jsx("span",{className:qe("shrink-0",A1(e).text),children:A1(e).label}),y&&m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"text-muted-foreground/60 shrink-0","aria-hidden":"true",children:"·"}),m.jsx("span",{className:"text-muted-foreground shrink-0 tabular-nums",children:y})]})]})]}),(i||s)&&m.jsxs(_f,{children:[m.jsx(wf,{asChild:!0,children:m.jsx(vt,{variant:"ghost",size:"icon-xs",className:"size-11 md:size-6","aria-label":"会话操作","data-slot":"session-row-menu-trigger",onClick:w=>w.stopPropagation(),children:m.jsx(hb,{"aria-hidden":"true"})})}),m.jsxs(xf,{align:"end","data-slot":"session-row-menu",children:[i&&m.jsx(Zr,{"data-slot":"session-row-rename-item",onSelect:w=>{w.stopPropagation(),i()},children:"重命名"}),s&&m.jsx(Zr,{variant:"destructive","data-slot":"session-row-terminate-item",onSelect:w=>{w.stopPropagation(),s()},children:_})]})]})]})}function yo(e){const[t,n]=b.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(e).matches);return b.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const r=window.matchMedia(e),i=s=>n(s.matches);return n(r.matches),r.addEventListener("change",i),()=>r.removeEventListener("change",i)},[e]),t}function Zde({session:e,now:t,disabled:n,loading:r,onClick:i,modeTag:s}){const o=m.jsx(Qde,{title:e.title,modeTag:s}),l=m.jsx("span",{className:"text-xs text-muted-foreground tabular-nums",children:lF(e.updatedAt,t)}),u=m.jsxs("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[o,l]});return m.jsx("li",{"data-slot":"history-row","data-session-id":e.id,"data-loading":r?"true":void 0,className:"group w-full flex items-stretch",children:m.jsxs("button",{type:"button",onClick:i,disabled:n,"data-slot":"history-row-primary",className:qe("min-w-0 flex-1 flex items-start gap-2 pl-10 pr-4 py-2 min-h-[50px]","text-left transition-colors outline-none","hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring","disabled:opacity-50 disabled:cursor-wait disabled:hover:bg-transparent"),"aria-label":`恢复会话:${e.title}`,children:[u,m.jsx(CV,{className:qe("mt-0.5 size-3.5 shrink-0 text-muted-foreground transition-opacity",r?"animate-pulse opacity-100":"opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100"),"aria-hidden":"true"})]})})}function Qde({title:e,modeTag:t}){return m.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[m.jsx("span",{className:"text-sm font-normal truncate min-w-0",title:e,children:e}),t&&m.jsx(Jde,{mode:t})]})}function Jde({mode:e}){const t=e==="json"?"聊天视图":"终端视图",n=e==="json"?EC:kC;return m.jsx("span",{"data-slot":"history-mode-tag","data-mode":e,role:"img","aria-label":t,title:t,className:qe("inline-flex size-5 shrink-0 items-center justify-center rounded border","border-border bg-muted/50 text-muted-foreground"),children:m.jsx(n,{className:"size-3","aria-hidden":"true"})})}function cF({providerLabel:e}){return m.jsx("div",{className:"grid min-w-0 gap-4","data-slot":"bypass-permission-warning",role:"alert",children:m.jsxs("div",{className:"flex min-w-0 items-start gap-3 text-sm",children:[m.jsx(_K,{className:"mt-0.5 size-5 shrink-0 text-destructive","aria-hidden":"true"}),m.jsxs("div",{className:"grid min-w-0 gap-2",children:[m.jsxs("p",{className:"font-medium text-foreground",children:[e," 将不再请求工具审批。"]}),m.jsx("p",{className:"text-muted-foreground",children:"Agent 可以直接执行命令、修改或删除文件,并可能绕过部分沙箱保护。"})]})]})})}function efe({now:e}){const t=qr(I=>I.homePath),n=Ut(I=>I.historySessions),r=Ut(I=>I.historyLoadStatus),[i,s]=b.useState(null),[o,l]=b.useState(null),[u,d]=b.useState("json"),[f,h]=b.useState("default"),[y,g]=b.useState(!1),[_,w]=b.useState(new Set),[S,x]=b.useState(new Set),k=Cs(),R=b.useMemo(()=>{const I=new Map;for(const N of n){const L=qp(N);let B=I.get(L);B||(B=new Map,I.set(L,B));const O=uF(N.projectDir),D=B.get(O);D?D.sessions.push(N):B.set(O,{dir:O,sessions:[N]})}return Array.from(I.entries()).sort(([N],[L])=>aF(N,L)).map(([N,L])=>({provider:N,sessions:Array.from(L.values()).flatMap(B=>B.sessions),projects:Array.from(L.values()).map(B=>({dir:B.dir,shortDir:pm(B.dir,t,{compact:!0}),sessions:B.sessions}))}))},[n,t]);function A(I){l(I),d(tfe(I)),h(nfe(I))}async function M(I,N,L){if(i)return;const B=$t;if(!B){Ue.error("请先连接开发机");return}s(I.id);const O=qp(I);try{const D=await B.createSession({kind:"agent",cwd:I.projectDir,mode:N,provider:O,resumeSessionId:I.id,...L?{permissionMode:L}:{}});if(!D.success){if(D.errorCode===Ar.SESSION_ALREADY_ACTIVE){Ut.getState().setCodexActiveWriterConflict({...D.activeWriterPid?{activeWriterPid:D.activeWriterPid}:{}}),l(null);return}Ue.error(`恢复失败:${D.error}`);return}if(D.kind!=="agent"){Ue.error("恢复失败:开发机返回了错误的会话类型");return}const F={sessionId:D.sessionId,kind:"agent",...D.name!==void 0?{name:D.name}:{},...D.nameLocked!==void 0?{nameLocked:D.nameLocked}:{},state:"idle",cwd:D.cwd,lastActive:D.lastActive,provider:D.provider},V=D.mode==="pty"?{...F,mode:"pty",ptyOwner:D.ptyOwner}:{...F,mode:"json"};Ut.getState().addSession(V),k(`/chat/${D.sessionId}?mode=${D.mode}`),l(null)}catch(D){Ue.error(`恢复失败:${D instanceof Error?D.message:String(D)}`)}finally{s(null)}}function T(){const I=$t;!I||Ut.getState().historyLoadStatus==="loading"||YC(I).then(N=>{N.status==="failed"&&Ue.error(N.error instanceof Error?N.error.message:String(N.error))})}function P(I,N){const L=dI(I,N);x(B=>{const O=new Set(B);return O.has(L)?O.delete(L):O.add(L),O})}function z(I){w(N=>{const L=new Set(N);return L.has(I)?L.delete(I):L.add(I),L})}const Y=n.length>0,U=r==="loading",G=o?dF():[];return m.jsxs("div",{"data-slot":"history-list",className:"flex flex-col",children:[m.jsxs("div",{className:"flex min-h-11 w-full items-center gap-1.5 px-4 py-1.5 md:min-h-[36px]",children:[m.jsxs("button",{type:"button",onClick:()=>Y&&g(I=>!I),disabled:!Y,"aria-expanded":Y?y:void 0,"data-slot":"history-section-header","data-expanded":y,className:qe("flex min-w-0 flex-1 items-center gap-1.5 rounded-md py-0.5 text-left","transition-colors outline-none","hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring","disabled:cursor-default disabled:hover:text-inherit"),children:[m.jsxs("h3",{className:"min-w-0 text-sm font-semibold text-foreground",children:["全部会话",Y?m.jsxs("span",{className:"ml-1 text-muted-foreground/70 font-normal",children:["· ",n.length]}):null]}),Y?m.jsx(Hd,{className:qe("size-3.5 shrink-0 text-muted-foreground/80 transition-transform",y&&"rotate-90"),"aria-hidden":"true"}):null]}),m.jsx(vt,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"刷新全部会话","aria-busy":U,title:U?"正在加载":"刷新",onClick:T,disabled:U,"data-slot":"history-refresh",className:"size-11 md:size-8",children:m.jsx(um,{className:qe("size-3.5",U&&"animate-spin motion-reduce:animate-none"),"aria-hidden":"true"})})]}),!Y&&U&&m.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 text-sm text-muted-foreground/80","data-slot":"history-loading",role:"status","aria-live":"polite",children:[m.jsx(li,{className:"size-3.5 shrink-0 animate-spin motion-reduce:animate-none","aria-hidden":"true"}),m.jsx("span",{children:"正在加载会话记录..."})]}),!Y&&r==="idle"&&m.jsx("div",{className:"px-4 py-3 text-sm text-muted-foreground/80","data-slot":"history-idle",role:"status",children:"会话记录尚未加载"}),!Y&&r==="error"&&m.jsx("div",{className:"px-4 py-3 text-sm text-muted-foreground/80","data-slot":"history-error",role:"status",children:"会话记录加载失败,请点击刷新重试"}),Y&&r==="error"&&m.jsx("div",{className:"px-4 pb-2 text-xs text-muted-foreground/80","data-slot":"history-stale",role:"status",children:"刷新失败,当前显示上次加载的结果"}),!Y&&r==="loaded"&&m.jsx("div",{className:"px-4 py-3 text-sm text-muted-foreground/70","data-slot":"history-empty",children:"暂无会话记录"}),Y&&y&&m.jsx("ul",{role:"list",className:"flex flex-col",children:R.map(I=>{const N=_.has(I.provider);return m.jsxs("li",{children:[m.jsxs("button",{type:"button",onClick:()=>z(I.provider),"aria-expanded":!N,"data-slot":"history-provider-header","data-expanded":!N,className:qe("w-full flex items-center gap-2 px-4 pt-2 pb-1 min-h-[32px]","text-xs text-muted-foreground text-left transition-colors outline-none","hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring"),children:[m.jsx("span",{className:"font-mono",children:Yb(I.provider)}),m.jsx("span",{className:"h-px flex-1 bg-border/70","aria-hidden":"true"}),m.jsx("span",{className:"tabular-nums",children:I.sessions.length}),m.jsx(Hd,{className:qe("size-3.5 shrink-0 text-muted-foreground/80 transition-transform",!N&&"rotate-90"),"aria-hidden":"true"})]}),!N&&m.jsx("ul",{role:"list",className:"flex flex-col",children:I.projects.map(L=>{const B=dI(I.provider,L.dir),O=S.has(B);return m.jsxs("li",{children:[m.jsxs("button",{type:"button",onClick:()=>P(I.provider,L.dir),"aria-expanded":O,"data-slot":"history-group-header","data-expanded":O,className:qe("w-full flex items-center gap-1.5 pl-6 pr-4 py-2 min-h-[36px]","text-left transition-colors outline-none","hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring"),children:[m.jsx("span",{className:"text-sm font-mono truncate flex-1 min-w-0",title:L.dir,children:L.shortDir}),m.jsx("span",{className:"text-xs text-muted-foreground/80 tabular-nums shrink-0",children:L.sessions.length}),m.jsx(Hd,{className:qe("size-3.5 shrink-0 text-muted-foreground/80 transition-transform",O&&"rotate-90"),"aria-hidden":"true"})]}),O&&m.jsx("ul",{role:"list",className:"flex flex-col",children:L.sessions.map(D=>m.jsx(Zde,{session:D,now:e,disabled:i!==null,loading:i===D.id,onClick:()=>A(D),modeTag:D.preferredMode},D.id))})]},B)})})]},I.provider)})}),m.jsx(rfe,{session:o,open:o!==null,modes:G,mode:u,permissionMode:f,submitting:i!==null,onOpenChange:I=>{I||l(null)},onModeChange:d,onPermissionModeChange:h,onConfirm:()=>{o&&M(o,u,f)}})]})}function dI(e,t){return`${e}:${uF(t)}`}function uF(e){const t=e.trim();return!t||t==="/"?t||"/":t.replace(/\/+$/,"")||"/"}function dF(){return["json","pty"]}function tfe(e){const t=dF();return e.preferredMode&&t.includes(e.preferredMode)?e.preferredMode:t[0]??"json"}function nfe(e){return qp(e)==="codex"?"auto":"default"}function rfe({session:e,open:t,modes:n,mode:r,permissionMode:i,submitting:s,onOpenChange:o,onModeChange:l,onPermissionModeChange:u,onConfirm:d}){const[f,h]=b.useState(!1),y=i==="bypassPermissions",g=yo("(min-width: 768px)"),_=e?qp(e):null,w=_==="codex",S=_==="kimi";b.useEffect(()=>{t||h(!1)},[t]);const x=f?m.jsx(cF,{providerLabel:e?Yb(qp(e)):"Agent"}):m.jsxs("div",{className:"grid min-w-0 gap-4",children:[m.jsxs("div",{className:"grid min-w-0 gap-2",children:[m.jsx("span",{className:"text-sm font-medium",children:"模式"}),m.jsxs("div",{role:"radiogroup","aria-label":"恢复模式",className:"grid min-w-0 grid-cols-2 gap-2",children:[n.includes("json")&&m.jsx(fI,{checked:r==="json",label:"聊天",icon:m.jsx(EC,{className:"size-4","aria-hidden":"true"}),disabled:s,onClick:()=>l("json")}),n.includes("pty")&&m.jsx(fI,{checked:r==="pty",label:"终端",icon:m.jsx(kC,{className:"size-4","aria-hidden":"true"}),disabled:s,onClick:()=>l("pty")})]})]}),m.jsxs("div",{className:"grid min-w-0 gap-2",children:[m.jsx("span",{className:"text-sm font-medium",children:"权限模式"}),m.jsxs("div",{role:"radiogroup","aria-label":"权限模式",className:"grid min-w-0 gap-2",children:[!w&&m.jsx(yv,{checked:i==="default",label:S?"手工审批":"严格审批",description:S?"工具调用会在 Web 中请求确认。":"所有需要权限的操作都要确认。",disabled:s,onClick:()=>u("default")}),m.jsx(yv,{checked:i==="auto",label:w?"按需审批":S?"自动审批":"自动判定",description:w?"Codex 在需要时请求确认。":S?"Kimi Code 使用原生 yolo 模式自动审批。":"交给 Agent CLI 的原生策略判断。",disabled:s,onClick:()=>u("auto")}),S&&m.jsx(yv,{checked:i==="plan",label:"只读规划",description:"Kimi Code 使用只读规划模式。",disabled:s,onClick:()=>u("plan")}),m.jsx(yv,{checked:i==="bypassPermissions",label:S?"全自动":"跳过全部审批",description:S?"危险模式,Kimi Code 将全自动执行。":"危险模式,会跳过工具审批和部分沙箱保护。",destructive:!0,disabled:s,onClick:()=>u("bypassPermissions")})]})]})]}),k=m.jsxs(m.Fragment,{children:[m.jsx(vt,{type:"button",variant:"ghost",disabled:s,onClick:()=>{f?h(!1):o(!1)},children:f?"返回":"取消"}),m.jsx(vt,{type:"button",variant:f?"destructive":"default",disabled:s,onClick:()=>{if(y&&!f){h(!0);return}d()},"data-slot":f?"bypass-permission-confirm":void 0,children:s?"恢复中...":f?"确认":"恢复"})]});return g?m.jsx(es,{open:t,onOpenChange:o,children:m.jsxs(ts,{focusSurfaceOnOpen:!0,className:"min-w-0 sm:max-w-md","data-slot":"history-restore-dialog",children:[m.jsxs(ns,{className:"min-w-0",children:[m.jsx($i,{children:f?"跳过全部审批?":"恢复会话"}),m.jsx(Es,{className:"min-w-0 truncate pr-10 sm:pr-0",title:e==null?void 0:e.title,children:(e==null?void 0:e.title)??""})]}),x,m.jsx(qs,{children:k})]})}):m.jsx(pc,{open:t,onOpenChange:o,children:m.jsxs(mc,{side:"bottom",focusSurfaceOnOpen:!0,className:"inset-x-2 w-auto max-h-[calc(100dvh-0.75rem)] min-w-0 overflow-hidden rounded-t-xl border bg-background p-0","data-slot":"history-restore-dialog",children:[m.jsxs(Eu,{className:"min-w-0 shrink-0 px-4 pb-2 pt-4 text-left",children:[m.jsx(gc,{children:f?"跳过全部审批?":"恢复会话"}),m.jsx(Vb,{className:"min-w-0 truncate pr-10",title:e==null?void 0:e.title,children:(e==null?void 0:e.title)??""})]}),m.jsx("div",{className:"min-h-0 overflow-y-auto px-4 pb-3","data-slot":"history-restore-body",children:x}),m.jsx("div",{className:"shrink-0 border-t border-border/70 bg-background px-4 pb-[max(theme(spacing.4),env(safe-area-inset-bottom))] pt-3","data-slot":"history-restore-footer",children:m.jsx("div",{className:"flex flex-col-reverse gap-2 [&_button]:min-h-11 [&_button]:w-full",children:k})})]})})}function fI({checked:e,label:t,icon:n,disabled:r,onClick:i}){return m.jsxs("button",{type:"button",role:"radio","aria-label":t,"aria-checked":e,disabled:r,onClick:i,className:qe("grid min-h-11 w-full min-w-0 max-w-full grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2 rounded-md border px-3 text-sm outline-none transition-colors md:h-10 md:min-h-0","focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-wait disabled:opacity-60",e?"border-primary text-foreground":"border-border text-muted-foreground hover:bg-accent/60 hover:text-foreground"),children:[n,m.jsx("span",{className:"min-w-0 text-center",children:t}),m.jsx(ua,{className:qe("size-3.5 justify-self-end transition-opacity",e?"opacity-100":"opacity-0"),"aria-hidden":"true"})]})}function yv({checked:e,label:t,description:n,destructive:r,disabled:i,onClick:s}){return m.jsxs("button",{type:"button",role:"radio","aria-label":t,"aria-checked":e,disabled:i,onClick:s,className:qe("grid w-full min-w-0 max-w-full grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-3 rounded-md border p-3 text-left outline-none transition-colors","focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-wait disabled:opacity-60",e?r?"border-destructive/70":"border-primary":"border-border hover:bg-accent/60"),children:[m.jsx("span",{className:qe("mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full border",e?r?"border-destructive":"border-primary":"border-muted-foreground/50"),"aria-hidden":"true",children:e&&m.jsx("span",{className:qe("size-2 rounded-full",r?"bg-destructive":"bg-primary")})}),m.jsxs("span",{className:"grid min-w-0 gap-1",children:[m.jsx("span",{className:qe("text-sm font-medium",r?"text-destructive":"text-foreground"),children:t}),m.jsx("span",{className:"min-w-0 break-words text-xs leading-5 text-muted-foreground",children:n})]}),e&&m.jsx(ua,{className:qe("mt-0.5 size-4 shrink-0",r?"text-destructive":"text-primary"),"aria-hidden":"true"})]})}function Kb({...e}){return m.jsx(que,{"data-slot":"select",...e})}function Gb({...e}){return m.jsx(Yue,{"data-slot":"select-value",...e})}function Xb({className:e,size:t="default",children:n,...r}){return m.jsxs(Vue,{"data-slot":"select-trigger","data-size":t,className:qe("flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/75 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",e),...r,children:[n,m.jsx(Kue,{asChild:!0,children:m.jsx(sc,{className:"size-4 opacity-50"})})]})}function Zb({className:e,children:t,position:n="item-aligned",align:r="center",inert:i,"aria-disabled":s,...o}){const l=km();return m.jsx(Gue,{children:m.jsxs(Xue,{"data-slot":"select-content",className:qe("relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,align:r,inert:l||i?!0:void 0,"aria-disabled":l?!0:s,"data-relay-interaction-blocked":l?"true":void 0,...o,children:[m.jsx(ife,{}),m.jsx(Zue,{className:qe("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),m.jsx(sfe,{})]})})}function Qb({className:e,children:t,...n}){return m.jsxs(Que,{"data-slot":"select-item",className:qe("relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...n,children:[m.jsx("span",{"data-slot":"select-item-indicator",className:"absolute right-2 flex size-3.5 items-center justify-center",children:m.jsx(ede,{children:m.jsx(ua,{className:"size-4"})})}),m.jsx(Jue,{children:t})]})}function ife({className:e,...t}){return m.jsx(tde,{"data-slot":"select-scroll-up-button",className:qe("flex cursor-default items-center justify-center py-1",e),...t,children:m.jsx(wC,{className:"size-4"})})}function sfe({className:e,...t}){return m.jsx(nde,{"data-slot":"select-scroll-down-button",className:qe("flex cursor-default items-center justify-center py-1",e),...t,children:m.jsx(sc,{className:"size-4"})})}function ofe(e,t,n){var u;if(t==="insert"){const d=e.split("@").pop()??"",f=au((n==null?void 0:n.baseCwd)??d)==="\\",h=Math.max(d.lastIndexOf("/"),f?d.lastIndexOf("\\"):-1);return{currentPath:h>=0?d.slice(0,h+1):f?".\\":"./",query:d.slice(h+1).toLowerCase()}}const r=oa((n==null?void 0:n.baseCwd)??"");if(!e)return{currentPath:fo(r),query:""};const i=bb(r,e);if(!i)return{currentPath:"",query:""};const s=qC(i),o=au(i);return e.endsWith("/")||o==="\\"&&e.endsWith("\\")||i===s||i===r||((u=n==null?void 0:n.knownDirs)==null?void 0:u.has(i))?{currentPath:fo(i),query:""}:{currentPath:fo(s),query:i.slice(i.lastIndexOf(o)+1).toLowerCase()}}function y0(e,t){return bb(e,t)}const fF=b.forwardRef(function({filter:t,onSelect:n,onNavigate:r,onSelectCurrentDirectory:i,onCreateDirectory:s,mode:o="insert",placement:l="floating",dirsOnly:u=!1,fileExtensions:d,includeHidden:f=!1,autoHighlightFirst:h=!0,title:y},g){const _=qr(ye=>f?ye.treeWithHidden:ye.tree),w=qr(ye=>ye.cwd),S=qr(ye=>ye.homePath),x=o==="insert"?w:S||w,k=b.useMemo(()=>new Set(_.keys()),[_]),R=b.useMemo(()=>ofe(t,o,{baseCwd:x,knownDirs:k}),[t,o,x,k]),A=R.currentPath,M=b.useMemo(()=>y0(x,A),[x,A]),T=R.query,P=b.useRef(new Map),[z,Y]=b.useState(!1),[U,G]=b.useState(""),[I,N]=b.useState(!1),[L,B]=b.useState(null),[O,D]=b.useState(0);b.useEffect(()=>{if(!M)return;const ye=`${f?"hidden":"default"}\0${M}`;if(_.has(M))return;const Re=$t;if(!Re)return;let Rt=!1;B(et=>(et==null?void 0:et.path)===M?null:et);let Ke=P.current.get(ye);if(!Ke){Ke=Re.requestDirectoryList(M,{includeHidden:f}),P.current.set(ye,Ke);const et=()=>{P.current.get(ye)===Ke&&P.current.delete(ye)};Ke.then(et,et)}return Ke.then(et=>{if(!Rt){if(et.error!==void 0||et.errorCode!==void 0){B({path:M,message:et.error||"读取失败"});return}qr.getState().setDirEntries(et.path,et.entries,et.includeHidden)}},et=>{Rt||B({path:M,message:et instanceof Error?et.message:"读取失败"})}),()=>{Rt=!0}},[M,f,_,O]);const F=(L==null?void 0:L.path)===M?L:null,V=!_.has(M)&&!F,j=b.useMemo(()=>d==null?void 0:d.map(ye=>ye.startsWith(".")?ye.toLowerCase():`.${ye.toLowerCase()}`),[d]),q=b.useMemo(()=>{let ye=_.get(M)??[];return u?ye=ye.filter(Re=>Re.isDir):j!=null&&j.length&&(ye=ye.filter(Re=>Re.isDir||j.some(Rt=>Re.name.toLowerCase().endsWith(Rt)))),T&&(ye=ye.filter(Re=>Re.name.toLowerCase().includes(T))),ye},[_,M,T,u,j]),[K,$]=b.useState(h?0:-1);b.useEffect(()=>$(h?0:-1),[h,A,T]),b.useEffect(()=>{Y(!1),G("")},[M]),b.useEffect(()=>{K>=q.length&&q.length>0&&$(q.length-1)},[q.length,K]);const te=b.useRef(null),J=b.useRef(!1);b.useEffect(()=>{var Re;if(!J.current)return;J.current=!1;const ye=(Re=te.current)==null?void 0:Re.querySelector(`[data-entry-index="${K}"]`);ye==null||ye.scrollIntoView({block:"nearest"})},[K]);const ne=b.useCallback(ye=>{const Re=au(x),Rt=`${fo(A,x)}${ye.name}${ye.isDir?Re:""}`;if(o==="insert")return Rt.replace(Re==="\\"?/^\.[\\/]/:/^\.\//,"");const Ke=y0(x,Rt);return ye.isDir?fo(Ke):Ke},[x,A,o]),Q=b.useCallback(ye=>{const Re=y0(x,ye);if(!Re)return;const Rt=fo(Re);if(o==="select"){r(Rt);return}n(Rt)},[x,o,r,n]),ce=b.useCallback(ye=>{const Re=ne(ye);if(ye.isDir){Q(Re);return}n(Re)},[ne,Q,n]);async function re(){const ye=l2(M,U);if(!(!ye||!s)){N(!0);try{const Re=await s(ye);if(!Re)return;if(G(""),Y(!1),i){i(fo(Re));return}Q(Re)}finally{N(!1)}}}b.useImperativeHandle(g,()=>({handleKey(ye){return q.length===0?!1:ye.key==="ArrowDown"?(J.current=!0,$(Re=>Math.min(q.length-1,Re+1)),!0):ye.key==="ArrowUp"?(J.current=!0,$(Re=>Math.max(0,Re-1)),!0):ye.key==="Enter"&&K>=0&&!ye.nativeEvent.isComposing?(ce(q[K]),!0):!1}}),[q,K,ce]);const le=b.useMemo(()=>qC(M),[M]),we=l==="inline"?"relative w-full bg-popover border border-border rounded-md overflow-hidden":o==="insert"?"absolute bottom-full left-0 right-0 z-50 mb-2 bg-popover border border-border rounded-md shadow-lg overflow-hidden":"absolute left-0 right-0 top-full z-50 mt-2 bg-popover border border-border rounded-md shadow-lg overflow-hidden",Ce=l==="inline"?"max-h-[min(11rem,30dvh)] overflow-y-auto overscroll-contain":o==="select"?"max-h-44 overflow-y-auto overscroll-contain":"max-h-60 overflow-y-auto overscroll-contain";return m.jsxs("div",{className:we,"data-slot":"file-path-picker","data-mode":o,"data-placement":l,children:[o==="select"?m.jsxs("div",{className:"border-b border-border/70 px-3 py-2",children:[m.jsxs("div",{className:"min-w-0",children:[y?m.jsx("p",{className:"mb-2 truncate text-xs text-muted-foreground","data-slot":"file-path-picker-title",children:y}):null,m.jsx("p",{className:"truncate font-mono text-xs text-foreground","data-slot":"file-path-picker-current-directory",title:M,children:pm(M,S)||"正在读取路径"})]}),m.jsxs("div",{className:"mt-1 flex items-center justify-between gap-2",role:"toolbar","aria-label":"路径操作","data-slot":"file-path-picker-actions",children:[m.jsx("button",{type:"button","data-slot":"file-path-picker-parent",className:"inline-flex min-h-11 min-w-11 items-center justify-start px-0 text-xs font-medium text-primary hover:underline focus-visible:underline focus-visible:outline-none disabled:cursor-not-allowed disabled:text-muted-foreground disabled:no-underline md:min-h-8 md:min-w-0",disabled:!M||M===le,onClick:()=>Q(le),children:"上一级"}),i||s?m.jsxs("span",{className:"flex shrink-0 items-center gap-4",children:[s?m.jsx("button",{type:"button","data-slot":"file-path-picker-create-directory-toggle",className:"inline-flex min-h-11 min-w-11 items-center justify-center px-0 text-xs font-medium text-primary hover:underline focus-visible:underline focus-visible:outline-none disabled:cursor-not-allowed disabled:text-muted-foreground disabled:no-underline md:min-h-8 md:min-w-0",disabled:!M||I,onClick:()=>Y(ye=>!ye),children:"新建目录"}):null,i?m.jsx("button",{type:"button","data-slot":"select-current-directory",className:"inline-flex min-h-11 min-w-11 items-center justify-center px-0 text-xs font-medium text-primary hover:underline focus-visible:underline focus-visible:outline-none disabled:cursor-not-allowed disabled:text-muted-foreground disabled:no-underline md:min-h-8 md:min-w-0",disabled:!M,onClick:()=>i(fo(M)),children:"选定"}):null]}):null]}),z?m.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[m.jsx("input",{type:"text","data-slot":"file-path-picker-create-directory-name",value:U,onChange:ye=>G(ye.target.value),onKeyDown:ye=>{ye.key==="Enter"&&!ye.nativeEvent.isComposing&&(ye.preventDefault(),re()),ye.key==="Escape"&&(Y(!1),G(""))},placeholder:"目录名称",className:"min-h-11 min-w-0 flex-1 rounded-md border border-border bg-input px-2 text-base outline-none focus-visible:ring-2 focus-visible:ring-ring md:h-8 md:min-h-0 md:text-sm",autoComplete:"off",autoCorrect:"off",spellCheck:!1}),m.jsx("button",{type:"button","data-slot":"file-path-picker-create-directory-submit",className:"min-h-11 rounded-md bg-primary px-3 text-sm text-primary-foreground disabled:cursor-not-allowed disabled:opacity-50 md:h-8 md:min-h-0",disabled:!l2(M,U)||I,onClick:()=>void re(),children:I?"创建中...":"创建目录"})]}):null]}):null,m.jsx("div",{className:Ce,"data-slot":"file-path-picker-entries",children:F?m.jsxs("div",{"data-slot":"file-path-picker-error",className:"flex items-center justify-between gap-3 px-3 py-2",role:"alert",children:[m.jsx("span",{className:"min-w-0 text-xs text-destructive",title:F.message,children:"无法读取这个文件夹"}),m.jsx("button",{type:"button","data-slot":"file-path-picker-retry",className:"shrink-0 rounded px-2 py-1 text-xs text-primary hover:bg-primary/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>D(ye=>ye+1),children:"重试"})]}):q.length===0?m.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:V?"加载中...":"没有匹配的路径"}):m.jsx("ul",{ref:te,role:"list",className:"flex flex-col",children:q.map((ye,Re)=>m.jsx("li",{children:m.jsx("button",{type:"button",onClick:()=>ce(ye),onMouseEnter:()=>$(Re),className:qe("w-full flex min-h-11 items-center gap-2 px-3 py-2 text-sm text-left transition-colors md:h-9 md:min-h-0 md:py-0",Re===K&&"bg-[color-mix(in_srgb,var(--primary)_15%,transparent)]",ye.isDir&&"font-semibold"),"data-slot":"file-entry","data-entry-type":ye.isDir?"dir":"file","data-entry-name":ye.name,"data-entry-index":Re,children:m.jsxs("span",{className:"font-mono text-[13px]",children:[ye.name,ye.isDir?"/":""]})})},ye.name))})})]})});function hI(e,t,n){const r=ly(e,t);return r?n==="file"?fo(qC(r)):r:t}function ly(e,t){const n=oa(e,t);return n?e.endsWith("/")||au(n)==="\\"&&e.endsWith("\\")?fo(n):n:""}function Nk({value:e,onValueChange:t,selectionKind:n,fileExtensions:r,includeHidden:i=!1,onCreateDirectory:s,disabled:o=!1,placeholder:l="选择路径",label:u,labelActions:d,id:f,name:h,required:y,autoFocus:g,"aria-describedby":_,"aria-invalid":w,"data-slot":S,className:x,onKeyDown:k}){const R=b.useId(),A=f??`remote-path-${R}`,M=`${A}-label`,T=qr(J=>J.homePath),P=yo("(pointer: coarse), (hover: none)"),z=pf().deviceKind,Y=P||z==="phone"||z==="tablet",[U,G]=b.useState(!1),[I,N]=b.useState(()=>hI(e,T,n)),[L,B]=b.useState(e),O=b.useRef(null),D=b.useRef(null);b.useEffect(()=>{U||L===e||B(e)},[L,U,e]),b.useEffect(()=>{if(!U)return;function J(ne){const Q=O.current,ce=ne.target;Q&&(ne.composedPath().includes(Q)||ce instanceof Node&&Q.contains(ce))||(G(!1),B(e))}return document.addEventListener("click",J),()=>document.removeEventListener("click",J)},[U,e]),b.useEffect(()=>{o&&(G(!1),B(e))},[o,e]);const F=n!=="file";function V(){if(o)return;const J=hI(e,T,n);N(J),B(e),G(!0)}function j(){G(!1),B(e)}function q(J){const ne=ly(J,T);ne&&(N(ne),B(ne),t(ne),G(!1))}function K(J){const ne=ly(J,T);ne&&N(ne)}function $(J){var ne;if(U&&((ne=D.current)!=null&&ne.handleKey(J))){J.preventDefault();return}if(J.key==="Escape"&&U){J.preventDefault(),j();return}k==null||k(J)}const te=U?m.jsx("div",{className:qe(Y&&"mt-2"),"data-slot":"remote-path-browser",children:m.jsx(fF,{ref:D,mode:"select",placement:Y?"inline":"floating",filter:I,dirsOnly:n==="directory",fileExtensions:r,includeHidden:i,autoHighlightFirst:!Y,title:l,onNavigate:K,onSelect:q,onSelectCurrentDirectory:F?q:void 0,onCreateDirectory:s})}):null;return m.jsxs("div",{className:qe("flex min-w-0 flex-col gap-1",x),children:[m.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[m.jsx("span",{id:M,className:"min-w-0 text-sm",children:u}),d?m.jsx("div",{className:"flex shrink-0 items-center gap-4",children:d}):null]}),m.jsx("div",{ref:O,className:"relative min-w-0",onBlur:J=>{if(!U||Y)return;const ne=J.relatedTarget;ne instanceof Node&&J.currentTarget.contains(ne)||window.setTimeout(()=>{var Q;(Q=O.current)!=null&&Q.contains(document.activeElement)||j()},0)},children:Y?m.jsxs(m.Fragment,{children:[m.jsxs("button",{id:A,type:"button","aria-labelledby":M,"aria-describedby":_,"aria-invalid":w,"aria-expanded":U,"aria-controls":`${A}-browser`,disabled:o,"data-slot":S,"data-path-control":"button",onClick:()=>{U?j():V()},className:"flex min-h-11 w-full min-w-0 items-center gap-2 rounded-md border border-border bg-input px-3 text-left text-base outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60",children:[m.jsx(bY,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),m.jsx("span",{className:qe("min-w-0 flex-1 truncate font-mono",e?"text-foreground":"text-muted-foreground"),title:e||void 0,children:pm(e,T)||l})]}),h?m.jsx("input",{type:"hidden",name:h,value:e,required:y}):null,m.jsx("div",{id:`${A}-browser`,children:te})]}):m.jsxs(m.Fragment,{children:[m.jsx("input",{id:A,type:"text","aria-labelledby":M,"aria-describedby":_,"aria-invalid":w,name:h,required:y,autoFocus:g,autoComplete:"off",autoCorrect:"off",spellCheck:!1,disabled:o,value:L,"data-slot":S,"data-path-control":"input",onFocus:V,onChange:J=>{const ne=J.target.value,Q=ly(ne,T);B(ne),N(Q||T),t(Q||ne),G(!0)},onKeyDown:$,placeholder:l,className:"min-h-11 min-w-0 w-full rounded-md border border-border bg-input px-3 font-mono text-base outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60 md:h-9 md:min-h-0 md:text-sm"}),te]})})]})}const pI="工作目录不存在或不可访问:",afe=[{value:"default",label:"严格审批"},{value:"auto",label:"自动判定"},{value:"acceptEdits",label:"自动接受编辑"},{value:"plan",label:"只读规划"},{value:"bypassPermissions",label:"跳过全部审批"}],hF=[{value:"auto",label:"按需审批"},{value:"bypassPermissions",label:"跳过全部审批"}],pF=[{value:"default",label:"手工审批"},{value:"auto",label:"自动审批"},{value:"plan",label:"只读规划"},{value:"bypassPermissions",label:"全自动"}],Vp={claude:"Claude Code",codex:"Codex",kimi:"Kimi Code"};function lfe(e,t){return t!==Ar.PATH_NOT_FOUND||!e.startsWith(pI)?null:e.slice(pI.length).trim()||null}function mF(e,t){if(!t)return{label:"检测中",disabled:!0};const n=t[e];return n.available?{label:"可用",disabled:!1,title:n.command}:{label:"未找到",disabled:!0,title:n.error}}function cfe(e,t){return e==="codex"?hF.some(n=>n.value===t)?t:"auto":e==="kimi"?pF.some(n=>n.value===t)?t:"default":t}async function ufe({relay:e,agentCli:t,form:n,timeoutMs:r=UC}){var d,f;const i=n.cwd.trim();if(!i)return{type:"validation_error",message:"请输入工作目录"};if(!e)return{type:"relay_missing",message:"请先连接开发机"};if(mF(n.provider,t).disabled){const h=(d=t==null?void 0:t[n.provider])==null?void 0:d.error;return{type:"provider_unavailable",message:h?`${Vp[n.provider]} 不可用:${h}`:`${Vp[n.provider]} 暂不可用`}}const o=n.mode,l=n.provider,u=n.name.trim();try{const h=await e.createSession({kind:"agent",cwd:i,name:u||void 0,mode:o,provider:l,permissionMode:n.permissionMode},r);if(!h.success){const w=lfe(h.error,h.errorCode);return w?{type:"missing_cwd",path:w,message:"找不到这个工作目录"}:{type:"create_error",message:`创建失败:${h.error}`}}if(h.kind!=="agent")return{type:"create_error",message:"创建失败:开发机返回了错误的会话类型"};const y=((f=h.name)==null?void 0:f.trim())||void 0,g={sessionId:h.sessionId,kind:"agent",name:y,...h.nameLocked!==void 0?{nameLocked:h.nameLocked}:{},state:"idle",cwd:h.cwd,lastActive:h.lastActive,provider:h.provider};return{type:"success",session:h.mode==="pty"?{...g,mode:"pty",ptyOwner:h.ptyOwner}:{...g,mode:"json"},route:`/chat/${h.sessionId}?mode=${h.mode}`}}catch(h){return{type:"exception",message:h instanceof Error?h.message:String(h)}}}async function dfe({relay:e,shell:t,timeoutMs:n=UC}){var r;if(!e)return{type:"relay_missing",message:"请先连接开发机"};try{const i=await e.createSession({kind:"terminal",mode:"pty",...t?{shell:t}:{}},n);return i.success?i.kind!=="terminal"?{type:"create_error",message:"创建终端失败:开发机返回了错误的会话类型"}:{type:"success",session:{sessionId:i.sessionId,kind:"terminal",name:((r=i.name)==null?void 0:r.trim())||void 0,...i.shellFamily!==void 0?{shellFamily:i.shellFamily}:{},...i.nameLocked!==void 0?{nameLocked:i.nameLocked}:{},state:"idle",cwd:i.cwd,lastActive:i.lastActive,mode:"pty",provider:i.provider,ptyOwner:i.ptyOwner},route:`/chat/${i.sessionId}?mode=pty`}:{type:"create_error",message:`创建终端失败:${i.error}`}}catch(i){return{type:"exception",message:i instanceof Error?i.message:String(i)}}}const ffe=["claude","codex","kimi"];function hfe({agentCli:e,provider:t,cliPathDraftProvider:n,cliPathDraft:r,savingCliPath:i,onProviderChange:s,onCliPathDraftChange:o,onDiscardCliPathDraft:l,onSaveCliPath:u}){const d=e==null?void 0:e[t],f=(d==null?void 0:d.command)??"",h=n===t,y=h?r:f,g=h&&r.trim()!==f;return m.jsxs("section",{"aria-label":"Agent CLI",className:"flex min-w-0 flex-col gap-2",children:[m.jsx("span",{className:"text-sm",children:"Agent CLI"}),m.jsxs(Kb,{value:t,disabled:i,onValueChange:_=>s(_),children:[m.jsx(Xb,{className:"min-h-11 w-full md:min-h-0","aria-label":"Agent CLI","data-slot":"agent-cli-provider-select",children:m.jsx(Gb,{})}),m.jsx(Zb,{"data-slot":"agent-cli-provider-options",children:ffe.map(_=>m.jsx(Qb,{value:_,className:"min-h-11 md:min-h-0",children:Vp[_]},_))})]}),m.jsxs("div",{className:"relative min-w-0","data-slot":"agent-cli-path-card",children:[m.jsx(Nk,{id:`agent-cli-path-${t}`,"data-slot":"agent-cli-path",label:"CLI 路径",value:y,onValueChange:_=>o(t,_),selectionKind:"file",includeHidden:!0,disabled:i,placeholder:"选择 CLI 可执行文件",labelActions:g?m.jsxs("div",{className:"flex items-center gap-4","data-slot":"agent-cli-path-actions",children:[m.jsx("button",{type:"button",className:"inline-flex min-h-11 min-w-11 items-center justify-center px-0 text-xs font-medium text-muted-foreground hover:underline focus-visible:underline focus-visible:outline-none disabled:cursor-not-allowed disabled:no-underline md:min-h-8 md:min-w-0",onClick:l,disabled:i,children:"取消"}),m.jsx("button",{type:"button",className:"inline-flex min-h-11 min-w-11 items-center justify-center px-0 text-xs font-medium text-primary hover:underline focus-visible:underline focus-visible:outline-none disabled:cursor-not-allowed disabled:text-muted-foreground disabled:no-underline md:min-h-8 md:min-w-0",onClick:u,disabled:i||!r.trim(),children:i?"保存中...":"保存"})]}):void 0,onKeyDown:_=>{_.key==="Enter"&&g&&(_.preventDefault(),_.stopPropagation(),u()),_.key==="Escape"&&h&&(_.preventDefault(),_.stopPropagation(),l())}},t),d!=null&&d.error&&!g?m.jsx("p",{className:"mt-1 break-all text-xs text-destructive",children:d.error}):null]})]})}function lp({open:e,onOpenChange:t}){var Q;const[n,r]=b.useState(""),[i,s]=b.useState(""),[o,l]=b.useState("claude"),[u,d]=b.useState("pty"),[f,h]=b.useState("default"),[y,g]=b.useState(!1),[_,w]=b.useState(!1),[S,x]=b.useState(null),[k,R]=b.useState(null),[A,M]=b.useState(""),[T,P]=b.useState(!1),z=b.useRef(e);z.current=e;const Y=Cs(),U=qr(ce=>ce.homePath),G=qr(ce=>ce.agentCli),I=yo("(min-width: 768px)");b.useEffect(()=>{e&&!i&&U&&s(U)},[e,U,i]),b.useEffect(()=>{if(!e||U&&G)return;const ce=$t==null?void 0:$t.requestProxyInfo();ce&&ce.then(re=>{const le=qr.getState();le.setHomePath(re.homePath),le.setAgentCli(re.agentCli)}).catch(re=>{console.error("[create-session-dialog] requestProxyInfo failed",re)})},[e,U,G]);function N(){r(""),s(""),l("claude"),d("pty"),h("default"),g(!1),x(null),R(null),M(""),P(!1)}function L(){if(f==="bypassPermissions"){g(!0);return}q()}async function B(){await q(),z.current&&g(!1)}const O=o==="codex"?hF:o==="kimi"?pF:afe,D=mF(o,G),F=k===o&&A.trim()!==(((Q=G==null?void 0:G[o])==null?void 0:Q.command)??""),V=_||T||D.disabled||F;function j(ce){const re=cfe(ce,f);re!==f&&h(re)}async function q(ce){x(null),w(!0);try{const re=await ufe({relay:$t,agentCli:G,form:{cwd:ce??i,name:n,provider:o,permissionMode:f,mode:u}});if(re.type==="success"){if(Ut.getState().addSession(re.session),!z.current)return;t(!1),N(),Y(re.route);return}if(re.type==="missing_cwd"&&x(re.path),Ue.error(re.message),re.type==="validation_error"||re.type==="relay_missing")return}finally{w(!1)}}async function K(ce){const re=$t;if(!re)return Ue.error("请先连接开发机"),null;try{const le=await re.createDirectory(ce);return le.success?(x(null),Ue.success("目录已创建"),le.path):(Ue.error(`目录创建失败:${le.error??"未知错误"}`),null)}catch(le){return Ue.error(le instanceof Error?le.message:String(le)),null}}function $(ce,re){R(ce),M(re)}async function te(){if(!k)return;const ce=k,re=A.trim();if(!re){Ue.error("请选择 Agent CLI 可执行文件");return}const le=$t;if(!le){Ue.error("请先连接开发机");return}P(!0);try{const we=await le.updateAgentCliPath(ce,re);if(we.error||!we.agentCli){Ue.error(`路径保存失败:${we.error??"未知错误"}`);return}qr.getState().setAgentCli(we.agentCli),Ue.success(`${Vp[ce]} 路径已保存`),R(null),M("")}catch(we){Ue.error(we instanceof Error?we.message:String(we))}finally{P(!1)}}function J(ce){d(ce),j(o)}const ne=y?m.jsxs("div",{className:"grid min-w-0 gap-5","data-slot":"bypass-permission-confirmation",children:[m.jsx(cF,{providerLabel:Vp[o]}),m.jsxs(qs,{children:[m.jsx(vt,{type:"button",variant:"ghost",className:"min-h-11 md:min-h-0",onClick:()=>g(!1),disabled:_,children:"返回"}),m.jsx(vt,{type:"button",variant:"destructive",className:"min-h-11 md:min-h-0",onClick:()=>void B(),disabled:_,"data-slot":"bypass-permission-confirm",children:_?"创建中...":"确认"})]})]}):m.jsxs("form",{className:"flex min-w-0 flex-col gap-4","data-slot":"create-session-form",autoComplete:"off",onSubmit:ce=>{ce.preventDefault(),L()},children:[m.jsxs("label",{className:"flex min-w-0 flex-col gap-1",children:[m.jsx("span",{className:"text-sm",children:"名称(可选)"}),m.jsx("input",{type:"text",name:"dev-anywhere-session-name",autoComplete:"off",autoCorrect:"off",spellCheck:!1,value:n,onChange:ce=>r(ce.target.value),className:"min-h-11 min-w-0 rounded-md border border-border bg-input px-3 text-base outline-none focus-visible:ring-2 focus-visible:ring-ring md:h-9 md:min-h-0 md:text-sm",placeholder:"自动生成"})]}),m.jsx(Nk,{id:"create-session-cwd",name:"dev-anywhere-session-cwd","data-slot":"create-session-cwd",label:"工作目录",value:i,selectionKind:"directory",placeholder:"选择工作目录",onCreateDirectory:K,onValueChange:ce=>{s(ce),x(null)}}),S?m.jsxs("section",{role:"status","aria-live":"polite",className:"rounded-md border border-primary/50 bg-primary/10 p-3",children:[m.jsx("p",{className:"text-sm font-medium",children:"工作目录不存在"}),m.jsx("p",{className:"mt-1 break-all font-mono text-xs text-muted-foreground",children:S})]}):null,m.jsxs("section",{"aria-label":"交互方式",className:"flex min-w-0 flex-col gap-2",children:[m.jsx("span",{className:"text-sm",children:"交互方式"}),m.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-2 sm:grid-cols-2",children:[m.jsxs("button",{type:"button","aria-pressed":u==="pty",onClick:()=>J("pty"),className:qe("flex min-h-14 min-w-0 flex-col items-start justify-center gap-1 rounded-md border px-3 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",u==="pty"?"border-primary/70 bg-primary/10":"border-border bg-muted/20"),children:[m.jsx("span",{className:"text-sm font-medium",children:"终端模式"}),m.jsx("span",{className:"text-xs text-muted-foreground",children:"像本地终端一样操作"})]}),m.jsxs("button",{type:"button","aria-pressed":u==="json",onClick:()=>J("json"),className:qe("flex min-h-14 min-w-0 flex-col items-start justify-center gap-1 rounded-md border px-3 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",u==="json"?"border-primary/70 bg-primary/10":"border-border bg-muted/20"),children:[m.jsx("span",{className:"text-sm font-medium",children:"聊天模式"}),m.jsx("span",{className:"text-xs text-muted-foreground",children:"气泡式对话,支持 Voice Pilot"})]})]})]}),m.jsx(hfe,{agentCli:G,provider:o,cliPathDraftProvider:k,cliPathDraft:A,savingCliPath:T,onProviderChange:ce=>{l(ce),j(ce),R(null),M("")},onCliPathDraftChange:$,onDiscardCliPathDraft:()=>{R(null),M("")},onSaveCliPath:()=>void te()}),m.jsxs("label",{className:"flex min-w-0 flex-col gap-2",children:[m.jsx("span",{className:"text-sm",children:"权限模式"}),m.jsxs(Kb,{value:f,onValueChange:ce=>h(ce),children:[m.jsx(Xb,{className:"w-full",children:m.jsx(Gb,{})}),m.jsx(Zb,{children:O.map(ce=>m.jsx(Qb,{value:ce.value,children:ce.label},ce.value))})]})]}),m.jsxs(qs,{children:[m.jsx(vt,{type:"button",variant:"ghost",className:"min-h-11 md:min-h-0",onClick:()=>t(!1),disabled:_,children:"取消"}),m.jsx(vt,{type:"submit",className:"min-h-11 md:min-h-0",disabled:V,children:_?"创建中...":"创建"})]})]});return I?m.jsx(es,{open:e,onOpenChange:t,children:m.jsxs(ts,{className:"!w-[calc(100vw-2rem)] !max-w-none max-h-[calc(100dvh-2rem)] overflow-y-auto sm:!w-[44rem]","data-slot":"create-session-dialog",focusSurfaceOnOpen:!0,children:[m.jsx(ns,{children:m.jsx($i,{children:y?"跳过全部审批?":"新建会话"})}),ne]})}):m.jsx(pc,{open:e,onOpenChange:t,children:m.jsxs(mc,{side:"bottom",className:"inset-x-2 max-h-[calc(100dvh-0.75rem)] w-auto overflow-x-hidden overflow-y-auto rounded-t-xl border bg-background px-4 pb-[max(theme(spacing.4),env(safe-area-inset-bottom))] pt-3","data-slot":"create-session-dialog",focusSurfaceOnOpen:!0,children:[m.jsx(Eu,{className:"px-0 pb-1 pt-0 text-left",children:m.jsx(gc,{children:y?"跳过全部审批?":"新建会话"})}),ne]})})}function cp({open:e,sessionId:t,initialName:n,onOpenChange:r,onRename:i}){const s=b.useMemo(()=>(n==null?void 0:n.trim())??"",[n]),[o,l]=b.useState(s),[u,d]=b.useState(null),[f,h]=b.useState(!1);b.useEffect(()=>{e&&(l(s),d(null),h(!1))},[s,e]);async function y(g){g.preventDefault();const _=o.trim();if(!_){d("会话标题不能为空");return}if(t){h(!0);try{await i(t,_),r(!1)}catch(w){d(w instanceof Error?w.message:String(w))}finally{h(!1)}}}return m.jsx(es,{open:e,onOpenChange:r,children:m.jsx(ts,{className:"sm:max-w-md","data-slot":"session-rename-dialog",children:m.jsxs("form",{className:"grid gap-4",onSubmit:g=>void y(g),children:[m.jsxs(ns,{children:[m.jsx($i,{children:"重命名会话"}),m.jsx(Es,{children:"自定义名称会显示在会话列表和顶部标题中。"})]}),m.jsxs("div",{className:"grid gap-2",children:[m.jsx("label",{htmlFor:"session-rename-title",className:"text-sm font-medium",children:"会话标题"}),m.jsx("input",{id:"session-rename-title",value:o,autoFocus:!0,maxLength:100,"aria-invalid":!!u,"aria-describedby":u?"session-rename-error":void 0,className:qe("h-10 rounded-md border border-input bg-background px-3 text-sm shadow-xs outline-none transition-[border-color,box-shadow]","placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/75","disabled:cursor-not-allowed disabled:opacity-50",u&&"border-destructive focus-visible:ring-destructive/20"),disabled:f,onChange:g=>{l(g.target.value),u&&d(null)}}),u?m.jsx("p",{id:"session-rename-error",className:"text-sm text-destructive",children:u}):null]}),m.jsxs(qs,{children:[m.jsx(vt,{type:"button",variant:"outline",onClick:()=>r(!1),children:"取消"}),m.jsx(vt,{type:"submit",disabled:f,children:"保存"})]})]})})})}function pfe(e){return(e==null?void 0:e.kind)==="agent"&&e.mode==="pty"&&e.ptyOwner==="local-terminal"}function mfe(e){return(e==null?void 0:e.kind)==="terminal"}function gfe(e){return pfe(e)?{title:"断开远程连接?",description:"这只会断开当前页面和本地终端的连接,本地终端里的 Claude Code/Codex/Kimi Code 会继续运行。重新接入前,页面不能继续查看或输入这个会话。",confirmLabel:"断开远程连接",destructive:!1}:mfe(e)?{title:"终止终端?",description:"这会停止当前终端进程,并清理这个终端会话的运行状态。终止后不能继续输入,也无法恢复正在执行的命令。",confirmLabel:"终止终端",destructive:!0}:{title:"终止会话?",description:"这会停止当前 Agent 进程,并清理这个会话的运行状态。终止后不能继续输入,也无法恢复正在执行的任务。",confirmLabel:"终止会话",destructive:!0}}function bv({open:e,session:t,onOpenChange:n,onConfirm:r}){const i=gfe(t);function s(){t&&(r(t),n(!1))}return m.jsx(es,{open:e,onOpenChange:n,children:m.jsxs(ts,{"data-slot":"session-termination-dialog",children:[m.jsxs(ns,{children:[m.jsx($i,{children:i.title}),m.jsx(Es,{children:i.description})]}),m.jsxs(qs,{children:[m.jsx(vt,{type:"button",variant:"ghost",onClick:()=>n(!1),children:"取消"}),m.jsx(vt,{type:"button",variant:i.destructive?"destructive":"default",onClick:s,"data-slot":"session-termination-confirm",children:i.confirmLabel})]})]})})}function gF(e){var t,n,r,i,s,o,l,u,d,f,h,y;return e.connected===!1||e.proxyOnline===!1?"disconnected":e.routeSessionEnded||((t=e.session)==null?void 0:t.state)==="terminated"?"terminated":((n=e.session)==null?void 0:n.state)==="error"?"error":e.hasPendingApproval||((r=e.session)==null?void 0:r.state)==="waiting_approval"?"waiting_approval":((i=e.session)==null?void 0:i.state)==="compacting"?"compacting":((s=e.session)==null?void 0:s.state)==="working"?"working":((o=e.session)==null?void 0:o.state)==="idle"?"idle":((l=e.agentStatus)==null?void 0:l.phase)==="waiting_permission"||((u=e.ptyState)==null?void 0:u.state)==="approval_wait"?"waiting_approval":((d=e.agentStatus)==null?void 0:d.phase)==="thinking"||((f=e.agentStatus)==null?void 0:f.phase)==="tool_use"||((h=e.agentStatus)==null?void 0:h.phase)==="outputting"||((y=e.ptyState)==null?void 0:y.state)==="working"?"working":"idle"}function vfe(e){if(e.session.state==="error")return"error";const t=gF(e);return t==="disconnected"?e.session.state:t}const yfe=new Set(["localhost","127.0.0.1","[::1]"]),N1={cloudflare:{label:"Cloudflare Tunnel",executable:"cloudflared",installUrl:"https://developers.cloudflare.com/tunnel/downloads/"},cpolar:{label:"Cpolar",executable:"cpolar"}};function bfe(){return Ni("local",_n.webPreviewTunnelProvider)==="cpolar"?"cpolar":"cloudflare"}function vF(e,t){if(e)return t==="cloudflare"?e.cloudflared:e.cpolar}function b0(e,t){var n;return((n=vF(e,t))==null?void 0:n.available)===!0}function _fe(e){const t=e.trim();if(!t)return"请输入本机网站地址";let n;try{n=new URL(t)}catch{return"请输入完整的 http:// 本机网站地址"}return n.protocol!=="http:"||!yfe.has(n.hostname)||n.username!==""||n.password!==""?"只支持 localhost、127.0.0.1 或 [::1] 的 http:// 地址":null}function Mh(){return{status:"idle"}}function wfe({open:e,onOpenChange:t}){const[n,r]=b.useState(""),[i,s]=b.useState(bfe),[o,l]=b.useState("local"),[u,d]=b.useState(""),[f,h]=b.useState(""),[y,g]=b.useState(""),[_,w]=b.useState(Mh),[S,x]=b.useState(!1),k=b.useRef(null),R=b.useRef(null),A=b.useRef(null),M=b.useRef(null),T=b.useRef(i);T.current=i;const P=b.useRef(e);P.current=e;const z=yo("(min-width: 768px)"),Y=Me(ne=>ne.selectedProxyId),U=Hr(ne=>ne.capability),G=Hr(ne=>ne.capabilityStatus),I=Hr(ne=>ne.capabilityError),N=Hr(ne=>{var Q;return((Q=ne.authoritative)==null?void 0:Q.scope)??null}),L=N?`${N.proxyId}\0${N.bindingId}`:null,B=b.useCallback(ne=>{T.current=ne,s(ne),Rr("local",_n.webPreviewTunnelProvider,ne)},[]);function O(){var ne,Q;r(""),l("local"),d(""),h(""),g(""),w(Mh()),x(!1),(ne=k.current)==null||ne.abort(),k.current=null,(Q=R.current)==null||Q.abort(),R.current=null,A.current=null,M.current=null}const D=b.useCallback(async ne=>{var re;(re=k.current)==null||re.abort();const Q=new AbortController;k.current=Q;const ce=Pt.getActiveScope();if(!(!ce||ce.proxyId!==Y))try{const le=await Pt.requestWebPreviewCapability(ce,ne,{signal:Q.signal});if(!le||Q.signal.aborted||!P.current||!le.success)return;const we=T.current,Ce=we==="cloudflare"?"cpolar":"cloudflare";!b0(le.capability,we)&&b0(le.capability,Ce)&&B(Ce)}catch{}},[B,Y]);function F(ne){!ne&&S||t(ne)}b.useEffect(()=>{if(!e){O();return}return D(!1),()=>{var ne;(ne=k.current)==null||ne.abort(),k.current=null}},[D,e,L]),b.useEffect(()=>{var re;if(!e||o!=="static")return;(re=R.current)==null||re.abort(),R.current=null;const ne=f.trim();if(!ne){w(Mh()),g("");return}const Q=new AbortController;R.current=Q,w({status:"loading"}),g("");const ce=window.setTimeout(()=>{const le=$t,we=Pt.getActiveScope();if(!le||!we||we.proxyId!==Y){w({status:"error",message:"请先连接开发机"});return}Pt.inspectStaticWebPreview(we,ne,{signal:Q.signal}).then(Ce=>{if(!Ce||Q.signal.aborted||!P.current||!Pt.isActive(le,we))return;if(!Ce.success){w({status:"error",message:Ce.error});return}const ye=Ce.htmlEntries;if(ye.length===0&&!Ce.entryPath){w({status:"error",message:"这里没有可以预览的网页"});return}const Re={entryPath:Ce.entryPath,htmlEntries:ye};w({status:"ready",path:ne,result:Re}),g(Ce.entryPath??"")}).catch(Ce=>{Q.signal.aborted||!P.current||Ce instanceof Error&&Ce.name==="AbortError"||!Pt.isActive(le,we)||w({status:"error",message:Ce instanceof Error?Ce.message:"检查网页失败"})})},300);return()=>{window.clearTimeout(ce),Q.abort(),R.current===Q&&(R.current=null)}},[e,L,Y,o,f]);const V=o==="local"?_fe(u):null,j=o==="static"&&_.status==="ready"&&_.path===f.trim()&&!!(_.result.entryPath||y),q=G==="loaded"&&b0(U,i),$=S||!q||!(o==="local"?V===null:j);async function te(){var le,we,Ce;if($)return;const ne=$t;if(!ne){Ue.error("请先连接开发机");return}let Q;if(o==="local")Q={kind:"local",url:u.trim()};else{if(_.status!=="ready"||_.path!==f.trim())return;const ye=_.result.entryPath??y;if(!ye)return;Q={kind:"static",path:_.path,entryPath:ye}}x(!0);const ce=Pt.getActiveScope();if(!ce){x(!1),Ue.error("请先连接开发机");return}let re=null;try{const ye=n.trim(),Re=JSON.stringify({proxyId:ce.proxyId,tunnelProvider:i,source:Q,name:ye||void 0});((le=A.current)==null?void 0:le.sourceKey)!==Re&&(A.current={sourceKey:Re,operationId:hm(`preview-operation-${i}`)}),re=A.current.operationId,M.current=re;const Rt=await Pt.createWebPreview(ce,Q,{tunnelProvider:i,operationId:re,...ye?{name:ye}:{}});if(M.current!==re)return;if(!Rt.accepted){((we=A.current)==null?void 0:we.operationId)===re&&(A.current=null),Ue.error(Rt.error);return}if(((Ce=A.current)==null?void 0:Ce.operationId)===re&&(A.current=null),!P.current||!Pt.isActive(ne,ce))return;t(!1)}catch(ye){if(!re||M.current!==re||!P.current||!Pt.isActive(ne,ce))return;Ue.error(ye instanceof Error?ye.message:"无法创建网页预览")}finally{re&&M.current===re&&(M.current=null,P.current&&x(!1))}}const J=m.jsxs("form",{className:"flex min-w-0 flex-col gap-4","data-slot":"create-web-preview-form",autoComplete:"off",onSubmit:ne=>{ne.preventDefault(),te()},children:[m.jsxs("label",{className:"flex min-w-0 flex-col gap-1",children:[m.jsx("span",{className:"text-sm",children:"名称(可选)"}),m.jsx("input",{type:"text",name:"dev-anywhere-web-preview-name",value:n,maxLength:256,autoComplete:"off",autoCorrect:"off",spellCheck:!1,disabled:S,placeholder:"自动生成","data-slot":"web-preview-name",onChange:ne=>{r(ne.target.value)},className:"min-h-11 min-w-0 rounded-md border border-border bg-input px-3 text-base outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60 md:h-9 md:min-h-0 md:text-sm"})]}),m.jsxs("section",{className:"flex min-w-0 flex-col gap-1","data-slot":"web-preview-tunnel-provider-field","data-provider":i,children:[m.jsx("span",{className:"text-sm",children:"内网穿透服务"}),m.jsxs(Kb,{value:i,disabled:S,onValueChange:ne=>B(ne),children:[m.jsx(Xb,{"aria-label":"内网穿透服务","data-slot":"web-preview-tunnel-provider-select","data-provider":i,className:"min-h-11 w-full md:min-h-0",children:m.jsx(Gb,{})}),m.jsx(Zb,{"data-slot":"web-preview-tunnel-provider-options",children:Object.keys(N1).map(ne=>m.jsx(Qb,{value:ne,"data-slot":"web-preview-tunnel-provider-option","data-provider":ne,children:N1[ne].label},ne))})]})]}),m.jsx(xfe,{status:G,capability:U,provider:i,error:I,disabled:S,onRetry:()=>void D(!0)}),m.jsxs("section",{"aria-label":"网页来源",className:"flex min-w-0 flex-col gap-2",children:[m.jsx("span",{className:"text-sm",children:"网页来源"}),m.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-2 sm:grid-cols-2",children:[m.jsxs("button",{type:"button","data-slot":"web-preview-source-local",disabled:S,"aria-pressed":o==="local",onClick:()=>{var ne;(ne=R.current)==null||ne.abort(),R.current=null,w(Mh()),g(""),l("local")},className:qe("flex min-h-16 min-w-0 flex-col items-start justify-center gap-1 rounded-md border px-3 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60",o==="local"?"border-primary/70 bg-primary/10":"border-border bg-muted/20"),children:[m.jsx("span",{className:"text-sm font-medium",children:"本机网站"}),m.jsx("span",{className:"text-xs text-muted-foreground",children:"输入 localhost 地址"})]}),m.jsxs("button",{type:"button","data-slot":"web-preview-source-static",disabled:S,"aria-pressed":o==="static",onClick:()=>{var ne;(ne=R.current)==null||ne.abort(),R.current=null,w(Mh()),g(""),l("static")},className:qe("flex min-h-16 min-w-0 flex-col items-start justify-center gap-1 rounded-md border px-3 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60",o==="static"?"border-primary/70 bg-primary/10":"border-border bg-muted/20"),children:[m.jsx("span",{className:"text-sm font-medium",children:"网页文件"}),m.jsx("span",{className:"text-xs text-muted-foreground",children:"选择 HTML 网页文件或目录"})]})]})]}),o==="local"?m.jsxs("label",{className:"flex min-w-0 flex-col gap-1",children:[m.jsx("span",{className:"text-sm",children:"本机网站地址"}),m.jsx("input",{type:"url","data-slot":"web-preview-local-url","aria-label":"本机网站地址",inputMode:"url",name:"dev-anywhere-preview-local-url",autoComplete:"off",autoCorrect:"off",spellCheck:!1,disabled:S,value:u,onChange:ne=>{d(ne.target.value)},placeholder:"http://localhost:5173","aria-invalid":u.length>0&&V!==null,className:"min-h-11 min-w-0 rounded-md border border-border bg-input px-3 font-mono text-base outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60 md:h-9 md:min-h-0 md:text-sm"}),u.length>0&&V?m.jsx("span",{"data-slot":"web-preview-local-url-error",className:"text-xs text-destructive",role:"alert",children:V}):null]}):m.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[m.jsx(Nk,{id:"create-web-preview-path",name:"dev-anywhere-preview-static-path","data-slot":"web-preview-static-path",label:"网页位置",value:f,selectionKind:"file-or-directory",fileExtensions:[".html",".htm"],disabled:S,placeholder:"选择 HTML 网页文件或目录",onValueChange:h}),m.jsx(Sfe,{inspection:_,selectedEntryPath:y,disabled:S,onEntryPathChange:ne=>{g(ne)}})]}),m.jsxs(qs,{children:[m.jsx(vt,{type:"button",variant:"ghost","data-slot":"create-web-preview-cancel",className:"min-h-11 md:min-h-0",onClick:()=>F(!1),disabled:S,children:"取消"}),m.jsx(vt,{type:"submit",className:"min-h-11 md:min-h-0",disabled:$,"data-slot":"create-web-preview-submit",children:S?"正在创建...":"创建预览"})]})]});return z?m.jsx(es,{open:e,onOpenChange:F,children:m.jsxs(ts,{showCloseButton:!S,onEscapeKeyDown:ne=>{S&&ne.preventDefault()},onPointerDownOutside:ne=>{S&&ne.preventDefault()},className:"!w-[calc(100vw-2rem)] !max-w-none max-h-[calc(100dvh-2rem)] overflow-y-auto sm:!w-[40rem]","data-slot":"create-web-preview-dialog",focusSurfaceOnOpen:!0,children:[m.jsxs(ns,{children:[m.jsx($i,{children:"新建网页预览"}),m.jsx(Es,{children:"输入本机网站地址,或选择 HTML 网页文件或目录。"})]}),J]})}):m.jsx(pc,{open:e,onOpenChange:F,children:m.jsxs(mc,{side:"bottom",showCloseButton:!S,onEscapeKeyDown:ne=>{S&&ne.preventDefault()},onPointerDownOutside:ne=>{S&&ne.preventDefault()},className:"inset-x-2 max-h-[calc(100dvh-0.75rem)] w-auto overflow-x-hidden overflow-y-auto rounded-t-xl border bg-background px-4 pb-[max(theme(spacing.4),env(safe-area-inset-bottom))] pt-3","data-slot":"create-web-preview-dialog",focusSurfaceOnOpen:!0,children:[m.jsxs(Eu,{className:"px-0 pb-1 pt-0 text-left",children:[m.jsx(gc,{children:"新建网页预览"}),m.jsx(Vb,{children:"输入本机网站地址,或选择 HTML 网页文件或目录。"})]}),J]})})}function xfe({status:e,capability:t,provider:n,error:r,disabled:i,onRetry:s}){const o=N1[n];if(e==="loading"||e==="idle")return m.jsxs("div",{"data-slot":"web-preview-capability-status","data-status":"loading","data-provider":n,className:"flex items-center gap-2 rounded-md border border-border/70 bg-muted/20 px-3 py-2 text-sm text-muted-foreground",role:"status",children:[m.jsx(li,{className:"size-4 animate-spin","aria-hidden":"true"}),"正在检测 ",o.label,"..."]});if(e==="error")return m.jsx("div",{"data-slot":"web-preview-capability-status","data-status":"error","data-provider":n,className:"rounded-md border border-destructive/45 bg-destructive/5 p-3",role:"alert",children:m.jsxs("div",{className:"flex items-start gap-2",children:[m.jsx(wz,{className:"mt-0.5 size-4 shrink-0 text-destructive","aria-hidden":"true"}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsxs("p",{className:"text-sm font-medium",children:["无法检测 ",o.label]}),r?m.jsx("p",{className:"mt-1 break-words text-xs text-muted-foreground",children:r}):null]}),m.jsx(mI,{onClick:s,disabled:i})]})});const l=vF(t,n);if(!(l!=null&&l.available)){const u=(l==null?void 0:l.suggestions)??[],d=`未找到 ${o.label}`,f=(l==null?void 0:l.error)&&l.error!==d;return m.jsx("div",{"data-slot":"web-preview-capability-status","data-status":"missing","data-provider":n,className:"rounded-md border border-[var(--color-status-warning)]/45 bg-[var(--color-status-warning)]/5 p-3",role:"alert",children:m.jsxs("div",{className:"flex items-start gap-2",children:[m.jsx(YV,{className:"mt-0.5 size-4 shrink-0 text-[var(--color-status-warning)]","aria-hidden":"true"}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsx("p",{className:"text-sm font-medium",children:d}),m.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["请先安装 ",o.executable,",并确保它在用户 Shell 的 PATH 中,然后重新检测。"]}),u.length>0?m.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:[m.jsx("span",{children:"检测到的位置:"}),m.jsx("ul",{className:"mt-1 space-y-1",children:u.map(h=>m.jsx("li",{"data-slot":n==="cloudflare"?"web-preview-cloudflared-suggestion":"web-preview-cpolar-suggestion","data-provider":n,"data-path":h,children:m.jsx("code",{className:"break-all rounded bg-muted px-1 py-0.5",children:h})},h))})]}):null,o.installUrl?m.jsx("a",{"data-slot":"web-preview-cloudflared-install-link","data-provider":n,href:o.installUrl,target:"_blank",rel:"noopener noreferrer",className:"mt-2 inline-block text-xs text-primary underline-offset-4 hover:underline",children:"查看官方安装说明"}):null,f?m.jsx("p",{className:"mt-1 break-words text-xs text-muted-foreground/80",children:l.error}):null]}),m.jsx(mI,{onClick:s,disabled:i})]})})}return m.jsxs("div",{"data-slot":"web-preview-capability-status","data-status":"ready","data-provider":n,className:"flex items-center gap-2 rounded-md border border-[var(--color-status-success)]/35 bg-[var(--color-status-success)]/5 px-3 py-2 text-sm",role:"status",children:[m.jsx(jV,{className:"size-4 text-[var(--color-status-success)]","aria-hidden":"true"}),m.jsxs("span",{children:[o.label," 已安装"]}),l.version?m.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:["· ",l.version]}):null]})}function mI({onClick:e,disabled:t}){return m.jsxs(vt,{type:"button",variant:"outline",size:"sm","data-slot":"web-preview-capability-retry",className:"shrink-0",onClick:e,disabled:t,children:[m.jsx(um,{className:"size-3.5","aria-hidden":"true"}),"重新检测"]})}function Sfe({inspection:e,selectedEntryPath:t,disabled:n,onEntryPathChange:r}){if(e.status==="idle")return null;if(e.status==="loading")return m.jsxs("span",{"data-slot":"web-preview-static-inspection","data-status":"loading",className:"flex items-center gap-2 text-xs text-muted-foreground",role:"status",children:[m.jsx(li,{className:"size-3.5 animate-spin","aria-hidden":"true"}),"正在检查网页..."]});if(e.status==="error")return m.jsx("span",{"data-slot":"web-preview-static-inspection","data-status":"error",className:"text-xs text-destructive",role:"alert",children:e.message});if(!e.result.entryPath&&e.result.htmlEntries.length>1)return m.jsxs("label",{"data-slot":"web-preview-static-inspection","data-status":"choose-entry",className:"mt-1 flex min-w-0 flex-col gap-2",children:[m.jsx("span",{className:"text-sm",children:"这个文件夹里有多个网页,打开预览时先显示哪个?"}),m.jsxs(Kb,{value:t,onValueChange:r,disabled:n,children:[m.jsx(Xb,{"data-slot":"web-preview-entry-select",className:"w-full font-mono",children:m.jsx(Gb,{placeholder:"选择网页"})}),m.jsx(Zb,{children:e.result.htmlEntries.map(o=>m.jsx(Qb,{value:o,"data-entry-path":o,children:o},o))})]})]});const s=e.result.entryPath;return s?m.jsxs("span",{"data-slot":"web-preview-static-inspection","data-status":"ready","data-entry-path":s,className:"truncate text-xs text-muted-foreground",title:s,children:["打开时显示:",m.jsx("span",{className:"font-mono",children:s})]}):null}const M1={ios:"iOS Simulator",android:"Android Emulator"};function Efe({open:e,platform:t,onOpenChange:n}){const r=Cs(),i=yo("(min-width: 768px)"),s=Me(F=>F.selectedProxyId),o=fr(F=>F.capability),l=fr(F=>F.targets),u=fr(F=>F.targetsStatus),d=fr(F=>F.targetsError),f=fr(c5),h=fr(F=>{var V;return((V=F.authoritative)==null?void 0:V.scope)??null}),y=h?`${h.proxyId}\0${h.bindingId}`:null,[g,_]=b.useState(""),[w,S]=b.useState(null),[x,k]=b.useState(!1),R=b.useRef(null),A=b.useRef(e);A.current=e;const M=b.useRef(null),T=b.useRef(null),P=b.useMemo(()=>l.filter(F=>F.platform===t),[t,l]),z=b.useMemo(()=>new Set(f.map(F=>F.targetId)),[f]),Y=b.useMemo(()=>P.filter(F=>!z.has(F.targetId)),[z,P]),U=Y.find(F=>F.targetId===w),G=o==null?void 0:o[t],I=b.useCallback(async F=>{var K;(K=R.current)==null||K.abort();const V=new AbortController;R.current=V;const j=$t,q=Pt.getActiveScope();if(!(!j||!q||q.proxyId!==s))try{const $=await Pt.requestDevicePreviewCapability(q,F,{signal:V.signal});if(!$||V.signal.aborted||!A.current||!$.success)return;await Pt.requestDevicePreviewTargets(q,!0,{signal:V.signal})}catch{}},[s]);b.useEffect(()=>{var F;if(!e){(F=R.current)==null||F.abort(),R.current=null,_(""),S(null),k(!1),M.current=null,T.current=null;return}return I(!1),()=>{var V;(V=R.current)==null||V.abort(),R.current=null}},[I,e,t,y]),b.useEffect(()=>{if(e){if(w&&!U){S(null);return}!w&&Y.length===1&&S(Y[0].targetId)}},[e,Y,U,w]);async function N(){var K,$,te;const F=U;if(!F||x||(G==null?void 0:G.available)!==!0)return;const V=$t,j=Pt.getActiveScope();if(!V||!j||j.proxyId!==s){Ue.error("请先连接开发机");return}k(!0);let q=null;try{const J=g.trim(),ne=((K=M.current)==null?void 0:K.proxyId)===j.proxyId&&M.current.targetId===F.targetId&&M.current.name===J?M.current:{proxyId:j.proxyId,targetId:F.targetId,name:J,operationId:hm("device-preview-operation")};M.current=ne,q=ne.operationId,T.current=q;const Q=await Pt.createDevicePreview(j,F.targetId,{operationId:ne.operationId,...J?{name:J}:{}});if(T.current!==ne.operationId)return;if(!Q.accepted){if((($=M.current)==null?void 0:$.operationId)===ne.operationId&&(M.current=null),!A.current||!Pt.isActive(V,j))return;Ue.error(Q.error);return}if(((te=M.current)==null?void 0:te.operationId)===ne.operationId&&(M.current=null),!A.current||!Pt.isActive(V,j))return;n(!1),r(`/preview/device/${Q.previewId}`)}catch(J){if(!q||T.current!==q||!A.current||!Pt.isActive(V,j))return;Ue.error(J instanceof Error?J.message:"无法创建模拟器预览")}finally{q&&T.current===q&&(T.current=null,A.current&&k(!1))}}function L(F){var V;!F&&x||(F||((V=R.current)==null||V.abort(),R.current=null,M.current=null,T.current=null,_(""),S(null)),n(F))}const B=m.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-4",children:[m.jsxs("label",{className:"flex min-w-0 flex-col gap-1",children:[m.jsx("span",{className:"text-sm",children:"名称(可选)"}),m.jsx("input",{type:"text",name:"dev-anywhere-device-preview-name",value:g,maxLength:256,autoComplete:"off",autoCorrect:"off",spellCheck:!1,disabled:x,placeholder:"自动生成","data-slot":"device-preview-name",onChange:F=>{_(F.target.value)},className:"min-h-11 min-w-0 rounded-md border border-border bg-input px-3 text-base outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60 md:h-9 md:min-h-0 md:text-sm"})]}),m.jsx(Cfe,{platform:t,tool:G}),m.jsx("div",{className:"grid min-w-0 grid-cols-1 gap-2","data-slot":"device-preview-targets",children:u==="loading"?m.jsxs("div",{className:"flex min-h-28 items-center justify-center gap-2 text-sm text-muted-foreground",children:[m.jsx(li,{className:"size-4 animate-spin","aria-hidden":"true"}),"正在查找已启动的模拟器..."]}):u==="error"?m.jsx(gI,{message:d??"无法读取模拟器列表"}):P.length===0?m.jsx(gI,{message:`没有已启动的 ${M1[t]}`}):P.map(F=>{const V=F.targetId===w,j=z.has(F.targetId);return m.jsx(kfe,{target:F,selected:V,disabled:j||x,alreadyOpen:j,onClick:()=>{S(F.targetId)}},F.targetId)})}),m.jsxs(qs,{className:"gap-2 sm:gap-2",children:[m.jsxs(vt,{type:"button",variant:"outline",disabled:x||u==="loading",onClick:()=>void I(!0),"data-slot":"device-preview-refresh",children:[m.jsx(um,{className:"size-4","aria-hidden":"true"}),"重新检测"]}),m.jsx(vt,{type:"button",disabled:!U||x||(G==null?void 0:G.available)!==!0,onClick:()=>void N(),"data-slot":"create-device-preview-submit",children:x?"正在创建...":"创建预览"})]})]}),O=`新建 ${M1[t]} 预览`,D="选择开发机上已经启动的模拟器。";return i?m.jsx(es,{open:e,onOpenChange:L,children:m.jsxs(ts,{showCloseButton:!x,className:"sm:max-w-xl","data-slot":"create-device-preview-dialog","data-platform":t,focusSurfaceOnOpen:!0,children:[m.jsxs(ns,{children:[m.jsx($i,{children:O}),m.jsx(Es,{children:D})]}),B]})}):m.jsx(pc,{open:e,onOpenChange:L,children:m.jsxs(mc,{side:"bottom",showCloseButton:!x,className:"inset-x-2 max-h-[calc(100dvh-0.75rem)] w-auto min-w-0 max-w-[calc(100%-1rem)] overflow-x-hidden overflow-y-auto rounded-t-xl border bg-background px-4 pb-[max(theme(spacing.4),env(safe-area-inset-bottom))] pt-3","data-slot":"create-device-preview-dialog","data-platform":t,focusSurfaceOnOpen:!0,children:[m.jsxs(Eu,{className:"px-0 pb-1 pt-0 text-left",children:[m.jsx(gc,{children:O}),m.jsx(Vb,{children:D})]}),B]})})}function Cfe({platform:e,tool:t}){if(!t||t.available)return null;const n=e==="android"&&!!t.command,r=e==="ios"?"Baguette":"adb",i=t.supported?e==="ios"&&t.version?"outdated":t.command?"unavailable":"missing":"unsupported",s=n?"Android 模拟器预览不可用":i==="unsupported"?`${M1[e]} 不可用`:i==="outdated"?`需要更新 ${r}`:i==="unavailable"?`${r} 暂时不可用`:`未找到 ${r}`,o=t.error??(e==="ios"?"需要先在开发机上安装 Baguette 0.1.96 或更高版本。":"需要先在开发机上安装 adb。"),l=o.trim()!==s.trim();return m.jsx("div",{className:"rounded-lg border border-amber-500/45 bg-amber-500/5 p-3 text-sm","data-slot":"device-preview-tool-status","data-status":i,children:m.jsxs("div",{className:"flex gap-2",children:[m.jsx(wz,{className:"mt-0.5 size-4 shrink-0 text-amber-600","aria-hidden":"true"}),m.jsxs("div",{className:"min-w-0",children:[m.jsx("p",{className:"font-medium",children:s}),l?m.jsx("p",{className:"mt-1 text-muted-foreground","data-slot":"device-preview-tool-description",children:o}):null,i!=="unsupported"&&!n?m.jsx("a",{href:e==="ios"?"https://github.com/tddworks/baguette#install":"https://developer.android.com/tools/releases/platform-tools",target:"_blank",rel:"noreferrer",className:"mt-1 inline-block text-primary underline underline-offset-4",children:"查看安装方法"}):null]})]})})}function gI({message:e}){return m.jsx("div",{className:"flex min-h-28 items-center justify-center rounded-lg border border-dashed px-4 text-center text-sm text-muted-foreground",children:e})}function kfe({target:e,selected:t,disabled:n,alreadyOpen:r,onClick:i}){const s=e.platform==="ios"?"iOS":"Android",o=`${e.model} · ${s} ${e.osVersion}`;return m.jsxs("button",{type:"button",className:qe("flex min-h-16 w-full min-w-0 max-w-full items-center gap-3 overflow-hidden rounded-lg border px-3 py-2 text-left outline-none transition-colors",t?"border-primary bg-primary/5":"border-border hover:bg-accent",n&&"cursor-not-allowed opacity-55"),disabled:n,"aria-pressed":t,onClick:i,"data-slot":"device-preview-target","data-target-id":e.targetId,"data-already-open":r?"true":"false","data-interactive":e.interactive?"true":"false",children:[m.jsx(Ty,{className:"size-5 shrink-0 text-muted-foreground","aria-hidden":"true"}),m.jsxs("span",{className:"min-w-0 flex-1",children:[m.jsx("span",{className:"block truncate text-sm font-medium",children:e.name}),m.jsx("span",{className:"mt-0.5 block truncate text-xs text-muted-foreground","data-slot":"device-preview-target-device","data-device-model":e.model,"data-os-version":e.osVersion,children:o})]}),r?m.jsx("span",{className:"text-xs text-muted-foreground",children:"已在预览"}):t?m.jsx(ua,{className:"size-4 text-primary","aria-hidden":"true"}):null]})}function yF({open:e,onOpenChange:t}){const[n,r]=b.useState(()=>e?"chooser":"closed"),i=b.useRef(null),s=yo("(min-width: 768px)");b.useLayoutEffect(()=>{if(e){n==="closed"&&r("chooser");return}n!=="closed"&&(i.current=n,r("closed"))},[e,n]);function o(){t(!1)}const l=m.jsxs("div",{className:"grid gap-2 pt-2","data-slot":"frontend-preview-options",children:[m.jsx(_0,{icon:m.jsx(Ez,{className:"size-5","aria-hidden":"true"}),title:"网页",description:"通过临时链接访问或分享本机网页",slot:"frontend-preview-web",onClick:()=>r("web")}),m.jsx(_0,{icon:m.jsx(Ty,{className:"size-5","aria-hidden":"true"}),title:"iOS Simulator",description:"查看和操控开发机上已启动的 iPhone 或 iPad 模拟器",slot:"frontend-preview-ios",onClick:()=>r("ios")}),m.jsx(_0,{icon:m.jsx(Ty,{className:"size-5","aria-hidden":"true"}),title:"Android Emulator",description:"查看和操控开发机上已启动的 Android 模拟器",slot:"frontend-preview-android",onClick:()=>r("android")})]}),u=n==="closed"?i.current:n,d=e&&n!=="closed";switch(u){case"chooser":return s?m.jsx(es,{open:d,onOpenChange:f=>!f&&o(),children:m.jsxs(ts,{className:"sm:max-w-lg","data-slot":"create-frontend-preview-dialog",children:[m.jsxs(ns,{children:[m.jsx($i,{children:"新建预览"}),m.jsx(Es,{children:"选择预览类型。"})]}),l]})},"chooser"):m.jsx(pc,{open:d,onOpenChange:f=>!f&&o(),children:m.jsxs(mc,{side:"bottom",className:"inset-x-2 w-auto rounded-t-xl border bg-background px-4 pb-[max(theme(spacing.4),env(safe-area-inset-bottom))] pt-3","data-slot":"create-frontend-preview-dialog",focusSurfaceOnOpen:!0,children:[m.jsxs(Eu,{className:"px-0 pb-1 pt-0 text-left",children:[m.jsx(gc,{children:"新建预览"}),m.jsx(Vb,{children:"选择预览类型。"})]}),l]})},"chooser");case"web":return m.jsx(wfe,{open:d,onOpenChange:f=>!f&&o()},"web");case"ios":case"android":return m.jsx(Efe,{open:d,platform:u,onOpenChange:f=>!f&&o()},u);case null:return null}}function _0({icon:e,title:t,description:n,slot:r,onClick:i}){return m.jsxs(vt,{type:"button",variant:"outline",className:"h-auto min-h-[4.5rem] justify-start gap-3 px-4 py-3 text-left","data-slot":r,onClick:i,children:[m.jsx("span",{className:"text-muted-foreground",children:e}),m.jsxs("span",{className:"min-w-0",children:[m.jsx("span",{className:"block font-medium text-foreground",children:t}),m.jsx("span",{className:"mt-0.5 block whitespace-normal text-xs leading-5 text-muted-foreground",children:n})]})]})}function Tfe({preview:e,closing:t,onOpenChange:n,onConfirm:r}){return m.jsx(es,{open:e!==null,onOpenChange:n,children:m.jsxs(ts,{"data-slot":"device-preview-close-dialog",children:[m.jsxs(ns,{children:[m.jsx($i,{children:"停止预览?"}),m.jsx(Es,{children:"模拟器会继续在开发机上运行。"})]}),m.jsxs(qs,{children:[m.jsx(vt,{type:"button",variant:"ghost",disabled:t,onClick:()=>n(!1),children:"取消"}),m.jsx(vt,{type:"button",variant:"destructive",disabled:!e||t,onClick:()=>e&&r(e),"data-slot":"device-preview-close-confirm",children:t?"正在停止...":"停止预览"})]})]})})}const Rfe={ready:{dot:"bg-[var(--color-status-success)]",text:"text-[var(--color-status-success)]",label:"已连接"},disconnected:{dot:"bg-muted-foreground",text:"text-muted-foreground",label:"已断开"}};function Afe({preview:e,selected:t,pendingOperation:n,onRename:r,onReconnect:i,onClose:s}){const o=Rfe[e.state],l=n==="reconnect"?{dot:"bg-[var(--color-status-working)] animate-pulse",text:"text-[var(--color-status-working)]",label:"正在重新连接",busy:!0}:n==="close"?{dot:"bg-muted-foreground animate-pulse",text:"text-muted-foreground",label:"正在停止",busy:!0}:o,u=e.state==="ready",d=e.state==="disconnected",f=e.platform==="ios"?"iOS":"Android",h=m.jsxs(m.Fragment,{children:[m.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[m.jsx("span",{className:qe("inline-block size-2 shrink-0 rounded-full",l.dot),role:"status","aria-label":`预览状态:${l.label}`}),m.jsx("span",{className:"flex-1 truncate text-sm font-normal",title:e.name,children:e.name})]}),m.jsxs("span",{className:"flex h-5 min-w-0 items-center gap-1.5 text-xs leading-5",children:[m.jsx(Ty,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),m.jsxs("span",{className:"min-w-0 flex-1 truncate text-muted-foreground","data-slot":"device-preview-row-device","data-device-model":e.model,"data-os-version":e.osVersion,children:[e.model," · ",f," ",e.osVersion]}),m.jsx("span",{className:qe("shrink-0",l.text),children:l.label})]})]});return m.jsxs("li",{className:qe("relative flex min-h-[44px] w-full min-w-0 items-center gap-2 px-4 py-2 transition-colors hover:bg-accent",t&&"bg-accent"),"data-slot":"device-preview-row","data-preview-id":e.previewId,"data-preview-state":e.state,"data-preview-operation":n,children:[u?m.jsx(_C,{to:`/preview/device/${e.previewId}`,className:"flex min-h-11 min-w-0 flex-1 flex-col justify-center gap-1 rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring md:min-h-0","data-slot":"device-preview-row-open",children:h}):m.jsx("div",{className:"flex min-h-11 min-w-0 flex-1 flex-col justify-center gap-1 md:min-h-0",children:h}),m.jsxs(_f,{children:[m.jsx(wf,{asChild:!0,children:m.jsx(vt,{variant:"ghost",size:"icon-xs",className:"size-11 md:size-6","aria-label":"模拟器预览操作",disabled:n!==void 0,"data-slot":"device-preview-row-menu-trigger",children:l.busy||n==="rename"?m.jsx(li,{className:"animate-spin","aria-hidden":"true"}):m.jsx(hb,{"aria-hidden":"true"})})}),m.jsxs(xf,{align:"end","data-slot":"device-preview-row-menu",children:[m.jsx(Zr,{"data-slot":"device-preview-row-rename-item",onSelect:r,children:"重命名"}),d?m.jsx(Zr,{"data-slot":"device-preview-row-reconnect-item",onSelect:i,children:"重新连接"}):null,m.jsx(Gc,{}),m.jsx(Zr,{variant:"destructive","data-slot":"device-preview-row-close-item",onSelect:s,children:"停止预览"})]})]})]})}function Nfe({preview:e,closing:t,onOpenChange:n,onConfirm:r}){return m.jsx(es,{open:e!==null,onOpenChange:n,children:m.jsxs(ts,{"data-slot":"preview-close-dialog",children:[m.jsxs(ns,{children:[m.jsx($i,{children:"关闭预览?"}),m.jsx(Es,{children:"关闭后,当前预览链接将立即失效。"})]}),m.jsxs(qs,{children:[m.jsx(vt,{type:"button",variant:"ghost",disabled:t,onClick:()=>n(!1),children:"取消"}),m.jsx(vt,{type:"button",variant:"destructive",disabled:!e||t,onClick:()=>e&&r(e),"data-slot":"preview-close-confirm",children:t?"正在关闭...":"关闭预览"})]})]})})}function Mfe({target:e,onOpenChange:t,onRename:n}){return m.jsx(Pfe,{target:e,onOpenChange:t,onRename:n},(e==null?void 0:e.targetKey)??"closed")}function Pfe({target:e,onOpenChange:t,onRename:n}){const[r,i]=b.useState(()=>(e==null?void 0:e.name.trim())??""),[s,o]=b.useState(null),[l,u]=b.useState(!1),d=b.useRef((e==null?void 0:e.targetKey)??null);b.useLayoutEffect(()=>()=>{d.current=null},[]);function f(y){!y&&l||t(y)}async function h(y){y.preventDefault();const g=r.trim();if(!g){o("名称不能为空");return}if(!e||l)return;const _=e.targetKey;u(!0);try{if(await n(g),d.current!==_)return;t(!1)}catch(w){if(d.current!==_)return;o(w instanceof Error?w.message:String(w))}finally{d.current===_&&u(!1)}}return m.jsx(es,{open:e!==null,onOpenChange:f,children:m.jsx(ts,{showCloseButton:!l,className:"sm:max-w-md","data-slot":"preview-rename-dialog",children:m.jsxs("form",{className:"grid gap-4",onSubmit:y=>void h(y),children:[m.jsx(ns,{children:m.jsx($i,{children:"重命名预览"})}),m.jsxs("div",{className:"grid gap-2",children:[m.jsx("label",{htmlFor:"preview-rename-name",className:"text-sm font-medium",children:"预览名称"}),m.jsx("input",{id:"preview-rename-name",value:r,autoFocus:!0,maxLength:256,autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-invalid":!!s,"aria-describedby":s?"preview-rename-error":void 0,"data-slot":"preview-rename-input",className:qe("h-10 rounded-md border border-input bg-background px-3 text-sm shadow-xs outline-none transition-[border-color,box-shadow]","placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/75","disabled:cursor-not-allowed disabled:opacity-50",s&&"border-destructive focus-visible:ring-destructive/20"),disabled:l,onChange:y=>{i(y.target.value),s&&o(null)}}),s?m.jsx("p",{id:"preview-rename-error",className:"text-sm text-destructive",role:"alert",children:s}):null]}),m.jsxs(qs,{children:[m.jsx(vt,{type:"button",variant:"outline",disabled:l,onClick:()=>f(!1),children:"取消"}),m.jsx(vt,{type:"submit",disabled:l,"data-slot":"preview-rename-submit",children:"保存"})]})]})})})}const Ife={starting:{dot:"bg-[var(--color-status-working)] animate-pulse",text:"text-[var(--color-status-working)]",label:"正在创建",busy:!0},ready:{dot:"bg-[var(--color-status-success)]",text:"text-[var(--color-status-success)]",label:"可访问"},failed:{dot:"bg-[var(--color-status-error)]",text:"text-[var(--color-status-error)]",label:"连接失败"},disconnected:{dot:"bg-muted-foreground",text:"text-muted-foreground",label:"已断开"},stopping:{dot:"bg-muted-foreground animate-pulse",text:"text-muted-foreground",label:"正在关闭",busy:!0}};function Ofe(e){return e.source.kind==="local"?e.source.url:bb(e.source.rootPath,e.source.entryPath)}async function Lfe(e){if(await Fp(e,{allowUserGestureFallback:!0})==="failed"){Ue.error("复制失败,请稍后重试");return}Ue.success("链接已复制")}async function Dfe(e,t){if(typeof navigator.share=="function")try{await navigator.share({title:e,url:t})}catch(n){if(n instanceof DOMException&&n.name==="AbortError")return;Ue.error("无法打开系统分享面板")}}function Bfe({preview:e,pendingOperation:t,onRename:n,onReconnect:r,onClose:i}){const s=qr(w=>w.homePath),o=Ife[e.state],l=t==="reconnect"?{dot:"bg-[var(--color-status-working)] animate-pulse",text:"text-[var(--color-status-working)]",label:"正在重新连接",busy:!0}:t==="close"?{dot:"bg-muted-foreground animate-pulse",text:"text-muted-foreground",label:"正在关闭",busy:!0}:o,u=e.state==="ready"?e.publicUrl:null,d=u!==null,f=e.state==="failed"||e.state==="disconnected",h=d&&typeof navigator<"u"&&typeof navigator.share=="function",y=Ofe(e),g=e.source.kind==="static"?pm(y,s):y,_=m.jsxs(m.Fragment,{children:[m.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[m.jsx("span",{className:qe("inline-block size-2 shrink-0 rounded-full",l.dot),role:"status","aria-label":`预览状态:${l.label}`}),m.jsx("span",{className:"flex-1 truncate text-sm font-normal",title:e.name,children:e.name})]}),m.jsxs("span",{className:"flex h-5 min-w-0 items-center gap-1.5 text-xs leading-5",children:[m.jsx(Ez,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),m.jsx("span",{className:"min-w-0 truncate font-mono text-muted-foreground",title:y,children:g}),m.jsx("span",{className:"shrink-0 text-muted-foreground/60","aria-hidden":"true",children:"·"}),m.jsx("span",{className:qe("shrink-0",l.text),children:l.label})]}),e.state==="failed"?m.jsx("span",{"data-slot":"preview-row-error",className:"truncate text-xs text-destructive/90",title:e.error,children:e.error}):null]});return m.jsxs("li",{className:"relative flex min-h-[44px] w-full min-w-0 items-center gap-2 px-4 py-2 transition-colors hover:bg-accent","data-slot":"preview-row","data-preview-id":e.previewId,"data-preview-state":e.state,"data-preview-operation":t,children:[d?m.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer","data-slot":"preview-row-open",className:"flex min-h-11 min-w-0 flex-1 flex-col justify-center gap-1 rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring md:min-h-0",children:_}):m.jsx("div",{"data-slot":"preview-row-inactive","aria-disabled":"true",className:"flex min-h-11 min-w-0 flex-1 flex-col justify-center gap-1 md:min-h-0",children:_}),m.jsxs(_f,{children:[m.jsx(wf,{asChild:!0,children:m.jsx(vt,{variant:"ghost",size:"icon-xs",className:"size-11 md:size-6","aria-label":"预览操作","data-slot":"preview-row-menu-trigger",disabled:e.state==="stopping"||t!==void 0,children:l.busy||t==="rename"?m.jsx(li,{className:"animate-spin","aria-hidden":"true"}):m.jsx(hb,{"aria-hidden":"true"})})}),m.jsxs(xf,{align:"end","data-slot":"preview-row-menu",children:[m.jsx(Zr,{"data-slot":"preview-row-rename-item",onSelect:n,children:"重命名"}),d?m.jsx(Zr,{"data-slot":"preview-row-copy-item",onSelect:()=>void Lfe(u),children:"复制链接"}):null,h?m.jsx(Zr,{"data-slot":"preview-row-share-item",onSelect:()=>void Dfe(e.name,u),children:"分享…"}):null,f?m.jsx(Zr,{"data-slot":"preview-row-reconnect-item",onSelect:r,children:"重新连接"}):null,m.jsx(Gc,{}),m.jsx(Zr,{variant:"destructive","data-slot":"preview-row-close-item",onSelect:i,children:"关闭预览"})]})]})]})}const zfe=Object.freeze([]),jfe=Object.freeze([]);function ud(e,t,n){return Object.freeze({kind:e,previewId:t,scope:Object.freeze({proxyId:n.proxyId,bindingId:n.bindingId})})}function jc(e,t){return e!==null&&e.kind===t.kind&&e.previewId===t.previewId&&Jt(e.scope,t.scope)}function up(e,t,n){return t!==null&&n!==void 0&&Jt(e.scope,t)&&Jt(e.scope,n)}function Ph(e){const t=Pt.getActiveScope(),n=e.kind==="web"?Hr.getState().authoritative:fr.getState().authoritative;return!n||!up(e,t,n.scope)?!1:n.previews.some(r=>r.previewId===e.previewId)}function Uo(e){const t=Pt.getActiveScope();return t!==null&&Jt(t,e)}function vI(){const e=Hr(N=>N.authoritative),t=fr(N=>N.authoritative),n=Zo(N=>N.registry),r=Pt.getActiveScope(),i=r&&e&&Jt(r,e.scope)?e.scope:null,s=r&&t&&Jt(r,t.scope)?t.scope:null,o=i&&e?e.previews:zfe,l=s&&t?t.previews:jfe,u=lz("/preview/device/:id"),d=Cs(),[f,h]=b.useState(null),[y,g]=b.useState(null),_=(y==null?void 0:y.kind)==="web"&&up(y,r,e==null?void 0:e.scope)?o.find(N=>N.previewId===y.previewId)??null:null,w=(y==null?void 0:y.kind)==="device"&&up(y,r,t==null?void 0:t.scope)?l.find(N=>N.previewId===y.previewId)??null:null,S=_??w,x=(f==null?void 0:f.kind)==="web"&&up(f,r,e==null?void 0:e.scope)?o.find(N=>N.previewId===f.previewId)??null:null,k=(f==null?void 0:f.kind)==="device"&&up(f,r,t==null?void 0:t.scope)?l.find(N=>N.previewId===f.previewId)??null:null;b.useEffect(()=>{y&&!S&&g(N=>jc(N,y)?null:N),f&&!x&&!k&&h(N=>jc(N,f)?null:N)},[f,k,y,S,x]);function R(N,L,B){var O;return(O=s5(n,N,L,B)[0])==null?void 0:O.kind}if(o.length===0&&l.length===0)return null;async function A(N){if(Ph(N))try{const L=await Pt.reconnectWebPreview(N.scope,N.previewId);if(!Uo(N.scope))return;L.success||Ue.error(L.error)}catch(L){if(!Uo(N.scope))return;Ue.error(L instanceof Error?L.message:"无法重新连接网页预览")}}async function M(N,L){if(!Ph(N))return;let B;try{B=N.kind==="web"?await Pt.renameWebPreview(N.scope,N.previewId,L):await Pt.renameDevicePreview(N.scope,N.previewId,L)}catch(O){if(!Uo(N.scope))return;throw O}if(Uo(N.scope)&&!B.success)throw new Error(B.error)}async function T(N){if(Ph(N))try{const L=await Pt.closeWebPreview(N.scope,N.previewId);if(!Uo(N.scope))return;if(!L.success){Ue.error(L.error);return}h(B=>jc(B,N)?null:B)}catch(L){if(!Uo(N.scope))return;Ue.error(L instanceof Error?L.message:"无法关闭网页预览")}}async function P(N){if(Ph(N))try{const L=await Pt.reconnectDevicePreview(N.scope,N.previewId);if(!Uo(N.scope))return;L.success||Ue.error(L.error)}catch(L){if(!Uo(N.scope))return;Ue.error(L instanceof Error?L.message:"无法重新连接模拟器预览")}}async function z(N){if(Ph(N))try{const L=await Pt.closeDevicePreview(N.scope,N.previewId);if(!Uo(N.scope))return;if(!L.success){Ue.error(L.error);return}h(B=>jc(B,N)?null:B),(u==null?void 0:u.params.id)===N.previewId&&d("/sessions")}catch(L){if(!Uo(N.scope))return;Ue.error(L instanceof Error?L.message:"无法停止模拟器预览")}}const Y=(f==null?void 0:f.kind)==="web"&&R(f.scope,"web",f.previewId)==="close",U=(f==null?void 0:f.kind)==="device"&&R(f.scope,"device",f.previewId)==="close",G=y,I=f;return m.jsxs("section",{"data-slot":"preview-section","aria-labelledby":"preview-section-title",children:[m.jsxs("h3",{id:"preview-section-title",className:"px-4 pb-2 pt-3 text-sm font-semibold text-foreground",children:["预览",m.jsxs("span",{className:"ml-1 font-normal text-muted-foreground/70",children:["· ",o.length+l.length]})]}),m.jsxs("ul",{role:"list",className:"flex w-full min-w-0 flex-col",children:[o.map(N=>m.jsx(Bfe,{preview:N,pendingOperation:i?R(i,"web",N.previewId):void 0,onRename:()=>i&&g(ud("web",N.previewId,i)),onReconnect:()=>i&&void A(ud("web",N.previewId,i)),onClose:()=>i&&h(ud("web",N.previewId,i))},N.previewId)),l.map(N=>m.jsx(Afe,{preview:N,selected:(u==null?void 0:u.params.id)===N.previewId,pendingOperation:s?R(s,"device",N.previewId):void 0,onRename:()=>s&&g(ud("device",N.previewId,s)),onReconnect:()=>s&&void P(ud("device",N.previewId,s)),onClose:()=>s&&h(ud("device",N.previewId,s))},N.previewId))]}),m.jsx(Mfe,{target:G&&S?{targetKey:`${G.kind}\0${G.scope.proxyId}\0${G.scope.bindingId}\0${G.previewId}`,name:S.name}:null,onOpenChange:N=>{!N&&G&&g(L=>jc(L,G)?null:L)},onRename:N=>G?M(G,N):Promise.resolve()}),m.jsx(Nfe,{preview:x,closing:Y,onOpenChange:N=>{!N&&!Y&&I&&h(L=>jc(L,I)?null:L)},onConfirm:()=>I&&void T(I)}),m.jsx(Tfe,{preview:k,closing:U,onOpenChange:N=>{!N&&!U&&I&&h(L=>jc(L,I)?null:L)},onConfirm:()=>I&&void z(I)})]})}function bF({layout:e}){const t=Ut(re=>re.sessions),n=Ut(re=>re.sessionListLoaded),r=Ut(re=>re.agentStatusBySessionId),i=Ut(re=>re.ptyStateBySessionId),s=Ut(re=>re.renameSession),o=fn(re=>re.bySessionId),l=lz("/chat/:id"),u=(l==null?void 0:l.params.id)??null,d=Me(re=>!!re.selectedProxyId),f=Me(re=>re.proxyListLoaded),h=Me(re=>re.proxySwitchTarget),y=Ut(re=>re.loadingProxyName),g=h!==null||!f||d&&!n,_=(h==null?void 0:h.name)??y,w=_?`正在连接 ${_}...`:"连接中...",S=Cs(),[x,k]=b.useState(!1),[R,A]=b.useState(!1),[M,T]=b.useState(!1),[P,z]=b.useState(!1),[Y,U]=b.useState(null),[G,I]=b.useState(null),{creatingTerminal:N,creatingShell:L,createTerminal:B}=_F(),[O,D]=b.useState(new Set),[F,V]=b.useState(()=>Date.now());b.useEffect(()=>{const re=setInterval(()=>V(Date.now()),6e4);return()=>clearInterval(re)},[]);function j(re,le){S(`/chat/${re}?mode=${le}`,{replace:!1})}function q(re){const le=re.sessionId,we=$t;if(!we){Ue.error("请先连接开发机");return}we.sendControl({type:"session_terminate",sessionId:le}),Ut.getState().removeSession(le),fn.getState().clearSession(le),le===u&&S("/sessions"),(re==null?void 0:re.kind)==="agent"&&re.mode==="pty"&&re.ptyOwner==="local-terminal"?Ue.info("已断开页面连接,本地终端仍在运行"):Ue.info("正在终止会话",{duration:1500})}async function K(re,le){const we=$t;if(!we)throw new Error("请先连接开发机");const Ce=await we.renameSession(re,le);if(!Ce.success)throw new Error(Ce.error??"重命名失败");s(re,Ce.name??le),Ue.success("已重命名会话")}function $(re){D(le=>{const we=new Set(le);return we.has(re)?we.delete(re):we.add(re),we})}function te(re){var Ce;const le=re.mode==="json"&&(((Ce=o[re.sessionId])==null?void 0:Ce.pendingApprovals.some(ye=>ye.status==="pending"))??!1),we=vfe({session:re,agentStatus:r[re.sessionId],ptyState:i[re.sessionId],hasPendingApproval:le});return we===re.state?re:{...re,state:we}}const J=t.length>0;if(e==="sidebar"&&(g||!d))return m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"px-4 py-3 text-sm text-muted-foreground/70","data-slot":g?"session-list-loading":void 0,role:g?"status":void 0,"aria-live":g?"polite":void 0,children:g?w:"请先连接开发机"}),m.jsx(lp,{open:x,onOpenChange:k}),m.jsx(bv,{open:G!==null,session:G,onOpenChange:re=>{re||I(null)},onConfirm:q}),m.jsx(cp,{open:Y!==null,sessionId:(Y==null?void 0:Y.sessionId)??null,initialName:Y==null?void 0:Y.name,onOpenChange:re=>{re||U(null)},onRename:K})]});if(e==="page"&&g)return m.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 text-muted-foreground animate-in fade-in-0 duration-200 motion-reduce:animate-none","data-slot":"session-list-loading",role:"status","aria-live":"polite",children:[m.jsx(li,{className:"h-5 w-5 animate-spin","aria-hidden":!0}),m.jsx("p",{className:"max-w-[min(24rem,calc(100%-2rem))] truncate text-sm",children:w})]});if(e==="page"&&!d)return m.jsxs("div",{className:"flex flex-col h-full",children:[m.jsx("div",{className:"flex-1",children:m.jsx(Jc,{variant:"no-proxy"})}),m.jsx(lp,{open:x,onOpenChange:k}),m.jsx(bv,{open:G!==null,session:G,onOpenChange:re=>{re||I(null)},onConfirm:q}),m.jsx(cp,{open:Y!==null,sessionId:(Y==null?void 0:Y.sessionId)??null,initialName:Y==null?void 0:Y.name,onOpenChange:re=>{re||U(null)},onRename:K})]});const ne=m.jsxs("h3",{className:"px-4 pt-3 pb-2 text-sm font-semibold text-foreground","data-slot":"active-section-header",children:["活跃会话",J?m.jsxs("span",{className:"ml-1 text-muted-foreground/70 font-normal",children:["· ",t.length]}):null]}),Q=J?m.jsx("ul",{role:"list",className:"flex flex-col w-full min-w-0",children:Ffe(t).map(re=>m.jsxs("li",{children:[m.jsxs("button",{type:"button",onClick:()=>$(re.provider),"aria-expanded":!O.has(re.provider),className:qe("flex w-full items-center gap-2 px-4 pt-2 pb-1 min-h-[32px]","text-xs text-muted-foreground","text-left outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring"),children:[m.jsx("span",{className:"font-mono",children:$fe(re.provider)}),m.jsx("span",{className:"h-px flex-1 bg-border/70","aria-hidden":"true"}),m.jsx("span",{className:"tabular-nums",children:re.sessions.length}),m.jsx(Hd,{className:qe("size-3.5 shrink-0 text-muted-foreground/80 transition-transform",!O.has(re.provider)&&"rotate-90"),"aria-hidden":"true"})]}),O.has(re.provider)?null:m.jsx("ul",{role:"list",className:"flex flex-col",children:re.sessions.map(le=>m.jsx(Xde,{session:te(le),selected:le.sessionId===u,now:F,onClick:()=>j(le.sessionId,le.mode),onRename:()=>U(le),onTerminate:()=>I(le)},le.sessionId))})]},re.provider))}):m.jsx("div",{className:"px-4 py-3 text-sm text-muted-foreground/70","data-slot":"active-empty",children:"暂无活跃会话"}),ce=m.jsx(efe,{now:F});return e==="page"?m.jsxs("div",{className:"flex flex-col h-full",children:[m.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto overscroll-contain",children:[ne,Q,m.jsx(vI,{}),ce]}),m.jsx("div",{className:"px-4 pt-4 pb-[calc(env(safe-area-inset-bottom)+1rem)] border-t border-border",children:m.jsxs(vt,{className:"min-h-11 w-full md:min-h-0","data-slot":"create-session-mobile-trigger",onClick:()=>A(!0),children:[m.jsx(xz,{"aria-hidden":"true"}),"新建"]})}),m.jsx(Vfe,{open:R,creatingTerminal:N,onOpenChange:A,onCreateAgent:()=>{A(!1),k(!0)},onCreateTerminal:()=>{wF()?(A(!1),T(!0)):B(void 0,()=>A(!1))},onCreatePreview:()=>{A(!1),z(!0)}}),m.jsx(xF,{layout:"mobile",open:M,creatingTerminal:N,creatingShell:L,onOpenChange:T,onBack:()=>{T(!1),A(!0)},onCreate:re=>void B(re,()=>T(!1))}),m.jsx(lp,{open:x,onOpenChange:k}),m.jsx(yF,{open:P,onOpenChange:z}),m.jsx(bv,{open:G!==null,session:G,onOpenChange:re=>{re||I(null)},onConfirm:q}),m.jsx(cp,{open:Y!==null,sessionId:(Y==null?void 0:Y.sessionId)??null,initialName:Y==null?void 0:Y.name,onOpenChange:re=>{re||U(null)},onRename:K})]}):m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"dev-sidebar-scroll h-full overflow-y-auto overscroll-contain",children:[ne,Q,m.jsx(vI,{}),ce]}),m.jsx(lp,{open:x,onOpenChange:k}),m.jsx(bv,{open:G!==null,session:G,onOpenChange:re=>{re||I(null)},onConfirm:q}),m.jsx(cp,{open:Y!==null,sessionId:(Y==null?void 0:Y.sessionId)??null,initialName:Y==null?void 0:Y.name,onOpenChange:re=>{re||U(null)},onRename:K})]})}function Ffe(e){const t=new Map;for(const n of e){const r=n.kind==="terminal"?"terminal":n.provider,i=t.get(r);i?i.push(n):t.set(r,[n])}return Array.from(t.entries()).sort(([n],[r])=>Hfe(n,r)).map(([n,r])=>({provider:n,sessions:r}))}function $fe(e){return e==="terminal"?"终端":Yb(e)}function Hfe(e,t){return e===t?0:e==="terminal"?-1:t==="terminal"?1:aF(e,t)}function _F(){const e=Cs(),[t,n]=b.useState(null),r=t!==null;async function i(s,o){var u;const l=Me.getState();if(!(r||!l.connected||!l.proxyOnline||!l.selectedProxyId||l.proxySwitchTarget)&&!Mk(l)&&!(s&&!((u=l.terminalShells)!=null&&u.some(d=>d.id===s)))){n(s??"default");try{const d=await dfe({relay:$t,shell:s});if(d.type!=="success"){Ue.error(d.message);return}Ut.getState().addSession(d.session),o==null||o(),e(d.route)}finally{n(null)}}}return{creatingTerminal:r,creatingShell:t,createTerminal:i}}function Mk(e){var t;return!e.terminalShellsLoaded&&((t=e.proxies.find(n=>n.proxyId===e.selectedProxyId))==null?void 0:t.osName)==="Windows"}function Ufe(e){const t=Me(u=>u.terminalShells),n=Me(Mk),r=Me(u=>u.selectedProxyId),[i,s]=b.useState(!1),[o,l]=b.useState(0);return b.useEffect(()=>{if(!e||!n)return;let u=!1;const d=$t,f=d==null?void 0:d.getPreviewScope();if(s(!1),!d||!f||f.proxyId!==r){s(!0);return}return d.requestProxyInfo().then(h=>{const y=Me.getState(),g=d.getPreviewScope();u||!y.connected||!y.proxyOnline||y.selectedProxyId!==r||!g||!Jt(f,g)||y.setTerminalShells(h.terminalShells)},()=>{u||s(!0)}),()=>{u=!0}},[e,n,r,o]),{terminalShells:t,needsDetection:n,failed:i,retry:()=>l(u=>u+1)}}const Wfe=[{label:"启动 Shell"}];function qfe(e){return e!=null&&e.length?e:Wfe}function wF(){var t;const e=Me.getState();return Mk(e)||!!((t=e.terminalShells)!=null&&t.length)}function yI({compact:e=!1}){const[t,n]=b.useState(!1),[r,i]=b.useState(!1),[s,o]=b.useState(!1),[l,u]=b.useState(!1),[d,f]=b.useState(!1),h=b.useRef(!1),y=Me(Y=>!!Y.selectedProxyId),g=Me(Y=>Y.proxySwitchTarget!==null),_=y&&!g,{creatingTerminal:w,creatingShell:S,createTerminal:x}=_F();function k(){f(!0),window.setTimeout(()=>f(!1),2e3)}function R(){if(!_){k();return}h.current=!0,o(!0)}function A(){if(!_){k();return}h.current=!0,wF()?i(!0):x()}function M(){if(!_){k();return}h.current=!0,u(!0)}function T(Y){Y.preventDefault(),k()}const P=m.jsxs(vt,{variant:"outline","data-slot":"create-session-trigger",className:qe(e?"h-11 w-11 justify-center border-border px-0":"h-[46px] w-full justify-center gap-2 border-border px-3",!_&&"opacity-50 hover:bg-background"),"aria-label":"新建","aria-disabled":!_,onClick:_?void 0:T,children:[m.jsx(xz,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),!e&&m.jsx("span",{className:"truncate",children:"新建"})]}),z=_?m.jsxs(_f,{open:t,onOpenChange:n,children:[m.jsx(wf,{asChild:!0,children:P}),m.jsxs(xf,{align:e?"end":"start",className:"w-80","data-slot":"create-session-type-menu",onCloseAutoFocus:Y=>{h.current&&(h.current=!1,Y.preventDefault())},children:[m.jsxs(Zr,{className:"min-h-9 gap-2.5","data-slot":"create-agent-session-item",onSelect:R,children:[m.jsx(_z,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),"Agent 会话"]}),m.jsxs(Zr,{className:"min-h-9 gap-2.5","data-slot":"create-terminal-session-item",disabled:w,onSelect:A,children:[m.jsx(ru,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),w?"正在创建 Shell 会话...":"Shell 会话"]}),m.jsx(Gc,{}),m.jsxs(Zr,{className:"min-h-[3.75rem] items-start gap-2.5 py-2","data-slot":"create-frontend-preview-item",onSelect:M,children:[m.jsx(CC,{className:"mt-0.5 size-4 text-muted-foreground","aria-hidden":"true"}),m.jsxs("span",{className:"min-w-0 flex-1",children:[m.jsx("span",{className:"flex items-center gap-1.5 font-medium",children:"预览"}),m.jsx("span",{className:"mt-0.5 block text-xs leading-4 text-muted-foreground",children:"在浏览器中预览网页或设备模拟器"})]})]})]})]}):P;return m.jsxs(m.Fragment,{children:[_?z:m.jsxs(Sf,{open:_?void 0:d,onOpenChange:_?void 0:f,children:[m.jsx(Ef,{asChild:!0,children:z}),m.jsx(Cf,{side:"top",children:g?"正在切换开发机":"请先连接开发机"})]}),m.jsx(xF,{layout:"desktop",open:r,creatingTerminal:w,creatingShell:S,onOpenChange:i,onBack:()=>{i(!1),n(!0)},onCreate:Y=>void x(Y,()=>i(!1))}),m.jsx(lp,{open:s,onOpenChange:o}),m.jsx(yF,{open:l,onOpenChange:u})]})}function Vfe({open:e,creatingTerminal:t,onOpenChange:n,onCreateAgent:r,onCreateTerminal:i,onCreatePreview:s}){const o=b.useRef(!1);function l(u){o.current=!0,u()}return m.jsx(pc,{open:e,onOpenChange:n,children:m.jsxs(mc,{side:"bottom",overlayClassName:"bg-black/10 dark:bg-black/30",className:"inset-x-2 w-auto rounded-t-xl border border-border/80 bg-background px-3 pb-[max(theme(spacing.4),env(safe-area-inset-bottom))] pt-3 shadow-2xl","data-slot":"create-session-type-sheet",focusSurfaceOnOpen:!0,onCloseAutoFocus:u=>{o.current&&(o.current=!1,u.preventDefault())},children:[m.jsx(Eu,{className:"px-1 pb-1 pt-0 text-left",children:m.jsx(gc,{children:"新建"})}),m.jsxs("div",{className:"grid gap-2 pb-1","data-slot":"create-session-type-options",children:[m.jsxs(vt,{type:"button",variant:"ghost",className:"min-h-12 justify-start gap-3 rounded-md px-3 text-left","data-slot":"create-agent-session-sheet-item",onClick:()=>l(r),children:[m.jsx(_z,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),"Agent 会话"]}),m.jsxs(vt,{type:"button",variant:"ghost",className:"min-h-12 justify-start gap-3 rounded-md px-3 text-left","data-slot":"create-terminal-session-sheet-item",disabled:t,onClick:()=>l(i),children:[m.jsx(ru,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),t?"正在创建 Shell 会话...":"Shell 会话"]}),m.jsx("div",{className:"mx-1 h-px bg-border","aria-hidden":"true"}),m.jsxs(vt,{type:"button",variant:"ghost",className:"min-h-16 justify-start gap-3 rounded-md px-3 text-left","data-slot":"create-frontend-preview-sheet-item",onClick:()=>l(s),children:[m.jsx(CC,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),m.jsxs("span",{className:"min-w-0",children:[m.jsx("span",{className:"flex items-center gap-1.5 font-medium",children:"预览"}),m.jsx("span",{className:"mt-0.5 block text-xs leading-4 text-muted-foreground",children:"在浏览器中预览网页或设备模拟器"})]})]})]})]})})}function xF({layout:e,open:t,creatingTerminal:n,creatingShell:r,onOpenChange:i,onBack:s,onCreate:o}){const{terminalShells:l,needsDetection:u,failed:d,retry:f}=Ufe(t),h=b.useRef(!1),y=Me(w=>w.connected&&w.proxyOnline&&!!w.selectedProxyId&&!w.proxySwitchTarget),g=m.jsxs("div",{className:"grid gap-2","data-slot":"terminal-shell-options",children:[u?m.jsxs(vt,{type:"button",variant:"ghost",className:"min-h-12 justify-start gap-3 rounded-md px-3 text-left","data-slot":"terminal-shell-detection",disabled:!d,onClick:f,children:[m.jsx(ru,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),d?"终端检测失败,点击重试":"正在检测终端..."]}):qfe(l).map(w=>m.jsxs(vt,{type:"button",variant:"ghost",className:"min-h-12 justify-start gap-3 rounded-md px-3 text-left","data-slot":"terminal-shell-option","data-shell":w.id,disabled:n||!y,onClick:()=>o(w.id),children:[m.jsx(ru,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),r===(w.id??"default")?"正在创建 Shell 会话...":w.label]},w.id??"default")),m.jsx("div",{className:"mx-1 h-px bg-border","aria-hidden":"true"}),m.jsxs(vt,{type:"button",variant:"ghost",className:"min-h-11 justify-start gap-3 px-3 text-muted-foreground",disabled:n,onClick:()=>{h.current=!0,s()},children:[m.jsx(ff,{className:"size-4","aria-hidden":"true"}),"返回"]})]});function _(w){h.current&&(h.current=!1,w.preventDefault())}return e==="mobile"?m.jsx(pc,{open:t,onOpenChange:i,children:m.jsxs(mc,{side:"bottom",overlayClassName:"bg-black/10 dark:bg-black/30",className:"inset-x-2 w-auto rounded-t-xl border border-border/80 bg-background px-3 pb-[max(theme(spacing.4),env(safe-area-inset-bottom))] pt-3 shadow-2xl","data-slot":"create-terminal-shell-dialog",focusSurfaceOnOpen:!0,onCloseAutoFocus:_,children:[m.jsx(Eu,{className:"px-1 pb-1 pt-0 text-left",children:m.jsx(gc,{children:"Shell 会话"})}),g]})}):m.jsx(es,{open:t,onOpenChange:i,children:m.jsxs(ts,{className:"sm:max-w-sm","data-slot":"create-terminal-shell-dialog",focusSurfaceOnOpen:!0,onCloseAutoFocus:_,children:[m.jsx(ns,{children:m.jsx($i,{children:"Shell 会话"})}),g]})})}const Yfe="0.9.14",Kfe={version:Yfe},Gfe={playback:"playback",capture:"play-and-record"};function Xfe(){return typeof navigator>"u"?null:navigator.audioSession??null}function Zfe(){return{setMode:()=>{},release:()=>{}}}class Qfe{constructor(t=Xfe){je(this,"leases",new Map);je(this,"session",null);je(this,"baselineType",null);je(this,"nextLeaseId",1);je(this,"nextOrder",1);this.getAudioSession=t}acquire(t){const n=this.getAudioSession();if(!n)return Zfe();this.leases.size===0&&(this.session=n,this.baselineType=n.type);const r=this.nextLeaseId++;this.leases.set(r,{mode:t,order:this.nextOrder++});try{this.applyActiveMode()}catch(s){throw this.leases.delete(r),this.leases.size===0?this.restoreWhenUnused():this.applyActiveModeBestEffort(),s}let i=!1;return{setMode:s=>{if(i)return;const o=this.leases.get(r);if(!o)return;const l={...o};o.mode=s,o.order=this.nextOrder++;try{this.applyActiveMode()}catch(u){throw this.leases.set(r,l),this.applyActiveModeBestEffort(),u}},release:()=>{if(!i){if(i=!0,this.leases.delete(r),this.leases.size===0){this.restoreWhenUnused();return}this.applyActiveModeBestEffort()}}}}applyActiveMode(){const t=[...this.leases.values()].reduce((n,r)=>!n||r.order>n.order?r:n,null);!t||!this.session||this.setNativeType(Gfe[t.mode])}applyActiveModeBestEffort(){try{this.applyActiveMode()}catch{}}restoreWhenUnused(){const t=this.session,n=this.baselineType;if(this.session=null,this.baselineType=null,!(!t||n===null))try{t.type=n}catch{}}setNativeType(t){if(!(!this.session||this.session.type===t)){try{this.session.type=t}catch{throw new Error("浏览器无法切换语音音频模式")}if(this.session.type!==t)throw new Error("浏览器无法切换语音音频模式")}}}const Pk=new Qfe,P1=64,bI=-60,SF=32;function _I(e){if(!Number.isFinite(e)||e===0)return 0;const t=Math.min(1,Math.abs(e)),n=20*Math.log10(t),r=Math.max(0,Math.min(1,(n-bI)/-bI));return e<0?-r:r}function wI(e,t=8){const n=Math.floor(e.byteLength/2);if(n===0||!Number.isFinite(t)||t<=0)return[];const r=Math.min(n,Math.max(1,Math.floor(t))),i=new DataView(e.buffer,e.byteOffset,e.byteLength),s=[];for(let o=0;o<r;o+=1){const l=Math.floor(o*n/r),u=Math.max(l+1,Math.floor((o+1)*n/r));let d=1,f=-1;for(let h=l;h<u;h+=1){const y=i.getInt16(h*2,!0)/32768;d=Math.min(d,y),f=Math.max(f,y)}s.push({min:d,max:f})}return s}function Jfe(e){const t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=Math.floor(e.byteLength/2),r=new Float32Array(n);for(let i=0;i<n;i+=1)r[i]=t.getInt16(i*2,!0)/32768;return r}function ehe(e){if(e.length===0)return 0;const t=Math.max(1,Math.floor(e.length/512));let n=0,r=0;for(let i=0;i<e.length;i+=t){const s=e[i]??0;n+=s*s,r+=1}return r===0?0:Math.min(1,Math.sqrt(n/r)*10)}class EF{constructor(t,n=24e3,r={}){je(this,"nextStartTime",0);je(this,"activityEndToken",0);je(this,"timelineTimers",new Set);this.context=t,this.sampleRate=n,this.options=r}async resume(){this.emitPlaybackEvent("resume-start");try{if(this.context.state!=="running"&&this.context.state!=="closed"&&await this.context.resume(),this.context.state!=="running")throw new Error("浏览器未允许播放 Voice Pilot 提示音");this.emitPlaybackEvent("resume-finished")}catch(t){throw this.emitPlaybackEvent("resume-failed",{error:t instanceof Error?t.message:String(t)}),t}}enqueue(t){this.context.state==="suspended"&&this.resume().catch(()=>{});const n=Jfe(t),r=this.context.createBuffer(1,n.length,this.sampleRate);r.getChannelData(0).set(n);const i=this.context.createBufferSource();i.buffer=r,i.connect(this.context.destination);const s=Math.max(this.context.currentTime,this.nextStartTime);i.start(s);const o=s+r.duration;this.nextStartTime=o,this.schedulePlaybackFrames(t,n,s,o);const l=Math.max(0,(o-this.context.currentTime)*1e3);return this.emitPlaybackEvent("pcm-scheduled",{bytes:t.byteLength,durationMs:r.duration*1e3}),typeof i.addEventListener=="function"&&i.addEventListener("ended",()=>{this.emitPlaybackEvent("source-ended",{bytes:t.byteLength,durationMs:r.duration*1e3})},{once:!0}),l}stop(){var t,n;this.nextStartTime=this.context.currentTime,this.activityEndToken+=1;for(const r of this.timelineTimers)clearTimeout(r);this.timelineTimers.clear(),(n=(t=this.options).onActivityLevel)==null||n.call(t,0),this.emitPlaybackEvent("stopped")}snapshot(){const t=this.context.currentTime;return{contextState:String(this.context.state??"unknown"),contextTime:t,nextStartTime:this.nextStartTime,queuedMs:Math.max(0,(this.nextStartTime-t)*1e3)}}schedulePlaybackFrames(t,n,r,i){if(!this.options.onActivityLevel&&!this.options.onPlaybackChunk)return;const s=Math.max(1,Math.round(this.sampleRate*SF/1e3)),o=this.activityEndToken+=1;for(let l=0;l<n.length;l+=s){const u=Math.min(n.length,l+s),d=r+l/this.sampleRate,f=Math.max(0,(d-this.context.currentTime)*1e3),h=t.slice(l*Int16Array.BYTES_PER_ELEMENT,u*Int16Array.BYTES_PER_ELEMENT),y=ehe(n.subarray(l,u));this.scheduleTimer(()=>{var g,_,w,S;(_=(g=this.options).onActivityLevel)==null||_.call(g,y),(S=(w=this.options).onPlaybackChunk)==null||S.call(w,h)},f)}if(this.options.onActivityLevel){const l=Math.max(0,(i-this.context.currentTime)*1e3);this.scheduleTimer(()=>{var u,d;o===this.activityEndToken&&((d=(u=this.options).onActivityLevel)==null||d.call(u,0))},l)}}scheduleTimer(t,n){const r=setTimeout(()=>{this.timelineTimers.delete(r),t()},n);this.timelineTimers.add(r)}emitPlaybackEvent(t,n={}){var r,i;(i=(r=this.options).onPlaybackEvent)==null||i.call(r,{event:t,...this.snapshot(),...n})}}const w0={provider:"aliyun-bailian",configured:!1,region:"cn",asrModel:"qwen3-asr-flash-realtime",ttsModel:"cosyvoice-v3-flash",ttsVoice:"longanyang",turnIdleSeconds:3},xI="min-h-11 min-w-0 rounded-md border border-border bg-input px-3 text-base outline-none transition-colors placeholder:text-muted-foreground/65 focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring md:h-9 md:min-h-0 md:text-sm",the=800,SI=300,nhe=1600;function I1(e,t){return e.filter(n=>!n.model||n.model===t)}function EI({label:e,children:t,help:n}){return m.jsxs("div",{className:"block min-w-0 rounded-lg border border-border/75 bg-card/55 p-3.5 transition-colors focus-within:border-ring/55 focus-within:bg-card/75 sm:p-3",children:[m.jsx("span",{className:"block text-[13px] font-medium leading-none text-muted-foreground",children:e}),m.jsx("div",{className:"mt-2 min-w-0",children:t}),n?m.jsx("span",{className:"mt-2 block text-xs leading-relaxed text-muted-foreground",children:n}):null]})}function _v({label:e,value:t,options:n,onChange:r,placeholder:i="请选择",help:s}){const[o,l]=b.useState(!1),u=b.useId(),d=n.find(g=>g.value===t),f=(d==null?void 0:d.label)??(t||i),h=n.filter(g=>!g.disabled),y=!!CF(f).detail;return m.jsxs("div",{className:"min-w-0 rounded-lg border border-border/75 bg-card/55 p-3.5 sm:p-3",onBlur:g=>{g.currentTarget.contains(g.relatedTarget)||l(!1)},children:[m.jsx("div",{id:u,className:"text-[13px] font-medium leading-none text-muted-foreground",children:e}),m.jsxs("button",{type:"button","aria-labelledby":u,"aria-haspopup":"listbox","aria-expanded":o,disabled:h.length===0,className:`mt-2 flex w-full min-w-0 items-center justify-between gap-3 rounded-md border border-border bg-input px-3 text-left outline-none transition-colors hover:border-primary/40 focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-60 ${y?"min-h-[60px] py-2":"min-h-11"}`,onClick:()=>l(g=>!g),"data-slot":"voice-settings-choice-trigger",children:[m.jsx(CI,{label:f,muted:!d&&!t}),m.jsx(sc,{className:`size-4 shrink-0 text-muted-foreground transition-transform ${o?"rotate-180":""}`,"aria-hidden":"true"})]}),o?m.jsx("div",{role:"listbox","aria-labelledby":u,className:"mt-2 max-h-64 overflow-y-auto rounded-md border border-border/80 bg-popover p-1 shadow-sm",children:n.map(g=>{const _=g.value===t;return m.jsxs("button",{type:"button",role:"option","aria-label":g.label,"aria-selected":_,disabled:g.disabled,className:"flex w-full min-w-0 items-center gap-2 rounded-sm px-2.5 py-2.5 text-left text-sm outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>{g.disabled||(r(g.value),l(!1))},children:[m.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center text-primary",children:_?m.jsx(ua,{className:"size-4","aria-hidden":"true"}):null}),m.jsx(CI,{label:g.label})]},g.value)})}):null,s?m.jsx("div",{className:"mt-2 text-xs leading-relaxed text-muted-foreground",children:s}):null]})}function CI({label:e,muted:t=!1}){const n=CF(e);return m.jsxs("span",{className:"min-w-0 flex-1",children:[m.jsx("span",{className:`block truncate text-base leading-6 md:text-sm ${t?"text-muted-foreground":"text-foreground"}`,children:n.title}),n.detail?m.jsx("span",{className:"mt-0.5 block truncate text-xs leading-4 text-muted-foreground",children:n.detail}):null]})}function rhe({scrollRef:e}={}){const[t,n]=b.useState(w0),[r,i]=b.useState(String(w0.turnIdleSeconds)),[s,o]=b.useState(()=>sv()),[l,u]=b.useState(""),[d,f]=b.useState(!1),[h,y]=b.useState(!1),[g,_]=b.useState({kind:"idle"}),w=b.useRef(null),S=b.useRef(null),x=b.useRef(null),k=b.useRef(null),R=b.useRef(null),A=b.useRef(!1);b.useEffect(()=>{const Q=$t;if(!Q){_({kind:"error",message:"请先连接 Relay 服务器"});return}let ce=!1;return _({kind:"loading"}),Q.requestVoiceConfig().then(re=>{if(!ce){if(re.error||!re.config){_({kind:"error",message:re.error??"读取语音设置失败"});return}n(re.config),i(String(re.config.turnIdleSeconds)),u(""),f(!1),y(!0),_({kind:"idle"})}}).catch(re=>{ce||_({kind:"error",message:re instanceof Error?re.message:"读取语音设置失败"})}),()=>{ce=!0}},[]),b.useEffect(()=>{const Q=$t;if(!Q||!h)return;let ce=!1;return Q.requestVoiceCapabilities({region:t.region}).then(re=>{if(!ce){if(re.error||!re.capabilities){o(sv());return}o(re.capabilities)}}).catch(()=>{ce||o(sv())}),()=>{ce=!0}},[t.region,h]),b.useEffect(()=>(A.current=!0,()=>{A.current=!1,$(),te()}),[]);const M=b.useMemo(()=>g.kind==="loading"?"读取中...":g.kind==="saving"?"保存中...":g.kind==="testing"?"正在测试语音合成":g.kind==="playingTest"?"正在播放测试音频":g.kind==="testPassed"?"测试通过":g.kind==="saved"?"已保存":g.kind==="error"?g.message:null,[g]),T=g.kind==="saving"||g.kind==="loading"||g.kind==="testing"||g.kind==="playingTest",P=b.useMemo(()=>I1(s.ttsVoices,t.ttsModel),[s.ttsVoices,t.ttsModel]),Y=P.some(Q=>Q.value===t.ttsVoice)?t.ttsVoice:"",U=P.length===0?"当前模型暂无可用音色":Y?null:"请选择可用音色",G=b.useMemo(()=>ahe(r),[r]),I=G?null:"请输入正整数秒数",N=U??I,L=T||!!N,B=b.useMemo(()=>[{value:"cn",label:"中国大陆"},{value:"intl",label:"国际"}],[]),O=b.useMemo(()=>RI(s.asrModels,t.asrModel),[s.asrModels,t.asrModel]),D=b.useMemo(()=>lhe(s.ttsModels,s.ttsVoices,t.ttsModel),[s.ttsModels,s.ttsVoices,t.ttsModel]),F=b.useMemo(()=>RI(P,Y),[P,Y]);function V(){return{...d?{clearApiKey:!0}:{},...!d&&l.trim()?{apiKey:l.trim()}:{},region:t.region,asrModel:t.asrModel.trim(),ttsModel:t.ttsModel.trim(),ttsVoice:t.ttsVoice.trim(),turnIdleSeconds:G??w0.turnIdleSeconds}}async function j(){if(T)return;if(N){_({kind:"error",message:N});return}const Q=$t;if(!Q){_({kind:"error",message:"请先连接 Relay 服务器"});return}const ce=V();te(),_({kind:"saving"});const re=performance.now();try{const le=await Q.updateVoiceConfig(ce);if(!A.current)return;const we=performance.now()-re;if(we<SI&&await ohe(SI-we),!A.current)return;if(!le.success||le.error||!le.config){_({kind:"error",message:le.error??"保存语音设置失败"});return}n(le.config),i(String(le.config.turnIdleSeconds)),u(""),f(!1),_({kind:"saved"}),R.current=setTimeout(()=>{R.current=null,_(Ce=>Ce.kind==="saved"?{kind:"idle"}:Ce)},nhe),Q.requestVoiceCapabilities({region:le.config.region}).then(Ce=>{A.current&&Ce.capabilities&&o(Ce.capabilities)}).catch(()=>{A.current&&o(sv())})}catch(le){if(!A.current)return;_({kind:"error",message:le instanceof Error?le.message:"保存语音设置失败"})}}async function q(){if(T)return;if(N){_({kind:"error",message:N});return}const Q=$t;if(!Q){_({kind:"error",message:"请先连接 Relay 服务器"});return}let ce;try{ce=K()}catch(re){_({kind:"error",message:TI(re)});return}_({kind:"testing"});try{const[re]=await Promise.all([Q.testVoiceConfig(V()),ce.ready]);if(!re.success||re.error){$(),_({kind:"error",message:re.error??"语音配置测试失败"});return}const le=await J(re,ce.context);_({kind:"playingTest",transcript:re.transcript}),k.current=setTimeout(()=>{k.current=null,$(),_({kind:"testPassed",transcript:re.transcript})},le)}catch(re){$(),_({kind:"error",message:TI(re)})}}function K(){$();const Q=Pk.acquire("playback");S.current=Q;try{const ce=she();return w.current=ce,{context:ce,ready:kI(ce)}}catch(ce){throw Q.release(),S.current=null,ce}}function $(){var Q,ce,re;k.current&&(clearTimeout(k.current),k.current=null),(Q=x.current)==null||Q.stop(),x.current=null,(ce=w.current)==null||ce.close(),w.current=null,(re=S.current)==null||re.release(),S.current=null}function te(){R.current&&(clearTimeout(R.current),R.current=null)}async function J(Q,ce){if(!Q.audioBase64)throw new Error("语音测试未返回可播放音频");if(Q.audioEncoding&&Q.audioEncoding!=="pcm_s16le")throw new Error("测试音频格式暂不支持");const re=Q.audioSampleRate??24e3,le=ihe(Q.audioBase64);if(le.byteLength===0||le.byteLength%2!==0)throw new Error("测试音频数据无效");await kI(ce);const we=new EF(ce,re);x.current=we,we.enqueue(le);const Ce=Math.ceil(le.byteLength/2/re*1e3);return Math.max(the,Ce)}function ne(Q){var ce;return((ce=I1(s.ttsVoices,Q)[0])==null?void 0:ce.value)??""}return m.jsxs("form",{className:"flex min-h-0 min-w-0 flex-1 flex-col","data-slot":"voice-settings-panel",autoComplete:"off",onSubmit:Q=>{Q.preventDefault(),j()},children:[m.jsx("div",{className:"flex min-h-0 flex-1 flex-col px-4 py-3 sm:px-5 sm:py-3.5","data-slot":"voice-settings-body-frame",children:m.jsx("div",{className:"dev-render-scroll min-h-0 flex-1 overflow-y-auto overscroll-contain pr-4 sm:pr-1","data-slot":"voice-settings-scroll",ref:e,children:m.jsxs("div",{className:"space-y-3","data-slot":"voice-settings-fields",children:[m.jsx("div",{className:"grid gap-2 rounded-lg border border-border/75 bg-card/55 p-3.5 sm:p-3",children:m.jsxs("div",{className:"flex items-center justify-between gap-3",children:[m.jsxs("div",{className:"min-w-0",children:[m.jsx("div",{className:"text-[13px] font-medium leading-none text-muted-foreground",children:"服务商"}),m.jsx("div",{className:"mt-2 truncate text-base font-medium text-foreground md:text-sm",children:"阿里云百炼"})]}),m.jsx("span",{className:"shrink-0 rounded-full border border-primary/35 bg-primary/10 px-2.5 py-1 text-xs font-medium text-primary",children:"Bailian"})]})}),m.jsx(EI,{label:"阿里云百炼 API Key",help:d?"保存后会清空已保存的 key":null,children:m.jsxs("div",{className:"flex min-w-0 gap-2",children:[m.jsxs("div",{className:"relative min-w-0 flex-1",children:[m.jsx(kz,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground","aria-hidden":"true"}),m.jsx("input",{"aria-label":"阿里云百炼 API Key",type:"password",name:"dev-anywhere-bailian-api-key",autoComplete:"off",value:l,onChange:Q=>{u(Q.target.value),f(!1)},placeholder:d?"保存后清空":t.configured?"••••••••••••••••":"输入 API Key",className:`${xI} w-full pl-9`})]}),t.configured&&m.jsxs(vt,{type:"button",variant:"outline",className:"min-h-11 shrink-0 px-3 md:h-9 md:min-h-0",onClick:()=>{u(""),f(!0)},children:[m.jsx(Mz,{className:"size-4","aria-hidden":"true"}),"清空"]})]})}),m.jsx(_v,{label:"地域",value:t.region,options:B,onChange:Q=>n(ce=>({...ce,region:Q==="intl"?"intl":"cn"}))}),m.jsx(_v,{label:"语音识别模型",value:t.asrModel,options:O,onChange:Q=>n(ce=>({...ce,asrModel:Q}))}),m.jsx(_v,{label:"语音合成模型",value:t.ttsModel,options:D,onChange:Q=>n(ce=>({...ce,ttsModel:Q,ttsVoice:ne(Q)}))}),m.jsx(_v,{label:"语音音色",value:Y,options:F,placeholder:P.length===0?"暂无可用音色":"请选择音色",onChange:Q=>n(ce=>({...ce,ttsVoice:Q})),help:U}),m.jsx(EI,{label:"结束停顿时间(秒)",help:I,children:m.jsx("input",{"aria-label":"结束停顿时间(秒)",type:"number",min:1,step:1,inputMode:"numeric",value:r,onChange:Q=>i(Q.target.value),className:`${xI} w-full`})})]})})}),m.jsxs("div",{className:"bg-background/95 px-4 pb-3.5 pt-0 backdrop-blur sm:px-5","data-slot":"voice-settings-footer",children:[m.jsx("div",{className:"mr-4 border-t border-border/70","data-slot":"voice-settings-footer-divider"}),m.jsxs("div",{className:"mt-3.5 flex items-center justify-end gap-2",children:[M?m.jsx("div",{role:g.kind==="error"?"alert":"status","aria-live":"polite",className:g.kind==="error"?"min-w-0 flex-1 text-sm text-destructive":"min-w-0 flex-1 text-sm text-muted-foreground",children:M}):null,m.jsxs(vt,{type:"button",variant:"outline",disabled:L,onClick:()=>void q(),children:[m.jsx(Rz,{className:"size-4","aria-hidden":"true"}),"测试"]}),m.jsxs(vt,{type:"submit",disabled:L,children:[m.jsx(sK,{className:"size-4","aria-hidden":"true"}),g.kind==="saving"?"保存中...":"保存"]})]})]})]})}function ihe(e){const t=window.atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r+=1)n[r]=t.charCodeAt(r);return n}function she(){const e=window,t=e.AudioContext??e.webkitAudioContext;if(!t)throw new Error("当前浏览器不支持音频播放");return new t}async function kI(e){if(e.state!=="running")try{await e.resume()}catch{throw new Error("浏览器阻止了测试音频播放,请再次点击测试")}if(e.state!=="running")throw new Error("浏览器阻止了测试音频播放,请再次点击测试")}function TI(e){return e instanceof Error?e.message:"语音配置测试失败"}function ohe(e){return new Promise(t=>setTimeout(t,e))}function ahe(e){const t=e.trim();if(!/^[1-9]\d*$/.test(t))return null;const n=Number(t);return Number.isSafeInteger(n)?n:null}function RI(e,t){const n=e.map(r=>({value:r.value,label:kF(r)}));return!t||n.some(r=>r.value===t)?n:[{value:t,label:t},...n]}function lhe(e,t,n){const r=e.map(i=>{const s=I1(t,i.value).length===0;return{value:i.value,label:`${kF(i)}${s?" · 暂无音色":""}`,disabled:s}});return!n||r.some(i=>i.value===n)?r:[{value:n,label:`${n} · 暂无音色`,disabled:!0},...r]}function CF(e){const t=e.split(" · ").map(n=>n.trim()).filter(Boolean);return t.length<=1?{title:e,detail:null}:{title:t[0],detail:t.slice(1).join(" · ")}}function kF(e){if(!e.age)return e.label;const t=`年龄 ${e.age}`;if(e.label.includes(t))return e.label;const n=` · ${e.age}`;return e.label.endsWith(n)?`${e.label.slice(0,-n.length)} · ${t}`:`${e.label} · ${t}`}const che=[{value:"auto",label:"跟随系统"},{value:"light",label:"浅色"},{value:"dark",label:"深色"}],uhe=[{value:"auto",label:"自动"},{value:"touch",label:"触控优先"},{value:"hardware",label:"实体键盘优先"}],Ik="dev-render-scroll min-h-0 space-y-3 overflow-y-auto overscroll-contain pr-4 sm:pr-1";function TF(e){if(!Number.isFinite(e)||e<0)return"未知";if(e<60)return`${Math.floor(e)} 秒`;const t=Math.floor(e/60);if(t<60)return`${t} 分钟`;const n=Math.floor(t/60),r=t%60;if(n<24)return r>0?`${n} 小时 ${r} 分钟`:`${n} 小时`;const i=Math.floor(n/24),s=n%24;return s>0?`${i} 天 ${s} 小时`:`${i} 天`}function dhe(e){const t=e||window.location.origin;return new URL("/health",t).toString()}function fhe(e){return e==="version"?"版本":e==="relay-token"?"Relay Token":e==="clients"?"客户端管理":"设置 Voice Pilot"}function hhe(e){return e==="version"?"Web 与 Relay 服务器版本。":e==="relay-token"?"连接受保护的 Relay 服务器,保存后立即重连。":e==="clients"?"管理当前连接的 Web 客户端。":"连接语音服务后,即可以语音交互的形式驱动会话。"}function O1({open:e,onOpenChange:t}){const n=Me(G=>G.relayUrl),r=Me(G=>G.latencyMonitorEnabled),i=Me(G=>G.setLatencyMonitorEnabled),s=Me(G=>G.sessionIdleNotificationsEnabled),o=Me(G=>G.setSessionIdleNotificationsEnabled),l=Me(G=>G.inputModePreference),u=Me(G=>G.setInputModePreference),d=Me(G=>G.themePreference),f=Me(G=>G.setThemePreference),h=Me(G=>G.ptyScrollTraceEnabled),y=Me(G=>G.setPtyScrollTraceEnabled),[g,_]=b.useState("menu"),[w,S]=b.useState(e),[x,k]=b.useState({kind:"idle"}),R=b.useRef(null),A=b.useRef(null),M=Ose(),T=b.useMemo(()=>pf().osName==="iPad",[]);e!==w&&(S(e),e&&_("menu"));const P=b.useCallback(async G=>{if(!G){o(!1);return}const I=await sse();if(I==="granted"){o(!0);return}if(I==="denied"){Ue.error("浏览器未授予通知权限,请在浏览器设置中允许通知");return}if(I==="default"){Ue.info("未授予通知权限,会话通知保持关闭");return}Ue.error("当前浏览器不支持系统通知")},[o]),z=b.useCallback(async G=>{k({kind:"loading"});try{const I=await fetch(dhe(n),{cache:"no-store",signal:G});if(!I.ok)throw new Error(`HTTP ${I.status}`);const N=await I.json();if(N.status!=="ok")throw new Error("状态异常");k({kind:"ready",version:N.version??"未知",uptime:N.uptime??0})}catch(I){if(I instanceof DOMException&&I.name==="AbortError")return;k({kind:"error",message:I instanceof Error?"当前 Relay 服务器无法读取版本":"读取失败"})}},[n]);b.useEffect(()=>{if(!e||g!=="version")return;const G=new AbortController;return z(G.signal),()=>G.abort()},[z,e,g]),b.useEffect(()=>{if(!e||g!=="voice")return;const G=window.requestAnimationFrame(()=>{var I;(I=R.current)==null||I.focus({preventScroll:!0}),A.current&&(A.current.scrollTop=0)});return()=>window.cancelAnimationFrame(G)},[e,g]);const Y=x.kind==="ready"?x.version:x.kind==="loading"?"读取中...":x.kind==="error"?"读取失败":"未读取",U=x.kind==="ready"?`运行 ${TF(x.uptime)}`:x.kind==="error"?x.message:"从当前 Relay 服务器 /health 读取";return m.jsx(es,{open:e,onOpenChange:t,children:m.jsxs(ts,{className:qe("grid max-h-[calc(100dvh-1rem)] grid-rows-[auto_minmax(0,1fr)] overflow-hidden p-4 sm:max-w-[440px] sm:p-6",g==="voice"&&"max-h-[min(760px,calc(100dvh-1rem))] !gap-0 !p-0 sm:max-w-[480px]",g==="voice"&&"max-sm:top-auto max-sm:bottom-0 max-sm:left-2 max-sm:right-2 max-sm:h-[calc(100dvh-1rem)] max-sm:w-auto max-sm:max-h-none max-sm:max-w-none max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-b-none max-sm:rounded-t-2xl max-sm:border-x max-sm:border-b-0"),"data-slot":"settings-dialog","data-view":g,focusSurfaceOnOpen:!0,ref:R,showCloseButton:g==="menu",children:[m.jsx(ns,{className:qe(g==="menu"&&"pr-12 text-left",g!=="menu"&&"text-left",g==="voice"&&"gap-0 px-4 pb-0 pt-3.5 text-left sm:px-5 sm:pt-4"),children:g!=="menu"?m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"flex items-start gap-2",children:[m.jsx(vt,{type:"button",variant:"ghost",size:"icon",className:"-ml-2 mt-0.5 size-11 sm:size-9","aria-label":"返回设置","data-slot":"voice-settings-back",onClick:()=>_("menu"),children:m.jsx(ff,{className:"size-4","aria-hidden":"true"})}),m.jsxs("div",{className:"min-w-0 space-y-1.5 pt-0.5 text-left",children:[m.jsx($i,{children:fhe(g)}),m.jsx(Es,{className:"max-w-[28rem] leading-5",children:hhe(g)})]})]}),g==="voice"?m.jsx("div",{className:"mr-4 mt-3.5 border-t border-border/70","data-slot":"voice-settings-header-divider"}):null]}):m.jsxs(m.Fragment,{children:[m.jsx($i,{children:"设置"}),m.jsx(Es,{children:"连接、外观、通知和高级诊断选项。"})]})}),g==="version"?m.jsx(phe,{relayVersion:Y,relayDetail:U,relayMuted:x.kind==="error"}):g==="relay-token"?m.jsx(ghe,{saved:M}):g==="clients"?m.jsx(whe,{}):g==="voice"?m.jsx(rhe,{scrollRef:A}):m.jsx(mhe,{relayTokenSaved:M,themePreference:d,onThemePreferenceChange:f,inputModePreference:l,onInputModePreferenceChange:u,showInputModeSetting:T,sessionIdleNotificationsEnabled:s,onSessionIdleNotificationsEnabledChange:P,ptyScrollTraceEnabled:h,onPtyScrollTraceEnabledChange:y,latencyMonitorEnabled:r,onLatencyMonitorEnabledChange:i,onOpenVoice:()=>_("voice"),onOpenRelayToken:()=>_("relay-token"),onOpenClients:()=>_("clients"),onOpenVersion:()=>_("version")})]})})}function phe({relayVersion:e,relayDetail:t,relayMuted:n}){return m.jsxs("div",{className:Ik,"data-slot":"settings-dialog-body",children:[m.jsx(NI,{icon:m.jsx(Tz,{className:"size-4","aria-hidden":"true"}),label:"Web",value:Kfe.version,detail:"当前浏览器加载的版本"}),m.jsx(NI,{icon:m.jsx(Az,{className:"size-4","aria-hidden":"true"}),label:"Relay 服务器",value:e,detail:t,muted:n})]})}function mhe({relayTokenSaved:e,themePreference:t,onThemePreferenceChange:n,inputModePreference:r,onInputModePreferenceChange:i,showInputModeSetting:s,sessionIdleNotificationsEnabled:o,onSessionIdleNotificationsEnabledChange:l,ptyScrollTraceEnabled:u,onPtyScrollTraceEnabledChange:d,latencyMonitorEnabled:f,onLatencyMonitorEnabledChange:h,onOpenVoice:y,onOpenRelayToken:g,onOpenClients:_,onOpenVersion:w}){return m.jsxs("div",{className:"dev-render-scroll min-h-0 space-y-4 overflow-y-auto overscroll-contain pr-4 sm:pr-1","data-slot":"settings-dialog-body",children:[m.jsxs(dd,{title:"服务",children:[m.jsx(wv,{icon:m.jsx(AV,{className:"size-4","aria-hidden":"true"}),label:"Voice Pilot",detail:"用语音输入、听取回复和处理审批",onClick:y}),m.jsx(wv,{icon:m.jsx(kz,{className:"size-4","aria-hidden":"true"}),label:"Relay Token",detail:`${e?"已保存":"未设置"} · 受保护的 Relay 服务器`,onClick:g}),m.jsx(wv,{icon:m.jsx(TK,{className:"size-4","aria-hidden":"true"}),label:"客户端管理",detail:"已连接的浏览器页面和设备",onClick:_})]}),m.jsx(dd,{title:"外观",children:m.jsx(AI,{icon:m.jsx(gK,{className:"size-4","aria-hidden":"true"}),label:"主题",value:t,options:che,onValueChange:n})}),m.jsx(dd,{title:"通知",children:m.jsx(S0,{icon:m.jsx(MV,{className:"size-4","aria-hidden":"true"}),label:"会话空闲通知",detail:"会话从工作中转为空闲时发送浏览器通知",checked:o,onCheckedChange:l})}),s?m.jsx(dd,{title:"交互",children:m.jsx(AI,{icon:m.jsx(SC,{className:"size-4","aria-hidden":"true"}),label:"输入方式",detail:"默认自动识别软键盘和实体键盘;必要时可强制一种方式",value:r,options:uhe,onValueChange:i})}):null,m.jsxs(dd,{title:"高级诊断",children:[m.jsx(S0,{icon:m.jsx(ru,{className:"size-4","aria-hidden":"true"}),label:"PTY 滚动追踪",detail:"记录终端滚动和视口同步现场,方便复制诊断报告",checked:u,onCheckedChange:d}),m.jsx(S0,{icon:m.jsx(yz,{className:"size-4","aria-hidden":"true"}),label:"延迟监控",detail:"显示可拖动的连接延迟浮窗",checked:f,onCheckedChange:h})]}),m.jsx(dd,{title:"关于",children:m.jsx(wv,{icon:m.jsx(Az,{className:"size-4","aria-hidden":"true"}),label:"版本",onClick:w})})]})}function dd({title:e,children:t}){return m.jsxs("section",{className:"space-y-2","data-slot":"settings-section",children:[m.jsx("h3",{className:"px-1 text-xs font-medium text-muted-foreground",children:e}),m.jsx("div",{className:"overflow-hidden rounded-lg border border-border bg-card/55 divide-y divide-border/70",children:t})]})}function AI({icon:e,label:t,detail:n,value:r,options:i,onValueChange:s}){const o=b.useId(),l=b.useId();return m.jsxs("div",{className:"flex w-full items-start gap-3 px-3 py-3 text-left","data-slot":"settings-choice-item",children:[m.jsx("div",{className:"flex size-8 shrink-0 items-center justify-center rounded-md bg-background/55 text-muted-foreground",children:e}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsx("div",{id:o,className:"text-sm font-medium text-foreground",children:t}),n?m.jsx("div",{id:l,className:"mt-1 text-xs text-muted-foreground",children:n}):null,m.jsx("div",{role:"radiogroup","aria-labelledby":o,"aria-describedby":n?l:void 0,className:"mt-3 grid grid-cols-3 gap-1 rounded-md border border-border bg-muted/70 p-1","data-slot":"settings-segmented-choice",children:i.map(u=>{const d=u.value===r;return m.jsx("button",{type:"button",role:"radio","aria-checked":d,className:qe("min-w-0 whitespace-nowrap rounded px-2 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",d?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:bg-background/55 hover:text-foreground"),onClick:()=>s(u.value),children:u.label},u.value)})})]})]})}function ghe({saved:e}){const t=b.useId(),n=b.useId(),[r,i]=b.useState(""),[s,o]=b.useState(null),l=()=>{_5().catch(f=>{o(f instanceof Error?f.message:"Relay 重连失败。")})},u=()=>{const f=r.trim();if(!f){o("请输入 token。");return}if(!y5(f)){const h="Relay Token 保存失败,请检查浏览器存储权限。";o(h),Ue.error(h);return}o(null),Ue.success("Relay Token 已保存,正在重新连接"),l()},d=()=>{b5(),l()};return m.jsxs("form",{className:Ik,"data-slot":"settings-dialog-body",onSubmit:f=>{f.preventDefault(),u()},children:[m.jsxs("div",{className:"rounded-md border border-border bg-card/70 p-3","data-slot":"relay-token-card",children:[m.jsx("label",{htmlFor:t,className:"text-sm font-medium text-foreground",children:"Token"}),m.jsx("input",{id:t,type:"password",value:r,onChange:f=>{i(f.currentTarget.value),s&&o(null)},autoComplete:"off",spellCheck:!1,"aria-describedby":s?n:void 0,className:"mt-2 h-10 w-full rounded-md border border-border bg-background px-3 font-mono text-sm text-foreground outline-none transition-colors placeholder:text-muted-foreground focus:border-ring focus:ring-2 focus:ring-ring/75",placeholder:"粘贴 token"}),s?m.jsx("p",{id:n,className:"mt-2 text-xs text-destructive",children:s}):null]}),m.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[e?m.jsx(vt,{type:"button",variant:"outline",onClick:d,children:"清空"}):null,m.jsx(vt,{type:"submit",disabled:!r.trim(),children:"保存"})]})]})}function vhe(e){return e.length<=16?e:`${e.slice(0,8)}...${e.slice(-4)}`}function yhe(e,t){var r;return((r=t.get(e))==null?void 0:r.trim())||vhe(e)}function bhe(e){return Xne(e)}function _he(e){const t=Math.max(0,Math.floor((Date.now()-e)/1e3));return TF(t)}function x0({label:e,value:t,title:n}){return m.jsxs("div",{className:"grid grid-cols-[3.75rem_minmax(0,1fr)] items-baseline gap-2 text-xs leading-5",children:[m.jsx("span",{className:"shrink-0 text-muted-foreground/80",children:e}),m.jsx("span",{className:"min-w-0 truncate text-muted-foreground",title:n??t,children:t})]})}function whe(){const e=Me(y=>y.proxies),[t,n]=b.useState([]),[r,i]=b.useState(!0),[s,o]=b.useState(null),[l,u]=b.useState(null),d=b.useMemo(()=>new Map(e.map(y=>[y.proxyId,y.name]).filter(y=>typeof y[1]=="string")),[e]),f=b.useCallback(async()=>{const y=$t;if(!y){n([]),o("Relay 未连接。"),i(!1);return}i(!0),o(null);try{n(await y.requestRelayClients())}catch(g){o(g instanceof Error?g.message:"读取客户端列表失败。")}finally{i(!1)}},[]);b.useEffect(()=>{f()},[f]);const h=b.useCallback(async y=>{const g=$t;if(!g){o("Relay 未连接。");return}u(y),o(null);try{const _=await g.kickRelayClient(y);if(!_.success){o(_.error??"断开客户端失败。");return}n(w=>w.filter(S=>S.clientId!==y))}catch(_){o(_ instanceof Error?_.message:"断开客户端失败。")}finally{u(null)}},[]);return m.jsxs("div",{className:Ik,"data-slot":"settings-dialog-body",children:[m.jsxs("div",{className:"flex min-h-9 items-center gap-2","data-slot":"relay-clients-toolbar",children:[m.jsx("div",{className:"text-sm font-medium text-foreground",children:r?"正在读取客户端":`${t.length} 个在线客户端`}),m.jsx(vt,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"刷新客户端列表",title:"刷新",onClick:()=>void f(),disabled:r,"data-slot":"relay-clients-refresh",children:m.jsx(um,{className:qe("size-3.5",r&&"animate-spin"),"aria-hidden":"true"})})]}),s?m.jsx("div",{className:"rounded-md border border-destructive/35 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:s}):null,!r&&t.length===0?m.jsx("div",{className:"rounded-md border border-border bg-card/70 px-3 py-6 text-center text-sm text-muted-foreground",children:"当前没有在线客户端"}):null,t.map(y=>{const g=y.current===!0,_=l===y.clientId;return m.jsx("div",{className:"rounded-md border border-border bg-card/70 p-3","data-slot":"relay-client-row","data-client-id":y.clientId,title:`客户端 ${y.clientId}`,children:m.jsxs("div",{className:"grid gap-3 sm:grid-cols-[minmax(0,1fr)_7.5rem] sm:items-start",children:[m.jsxs("div",{className:"min-w-0 space-y-1.5",children:[m.jsx("div",{className:"min-w-0",children:m.jsx("div",{className:"truncate text-sm font-medium leading-5 text-foreground",children:bhe(y)})}),m.jsxs("div",{className:"space-y-1",children:[m.jsx(x0,{label:"已连接",value:_he(y.connectedAt)}),y.proxyId?m.jsx(x0,{label:"连接到",value:yhe(y.proxyId,d),title:y.proxyId}):null,y.remoteAddress?m.jsx(x0,{label:"来源 IP",value:y.remoteAddress}):null]})]}),g?m.jsx("div",{className:"inline-flex h-9 w-full items-center justify-center rounded-md border border-primary/30 bg-primary/10 px-3 text-sm font-normal text-primary","aria-label":"当前设备","data-slot":"relay-client-current-indicator",children:"当前设备"}):m.jsxs(vt,{type:"button",variant:"outline",size:"sm",className:"h-9 w-full justify-center",disabled:_,onClick:()=>void h(y.clientId),"data-slot":"relay-client-action",children:[m.jsx(PY,{className:"size-3.5","aria-hidden":"true"}),_?"断开中...":"断开"]})]})},y.clientId)})]})}function S0({icon:e,label:t,detail:n,checked:r,onCheckedChange:i}){const s=b.useId(),o=b.useId();return m.jsxs("button",{type:"button",role:"switch",className:"group flex w-full items-center gap-3 px-3 py-3 text-left transition-colors hover:bg-accent/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:()=>i(!r),"aria-checked":r,"aria-labelledby":s,"aria-describedby":o,"data-slot":"settings-toggle-item",children:[m.jsx("div",{className:qe("flex size-8 shrink-0 items-center justify-center rounded-md bg-background/55 transition-colors",r?"text-primary":"text-muted-foreground"),children:e}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsx("div",{id:s,className:"text-sm font-medium text-foreground",children:t}),m.jsx("div",{id:o,className:"mt-1 text-xs text-muted-foreground",children:n})]}),m.jsx("span",{className:qe("relative h-6 w-11 shrink-0 rounded-full border transition-colors",r?"border-primary/65 bg-primary/70":"border-border bg-muted/50"),"aria-hidden":"true","data-slot":"settings-toggle-switch",children:m.jsx("span",{className:qe("absolute top-1/2 size-4 -translate-y-1/2 rounded-full bg-background shadow-sm transition-transform",r?"translate-x-[1.35rem]":"translate-x-1")})})]})}function wv({icon:e,label:t,detail:n,onClick:r}){const i=b.useId(),s=b.useId();return m.jsxs("button",{type:"button",className:"group flex w-full items-center gap-3 px-3 py-3 text-left transition-colors hover:bg-accent/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",onClick:r,"aria-labelledby":i,"aria-describedby":n?s:void 0,"data-slot":"settings-menu-item",children:[m.jsx("div",{className:"flex size-8 shrink-0 items-center justify-center rounded-md bg-background/55 text-muted-foreground transition-colors group-hover:text-foreground",children:e}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsx("div",{id:i,className:"text-sm font-medium text-foreground",children:t}),n?m.jsx("div",{id:s,className:"mt-1 text-xs text-muted-foreground",children:n}):null]}),m.jsx(Hd,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"})]})}function NI({icon:e,label:t,value:n,detail:r,muted:i=!1}){return m.jsxs("div",{className:"flex gap-3 rounded-md border border-border bg-card/70 p-3",children:[m.jsx("div",{className:qe("mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-md border",i?"border-border text-muted-foreground":"border-primary/35 bg-primary/10 text-primary"),children:e}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[m.jsx("div",{className:"text-sm text-muted-foreground",children:t}),m.jsx("div",{className:"min-w-0 truncate font-mono text-sm text-foreground",children:n})]}),m.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:r})]})]})}const xhe="xterm-helper-textarea";function She(e=document.activeElement){return!(e instanceof HTMLElement)||!e.classList.contains(xhe)?!1:(e.blur(),!0)}function MI(e,t,n){if(!e||Math.abs(n)<1)return!1;let r=e instanceof Element?e:null;for(;r&&t.contains(r);){if(r instanceof HTMLElement&&Ehe(r,n))return!0;if(r===t)break;r=r.parentElement}return!1}function Ehe(e,t){if(e.scrollHeight<=e.clientHeight+1)return!1;const n=window.getComputedStyle(e).overflowY;return n!=="auto"&&n!=="scroll"&&n!=="overlay"?!1:t<0?e.scrollTop>0:e.scrollTop+e.clientHeight<e.scrollHeight-1}function Che({releasePtyFocus:e=!0,containVerticalScroll:t=!0}={}){const n=b.useRef(null),r=b.useCallback(()=>{e&&She()},[e]),i=b.useCallback(l=>{var u;n.current=((u=l.touches[0])==null?void 0:u.clientY)??null,r()},[r]),s=b.useCallback(l=>{if(!t)return;const u=l.touches[0];if(!u)return;const f=(n.current??u.clientY)-u.clientY;n.current=u.clientY,MI(l.target,l.currentTarget,f)||l.preventDefault()},[t]),o=b.useCallback(l=>{r(),t&&(MI(l.target,l.currentTarget,l.deltaY)||l.preventDefault())},[t,r]);return{onPointerDownCapture:r,onTouchStartCapture:i,onTouchMoveCapture:s,onWheelCapture:o}}function khe({className:e}){const t=Me(o=>o.sidebarCollapsed),n=Me(o=>o.toggleSidebarCollapsed),[r,i]=b.useState(!1),s=Che();return t?m.jsxs(m.Fragment,{children:[m.jsxs("nav",{className:qe("dev-sidebar-shell dev-sidebar-rail relative flex-col items-center w-12 shrink-0 bg-card border-r border-border overflow-hidden px-1.5 pb-[calc(var(--dev-safe-area-bottom,env(safe-area-inset-bottom))+0.5rem)] pt-[max(0.5rem,env(safe-area-inset-top))]",e),"aria-label":"侧边栏","data-slot":"sidebar-rail","data-collapsed":"true",...s,children:[m.jsx(II,{collapsed:!0,onClick:n}),m.jsx("div",{className:"mt-3 h-px w-5 bg-border/70","aria-hidden":"true"}),m.jsxs("div",{className:"mt-auto flex flex-col gap-2",children:[m.jsx(PI,{compact:!0,tooltipSide:"right",onClick:()=>i(!0)}),m.jsx(yI,{compact:!0})]})]}),m.jsx(O1,{open:r,onOpenChange:i})]}):m.jsxs(m.Fragment,{children:[m.jsxs("nav",{className:qe("dev-sidebar-shell group/sidebar relative flex-col w-[280px] shrink-0 bg-card border-r border-border overflow-visible pt-[env(safe-area-inset-top)]",e),"aria-label":"侧边栏","data-slot":"sidebar","data-collapsed":"false",...s,children:[m.jsx("div",{className:"dev-sidebar-fade p-2.5","data-slot":"sidebar-proxy-switcher",children:m.jsxs("div",{className:"dev-sidebar-chrome rounded-lg border p-3",children:[m.jsxs("div",{className:"flex items-center justify-between gap-3",children:[m.jsx(Gz,{className:"text-[13px]",slot:"sidebar-brand"}),m.jsx(II,{collapsed:!1,onClick:n})]}),m.jsx("div",{className:"mt-2.5",children:m.jsx(oF,{layout:"dropdown",variant:"sidebarChrome"})})]})}),m.jsx("div",{className:"dev-sidebar-fade flex min-h-0 flex-1 flex-col overflow-hidden","data-slot":"sidebar-session-list",children:m.jsx("div",{className:"flex-1 min-h-0",children:m.jsx(bF,{layout:"sidebar"})})}),m.jsxs("div",{className:"dev-sidebar-fade flex shrink-0 gap-2 px-2 pb-[calc(var(--dev-safe-area-bottom,env(safe-area-inset-bottom))+0.5rem)] pt-2","data-slot":"sidebar-new-session",children:[m.jsx("div",{className:"min-w-0 flex-1",children:m.jsx(yI,{})}),m.jsx("div",{className:"min-w-0 flex-1",children:m.jsx(PI,{onClick:()=>i(!0)})})]})]}),m.jsx(O1,{open:r,onOpenChange:i})]})}function PI({compact:e=!1,tooltipSide:t="top",onClick:n}){return m.jsxs(Sf,{delayDuration:500,children:[m.jsx(Ef,{asChild:!0,children:m.jsxs("button",{type:"button","aria-label":"设置","data-slot":"sidebar-settings-trigger",onClick:n,className:qe("inline-flex items-center justify-center shrink-0 border text-muted-foreground outline-none transition-[color,background-color,border-color,box-shadow]","focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",e?"h-11 w-11 rounded-md border-border bg-card/70 hover:border-primary/60 hover:bg-accent hover:text-foreground":"h-[46px] w-full gap-2 rounded-md border-border bg-background hover:border-primary/50 hover:bg-accent hover:text-foreground"),children:[m.jsx(Nz,{className:"size-4","aria-hidden":"true"}),!e&&m.jsx("span",{className:"truncate text-sm font-medium",children:"设置"})]})}),m.jsx(Cf,{side:t,sideOffset:10,hideArrow:!0,className:"border border-border/80 bg-card/95 px-2.5 py-1 text-muted-foreground shadow-sm backdrop-blur",children:"设置"})]})}function II({collapsed:e,onClick:t}){const n=e?"展开侧边栏":"收起侧边栏",r=e?WY:HY;return m.jsxs(Sf,{delayDuration:500,children:[m.jsx(Ef,{asChild:!0,children:m.jsx("button",{type:"button","aria-label":n,"data-slot":e?"sidebar-expand-trigger":"sidebar-collapse-trigger",onClick:t,className:qe("group inline-flex items-center justify-center text-muted-foreground outline-none transition-[opacity,color,background-color,border-color,box-shadow,transform]","outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",e?"h-9 w-9 rounded-md border border-border/80 bg-card/70 hover:border-primary/60 hover:bg-accent hover:text-foreground":"h-9 w-9 rounded-full border border-primary/25 bg-primary/10 hover:border-primary/60 hover:bg-primary/15 hover:text-foreground"),children:m.jsx(r,{className:qe("size-3.5 transition-transform",e&&"group-hover:translate-x-0.5",!e&&"group-hover:-translate-x-0.5"),"aria-hidden":"true"})})}),m.jsx(Cf,{side:e?"right":"top",sideOffset:10,hideArrow:!0,className:"border border-border/80 bg-card/95 px-2.5 py-1 text-muted-foreground shadow-sm backdrop-blur",children:n})]})}const The=1500,Rhe=300,OI=70,LI=35;function RF({texts:e,className:t}){const[n,r]=b.useState(""),[i,s]=b.useState(!0),o=b.useRef("typing"),l=b.useRef(0),u=b.useRef(0);b.useEffect(()=>{const f=setInterval(()=>s(h=>!h),530);return()=>clearInterval(f)},[]),b.useEffect(()=>{let f;const h=()=>e[u.current%e.length],y=()=>{const g=o.current;if(g==="typing"){const _=h();l.current<_.length?(l.current+=1,r(_.slice(0,l.current)),f=setTimeout(y,OI)):(o.current="paused",f=setTimeout(y,The))}else g==="paused"?(o.current="deleting",f=setTimeout(y,LI)):g==="deleting"?l.current>0?(l.current-=1,r(h().slice(0,l.current)),f=setTimeout(y,LI)):(u.current+=1,o.current="waiting",f=setTimeout(y,Rhe)):(o.current="typing",f=setTimeout(y,OI))};return f=setTimeout(y,500),()=>clearTimeout(f)},[e]);const d=n.startsWith("DEV")?3:n.length<=3&&"DEV".startsWith(n)?n.length:0;return m.jsxs("div",{className:`font-mono leading-tight select-none ${t??""}`,"data-slot":"brand-typewriter",children:[m.jsx("span",{className:"text-green-500",children:"> "}),m.jsx("span",{className:"text-primary","data-slot":"brand-typewriter-dev",children:n.slice(0,d)}),m.jsx("span",{className:"text-foreground/90",children:n.slice(d)}),m.jsx("span",{className:`text-primary ${i?"opacity-100":"opacity-0"}`,children:"_"})]})}const AF=["DEV Anywhere","/unlimited @anytime"];function Ahe({subtitle:e,action:t}){return m.jsx("section",{className:"dev-mobile-brand-hero border-b border-border/80 px-4 pb-5 pt-[calc(env(safe-area-inset-top)+1.25rem)] md:hidden","data-slot":"mobile-brand-hero","aria-label":"DEV Anywhere",children:m.jsxs("div",{className:"dev-mobile-brand-content min-w-0 space-y-3 pr-12",children:[m.jsx(RF,{texts:AF,className:"dev-mobile-brand-typewriter max-w-full overflow-hidden text-ellipsis whitespace-nowrap font-bold tracking-normal"}),e?m.jsx("p",{className:"dev-mobile-brand-subtitle max-w-[34rem] text-sm leading-5 text-muted-foreground",children:e}):null,t?m.jsx("div",{className:"dev-mobile-brand-action flex max-w-full min-w-0 pt-1",children:t}):null]})})}const Nhe=3e3,Mhe=1e4,xv=12,Phe=4,DI={webRelay:"浏览器 ↔ Relay 服务器",relayProxy:"Relay 服务器 ↔ 开发机",webProxy:"浏览器 ↔ 开发机"},Ihe={webRelay:{state:"idle"},relayProxy:{state:"idle"},webProxy:{state:"idle"}};function E0(e){if(!e.success||e.rttMs===void 0)return{state:"unavailable",error:e.error??"不可用",updatedAt:Date.now()};const t=e.rttMs;return{state:t<=120?"ok":t<=300?"warn":"bad",rttMs:t,updatedAt:Date.now()}}function fd(e){return{state:"unavailable",error:e,updatedAt:Date.now()}}function dp(e){return e===void 0||!Number.isFinite(e)?"--":`${Math.max(0,Math.round(e))}ms`}function BI(e){switch(e){case"bad":return 4;case"unavailable":return 3;case"warn":return 2;case"measuring":return 1;default:return 0}}function NF(e){return e==="bad"||e==="unavailable"?"bad":e==="warn"?"warn":e==="ok"?"ok":"neutral"}function Ohe(e){switch(e){case"ok":return"border-emerald-500/35 bg-emerald-500/10 text-emerald-300";case"warn":return"border-amber-500/40 bg-amber-500/10 text-amber-300";case"bad":return"border-destructive/55 bg-destructive/10 text-destructive";default:return"border-border bg-card/90 text-muted-foreground"}}function Lhe(e){return e.state==="measuring"?"检测中":e.state==="unavailable"?e.error??"不可用":e.rttMs!==void 0?dp(e.rttMs):"等待检测"}function Dhe(){const e=Ni("local",_n.latencyMonitorPosition);if(!e)return null;try{const t=JSON.parse(e);return!Number.isFinite(t.x)||!Number.isFinite(t.y)?null:{x:Number(t.x),y:Number(t.y)}}catch{return null}}function zI(e){Rr("local",_n.latencyMonitorPosition,JSON.stringify(e))}function Bhe(){var e,t;return{width:((e=window.visualViewport)==null?void 0:e.width)??window.innerWidth??document.documentElement.clientWidth??0,height:((t=window.visualViewport)==null?void 0:t.height)??window.innerHeight??document.documentElement.clientHeight??0}}function C0(e,t){const n=Bhe(),r=xv,i=xv,s=Math.max(r,n.width-t.width-xv),o=Math.max(i,n.height-t.height-xv);return{x:Math.min(s,Math.max(r,Math.round(e.x))),y:Math.min(o,Math.max(i,Math.round(e.y)))}}function zhe(){const e=Me(T=>T.latencyMonitorEnabled),t=Me(T=>T.connected),n=Me(T=>T.proxyOnline),r=Me(T=>T.selectedProxyId),[i,s]=b.useState(Ihe),[o,l]=b.useState(()=>Dhe()),u=b.useRef(!1),d=b.useRef(null),f=b.useRef(null),h=b.useRef(!1),y=b.useMemo(()=>(Object.values(i).sort((T,P)=>BI(P.state)-BI(T.state))[0]??{state:"idle"}).state,[i]),g=NF(y);async function _(){if(u.current)return;const T=$t;if(!T||!t){const U=fd("Relay 服务器未连接");s({webRelay:U,relayProxy:U,webProxy:U});return}u.current=!0,s(U=>({webRelay:{...U.webRelay,state:"measuring"},relayProxy:n?{...U.relayProxy,state:"measuring"}:fd("未连接开发机"),webProxy:n?{...U.webProxy,state:"measuring"}:fd("未连接开发机")}));const[P,z,Y]=await Promise.allSettled([T.measureWebRelayLatency(),n?T.measureRelayProxyLatency():Promise.resolve({success:!1}),n?T.measureWebProxyLatency():Promise.resolve({success:!1})]);s({webRelay:P.status==="fulfilled"?E0(P.value):fd(P.reason instanceof Error?P.reason.message:"测速失败"),relayProxy:z.status==="fulfilled"?E0(z.value):fd(z.reason instanceof Error?z.reason.message:"测速失败"),webProxy:Y.status==="fulfilled"?E0(Y.value):fd(Y.reason instanceof Error?Y.reason.message:"测速失败")}),u.current=!1}if(b.useEffect(()=>{if(!e)return;let T=!1,P=null;const z=async()=>{await _(),!T&&(P=setTimeout(z,document.hidden?Mhe:Nhe))};return z(),()=>{T=!0,u.current=!1,P&&clearTimeout(P)}},[e,t,n,r]),b.useEffect(()=>{if(!e||!o)return;const T=d.current;if(!T)return;const P=T.getBoundingClientRect(),z=C0(o,{width:P.width,height:P.height});z.x===o.x&&z.y===o.y||(l(z),zI(z))},[e,o]),!e)return null;const w=i.webProxy.rttMs!==void 0?i.webProxy:i.relayProxy,S=o!==null?{left:`${o.x}px`,top:`${o.y}px`}:void 0;function x(T){var z,Y;if(T.button!==0)return;const P=T.currentTarget.getBoundingClientRect();f.current={pointerId:T.pointerId,startX:T.clientX,startY:T.clientY,originX:P.left,originY:P.top,width:P.width,height:P.height,dragging:!1},(Y=(z=T.currentTarget).setPointerCapture)==null||Y.call(z,T.pointerId)}function k(T){const P=f.current;if(!P||P.pointerId!==T.pointerId)return;const z=T.clientX-P.startX,Y=T.clientY-P.startY;if(!P.dragging&&Math.hypot(z,Y)<Phe)return;P.dragging=!0,T.preventDefault();const U=C0({x:P.originX+z,y:P.originY+Y},{width:P.width,height:P.height});l(U)}function R(T){var G,I;const P=f.current;if(!P||P.pointerId!==T.pointerId||(f.current=null,(I=(G=T.currentTarget).releasePointerCapture)==null||I.call(G,T.pointerId),!P.dragging))return;T.preventDefault(),h.current=!0,window.setTimeout(()=>{h.current=!1},200);const z=T.clientX-P.startX,Y=T.clientY-P.startY,U=C0({x:P.originX+z,y:P.originY+Y},{width:P.width,height:P.height});l(U),zI(U)}function A(T){var z,Y;const P=f.current;!P||P.pointerId!==T.pointerId||(f.current=null,(Y=(z=T.currentTarget).releasePointerCapture)==null||Y.call(z,T.pointerId))}function M(T){h.current&&(h.current=!1,T.preventDefault(),T.stopPropagation())}return m.jsxs(Ub,{children:[m.jsx(Wb,{asChild:!0,children:m.jsxs("button",{ref:d,type:"button",className:qe("fixed z-40 flex max-w-[calc(100vw-1.5rem)] touch-none cursor-move select-none items-center gap-2 rounded-md border px-2.5 py-1.5 text-xs shadow-lg backdrop-blur transition-colors",o===null&&"right-[calc(env(safe-area-inset-right)+0.75rem)] top-[calc(env(safe-area-inset-top)+3.75rem)] md:right-4 md:top-4",Ohe(g)),style:S,"data-slot":"latency-monitor-trigger","aria-label":`延迟监控,Relay 服务器 ${dp(i.webRelay.rttMs)},开发机 ${dp(w.rttMs)}`,onPointerDown:x,onPointerMove:k,onPointerUp:R,onPointerCancel:A,onClickCapture:M,children:[m.jsx(yz,{className:"size-3.5","aria-hidden":"true"}),m.jsx("span",{className:"font-medium text-foreground",children:"延迟"}),m.jsxs("span",{className:"hidden text-muted-foreground sm:inline",children:["Relay ",dp(i.webRelay.rttMs)]}),m.jsxs("span",{className:"text-muted-foreground",children:["开发机 ",dp(w.rttMs)]}),m.jsx(sc,{className:"size-3 text-muted-foreground","aria-hidden":"true"})]})}),m.jsxs(qb,{align:"end",className:"w-[320px] p-3","data-slot":"latency-monitor-popover",children:[m.jsxs("div",{className:"flex items-start justify-between gap-3",children:[m.jsxs("div",{children:[m.jsx("div",{className:"text-sm font-medium text-foreground",children:"连接延迟"}),m.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:"数值越低,操作响应通常越快。"})]}),m.jsx(vt,{type:"button",variant:"ghost",size:"icon-xs","aria-label":"立即测速",onClick:()=>void _(),children:m.jsx(um,{className:"size-3","aria-hidden":"true"})})]}),m.jsx("div",{className:"mt-3 space-y-2",children:Object.keys(DI).map(T=>m.jsx(jhe,{label:DI[T],measurement:i[T]},T))})]})]})}function jhe({label:e,measurement:t}){const n=NF(t.state);return m.jsxs("div",{className:"flex min-h-10 items-center justify-between gap-3 rounded-md border border-border/70 bg-card/60 px-3 py-2",children:[m.jsx("div",{className:"min-w-0 truncate text-xs font-medium text-foreground",children:e}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("span",{className:qe("size-1.5 rounded-full",n==="ok"?"bg-emerald-400":n==="warn"?"bg-amber-400":n==="bad"?"bg-destructive":"bg-muted-foreground/60"),"aria-hidden":"true"}),m.jsx("span",{className:"min-w-[4rem] text-right font-mono text-xs text-foreground",children:Lhe(t)})]})]})}const MF="/__dev_anywhere_debug/browser-state-dumps",Fhe=1500,$he=10,k0=80,Ok=500,Hhe=["id","class","data-slot","data-state","data-testid","role","aria-label","aria-hidden","name","type","autocomplete","autocorrect","autocapitalize","inputmode","enterkeyhint","virtualkeyboardpolicy","contenteditable","placeholder","href","src"],Uhe=["display","position","visibility","opacity","pointer-events","z-index","overflow","overflow-x","overflow-y","touch-action","transform","translate","color-scheme","background-color","color","font-size","line-height","padding-top","padding-right","padding-bottom","padding-left","margin-top","margin-right","margin-bottom","margin-left"];function jI(){if(typeof window>"u")return"off";const e=jF("debugDump");return e==="auto"?"auto":e!==null||Qhe("debugInput")?"manual":"off"}function Whe(e="manual"){const t={count:0,truncated:!1},n=window,r={schemaVersion:1,createdAt:new Date().toISOString(),trigger:e,url:{href:window.location.href,origin:window.location.origin,pathname:window.location.pathname,search:window.location.search,hash:window.location.hash},browser:{userAgent:navigator.userAgent,language:navigator.language,languages:Array.from(navigator.languages??[]),platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints??0,cookieEnabled:navigator.cookieEnabled,onLine:navigator.onLine},viewport:Khe(),document:{title:document.title,readyState:document.readyState,visibilityState:document.visibilityState,activeElement:FI(document.activeElement),selection:Ghe(),focusedInputs:Array.from(document.querySelectorAll("input, textarea, select, [contenteditable]")).filter(i=>i===document.activeElement||i.matches(":focus")).map(i=>FI(i)).filter(i=>!!i),root:PF(document.documentElement,0,t),truncated:t.truncated,nodeCount:t.count},devAnywhere:{ptyDebug:hd(()=>{var i;return((i=n.__devAnywherePtyDebug)==null?void 0:i.call(n))??null}),ptyInputDebugSnapshot:hd(()=>n.__devAnywherePtyInputDebugSnapshot??null),ptyInputDebugText:n.__devAnywherePtyInputDebugText??null,ptyInputDebugEvents:hd(()=>n.__devAnywherePtyInputDebugEvents??null),ptyScrollTraceTail:hd(()=>$I(n.__devAnywherePtyScrollTrace)),jsonScrollTraceTail:hd(()=>$I(n.__devAnywhereJsonScrollTrace)),voicePilotDiagnostics:hd(()=>{var i;return((i=n.__devAnywhereVoicePilotDiagnostics)==null?void 0:i.snapshot())??null})}};return window.__devAnywhereLastBrowserStateDump=r,r}async function qhe(e="manual"){const t=Whe(e);return Vhe(t)}async function Vhe(e){const t=JSON.stringify(e,null,2),n=new Blob([t]).size;try{const r=await Yhe(t);return{status:"saved",path:r.path,bytes:r.bytes,endpoint:MF}}catch(r){const i=FF(r),s=Xhe(e.createdAt);return Zhe(s,t,"application/json")?{status:"downloaded",filename:s,bytes:n,endpointError:i}:{status:"failed",error:"无法保存或下载诊断包",endpointError:i}}}async function Yhe(e){const t=await fetch(MF,{method:"POST",headers:{"content-type":"application/json"},body:e});if(!t.ok)throw new Error(`${t.status} ${await t.text()}`);const n=await t.json();if(!n.ok||!n.path||typeof n.bytes!="number")throw new Error("debug endpoint returned an invalid response");return{path:n.path,bytes:n.bytes}}function PF(e,t,n){if(n.count>=Fhe||t>$he)return n.truncated=!0,{kind:"truncated"};if(n.count+=1,e.nodeType===Node.TEXT_NODE){const u=HI(e.textContent??"");return u?{kind:"text",text:Jb(u,Ok)}:{kind:"text",text:""}}if(!(e instanceof HTMLElement))return{kind:"truncated"};const r=[];let i=0;const s=Array.from(e.childNodes);for(const u of s.slice(0,k0))u.nodeType===Node.TEXT_NODE&&!HI(u.textContent??"")||r.push(PF(u,t+1,n));s.length>k0&&(i=s.length-k0,n.truncated=!0);const o={kind:"element",tag:e.tagName.toLowerCase(),path:zF(e),attrs:IF(e),rect:OF(e),scroll:LF(e),style:DF(e)},l=BF(e);return l&&(o.value=l),r.length>0&&(o.children=r),i>0&&(o.omittedChildren=i),o}function FI(e){if(!(e instanceof HTMLElement))return null;const t=BF(e);return{path:zF(e),tag:e.tagName.toLowerCase(),id:e.id||null,className:e.className||null,attrs:IF(e),rect:OF(e),scroll:LF(e),style:DF(e),...t?{value:t}:{}}}function Khe(){var n;const e=window.visualViewport,t=((n=screen.orientation)==null?void 0:n.type)??null;return{window:{innerWidth:window.innerWidth,innerHeight:window.innerHeight,outerWidth:window.outerWidth,outerHeight:window.outerHeight,devicePixelRatio:window.devicePixelRatio,scrollX:window.scrollX,scrollY:window.scrollY},visualViewport:e?{width:e.width,height:e.height,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,pageLeft:e.pageLeft,pageTop:e.pageTop,scale:e.scale}:null,screen:{width:screen.width,height:screen.height,availWidth:screen.availWidth,availHeight:screen.availHeight,orientation:t}}}function IF(e){const t={};for(const n of Hhe){const r=e.getAttribute(n);r!==null&&(t[n]=Jb(r,500))}return t}function OF(e){const t=e.getBoundingClientRect();return{x:Ss(t.x),y:Ss(t.y),width:Ss(t.width),height:Ss(t.height),top:Ss(t.top),right:Ss(t.right),bottom:Ss(t.bottom),left:Ss(t.left)}}function LF(e){return{top:Ss(e.scrollTop),left:Ss(e.scrollLeft),height:Ss(e.scrollHeight),width:Ss(e.scrollWidth),clientHeight:Ss(e.clientHeight),clientWidth:Ss(e.clientWidth)}}function DF(e){const t=window.getComputedStyle(e),n={};for(const r of Uhe)n[r]=t.getPropertyValue(r);return n}function BF(e){if(!(!(e instanceof HTMLInputElement)&&!(e instanceof HTMLTextAreaElement)))return{length:e.value.length,preview:Jb(e.value,Ok),selectionStart:e.selectionStart,selectionEnd:e.selectionEnd}}function Ghe(){var e;try{return Jb(((e=window.getSelection())==null?void 0:e.toString())??"",Ok)}catch{return null}}function zF(e){const t=[];let n=e;for(;n&&n!==document.documentElement;){let r=n.tagName.toLowerCase();if(n.id){r+=`#${n.id}`,t.unshift(r);break}const i=n.getAttribute("data-slot");i?r+=`[data-slot="${i}"]`:n.classList.length>0&&(r+=`.${Array.from(n.classList).slice(0,3).join(".")}`);const s=n.parentElement;if(s){const o=n.tagName,l=Array.from(s.children).filter(u=>u instanceof HTMLElement&&u.tagName===o);l.length>1&&(r+=`:nth-of-type(${l.indexOf(n)+1})`)}t.unshift(r),n=s}return`html>${t.join(">")}`}function Xhe(e){return`dev-anywhere-browser-state-${e.replace(/[:.]/g,"-")}.json`}function Zhe(e,t,n){if(typeof document>"u")return!1;const r=new Blob([t],{type:n}),i=URL.createObjectURL(r),s=document.createElement("a");return s.href=i,s.download=e,s.rel="noopener",document.body.append(s),s.click(),s.remove(),window.setTimeout(()=>URL.revokeObjectURL(i),1e3),!0}function Qhe(e){return jF(e)!==null}function jF(e){const t=new URLSearchParams(window.location.search);if(t.has(e))return t.get(e)??"";const[,n=""]=window.location.hash.split("?"),r=new URLSearchParams(n);return r.has(e)?r.get(e)??"":null}function $I(e){return e?qy(e.slice(-200)):null}function hd(e){try{return qy(e())}catch(t){return{error:FF(t)}}}function qy(e){if(e===null||typeof e=="string"||typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)?e:String(e);if(Array.isArray(e))return e.map(qy);if(typeof e=="object"){const t={};for(const[n,r]of Object.entries(e))t[n]=qy(r);return t}return String(e)}function HI(e){return e.replace(/\s+/g," ").trim()}function Jb(e,t){return e.length>t?`${e.slice(0,t)}...`:e}function Ss(e){return Math.round(e*100)/100}function FF(e){return e instanceof Error?e.message:String(e)}const Jhe=500,epe=1e3,tpe=60;function npe(){const[e,t]=b.useState(()=>jI()),[n,r]=b.useState(!1),[i,s]=b.useState(null),o=b.useRef(null),l=b.useRef(!1),u=b.useRef(0),d=b.useRef(0),f=b.useRef(null);b.useEffect(()=>{const _=()=>t(jI());return window.addEventListener("hashchange",_),window.addEventListener("popstate",_),()=>{window.removeEventListener("hashchange",_),window.removeEventListener("popstate",_)}},[]);const h=b.useCallback(async(_="manual")=>{if(l.current)return o.current??{status:"failed",error:"dump already running"};l.current=!0,r(!0);try{const w=await qhe(_);return o.current=w,s(w),(_==="manual"||w.status==="failed")&&rpe(w),w}finally{l.current=!1,r(!1)}},[]);if(b.useEffect(()=>(window.__devAnywhereDumpBrowserState=h,()=>{window.__devAnywhereDumpBrowserState===h&&delete window.__devAnywhereDumpBrowserState}),[h]),b.useEffect(()=>{var k,R;if(e!=="auto")return;const _=()=>{f.current!==null&&(window.clearTimeout(f.current),f.current=null)},w=A=>{d.current>=tpe||(_(),f.current=window.setTimeout(()=>{f.current=null;const M=Date.now(),T=epe-(M-u.current);if(T>0){f.current=window.setTimeout(()=>w(A),T);return}u.current=Date.now(),d.current+=1,h(`auto:${d.current}:${A}`)},Jhe))};w("initial");const S=["focusin","focusout","beforeinput","input","compositionstart","compositionupdate","compositionend","keydown","keyup","pointerdown","pointerup","resize","visibilitychange"],x=A=>w(A.type);return S.forEach(A=>window.addEventListener(A,x,!0)),(k=window.visualViewport)==null||k.addEventListener("resize",x),(R=window.visualViewport)==null||R.addEventListener("scroll",x),()=>{var A,M;_(),S.forEach(T=>window.removeEventListener(T,x,!0)),(A=window.visualViewport)==null||A.removeEventListener("resize",x),(M=window.visualViewport)==null||M.removeEventListener("scroll",x)}},[h,e]),e==="off")return null;const y=e==="auto"?"自动诊断中":"保存诊断",g=ipe(i);return m.jsxs("div",{className:"fixed bottom-3 right-3 z-[90] flex max-w-[min(360px,calc(100vw-24px))] flex-col items-end gap-1",children:[g?m.jsx("div",{className:"max-w-full truncate rounded-md border border-border/70 bg-popover/95 px-2 py-1 text-[10px] text-muted-foreground shadow",children:g}):null,m.jsxs(vt,{type:"button",size:"sm",variant:e==="auto"?"secondary":"outline",className:"h-9 rounded-md px-3 text-xs shadow-lg",onClick:()=>void h("manual"),disabled:n,"data-slot":"browser-state-dump",children:[n?m.jsx(li,{className:"size-3.5 animate-spin","aria-hidden":"true"}):m.jsx(pY,{className:"size-3.5","aria-hidden":"true"}),m.jsx("span",{children:y})]})]})}function rpe(e){if(e.status==="saved"){Ue.success(`诊断已保存: ${e.path}`);return}if(e.status==="downloaded"){Ue.info(`诊断已下载: ${e.filename}`);return}Ue.error(e.endpointError?`${e.error}: ${e.endpointError}`:e.error)}function ipe(e){return e?e.status==="saved"?`已保存 ${e.path}`:e.status==="downloaded"?`已下载 ${e.filename}`:`失败 ${e.endpointError??e.error}`:null}function spe({issue:e}){const t=e==="unreachable"?"暂时无法连接":e==="page_outdated"?"当前页面版本较旧,请刷新后重试":e==="service_outdated"?"服务端版本较旧,请更新服务后重试":e==="protocol_mismatch"?"页面与服务端版本不一致,请刷新后重试":"连接已断开",n=e==="page_outdated"||e==="protocol_mismatch"?"刷新页面":e==="service_outdated"?"重新检测":null;return m.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 px-6 text-center text-muted-foreground","data-slot":"relay-connection-state","data-state":"unavailable","data-issue":e,role:"status","aria-live":"polite",children:[e==="unreachable"?m.jsx(li,{className:"size-5 animate-spin","aria-hidden":"true"}):null,m.jsx("p",{className:"text-sm",children:t}),n?m.jsx(vt,{type:"button",size:"sm",onClick:()=>window.location.reload(),children:n}):null]})}function ope(e){if(typeof window>"u")return null;try{const t=window.localStorage;return!t||typeof t.getItem!="function"?null:t.getItem(e)}catch{return null}}function Lk(e){const{windowKey:t,storageKey:n,maxEntries:r=5e3,dedupeKey:i}=e,s=new Map,o=()=>typeof window>"u"?!1:ope(n)==="1",l=()=>typeof window>"u"?[]:window[t]??[],u=d=>{typeof window>"u"||(window[t]=d)};return{isEnabled:o,append(d){if(typeof window>"u")return;const f=l();if(i){const h=i(d);if(h!==null){const y=s.get(d.event);if(y&&i(y)===h&&f.includes(y)){y.t=d.t,y.repeat=(y.repeat??0)+1;const g=f.indexOf(y);g>=0&&g!==f.length-1&&(f.splice(g,1),f.push(y)),u(f);return}}}if(f.push(d),i&&s.set(d.event,d),f.length>r){const h=f.splice(0,f.length-r);if(i)for(const y of h)s.get(y.event)===y&&s.delete(y.event)}u(f)},getAll:l}}function Kn(e){return Math.round(e*10)/10}function Bl(e){return e.length===0?"":`${Kn(Math.min(...e))}..${Kn(Math.max(...e))}`}function Od(e){return[...new Set(e.filter(t=>t!==void 0).map(Kn))]}function $F(e){let t=0,n=0;for(let r=1;r<e.length;r+=1){const i=e[r]-e[r-1];if(Math.abs(i)<1)continue;const s=Math.sign(i);t!==0&&s!==t&&(n+=1),t=s}return n}const ape="dev_anywhere_pty_input_latency_trace",UI=80,lpe=1e4,cpe=new TextDecoder;let upe=0;const af=new Map,Cu=Lk({windowKey:"__devAnywherePtyInputLatencyTrace",storageKey:ape,dedupeKey:e=>e.event.startsWith("input")?null:`${e.event}|${e.sessionId}|${e.outputSeq??""}|${e.pendingInputs??""}`});function dpe(){typeof window>"u"||(window.__devAnywherePtyInputLatencyReport=mpe)}function fpe(e,t){if(!Cu.isEnabled())return null;const n=`pty-in-${Date.now().toString(36)}-${++upe}`,r=performance.now(),i={inputId:n,sessionId:e,data:t,kind:ype(t),dataLength:t.length,startedAt:r,sentAt:null,firstOutputAt:null,echoMatchedAt:null,xtermWriteAt:null,paintAt:null},s=af.get(e)??[];return s.push(i),Bk(s,r),af.set(e,s),Tm({t:r,event:"input:start",sessionId:e,inputId:n,inputKind:i.kind,dataLength:i.dataLength,pendingInputs:s.length}),{inputId:n,sessionId:e}}function WI(e,t){if(!e||!Cu.isEnabled())return;const n=performance.now(),r=gpe(e.sessionId,e.inputId);r&&(r.sentAt=n),Tm({t:n,event:"input:ws-send",sessionId:e.sessionId,inputId:e.inputId,inputKind:r==null?void 0:r.kind,dataLength:r==null?void 0:r.dataLength,sent:t.sent,queueWhenDisconnected:t.queueWhenDisconnected,deltaFromInputMs:r?n-r.startedAt:null,details:t.details})}function hpe(e,t,n){if(!Cu.isEnabled())return;const r=performance.now(),i=Dk(e,r),s=wpe(t),o=[],l=[];for(const u of i)u.firstOutputAt===null&&(u.firstOutputAt=r,o.push(u.inputId)),u.echoMatchedAt===null&&_pe(u)&&s.includes(u.data)&&(u.echoMatchedAt=r,l.push(u.inputId));Tm({t:r,event:"output:received",sessionId:e,outputSeq:n,bytes:t.byteLength,pendingInputs:i.length,deltaFromInputMs:zk(i,r),details:xpe([o.length>0?`first=${o.length}`:"",l.length>0?`echo=${l.length}`:""])})}function ppe(e,t,n=1){if(!Cu.isEnabled())return;const r=performance.now(),i=Dk(e,r),s=[];for(const o of i)o.xtermWriteAt===null&&(o.xtermWriteAt=r,s.push(o.inputId));Tm({t:r,event:"output:xterm-write",sessionId:e,bytes:t,chunkCount:n,pendingInputs:i.length,deltaFromInputMs:zk(i,r),details:s.length>0?`firstWrite=${s.length}`:""}),typeof requestAnimationFrame=="function"&&s.length>0&&requestAnimationFrame(()=>vpe(e,s))}function mpe(){const e=Cu.getAll(),t=e.slice(-200),n=[...af.values()].flat(),r=n.slice(-80).map(s=>[s.inputId,s.sessionId,s.kind,s.dataLength,s.sentAt===null?"":Kn(s.sentAt-s.startedAt),s.firstOutputAt===null?"":Kn(s.firstOutputAt-s.startedAt),s.echoMatchedAt===null?"":Kn(s.echoMatchedAt-s.startedAt),s.xtermWriteAt===null?"":Kn(s.xtermWriteAt-s.startedAt),s.paintAt===null?"":Kn(s.paintAt-s.startedAt)].join(" ")),i=t.map(s=>[Kn(s.t),s.repeat&&s.repeat>0?`${s.event} +${s.repeat}`:s.event,s.sessionId,s.inputId??"",s.inputKind??"",s.dataLength??"",s.sent===void 0?"":s.sent?"sent":"not-sent",s.queueWhenDisconnected?"queue-ok":"",s.outputSeq??"",s.bytes??"",s.chunkCount??"",s.pendingInputs??"",s.deltaFromInputMs===void 0||s.deltaFromInputMs===null?"":Kn(s.deltaFromInputMs),s.details??""].join(" "));return["DEV Anywhere PTY input latency trace",`events=${e.length}, included=${t.length}, pendingInputs=${n.length}`,"pending input summary:","inputId sessionId kind len wsSendMs firstOutputMs echoMatchMs xtermWriteMs paintMs",...r,"events:","t event sessionId inputId kind len sent queue outputSeq bytes chunks pending deltaMs details",...i].join(`
601
601
  `)}function Tm(e){Cu.append(e)}function Dk(e,t){const n=af.get(e)??[];return Bk(n,t),af.set(e,n),n}function Bk(e,t){for(let n=e.length-1;n>=0;n-=1){const r=e[n],i=r.paintAt!==null,s=t-r.startedAt>lpe;(i||s)&&e.splice(n,1)}e.length>UI&&e.splice(0,e.length-UI)}function gpe(e,t){return(af.get(e)??[]).find(n=>n.inputId===t)??null}function vpe(e,t){if(!Cu.isEnabled())return;const n=performance.now(),r=Dk(e,n);let i=0;for(const s of t){const o=r.find(l=>l.inputId===s);!o||o.paintAt!==null||(o.paintAt=n,i+=1)}Tm({t:n,event:"output:paint",sessionId:e,pendingInputs:r.length,deltaFromInputMs:zk(r,n),details:i>0?`paint=${i}`:""}),Bk(r,n)}function zk(e,t){const n=e[0];return n?t-n.startedAt:null}function ype(e){return e==="\r"||e===`
602
602
  `?"enter":e.startsWith("\x1B")?"escape":bpe(e)?"control":e.length>16?"paste":/[\r\n]/.test(e)?"mixed":"printable"}function bpe(e){for(let t=0;t<e.length;t+=1){const n=e.charCodeAt(t);if(n>=0&&n<=8||n>=11&&n<=31||n===127)return!0}return!1}function _pe(e){return e.kind==="printable"&&e.data.length>0&&e.data.length<=16}function wpe(e){try{return cpe.decode(e)}catch{return""}}function xpe(e){return e.filter(Boolean).join(" ")}function Mo(e,t){if(!e||!t)return;const n=fpe(e,t),r=Ua;if(!r){WI(n,{sent:!1,queueWhenDisconnected:!1,details:"no-ws-manager"});return}const i={type:"remote_input_raw",sessionId:e,data:t};n&&(i.traceId=n.inputId);const s=r.send(JSON.stringify(i),{queueWhenDisconnected:!0});WI(n,{sent:s,queueWhenDisconnected:!0,details:s?"sent-open-socket":"queued-or-dropped"})}function Spe({sessionId:e,enabled:t,waiting:n,approvalRequestId:r,approvalScopeKey:i=e,history:s,sendRawInput:o=Mo}){const l=b.useRef(new Map),u=s??l.current;b.useEffect(()=>{let d=u.get(i);if(d||(d={sent:!1,confirmedRequestIds:new Set},u.set(i,d)),!n){d.sent=!1,d.confirmedRequestId=void 0;return}if(r&&d.confirmedRequestIds.has(r)){d.sent=!0,d.confirmedRequestId=r;return}if(d.sent&&r&&d.confirmedRequestId===void 0){d.confirmedRequestId=r,d.confirmedRequestIds.add(r);return}d.sent&&(!r||d.confirmedRequestId===r)||t&&(d.sent=!0,d.confirmedRequestId=r,r&&d.confirmedRequestIds.add(r),o(e,"\r"))},[u,r,i,t,o,e,n])}function Epe(e){var i,s;if(e.session.mode!=="pty"||e.session.kind==="terminal"||e.session.provider==="codex")return null;const t=WC(e.proxyId,e.session.sessionId);if(!t)return null;const n=!["idle","error","terminated"].includes(e.session.state),r=((i=e.agentStatus)==null?void 0:i.provider)===e.session.provider&&e.agentStatus.phase==="waiting_permission"?(s=e.agentStatus.permissionRequest)==null?void 0:s.requestId:void 0;return{key:t,sessionId:e.session.sessionId,enabled:e.connected&&e.proxyOnline&&!!e.autoYesBySessionKey[t],waiting:n&&(e.session.state==="waiting_approval"||!!r),approvalRequestId:r}}function Cpe({target:e,sendRawInput:t,history:n}){return Spe({sessionId:e.sessionId,enabled:e.enabled,waiting:e.waiting,approvalRequestId:e.approvalRequestId,approvalScopeKey:e.key,history:n,sendRawInput:t}),null}function kpe({sendRawInput:e=Mo}){const t=Me(d=>d.connected),n=Me(d=>d.proxyOnline),r=Me(d=>d.selectedProxyId),i=Ut(d=>d.sessions),s=Ut(d=>d.agentStatusBySessionId),o=Ut(d=>d.ptyAutoYesBySessionKey),l=b.useRef(new Map),u=i.map(d=>Epe({proxyId:r,session:d,agentStatus:s[d.sessionId],autoYesBySessionKey:o,connected:t,proxyOnline:n})).filter(d=>d!==null);return m.jsx(m.Fragment,{children:u.map(d=>m.jsx(Cpe,{target:d,sendRawInput:e,history:l.current},d.key))})}function Tpe(e,t){return e.some(n=>n.sessionId===t)?e:[...e,{sessionId:t}]}var Xc=function(e,t){return Number(e.toFixed(t))},Rpe=function(e,t){return t},nr=function(e,t,n){n&&typeof n=="function"&&n(e,t)},Ape=function(e){return-Math.cos(e*Math.PI)/2+.5},Npe=function(e){return e},Mpe=function(e){return e*e},Ppe=function(e){return e*(2-e)},Ipe=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},Ope=function(e){return e*e*e},Lpe=function(e){return--e*e*e+1},Dpe=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},Bpe=function(e){return e*e*e*e},zpe=function(e){return 1- --e*e*e*e},jpe=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},Fpe=function(e){return e*e*e*e*e},$pe=function(e){return 1+--e*e*e*e*e},Hpe=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},HF={easeOut:Ape,linear:Npe,easeInQuad:Mpe,easeOutQuad:Ppe,easeInOutQuad:Ipe,easeInCubic:Ope,easeOutCubic:Lpe,easeInOutCubic:Dpe,easeInQuart:Bpe,easeOutQuart:zpe,easeInOutQuart:jpe,easeInQuint:Fpe,easeOutQuint:$pe,easeInOutQuint:Hpe},UF=function(e){typeof e=="number"&&cancelAnimationFrame(e)},No=function(e){e.mounted&&(UF(e.animation),e.isAnimating=!1,e.animation=null,e.velocity=null)};function WF(e,t,n,r){if(e.mounted){var i=new Date().getTime(),s=1;No(e),e.animation=function(){if(!e.mounted)return UF(e.animation);var o=new Date().getTime()-i,l=o/n,u=HF[t],d=u(l);o>=n?(r(s),e.animation=null):e.animation&&(r(d),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function Upe(e){var t=e.scale,n=e.positionX,r=e.positionY;return!(Number.isNaN(t)||Number.isNaN(n)||Number.isNaN(r))}function vc(e,t,n,r){var i=Upe(t);if(!(!e.mounted||!i)){var s=e.setState,o=e.state,l=o.scale,u=o.positionX,d=o.positionY,f=t.scale-l,h=t.positionX-u,y=t.positionY-d;n===0?s(t.scale,t.positionX,t.positionY):WF(e,r,n,function(g){g!==1?e.isAnimating=!0:e.isAnimating=!1;var _=l+f*g,w=u+h*g,S=d+y*g;s(_,w,S)})}}function Wpe(e,t,n){var r=e.offsetWidth,i=e.offsetHeight,s=t.offsetWidth,o=t.offsetHeight,l=s*n,u=o*n,d=r-l,f=i-u;return{wrapperWidth:r,wrapperHeight:i,newContentWidth:l,newDiffWidth:d,newContentHeight:u,newDiffHeight:f}}var qpe=function(e,t,n,r,i,s,o){var l=e>t?n*(o?.5:1):0,u=r>i?s*(o?.5:1):0,d=e-t-l,f=l,h=r-i-u,y=u;return{minPositionX:d,maxPositionX:f,minPositionY:h,maxPositionY:y,scaleWidthFactor:l,scaleHeightFactor:u}},jk=function(e,t){var n=e.wrapperComponent,r=e.contentComponent,i=e.setup,s=i.centerZoomedOut,o=i.disablePadding;if(!n||!r)throw new Error("Components are not mounted");var l=Wpe(n,r,t),u=l.wrapperWidth,d=l.wrapperHeight,f=l.newContentWidth,h=l.newContentHeight,y=l.newDiffWidth,g=l.newDiffHeight,_=qpe(u,f,y,d,h,g,!!s),w=u>=f&&d>=h;o&&w&&!s&&(_.minPositionX=0,_.maxPositionX=0,_.minPositionY=0,_.maxPositionY=0);var S=e.setup,x=S.minPositionX,k=S.maxPositionX,R=S.minPositionY,A=S.maxPositionY;return x!=null&&(_.minPositionX=u*(1-t)+x*t),k!=null&&(_.maxPositionX=k*t),R!=null&&(_.minPositionY=d*(1-t)+R*t),A!=null&&(_.maxPositionY=A*t),_},Yp=function(e,t,n,r){return r?e<t?Xc(t,2):e>n?Xc(n,2):Xc(e,2):Xc(e,2)},lf=function(e,t){var n=jk(e,t);return e.bounds=n,n};function Rm(e,t,n,r,i,s,o){var l=n.minPositionX,u=n.minPositionY,d=n.maxPositionX,f=n.maxPositionY,h=0,y=0;o&&(h=i,y=s);var g=Yp(e,l-h,d+h,r),_=Yp(t,u-y,f+y,r);return{x:g,y:_}}function e_(e,t,n,r,i,s){var o=e.state,l=o.scale,u=o.positionX,d=o.positionY,f=r-l;if(typeof t!="number"||typeof n!="number")return console.error("Mouse X and Y position were not provided!"),{x:u,y:d};var h=u-t*f,y=d-n*f,g=Rm(h,y,i,s,0,0,null);return g}var qI=1e-7;function Am(e,t,n,r,i){var s=i?r:0,o=Math.max(t-s,qI),l=n+s;return!Number.isNaN(n)&&e>=l?l:!Number.isNaN(t)&&e<=o?o:Math.max(e,qI)}var VI=function(e,t){var n=e.setup.panning.excluded,r=e.isInitialized,i=e.wrapperComponent,s=t.target,o="shadowRoot"in s&&"composedPath"in t,l=o?t.composedPath().some(function(f){return f instanceof Element?i==null?void 0:i.contains(f):!1}):i==null?void 0:i.contains(s),u=r&&s&&l;if(!u)return!1;var d=Nm(s,n);return!(d||s.getAttribute("draggable")==="true"||s.getAttribute("contenteditable")==="true"||s.isContentEditable)},YI=function(e){var t=e.isInitialized,n=e.isPanning,r=e.setup,i=r.panning.disabled,s=t&&n&&!i;return!!s},Vpe=function(e,t){var n=e.state,r=n.positionX,i=n.positionY;e.isPanning=!0;var s=t.clientX,o=t.clientY;e.startCoords={x:s-r,y:o-i}},Ype=function(e,t){var n=t.touches,r=e.state,i=r.positionX,s=r.positionY;e.isPanning=!0;var o=n.length===1;if(o){var l=n[0].clientX,u=n[0].clientY;e.startCoords={x:l-i,y:u-s}}};function Kpe(e){var t=e.state,n=t.positionX,r=t.positionY,i=t.scale,s=e.setup,o=s.disabled,l=s.limitToBounds,u=s.centerZoomedOut,d=e.wrapperComponent;if(!(o||!d||!e.bounds)){var f=e.bounds,h=f.maxPositionX,y=f.minPositionX,g=f.maxPositionY,_=f.minPositionY,w=n>h||n<y,S=r>g||r<_,x=n>h?d.offsetWidth:e.setup.minPositionX||0,k=r>g?d.offsetHeight:e.setup.minPositionY||0,R=e_(e,x,k,i,e.bounds,l||u),A=R.x,M=R.y;return{scale:i,positionX:w?A:n,positionY:S?M:r}}}function qF(e,t,n,r,i){var s=e.setup.limitToBounds,o=e.wrapperComponent,l=e.bounds,u=e.state,d=u.scale,f=u.positionX,h=u.positionY;if(!(o===null||l===null||t===f&&n===h)){var y=Rm(t,n,l,s,r,i,o),g=y.x,_=y.y;e.setState(d,g,_)}}var Gpe=function(e,t,n){var r=e.startCoords,i=e.state,s=e.setup.panning,o=s.lockAxisX,l=s.lockAxisY,u=i.positionX,d=i.positionY;if(!r)return{x:u,y:d};var f=t-r.x,h=n-r.y,y=o?u:f,g=l?d:h;return{x:y,y:g}},nc=function(e,t,n){var r=e.setup,i=e.state,s=r.minScale,o=r.disablePadding,l=r.centerZoomedOut,u=n??i.scale;return t>0&&u>=s&&!o&&!l?t:0},ql;(function(e){e.TRACK_PAD="track_pad",e.MOUSE="mouse",e.TOUCH="touch"})(ql||(ql={}));var Xpe=function(e){var t=e.mounted,n=e.wrapperComponent,r=e.contentComponent,i=e.setup,s=i.disabled,o=i.velocityAnimation,l=i.limitToBounds,u=e.state.scale,d=o.disabled;if(d||s||!t||!n||!r)return!1;if(!l)return!0;var f=n.offsetWidth<r.offsetWidth*u||n.offsetHeight<r.offsetHeight*u;return f},Zpe=function(e){var t=e.mounted,n=e.velocity,r=e.bounds,i=e.setup,s=i.disabled,o=i.velocityAnimation,l=o.disabled,u=!l&&!s&&t;return!(!u||!n||!r)};function Qpe(e,t){var n=e.setup.velocityAnimation,r=n.animationTime,i=n.maxAnimationTime,s=n.inertia;return Math.min(r*Math.max(1,Math.abs(t/s)),i)}function KI(e,t,n,r,i,s,o,l,u,d){if(i){if(t>o&&n>o){var f=o+(e-o)*d;return f>u?u:f<o?o:f}if(t<s&&n<s){var f=s+(e-s)*d;return f<l?l:f>s?s:f}}return r?t:Yp(e,s,o,i)}function Jpe(e){var t=1,n=e.offsetWidth/window.innerWidth;return Number.isNaN(n)?t:Math.min(t,n)}var T0=function(e,t,n){var r=0,i=e*n;return Number.isNaN(i)?r:e<0?Math.max(i,-t):Math.min(i,t)};function eme(e,t,n){var r,i,s=Xpe(e);if(s){var o=e.lastMousePosition,l=e.velocityTime,u=e.setup,d=e.wrapperComponent,f=u.velocityAnimation,h=f.maxStrengthMouse,y=f.maxStrengthTouch,g=f.sensitivityTouch,_=f.sensitivityMouse,w=Date.now();if(o&&l&&d){var S=Jpe(d),x=(r={},r[ql.TOUCH]=g,r[ql.MOUSE]=_,r)[n],k=(i={},i[ql.TOUCH]=y,i[ql.MOUSE]=h,i)[n],R=t.x-o.x,A=t.y-o.y,M=T0(R/S,k,x),T=T0(A/S,k,x),P=w-l,z=R*R+A*A,Y=T0(Math.sqrt(z)/P,k,x);e.velocity={velocityX:M,velocityY:T,total:Y}}e.lastMousePosition=t,e.velocityTime=w}}function tme(e){var t=e.velocity,n=e.bounds,r=e.setup,i=e.wrapperComponent,s=Zpe(e);if(!(!s||!t||!n||!i)){var o=t.velocityX,l=t.velocityY,u=t.total,d=n.maxPositionX,f=n.minPositionX,h=n.maxPositionY,y=n.minPositionY,g=r.limitToBounds,_=r.autoAlignment,w=r.zoomAnimation,S=r.panning,x=S.lockAxisY,k=S.lockAxisX,R=w.animationType,A=_.sizeX,M=_.sizeY,T=_.velocityAlignmentTime,P=T,z=Qpe(e,u),Y=Math.max(z,P),U=nc(e,A),G=nc(e,M),I=U*i.offsetWidth/100,N=G*i.offsetHeight/100,L=d+I,B=f-I,O=h+N,D=y-N,F=e.state,V=new Date().getTime();WF(e,R,Y,function(j){var q=e.state,K=q.scale,$=q.positionX,te=q.positionY,J=new Date().getTime()-V,ne=J/P,Q=HF[_.animationType],ce=1-Q(Math.min(1,ne)),re=1-j,le=$+o*re,we=te+l*re,Ce=KI(le,F.positionX,$,k,g,f,d,B,L,ce),ye=KI(we,F.positionY,te,x,g,y,h,D,O,ce);if($!==le||te!==we){e.setState(K,Ce,ye);var Re=e.props.onPanning;Re&&Re(Gn(e),{})}})}}function GI(e,t){var n=e.state,r=n.scale,i=n.positionX,s=n.positionY;e.panStartPosition={x:i,y:s},No(e),lf(e,r),window.TouchEvent!==void 0&&t instanceof TouchEvent?Ype(e,t):Vpe(e,t)}function VF(e,t){var n=e.state.scale,r=e.setup,i=r.minScale,s=r.autoAlignment,o=s.disabled,l=s.sizeX,u=s.sizeY,d=s.animationTime,f=s.animationType,h=o||n<i||!l&&!u;if(!h){var y=Kpe(e);y&&vc(e,y,d,f)}}function XI(e,t,n,r){var i=e.startCoords,s=e.setup,o=s.autoAlignment,l=o.sizeX,u=o.sizeY;if(i){var d=Gpe(e,t,n),f=d.x,h=d.y,y=nc(e,l),g=nc(e,u);eme(e,{x:f,y:h},r),qF(e,f,h,y,g)}}function nme(e,t){if(e.isPanning){var n=e.velocity,r=e.wrapperComponent,i=e.contentComponent;e.isPanning=!1;var s=e.state,o=s.positionX,l=s.positionY,u=s.scale,d=e.panStartPosition;if(e.panStartPosition=null,d){var f=o-d.x,h=l-d.y;if(f*f+h*h<=25)return}e.isAnimating=!1,e.animation=null;var y=(r==null?void 0:r.offsetWidth)||0,g=(r==null?void 0:r.offsetHeight)||0,_=((i==null?void 0:i.offsetWidth)||0)*u,w=((i==null?void 0:i.offsetHeight)||0)*u,S=!e.setup.limitToBounds||y<_||g<w,x=!t&&n&&n.total>.1&&S;x?tme(e):VF(e)}}function Fk(e,t,n,r){var i=e.setup,s=i.minScale,o=i.maxScale,l=i.limitToBounds,u=Am(Xc(t,2),s,o,0,!1),d=lf(e,u),f=e_(e,n,r,u,d,l),h=f.x,y=f.y;return{scale:u,positionX:h,positionY:y}}function $k(e,t,n){var r=e.state.scale,i=e.wrapperComponent,s=e.setup,o=s.minScale,l=s.maxScale,u=s.limitToBounds,d=s.zoomAnimation,f=d.disabled,h=d.animationTime,y=d.animationType,g=r>=o&&r<=l,_=f||g;if((r>=1||u)&&VF(e),!(_||!i||!e.mounted)){var w=t||i.offsetWidth/2,S=n||i.offsetHeight/2,x=r<o?o:l,k=Fk(e,x,w,S);k&&vc(e,k,h,y)}}var ho=function(){return ho=Object.assign||function(t){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},ho.apply(this,arguments)};function ZI(e,t,n){for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}var R0={scale:1,positionX:0,positionY:0},Yc={disabled:!1,minPositionX:null,maxPositionX:null,minPositionY:null,maxPositionY:null,minScale:1,maxScale:8,limitToBounds:!0,centerZoomedOut:!1,centerOnInit:!1,disablePadding:!1,smooth:!0,detached:!1,wheel:{step:.015,disabled:!1,wheelDisabled:!1,touchPadDisabled:!1,activationKeys:[],excluded:[]},trackPadPanning:{disabled:!0,velocityDisabled:!1,lockAxisX:!1,lockAxisY:!1,activationKeys:[],excluded:[]},panning:{disabled:!1,velocityDisabled:!1,lockAxisX:!1,lockAxisY:!1,allowLeftClickPan:!0,allowMiddleClickPan:!0,allowRightClickPan:!0,activationKeys:[],excluded:[]},pinch:{step:5,disabled:!1,allowPanning:!0,excluded:[]},doubleClick:{disabled:!1,step:.7,mode:"zoomIn",animationType:"easeOut",animationTime:200,excluded:[]},zoomAnimation:{disabled:!1,size:.4,animationTime:200,animationType:"easeOut"},autoAlignment:{disabled:!1,sizeX:100,sizeY:100,animationTime:200,velocityAlignmentTime:400,animationType:"easeOut"},velocityAnimation:{disabled:!1,sensitivityMouse:1,sensitivityTouch:1.2,maxStrengthMouse:20,maxStrengthTouch:40,inertia:1,animationTime:300,maxAnimationTime:800,animationType:"easeOut"}},L1={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},YF=function(e){var t,n,r,i,s,o,l,u,d,f=Math.max((t=e.minScale)!==null&&t!==void 0?t:Yc.minScale,1e-7),h=(n=e.maxScale)!==null&&n!==void 0?n:Yc.maxScale,y=(r=e.initialScale)!==null&&r!==void 0?r:R0.scale,g=Math.min(Math.max(y,f),h),_=Yp((i=e.initialPositionX)!==null&&i!==void 0?i:R0.positionX,(s=e.minPositionX)!==null&&s!==void 0?s:-1/0,(o=e.maxPositionX)!==null&&o!==void 0?o:1/0,e.minPositionX!=null||e.maxPositionX!=null),w=Yp((l=e.initialPositionY)!==null&&l!==void 0?l:R0.positionY,(u=e.minPositionY)!==null&&u!==void 0?u:-1/0,(d=e.maxPositionY)!==null&&d!==void 0?d:1/0,e.minPositionY!=null||e.maxPositionY!=null);return{previousScale:g,scale:g,positionX:_,positionY:w}},QI=function(e){var t=ho({},Yc);return Object.keys(e).forEach(function(n){var r=n,i=typeof e[r]<"u",s=typeof Yc[r]<"u";if(s&&i){var o=Object.prototype.toString.call(Yc[r]),l=o==="[object Object]",u=o==="[object Array]";l?t[r]=ho(ho({},Yc[r]),e[r]):u?t[r]=ZI(ZI([],Yc[r],!0),e[r]):t[r]=e[r]}}),t.minScale<=0&&(t.minScale=1e-7),t},KF=function(e,t,n){var r=e.state.scale,i=e.wrapperComponent,s=e.setup,o=s.maxScale,l=s.minScale,u=s.zoomAnimation,d=s.smooth,f=u.size;if(!i)throw new Error("Wrapper is not mounted");var h=d?r*Math.exp(t*n):r+t*n,y=Am(Xc(h,3),l,o,f,!1);return y};function GF(e,t,n,r,i){var s,o,l=e.wrapperComponent,u=e.state,d=u.scale,f=u.positionX,h=u.positionY,y=e.setup.zoomAnimation;if(!l)return console.error("No WrapperComponent found");var g=y.disabled?0:r,_=l.offsetWidth,w=l.offsetHeight,S=(_/2-f)/d,x=(w/2-h)/d,k=KF(e,t,n),R=Fk(e,k,S,x);if(!R)return console.error("Error during zoom event. New transformation state was not calculated.");var A=e.props,M=A.onZoomStart,T=A.onZoom,P=A.onZoomStop,z=new MouseEvent("mousemove",{bubbles:!0}),Y=Gn(e);nr(Y,z,M),nr(Y,z,T),vc(e,R,g,i);var U=(o=(s=l.ownerDocument)===null||s===void 0?void 0:s.defaultView)!==null&&o!==void 0?o:typeof window<"u"?window:null;U&&U.setTimeout(function(){e.mounted&&nr(Gn(e),z,P)},g)}function XF(e,t,n,r){var i,s,o=e.setup,l=e.wrapperComponent,u=e.contentComponent,d=o.limitToBounds,f=o.centerOnInit,h=YF(e.props),y=e.state,g=y.scale,_=y.positionX,w=y.positionY;if(l){var S=h.positionX,x=h.positionY;if(f&&u){var k=Hk(h.scale,l,u);S=k.positionX,x=k.positionY}var R=jk(e,h.scale),A=Rm(S,x,R,d,0,0,l),M={scale:h.scale,positionX:A.x,positionY:A.y};if(!(g===h.scale&&_===h.positionX&&w===h.positionY)){r==null||r();var T=e.props,P=T.onZoomStart,z=T.onZoom,Y=T.onZoomStop,U=new MouseEvent("mousemove",{bubbles:!0}),G=Gn(e);nr(G,U,P),nr(G,U,z),vc(e,M,t,n);var I=(s=(i=l.ownerDocument)===null||i===void 0?void 0:i.defaultView)!==null&&s!==void 0?s:typeof window<"u"?window:null;I&&I.setTimeout(function(){e.mounted&&nr(Gn(e),U,Y)},t)}}}function rme(e,t,n,r){var i=e.getBoundingClientRect(),s=t.getBoundingClientRect(),o=n.getBoundingClientRect(),l=s.x*r.scale,u=s.y*r.scale;return{x:(i.x-o.x+l)/r.scale,y:(i.y-o.y+u)/r.scale}}function ime(e,t,n,r,i){r===void 0&&(r=0),i===void 0&&(i=0);var s=e.wrapperComponent,o=e.contentComponent,l=e.state,u=e.setup,d=u.limitToBounds,f=u.minScale,h=u.maxScale;if(!s||!o)return l;var y=s.getBoundingClientRect(),g=t.getBoundingClientRect(),_=rme(t,s,o,l),w=_.x,S=_.y,x=g.width/l.scale,k=g.height/l.scale,R=s.offsetWidth/x,A=s.offsetHeight/k,M=Am(n||Math.min(R,A),f,h,0,!1),T=(y.width-x*M)/2,P=(y.height-k*M)/2,z=(y.left-w)*M+T+r,Y=(y.top-S)*M+P+i,U=jk(e,M),G=Rm(z,Y,U,d,0,0,s),I=G.x,N=G.y;return{positionX:I,positionY:N,scale:M}}var sme=function(e){return function(t,n,r){t===void 0&&(t=.5),n===void 0&&(n=300),r===void 0&&(r="easeOut"),GF(e,1,t,n,r)}},ome=function(e){return function(t,n,r){t===void 0&&(t=.5),n===void 0&&(n=300),r===void 0&&(r="easeOut"),GF(e,-1,t,n,r)}},ame=function(e){return function(t,n,r,i,s){i===void 0&&(i=300),s===void 0&&(s="easeOut");var o=e.state,l=o.positionX,u=o.positionY,d=o.scale,f=e.wrapperComponent,h=e.contentComponent,y=e.setup.disabled;if(!(y||!f||!h)){var g={positionX:Number.isNaN(t)?l:t,positionY:Number.isNaN(n)?u:n,scale:Number.isNaN(r)?d:r};vc(e,g,i,s)}}},lme=function(e){return function(t,n){t===void 0&&(t=200),n===void 0&&(n="easeOut"),XF(e,t,n)}},cme=function(e){return function(t,n,r){n===void 0&&(n=200),r===void 0&&(r="easeOut");var i=e.state,s=e.wrapperComponent,o=e.contentComponent;if(s&&o){var l=Hk(t||i.scale,s,o);vc(e,l,n,r)}}},ume=function(e){return function(t,n,r,i,s,o){r===void 0&&(r=600),i===void 0&&(i="easeOut"),s===void 0&&(s=0),o===void 0&&(o=0),No(e);var l=e.wrapperComponent,u=typeof t=="string"?document.getElementById(t):t;if(l&&u&&l.contains(u)){var d=ime(e,u,n,s,o);vc(e,d,r,i)}}},D1=function(e){return{instance:e,state:e.state,zoomIn:sme(e),zoomOut:ome(e),setTransform:ame(e),resetTransform:lme(e),centerView:cme(e),zoomToElement:ume(e)}},dme=function(e){return{instance:e,state:e.state}},Gn=function(e){var t={};return Object.assign(t,dme(e)),Object.assign(t,D1(e)),t},A0=!1;function N0(){try{var e={get passive(){return A0=!0,!1}};return e}catch{return A0=!1,A0}}var Sv=".".concat(L1.wrapperClass),Nm=function(e,t){return t.some(function(n){return e.matches("".concat(Sv," ").concat(n,", ").concat(Sv," .").concat(n,", ").concat(Sv," ").concat(n," *, ").concat(Sv," .").concat(n," *"))})},Kp=function(e){e&&clearTimeout(e)},fme=function(e){return Number.parseFloat(e.toFixed(8))},ZF=function(e,t,n){var r=fme(n);return"translate(".concat(e,"px, ").concat(t,"px) scale(").concat(r,")")},Hk=function(e,t,n){var r=n.offsetWidth*e,i=n.offsetHeight*e,s=(t.offsetWidth-r)/2,o=(t.offsetHeight-i)/2;return{scale:e,positionX:s,positionY:o}};function hme(e,t){e!=null&&(typeof e=="function"?e(t):e.current=t)}function pme(e){return function(t){e.forEach(function(n){typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var QF=function(e,t){var n=e.setup.wheel,r=n.disabled,i=n.wheelDisabled,s=n.touchPadDisabled,o=n.excluded,l=e.isInitialized,u=e.isPanning,d=t.target,f=l&&!u&&!r&&d;if(!f||i&&!t.ctrlKey||s&&t.ctrlKey)return!1;var h=Nm(d,o);if(h)return!1;var y=e.isPressingKeys(e.setup.wheel.activationKeys);return!!y},mme=function(e,t){var n=e.setup,r=n.disabled,i=n.trackPadPanning,s=i.activationKeys,o=i.excluded;if(!e.wrapperComponent||!e.contentComponent||r||i.disabled||t.ctrlKey)return!1;var l=QF(e,t);if(l)return!1;var u=t.target,d=Nm(u,o);if(d)return!1;var f=e.isPressingKeys(s);return!!f},gme=function(e){return e?e.deltaY<0?1:-1:0};function vme(e,t){var n=gme(e),r=Rpe(t,n);return r}function JF(e,t,n){var r=t.getBoundingClientRect(),i=0,s=0;if("clientX"in e)i=(e.clientX-r.left)/n,s=(e.clientY-r.top)/n;else{var o=e.touches[0];i=(o.clientX-r.left)/n,s=(o.clientY-r.top)/n}return(Number.isNaN(i)||Number.isNaN(s))&&console.error("No mouse or touch offset found"),{x:i,y:s}}var yme=function(e,t,n,r,i){var s=e.state.scale,o=e.wrapperComponent,l=e.setup,u=l.maxScale,d=l.minScale,f=l.zoomAnimation,h=l.disablePadding,y=f.size,g=f.disabled;if(!o)throw new Error("Wrapper is not mounted");var _=s+t*n,w=r?!1:!g,S=Am(_,d,u,y,w&&!h);return S},e$=function(e,t){var n=e.previousWheelEvent,r=e.state.scale,i=e.setup,s=i.maxScale,o=i.minScale;return n?r<s||r>o||Math.sign(n.deltaY)!==Math.sign(t.deltaY)||n.deltaY>0&&n.deltaY<t.deltaY||n.deltaY<0&&n.deltaY>t.deltaY||Math.sign(n.deltaY)!==Math.sign(t.deltaY):!1},bme=function(e,t){var n=e.setup.pinch,r=n.disabled,i=n.excluded,s=e.isInitialized,o=t.target,l=s&&!r&&o;if(!l)return!1;var u=Nm(o,i);return!u},_me=function(e){var t=e.setup.pinch.disabled,n=e.isInitialized,r=e.pinchStartDistance,i=n&&!t&&r!==null;return!!i},wme=function(e,t,n){var r=n.getBoundingClientRect(),i=e.touches,s=i[0].clientX-r.left,o=i[0].clientY-r.top,l=i[1].clientX-r.left,u=i[1].clientY-r.top;return{x:(s+l)/2/t,y:(o+u)/2/t}},t$=function(e){return Math.sqrt(Math.pow(e.touches[0].pageX-e.touches[1].pageX,2)+Math.pow(e.touches[0].pageY-e.touches[1].pageY,2))},xme=5,Sme=function(e,t){var n=e.pinchStartScale,r=e.pinchStartDistance,i=e.setup,s=i.maxScale,o=i.minScale,l=i.zoomAnimation,u=i.disablePadding,d=i.pinch,f=l.size,h=l.disabled,y=d.step;if(!n||r===null)throw new Error("Pinch touches distance was not provided");if(t<0)return e.state.scale;var g=t/r,_=g*n,w=(_-n)*(y/xme),S=n+w,x=S===1/0?0:Xc(S,10);return Am(x,o,s,f,!h&&!u)},n$=160,r$=100,Eme=function(e,t){var n=e.props,r=n.onWheelStart,i=n.onZoomStart;e.wheelStopEventTimer||(No(e),nr(Gn(e),t,r),nr(Gn(e),t,i))},Cme=function(e,t){var n=e.props,r=n.onWheel,i=n.onZoom,s=e.contentComponent,o=e.setup,l=e.state,u=l.scale,d=o.limitToBounds,f=o.centerZoomedOut,h=o.zoomAnimation,y=o.wheel,g=o.disablePadding,_=o.smooth,w=h.size,S=h.disabled,x=y.step;if(!s)throw new Error("Component not mounted");t.preventDefault(),t.stopPropagation();var k=vme(t,null),R=_?x*Math.abs(t.deltaY):x,A=yme(e,k,R,!t.ctrlKey);if(u!==A){var M=lf(e,A),T=JF(t,s,u),P=S||w===0||f||g,z=d&&P,Y=e_(e,T.x,T.y,A,M,z),U=Y.x,G=Y.y;e.previousWheelEvent=t,e.setState(A,U,G),nr(Gn(e),t,r),nr(Gn(e),t,i)}},kme=function(e,t){var n=e.props,r=n.onWheelStop,i=n.onZoomStop;Kp(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&($k(e,t.x,t.y),e.wheelAnimationTimer=null)},r$);var s=e$(e,t);s&&(Kp(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,nr(Gn(e),t,r),nr(Gn(e),t,i))},n$))},Tme=function(e,t){var n=e.props,r=n.onWheelStart,i=n.onPanningStart;e.wheelStopEventTimer||(No(e),nr(Gn(e),t,r),nr(Gn(e),t,i))},Rme=function(e,t){var n=e.props,r=n.onWheelStop,i=n.onPanningStop;Kp(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&($k(e,t.x,t.y),e.wheelAnimationTimer=null)},r$);var s=e$(e,t);s&&(Kp(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,nr(Gn(e),t,r),nr(Gn(e),t,i))},n$))},i$=function(e){for(var t=0,n=0,r=0;r<2;r+=1)t+=e.touches[r].clientX,n+=e.touches[r].clientY;var i=t/2,s=n/2;return{x:i,y:s}},Ame=function(e,t){var n=t$(t);e.pinchStartDistance=n,e.lastDistance=n,e.pinchStartScale=e.state.scale,e.isPanning=!1,e.isPinching=!0,e.pinchPreviousCenter=i$(t),No(e)},Nme=function(e,t){var n=e.contentComponent,r=e.pinchStartDistance,i=e.wrapperComponent,s=e.pinchPreviousCenter,o=e.state.scale,l=e.setup,u=l.limitToBounds,d=l.centerZoomedOut,f=l.zoomAnimation,h=l.autoAlignment,y=l.pinch,g=l.panning,_=f.disabled,w=f.size,S=y.allowPanning;if(!(r===null||!n)){var x=wme(t,o,n);if(!(!Number.isFinite(x.x)||!Number.isFinite(x.y))){var k=t$(t),R=Sme(e,k),A=i$(t),M=o/R,T=(A.x-((s==null?void 0:s.x)||0))*M,P=(A.y-((s==null?void 0:s.y)||0))*M;if(!(R===o&&T===0&&P===0)){e.pinchPreviousCenter=A;var z=lf(e,R),Y=_||w===0||d,U=u&&Y,G=e_(e,x.x,x.y,R,z,U),I=G.x,N=G.y;if(e.pinchMidpoint=x,e.lastDistance=k,g.disabled||!S)e.setState(R,I,N);else{var L=h.sizeX,B=h.sizeY,O=nc(e,L,R),D=nc(e,B,R),F=I+T,V=N+P,j=Rm(F,V,z,u,O,D,i),q=j.x,K=j.y;e.setState(R,q,K)}}}}},Mme=function(e){var t=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,e.isPinching=!1,$k(e,t==null?void 0:t.x,t==null?void 0:t.y)},s$=function(e,t){var n=e.props.onZoomStop,r=e.setup.doubleClick.animationTime;Kp(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,nr(Gn(e),t,n)},r)},Pme=function(e,t){var n=e.props,r=n.onZoomStart,i=n.onZoom,s=e.setup.doubleClick,o=s.animationTime,l=s.animationType;nr(Gn(e),t,r),XF(e,o,l,function(){return nr(Gn(e),t,i)}),s$(e,t)};function Ime(e,t){return e==="toggle"?t===1?1:-1:e==="zoomOut"?-1:1}function Ome(e,t){var n=e.setup,r=e.doubleClickStopEventTimer,i=e.state,s=e.contentComponent,o=i.scale,l=e.props,u=l.onZoomStart,d=l.onZoom,f=n.doubleClick,h=f.disabled,y=f.mode,g=f.step,_=f.animationTime,w=f.animationType;if(!h&&!r){if(y==="reset")return Pme(e,t);if(!s)return console.error("No ContentComponent found");var S=Ime(y,e.state.scale),x=KF(e,S,g);if(o!==x){nr(Gn(e),t,u);var k=JF(t,s,o),R=Fk(e,x,k.x,k.y);if(!R)return console.error("Error during zoom event. New transformation state was not calculated.");nr(Gn(e),t,d),vc(e,R,_,w),s$(e,t)}}}var Lme=function(e,t){var n=e.isInitialized,r=e.setup,i=e.wrapperComponent,s=r.doubleClick,o=s.disabled,l=s.excluded,u=t.target,d=i==null?void 0:i.contains(u),f=n&&u&&d&&!o;if(!f)return!1;var h=Nm(u,l);return!h},Dme=(function(){function e(t){var n=this;this.mounted=!0,this.onChangeCallbacks=new Set,this.onInitCallbacks=new Set,this.onTransformCallbacks=new Set,this.wrapperComponent=null,this.contentComponent=null,this.isInitialized=!1,this.bounds=null,this.previousWheelEvent=null,this.wheelStopEventTimer=null,this.wheelAnimationTimer=null,this.isPanning=!1,this.isWheelPanning=!1,this.startCoords=null,this.panStartPosition=null,this.lastTouch=null,this.isPinching=!1,this.distance=null,this.lastDistance=null,this.pinchStartDistance=null,this.pinchStartScale=null,this.pinchMidpoint=null,this.pinchPreviousCenter=null,this.doubleClickStopEventTimer=null,this.velocity=null,this.velocityTime=null,this.lastMousePosition=null,this.isAnimating=!1,this.animation=null,this.pressedKeys={},this.mount=function(){n.initializeWindowEvents()},this.unmount=function(){n.cleanupWindowEvents()},this.update=function(r){n.props=r,n.wrapperComponent&&n.contentComponent&&lf(n,n.state.scale),n.setup=QI(r)},this.initializeWindowEvents=function(){var r,i,s,o,l=N0(),u=(r=n.wrapperComponent)===null||r===void 0?void 0:r.ownerDocument,d=u==null?void 0:u.defaultView;(i=n.wrapperComponent)===null||i===void 0||i.addEventListener("wheel",n.onWheelPanning,l),(s=n.wrapperComponent)===null||s===void 0||s.addEventListener("keyup",n.setKeyUnPressed,l),(o=n.wrapperComponent)===null||o===void 0||o.addEventListener("keydown",n.setKeyPressed,l),d==null||d.addEventListener("mousedown",n.onPanningStart,l),d==null||d.addEventListener("mousemove",n.onPanning,l),d==null||d.addEventListener("mouseup",n.onPanningStop,l),u==null||u.addEventListener("mouseleave",n.clearPanning,l),d==null||d.addEventListener("keyup",n.setKeyUnPressed,l),d==null||d.addEventListener("keydown",n.setKeyPressed,l),d==null||d.addEventListener("blur",n.handleWindowBlur)},this.cleanupWindowEvents=function(){var r,i,s,o,l,u=N0(),d=(r=n.wrapperComponent)===null||r===void 0?void 0:r.ownerDocument,f=d==null?void 0:d.defaultView;f==null||f.removeEventListener("mousedown",n.onPanningStart,u),f==null||f.removeEventListener("mousemove",n.onPanning,u),f==null||f.removeEventListener("mouseup",n.onPanningStop,u),d==null||d.removeEventListener("mouseleave",n.clearPanning,u),f==null||f.removeEventListener("keyup",n.setKeyUnPressed,u),f==null||f.removeEventListener("keydown",n.setKeyPressed,u),f==null||f.removeEventListener("blur",n.handleWindowBlur),document.removeEventListener("mouseleave",n.clearPanning,u),(i=n.wrapperComponent)===null||i===void 0||i.removeEventListener("wheel",n.onWheelPanning,u),(s=n.wrapperComponent)===null||s===void 0||s.removeEventListener("keyup",n.setKeyUnPressed,u),(o=n.wrapperComponent)===null||o===void 0||o.removeEventListener("keydown",n.setKeyPressed,u),No(n),(l=n.observer)===null||l===void 0||l.disconnect()},this.handleInitializeWrapperEvents=function(r){var i=N0();r.addEventListener("wheel",n.onWheelZoom,i),r.addEventListener("dblclick",n.onDoubleClick,i),r.addEventListener("touchstart",n.onTouchPanningStart,i),r.addEventListener("touchmove",n.onTouchPanning,i),r.addEventListener("touchend",n.onTouchPanningStop,i)},this.handleInitialize=function(r){var i=n.setup.centerOnInit;n.applyTransformation(),n.onInitCallbacks.forEach(function(s){return s(Gn(n))}),i&&(n.setCenter(),n.observer=new ResizeObserver(function(){var s,o=r.offsetWidth,l=r.offsetHeight;(o>0||l>0)&&(n.onInitCallbacks.forEach(function(u){return u(Gn(n))}),n.setCenter(),(s=n.observer)===null||s===void 0||s.disconnect())}),setTimeout(function(){var s;(s=n.observer)===null||s===void 0||s.disconnect()},5e3),n.observer.observe(r))},this.onWheelZoom=function(r){var i=n.setup.disabled;if(!i){n.syncModifierKeys(r);var s=QF(n,r);s&&(Eme(n,r),Cme(n,r),kme(n,r))}},this.onWheelPanning=function(r){var i=n.props.onPanning,s=n.setup.trackPadPanning,o=s.lockAxisX,l=s.lockAxisY;n.syncModifierKeys(r);var u=mme(n,r);if(u){r.preventDefault(),r.stopPropagation();var d=n.state,f=d.positionX,h=d.positionY,y=f-r.deltaX,g=h-r.deltaY,_=o?f:y,w=l?h:g,S=n.setup.autoAlignment,x=S.sizeX,k=S.sizeY,R=nc(n,x),A=nc(n,k);_===f&&w===h||(Tme(n,r),qF(n,_,w,R,A),nr(Gn(n),r,i),Rme(n,r))}},this.onPanningStart=function(r){var i=n.setup.disabled,s=n.props.onPanningStart;if(!i){n.syncModifierKeys(r);var o=VI(n,r);if(o){var l=n.isPressingKeys(n.setup.panning.activationKeys);l&&(r.button===0&&!n.setup.panning.allowLeftClickPan||r.button===1&&!n.setup.panning.allowMiddleClickPan||r.button===2&&!n.setup.panning.allowRightClickPan||(r.preventDefault(),r.stopPropagation(),No(n),GI(n,r),nr(Gn(n),r,s)))}}},this.onPanning=function(r){var i=n.setup.disabled,s=n.props.onPanning;if(!i){if(n.syncModifierKeys(r),n.isPanning&&r.buttons===0){n.clearPanning(r);return}var o=YI(n);if(o){var l=n.isPressingKeys(n.setup.panning.activationKeys);l&&(r.preventDefault(),r.stopPropagation(),XI(n,r.clientX,r.clientY,ql.MOUSE),nr(Gn(n),r,s))}}},this.onPanningStop=function(r){var i=n.setup.panning.velocityDisabled,s=n.props.onPanningStop;n.isPanning&&(nme(n,i),nr(Gn(n),r,s))},this.onPinchStart=function(r){var i=n.setup.disabled,s=n.props.onPinchStart;if(!i){var o=bme(n,r);o&&(Ame(n,r),No(n),nr(Gn(n),r,s))}},this.onPinch=function(r){var i=n.setup.disabled,s=n.props.onPinch;if(!i){var o=_me(n);o&&(r.preventDefault(),r.stopPropagation(),Nme(n,r),nr(Gn(n),r,s))}},this.onPinchStop=function(r){var i=n.props.onPinchStop;n.pinchStartScale&&(Mme(n),nr(Gn(n),r,i))},this.onTouchPanningStart=function(r){var i=n.setup,s=i.disabled,o=i.doubleClick,l=n.props.onPanningStart;if(!s){var u=!(o!=null&&o.disabled),d=n.lastTouch&&+new Date-n.lastTouch<200;if(u&&d&&r.touches.length===1)n.onDoubleClick(r);else{n.lastTouch=+new Date,No(n);var f=r.touches,h=f.length===1,y=f.length===2,g=VI(n,r);if(h){if(!g)return;No(n),GI(n,r),nr(Gn(n),r,l)}y&&n.onPinchStart(r)}}},this.onTouchPanning=function(r){var i=n.setup.disabled,s=n.props.onPanning;if(n.isPanning&&r.touches.length===1){if(i)return;var o=YI(n);if(!o)return;r.cancelable&&r.preventDefault(),r.stopPropagation();var l=r.touches[0];XI(n,l.clientX,l.clientY,ql.TOUCH),nr(Gn(n),r,s)}else r.touches.length>1&&n.onPinch(r)},this.onTouchPanningStop=function(r){n.onPanningStop(r),n.onPinchStop(r)},this.onDoubleClick=function(r){var i=n.setup.disabled;if(!i){var s=Lme(n,r);s&&Ome(n,r)}},this.clearPanning=function(r){n.isPanning&&n.onPanningStop(r)},this.handleWindowBlur=function(){n.pressedKeys={},n.isPanning&&(n.isPanning=!1,n.startCoords=null)},this.syncModifierKeys=function(r){var i=r.ctrlKey,s=r.metaKey,o=r.shiftKey,l=r.altKey;typeof i=="boolean"&&(n.pressedKeys.Control=i),typeof s=="boolean"&&(n.pressedKeys.Meta=s),typeof o=="boolean"&&(n.pressedKeys.Shift=o),typeof l=="boolean"&&(n.pressedKeys.Alt=l)},this.setKeyPressed=function(r){n.pressedKeys[r.key]=!0},this.setKeyUnPressed=function(r){n.pressedKeys[r.key]=!1},this.isPressingKeys=function(r){return typeof r=="function"?r(Object.entries(n.pressedKeys).filter(function(i){var s=i[1];return s}).map(function(i){var s=i[0];return s})):r.length?!!r.every(function(i){return n.pressedKeys[i]}):!0},this.setCenter=function(){if(n.wrapperComponent&&n.contentComponent){var r=Hk(n.state.scale,n.wrapperComponent,n.contentComponent);n.setState(r.scale,r.positionX,r.positionY)}},this.handleTransformStyles=function(r,i,s){return n.props.customTransform?n.props.customTransform(r,i,s):ZF(r,i,s)},this.getContext=function(){return Gn(n)},this.applyTransformation=function(){if(!(!n.mounted||!n.contentComponent)){var r=n.state,i=r.scale,s=r.positionX,o=r.positionY,l=n.handleTransformStyles(s,o,i);n.props.detached||(n.contentComponent.style.transform=l),n.onTransformCallbacks.forEach(function(u){return u({scale:i,positionX:s,positionY:o,previousScale:n.state.previousScale,ref:Gn(n)})})}},this.setState=function(r,i,s){var o=n.props.onTransform;if(!Number.isNaN(r)&&!Number.isNaN(i)&&!Number.isNaN(s)){var l=Math.max(r,1e-7);l!==n.state.scale&&(n.state.previousScale=n.state.scale,n.state.scale=l),n.state.positionX=i,n.state.positionY=s,n.applyTransformation();var u=Gn(n);n.onChangeCallbacks.forEach(function(d){return d(u)}),nr(u,{scale:n.state.scale,positionX:i,positionY:s},o)}else console.error("Detected NaN set state values")},this.onTransform=function(r){return n.onTransformCallbacks.has(r)||n.onTransformCallbacks.add(r),function(){n.onTransformCallbacks.delete(r)}},this.onChange=function(r){return n.onChangeCallbacks.has(r)||n.onChangeCallbacks.add(r),function(){n.onChangeCallbacks.delete(r)}},this.onInit=function(r){return n.onInitCallbacks.has(r)||n.onInitCallbacks.add(r),function(){n.onInitCallbacks.delete(r)}},this.init=function(r,i){n.cleanupWindowEvents(),n.wrapperComponent=r,n.contentComponent=i,lf(n,n.state.scale),n.handleInitializeWrapperEvents(r),n.handleInitialize(i),n.initializeWindowEvents(),n.isInitialized=!0;var s=Gn(n);nr(s,void 0,n.props.onInit),hme(n.props.ref,s)},this.props=t,this.setup=QI(this.props),this.state=YF(this.props)}return e})(),t_=ft.createContext(null),Bme=function(e,t){return typeof e=="function"?e(t):e},zme=ft.forwardRef(function(e,t){var n=b.useRef(new Dme(e)).current,r=Bme(e.children,D1(n));return b.useImperativeHandle(t,function(){return D1(n)},[n]),b.useEffect(function(){n.update(e)},[n,e]),m.jsx(t_.Provider,ho({value:n},{children:r}))});ft.forwardRef(function(e,t){var n=b.useRef(null),r=b.useContext(t_);return b.useEffect(function(){return r.onChange(function(i){if(n.current){var s=0,o=0;n.current.style.transform=r.handleTransformStyles(s,o,1/i.instance.state.scale)}})},[r]),m.jsx("div",ho({},e,{ref:pme([n,t])}))});function jme(e,t){t===void 0&&(t={});var n=t.insertAt;if(!(typeof document>"u")){var r=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css",n==="top"&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}var Fme=`.transform-component-module_wrapper__SPB86 {
603
603
  position: relative;
@@ -728,7 +728,7 @@ WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){t
728
728
 
729
729
  `+t.stack):t},0)}}addListener(t){return this.listeners.push(t),()=>{this._removeListener(t)}}emit(t){this.listeners.forEach(n=>{n(t)})}_removeListener(t){this.listeners.splice(this.listeners.indexOf(t),1)}setUnexpectedErrorHandler(t){this.unexpectedErrorHandler=t}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(t){this.unexpectedErrorHandler(t),this.emit(t)}onUnexpectedExternalError(t){this.unexpectedErrorHandler(t)}},L_e=new O_e;function Q0(e){D_e(e)||L_e.onUnexpectedError(e)}var TE="Canceled";function D_e(e){return e instanceof B_e?!0:e instanceof Error&&e.name===TE&&e.message===TE}var B_e=class extends Error{constructor(){super(TE),this.name=this.message}},aL=class RE extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof RE)return t;let n=new RE;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}};function z_e(e,t){let n=this,r=!1,i;return function(){return r||(r=!0,t||(i=e.apply(n,arguments))),i}}var j_e;(e=>{function t(s){return s<0}e.isLessThan=t;function n(s){return s<=0}e.isLessThanOrEqual=n;function r(s){return s>0}e.isGreaterThan=r;function i(s){return s===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(j_e||(j_e={}));var v6;(e=>{function t(A){return A&&typeof A=="object"&&typeof A[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(A){yield A}e.single=i;function s(A){return t(A)?A:i(A)}e.wrap=s;function o(A){return A||n}e.from=o;function*l(A){for(let M=A.length-1;M>=0;M--)yield A[M]}e.reverse=l;function u(A){return!A||A[Symbol.iterator]().next().done===!0}e.isEmpty=u;function d(A){return A[Symbol.iterator]().next().value}e.first=d;function f(A,M){let T=0;for(let P of A)if(M(P,T++))return!0;return!1}e.some=f;function h(A,M){for(let T of A)if(M(T))return T}e.find=h;function*y(A,M){for(let T of A)M(T)&&(yield T)}e.filter=y;function*g(A,M){let T=0;for(let P of A)yield M(P,T++)}e.map=g;function*_(A,M){let T=0;for(let P of A)yield*M(P,T++)}e.flatMap=_;function*w(...A){for(let M of A)yield*M}e.concat=w;function S(A,M,T){let P=T;for(let z of A)P=M(P,z);return P}e.reduce=S;function*x(A,M,T=A.length){for(M<0&&(M+=A.length),T<0?T+=A.length:T>A.length&&(T=A.length);M<T;M++)yield A[M]}e.slice=x;function k(A,M=Number.POSITIVE_INFINITY){let T=[];if(M===0)return[T,A];let P=A[Symbol.iterator]();for(let z=0;z<M;z++){let Y=P.next();if(Y.done)return[T,e.empty()];T.push(Y.value)}return[T,{[Symbol.iterator](){return P}}]}e.consume=k;async function R(A){let M=[];for await(let T of A)M.push(T);return Promise.resolve(M)}e.asyncToArray=R})(v6||(v6={}));function y6(e){if(v6.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(r){t.push(r)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function F_e(...e){return b6(()=>y6(e))}function b6(e){return{dispose:z_e(()=>{e()})}}var _6=class w6{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{y6(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?w6.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};_6.DISABLE_DISPOSED_WARNING=!1;var iT=_6,Jy=class{constructor(){this._store=new iT,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};Jy.None=Object.freeze({dispose(){}});var $_e=globalThis.performance&&typeof globalThis.performance.now=="function",H_e=class x6{static create(t){return new x6(t)}constructor(t){this._now=$_e&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},U_e;(e=>{e.None=()=>Jy.None;function t(I,N){return h(I,()=>{},0,void 0,!0,void 0,N)}e.defer=t;function n(I){return(N,L=null,B)=>{let O=!1,D;return D=I(F=>{if(!O)return D?D.dispose():O=!0,N.call(L,F)},null,B),O&&D.dispose(),D}}e.once=n;function r(I,N,L){return d((B,O=null,D)=>I(F=>B.call(O,N(F)),null,D),L)}e.map=r;function i(I,N,L){return d((B,O=null,D)=>I(F=>{N(F),B.call(O,F)},null,D),L)}e.forEach=i;function s(I,N,L){return d((B,O=null,D)=>I(F=>N(F)&&B.call(O,F),null,D),L)}e.filter=s;function o(I){return I}e.signal=o;function l(...I){return(N,L=null,B)=>{let O=F_e(...I.map(D=>D(F=>N.call(L,F))));return f(O,B)}}e.any=l;function u(I,N,L,B){let O=L;return r(I,D=>(O=N(O,D),O),B)}e.reduce=u;function d(I,N){let L,B={onWillAddFirstListener(){L=I(O.fire,O)},onDidRemoveLastListener(){L==null||L.dispose()}},O=new Ol(B);return N==null||N.add(O),O.event}function f(I,N){return N instanceof Array?N.push(I):N&&N.add(I),I}function h(I,N,L=100,B=!1,O=!1,D,F){let V,j,q,K=0,$,te={leakWarningThreshold:D,onWillAddFirstListener(){V=I(ne=>{K++,j=N(j,ne),B&&!q&&(J.fire(j),j=void 0),$=()=>{let Q=j;j=void 0,q=void 0,(!B||K>1)&&J.fire(Q),K=0},typeof L=="number"?(clearTimeout(q),q=setTimeout($,L)):q===void 0&&(q=0,queueMicrotask($))})},onWillRemoveListener(){O&&K>0&&($==null||$())},onDidRemoveLastListener(){$=void 0,V.dispose()}},J=new Ol(te);return F==null||F.add(J),J.event}e.debounce=h;function y(I,N=0,L){return e.debounce(I,(B,O)=>B?(B.push(O),B):[O],N,void 0,!0,void 0,L)}e.accumulate=y;function g(I,N=(B,O)=>B===O,L){let B=!0,O;return s(I,D=>{let F=B||!N(D,O);return B=!1,O=D,F},L)}e.latch=g;function _(I,N,L){return[e.filter(I,N,L),e.filter(I,B=>!N(B),L)]}e.split=_;function w(I,N=!1,L=[],B){let O=L.slice(),D=I(j=>{O?O.push(j):V.fire(j)});B&&B.add(D);let F=()=>{O==null||O.forEach(j=>V.fire(j)),O=null},V=new Ol({onWillAddFirstListener(){D||(D=I(j=>V.fire(j)),B&&B.add(D))},onDidAddFirstListener(){O&&(N?setTimeout(F):F())},onDidRemoveLastListener(){D&&D.dispose(),D=null}});return B&&B.add(V),V.event}e.buffer=w;function S(I,N){return(L,B,O)=>{let D=N(new k);return I(function(F){let V=D.evaluate(F);V!==x&&L.call(B,V)},void 0,O)}}e.chain=S;let x=Symbol("HaltChainable");class k{constructor(){this.steps=[]}map(N){return this.steps.push(N),this}forEach(N){return this.steps.push(L=>(N(L),L)),this}filter(N){return this.steps.push(L=>N(L)?L:x),this}reduce(N,L){let B=L;return this.steps.push(O=>(B=N(B,O),B)),this}latch(N=(L,B)=>L===B){let L=!0,B;return this.steps.push(O=>{let D=L||!N(O,B);return L=!1,B=O,D?O:x}),this}evaluate(N){for(let L of this.steps)if(N=L(N),N===x)break;return N}}function R(I,N,L=B=>B){let B=(...V)=>F.fire(L(...V)),O=()=>I.on(N,B),D=()=>I.removeListener(N,B),F=new Ol({onWillAddFirstListener:O,onDidRemoveLastListener:D});return F.event}e.fromNodeEventEmitter=R;function A(I,N,L=B=>B){let B=(...V)=>F.fire(L(...V)),O=()=>I.addEventListener(N,B),D=()=>I.removeEventListener(N,B),F=new Ol({onWillAddFirstListener:O,onDidRemoveLastListener:D});return F.event}e.fromDOMEventEmitter=A;function M(I){return new Promise(N=>n(I)(N))}e.toPromise=M;function T(I){let N=new Ol;return I.then(L=>{N.fire(L)},()=>{N.fire(void 0)}).finally(()=>{N.dispose()}),N.event}e.fromPromise=T;function P(I,N){return I(L=>N.fire(L))}e.forward=P;function z(I,N,L){return N(L),I(B=>N(B))}e.runAndSubscribe=z;class Y{constructor(N,L){this._observable=N,this._counter=0,this._hasChanged=!1;let B={onWillAddFirstListener:()=>{N.addObserver(this)},onDidRemoveLastListener:()=>{N.removeObserver(this)}};this.emitter=new Ol(B),L&&L.add(this.emitter)}beginUpdate(N){this._counter++}handlePossibleChange(N){}handleChange(N,L){this._hasChanged=!0}endUpdate(N){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function U(I,N){return new Y(I,N).emitter.event}e.fromObservable=U;function G(I){return(N,L,B)=>{let O=0,D=!1,F={beginUpdate(){O++},endUpdate(){O--,O===0&&(I.reportChanges(),D&&(D=!1,N.call(L)))},handlePossibleChange(){},handleChange(){D=!0}};I.addObserver(F),I.reportChanges();let V={dispose(){I.removeObserver(F)}};return B instanceof iT?B.add(V):Array.isArray(B)&&B.push(V),V}}e.fromObservableLight=G})(U_e||(U_e={}));var AE=class NE{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${NE._idPool++}`,NE.all.add(this)}start(t){this._stopWatch=new H_e,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};AE.all=new Set,AE._idPool=0;var W_e=AE,q_e=-1,S6=class E6{constructor(t,n,r=(E6._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,n){let r=this.threshold;if(r<=0||n<r)return;this._stacks||(this._stacks=new Map);let i=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,i+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=r*.5;let[s,o]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${o}):`;console.warn(l),console.warn(s);let u=new K_e(l,s);this._errorHandler(u)}return()=>{let s=this._stacks.get(t.value)||0;this._stacks.set(t.value,s-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,n=0;for(let[r,i]of this._stacks)(!t||n<i)&&(t=[r,i],n=i);return t}};S6._idPool=1;var V_e=S6,Y_e=class C6{constructor(t){this.value=t}static create(){let t=new Error;return new C6(t.stack??"")}print(){console.warn(this.value.split(`
730
730
  `).slice(2).join(`
731
- `))}},K_e=class extends Error{constructor(t,n){super(t),this.name="ListenerLeakError",this.stack=n}},G_e=class extends Error{constructor(t,n){super(t),this.name="ListenerRefusalError",this.stack=n}},X_e=0,J0=class{constructor(t){this.value=t,this.id=X_e++}},Z_e=2,Q_e,Ol=class{constructor(e){var t,n,r,i;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new V_e((e==null?void 0:e.onListenerError)??Q0,((n=this._options)==null?void 0:n.leakWarningThreshold)??q_e):void 0,this._perfMon=(r=this._options)!=null&&r._profName?new W_e(this._options._profName):void 0,this._deliveryQueue=(i=this._options)==null?void 0:i.deliveryQueue}dispose(){var e,t,n,r;this._disposed||(this._disposed=!0,((e=this._deliveryQueue)==null?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(n=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||n.call(t),(r=this._leakageMon)==null||r.dispose())}get event(){return this._event??(this._event=(e,t,n)=>{var o,l,u,d,f;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let h=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(h);let y=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],g=new G_e(`${h}. HINT: Stack shows most frequent listener (${y[1]}-times)`,y[0]);return(((o=this._options)==null?void 0:o.onListenerError)||Q0)(g),Jy.None}if(this._disposed)return Jy.None;t&&(e=e.bind(t));let r=new J0(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=Y_e.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof J0?(this._deliveryQueue??(this._deliveryQueue=new J_e),this._listeners=[this._listeners,r]):this._listeners.push(r):((u=(l=this._options)==null?void 0:l.onWillAddFirstListener)==null||u.call(l,this),this._listeners=r,(f=(d=this._options)==null?void 0:d.onDidAddFirstListener)==null||f.call(d,this)),this._size++;let s=b6(()=>{i==null||i(),this._removeListener(r)});return n instanceof iT?n.add(s):Array.isArray(n)&&n.push(s),s}),this._event}_removeListener(e){var i,s,o,l;if((s=(i=this._options)==null?void 0:i.onWillRemoveListener)==null||s.call(i,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(l=(o=this._options)==null?void 0:o.onDidRemoveLastListener)==null||l.call(o,this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*Z_e<=t.length){let u=0;for(let d=0;d<t.length;d++)t[d]?t[u++]=t[d]:r&&(this._deliveryQueue.end--,u<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=u}}_deliver(e,t){var r;if(!e)return;let n=((r=this._options)==null?void 0:r.onListenerError)||Q0;if(!n){e.value(t);return}try{e.value(t)}catch(i){n(i)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,n,r,i;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(n=this._perfMon)==null||n.stop()),(r=this._perfMon)==null||r.start(this._size),this._listeners)if(this._listeners instanceof J0)this._deliver(this._listeners,e);else{let s=this._deliveryQueue;s.enqueue(this,e,this._listeners.length),this._deliverQueue(s)}(i=this._perfMon)==null||i.stop()}hasListeners(){return this._size>0}},J_e=class{constructor(){this.i=-1,this.end=0}enqueue(t,n,r){this.i=0,this.end=r,this.current=t,this.value=n}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Vd=class yy{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Ol,this.onChange=this._onChange.event;let t=new I_e;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,n,r=!1){return(t&16777215)<<3|(n&3)<<1|(r?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let n=0,r=0,i=t.length;for(let s=0;s<i;++s){let o=t.charCodeAt(s);if(55296<=o&&o<=56319){if(++s>=i)return n+this.wcwidth(o);let d=t.charCodeAt(s);56320<=d&&d<=57343?o=(o-55296)*1024+d-56320+65536:n+=this.wcwidth(d)}let l=this.charProperties(o,r),u=yy.extractWidth(l);yy.extractShouldJoin(l)&&(u-=yy.extractWidth(r)),n+=u,r=l}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},sT=0,k6=-3,Jp=class{constructor(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}},ewe=class{constructor(e,t){this.tag=0,this.bitcount=0,this.destLen=0,this.sourceIndex=0,this.source=e,this.dest=t,this.ltree=new Jp,this.dtree=new Jp}},T6=new Jp,R6=new Jp,oT=new Uint8Array(30),aT=new Uint16Array(30),A6=new Uint8Array(30),N6=new Uint16Array(30),twe=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),lL=new Jp,Vo=new Uint8Array(320);function M6(e,t,n,r){var i,s;for(i=0;i<n;++i)e[i]=0;for(i=0;i<30-n;++i)e[i+n]=i/n|0;for(s=r,i=0;i<30;++i)t[i]=s,s+=1<<e[i]}function nwe(e,t){var n;for(n=0;n<7;++n)e.table[n]=0;for(e.table[7]=24,e.table[8]=152,e.table[9]=112,n=0;n<24;++n)e.trans[n]=256+n;for(n=0;n<144;++n)e.trans[24+n]=n;for(n=0;n<8;++n)e.trans[168+n]=280+n;for(n=0;n<112;++n)e.trans[176+n]=144+n;for(n=0;n<5;++n)t.table[n]=0;for(t.table[5]=32,n=0;n<32;++n)t.trans[n]=n}var cL=new Uint16Array(16);function eS(e,t,n,r){var i,s;for(i=0;i<16;++i)e.table[i]=0;for(i=0;i<r;++i)e.table[t[n+i]]++;for(e.table[0]=0,s=0,i=0;i<16;++i)cL[i]=s,s+=e.table[i];for(i=0;i<r;++i)t[n+i]&&(e.trans[cL[t[n+i]]++]=i)}function rwe(e){e.bitcount--||(e.tag=e.source[e.sourceIndex++],e.bitcount=7);var t=e.tag&1;return e.tag>>>=1,t}function ea(e,t,n){if(!t)return n;for(;e.bitcount<24;)e.tag|=e.source[e.sourceIndex++]<<e.bitcount,e.bitcount+=8;var r=e.tag&65535>>>16-t;return e.tag>>>=t,e.bitcount-=t,r+n}function ME(e,t){for(;e.bitcount<24;)e.tag|=e.source[e.sourceIndex++]<<e.bitcount,e.bitcount+=8;var n=0,r=0,i=0,s=e.tag;do r=2*r+(s&1),s>>>=1,++i,n+=t.table[i],r-=t.table[i];while(r>=0);return e.tag=s,e.bitcount-=i,t.trans[n+r]}function iwe(e,t,n){var r,i,s,o,l,u;for(r=ea(e,5,257),i=ea(e,5,1),s=ea(e,4,4),o=0;o<19;++o)Vo[o]=0;for(o=0;o<s;++o){var d=ea(e,3,0);Vo[twe[o]]=d}for(eS(lL,Vo,0,19),l=0;l<r+i;){var f=ME(e,lL);switch(f){case 16:var h=Vo[l-1];for(u=ea(e,2,3);u;--u)Vo[l++]=h;break;case 17:for(u=ea(e,3,3);u;--u)Vo[l++]=0;break;case 18:for(u=ea(e,7,11);u;--u)Vo[l++]=0;break;default:Vo[l++]=f;break}}eS(t,Vo,0,r),eS(n,Vo,r,i)}function uL(e,t,n){for(;;){var r=ME(e,t);if(r===256)return sT;if(r<256)e.dest[e.destLen++]=r;else{var i,s,o,l;for(r-=257,i=ea(e,oT[r],aT[r]),s=ME(e,n),o=e.destLen-ea(e,A6[s],N6[s]),l=o;l<o+i;++l)e.dest[e.destLen++]=e.dest[l]}}}function swe(e){for(var t,n,r;e.bitcount>8;)e.sourceIndex--,e.bitcount-=8;if(t=e.source[e.sourceIndex+1],t=256*t+e.source[e.sourceIndex],n=e.source[e.sourceIndex+3],n=256*n+e.source[e.sourceIndex+2],t!==(~n&65535))return k6;for(e.sourceIndex+=4,r=t;r;--r)e.dest[e.destLen++]=e.source[e.sourceIndex++];return e.bitcount=0,sT}function owe(e,t){var n=new ewe(e,t),r,i,s;do{switch(r=rwe(n),i=ea(n,2,0),i){case 0:s=swe(n);break;case 1:s=uL(n,T6,R6);break;case 2:iwe(n,n.ltree,n.dtree),s=uL(n,n.ltree,n.dtree);break;default:s=k6}if(s!==sT)throw new Error("Data error")}while(!r);return n.destLen<n.dest.length?typeof n.dest.slice=="function"?n.dest.slice(0,n.destLen):n.dest.subarray(0,n.destLen):n.dest}nwe(T6,R6);M6(oT,aT,4,3);M6(A6,N6,2,1);oT[28]=0;aT[28]=258;var dL=owe,lT=11,nu=5,awe=lT-nu,lwe=65536>>lT,cwe=1<<awe,uwe=cwe-1,by=2,dwe=1<<nu,tS=dwe-1,P6=65536>>nu,fwe=1024>>nu,hwe=P6+fwe,pwe=hwe,mwe=32,gwe=pwe+mwe,vwe=1<<by,ywe=new Uint8Array(new Uint32Array([305419896]).buffer)[0]===18,bwe=class{constructor(e){let t=new DataView(e.buffer);this.highStart=t.getUint32(0,!0),this.errorValue=t.getUint32(4,!0);let n=t.getUint32(8,!0);if(e=e.subarray(12),e=dL(e,new Uint8Array(n)),e=dL(e,new Uint8Array(n)),ywe){let r=e.length;for(let i=0;i<r;i+=4){let s=e[i];e[i]=e[i+3],e[i+3]=s;let o=e[i+1];e[i+1]=e[i+2],e[i+2]=o}}this.data=new Uint32Array(e.buffer)}get(e){let t;return e<0||e>1114111?this.errorValue:e<55296||e>56319&&e<=65535?(t=(this.data[e>>nu]<<by)+(e&tS),this.data[t]):e<=65535?(t=(this.data[P6+(e-55296>>nu)]<<by)+(e&tS),this.data[t]):e<this.highStart?(t=this.data[gwe-lwe+(e>>lT)],t=this.data[t+(e>>nu&uwe)],t=(t<<by)+(e&tS),this.data[t]):this.data[this.data.length-vwe]}},_we=bwe,wwe="AAARAAAAAABwxwAAAb4LQfTtmw+sVmUdx58LL/ffe/kjzNBV80gW1F3yR+6CvbJiypoZa0paWmAWSluErSBbFtYkkuZykq6QamGJ4WRqo2kFGy6dYWtEq6G1MFAJbRbOVTQr+x7f5+x97q/n/3me87wXzm/3s+f/7/d7/p7znnvOlvGMbQM7wIPgEbAPHABPgcPgefAS+BfYwuv/F/Q2OulBxKcK6TMRPxu8FcwFbwcjYCFYDC4Cl4ArwNXgGvBJsA58UdBDwy+jbBO4La8DtoEd4H7wkNBuN+KPgn3gADgIngaHwFHwF/AyeAWMm4C+TGi3LdiJ/EnIex04A2RgFpgD5oKFYDG4CLwHXAo+IKSvAqt4/evA9bz9jWA6+Cq3dyvCP8HWNwX93wF38/ROcD94SCjP2+1B+BiPP4HwgOD/7xD/I08fRniMx48jPAFeBeuF+n29jE0G08FZvaPHYWZvh9mcEfAOjlhXx/qGfd2QvLO3zccmtMnzliC9lPt+GenD1nyMiK/LNf1cycs+gfAzPJ6vtxe4jhuQtx5sBLeA28G3eb3v8/Beif4HkPewxu5G6N/rMP4qfgEdvwZPgj+AZ8Cx3nYfxiE8Dk6AV0FfH/YEOB28AbwJDIPzQAtcAC4Gl/Z19F+J+NVCehWPr0b46b7RvixvdPg8yr7U10l/BfFN4La8DdgGdoAHwU/AI2AfOACeAofB8+AlcAKwfvyBKeCM/o7NrF9PXmdWv9/Ynot2I7ztIg8dF5I2a8i63CjZU+9Fm2Wcy4U4ZQVYyeOrwVoev57UuxHcJKRvFuJXgnU8/nUebtbYrKmpCUOx31P7UVNTU1NTU1NTU1OGLTz8Xr/77+W7+9vP0or0MxPMbXaizY8FW3sQ3wseB/t5/kGEh8DR/vbzwL8i/Af4Dy8fP8BYE0weaKenI/wV/DhrQG97JspngzlgLpgHzgPzwUhdVpfVZXVZXRa87HxwAVgQ4Pn5WEd85l5TUzOasvezFw/E3b/LoP9D4CpwrcTWWsGXNQOj748/G9k3G56d1KYxmbELwQbwKFiJvBM8nDWlHa5E+AOwCzwLzjkNeeB28NvTeB1OYyr0gQ1g99R23nGE50xj7MPgc+A+8K5Bxj4FHgB/G2z/T9XEzCZjd/S0WYX4Pc3/r/Nn5I0f6qQXIP5x8ENwBMyYyNhHJ3b0pOCuLrBvM941NTU1JyNHEp+BrC8dMyalt1/m3uWfhmeULzRGp9d3wf0WZSN8+prCr60Wz09tuNmx35sl9Y825HXvRN39KNveaL8flb9f913kbec67kHeTsR3gYcH2uV7ED4m2HhCYi/X9ZuBzvuXv0f8iKIfx5B/XCg7gTgbVPdvAsomCuWnD45eK28UyvL3Jt+s0fU2TVnOXJQvJHUWIb0ELAWXgCt4+UcMumSsEtpch/g6ouMGpG/ieZsc9N/q4YsLd3D9WyPbsWEbfNgO7hN82TWY/n8xKbmsC3xQsYKf+7sjrx2TH+u4H3vhx+OO6+X9hmtXN7C/4r15EPaeBs9J7L7YBeeED/k7wn8fbIf/Rji+yVizmd4vW6bB19cb/PU9w7MxMA60bzPHgM8+zG623+OnzOf55yNc3Gw/k303wveBy3nZcoTXgNVgLfiCRNcG5N3SbIebwZ08fhe4l8d/BH7K4yI/4+HPwS/BAfBks+PzIaHuc3x+ivSL4GUyZ68I6fwZYRNMG2qnz+Th2QjfMtTx/1zE5w61nyN+Q7C3aKgdin1dgrylYBn4INdhGn/Z2FfFiqH01/SUXMvnPD+jC+j85N/RqRhR/DYaS6T+P09K1mD+vzW+5zVqqeVUl0wTz2lK8odJHRGXfBufdGLSoSo3+ZFJ6sl0qvJVNmhI4z4i06mrZ6uT1le1z5h5HE3tMiHPtQ5javu+ItMXUr/MXpmwmyRL3D6U7UwIMyYfczGu0qdqb2pbhcw4xQkhWQBMerrZ/liXrGTbsQwTwrEu4zSczKLrd7fCSKiKn+zSo8BWXMe8myXWOivrUxWi60OPoQ7VIasbQ0S/Ukk3rZVullNhHEL1rYoxUF0PTfm6elWJzq54ZsU4z11ohOy0oxT2izFqCNj4TesXcWZo6+Jfqr1O+1O1beqDagypj2J9F1u2daucj3Eknmq/6PaHrK7Mb1o35DiW1a/a76LuhlDXZX25SOz11S33ErKxDb2/fc/bFKI6axskn+4/W90u9mOtbRf7smsoTdvOfwoRz0t6DaP9k81v6P7Re5aUQudTd303rX+bZzBl97/KR7E+Xbux9lLI+aNr1PfaYLpPDiW2/vrYTX1drMIeXbMye6HXlw8292Jl7ZXxLxRlxXbcaH9drjFlxfa3Qozx8NWRi834lPVZbD+SmN7EJPzc9TVCSVXXDps9L+513b2J7fMu176V2YOhx1A3JrJ8KrLxUumpcu5j/lYT+2tzLRVDZmhjO442a1Clu0ox9VPVXzE/lcS4V0k1D6LI1pJsz8fct9SGbO5l/rmKzTlvsxdj3IvRtC2uv0t1fotltvd2VaCy5Sp5m0EhnZG4CCNxXZrWp/VUIrOjapfnNw11ZNI0V/GWzKNuxtzGKKTEtJeR0NVmpojbtBuW5On0u0is9ZMxvU8ZM+8vEyadtu10oqtP9Q4rcJEm85+Two/QkpGwjI6YkgkhtUfzZOW6fFVexuRri+qj9TJJHZkdmW5abiu0rs6uj2TMfmx06bISUj9tZ9Lja8dVQtox6WpxTJKfW3M4MSTmvU4sWy1CU6BF4jIfdNeDjHWuO1lCWIm2Jr2ixNZvklD2fP0Q6+vsmO4hqN1hJvfDtV5G8mTlsvau4qPP1a64L1skT6QYEzEtq0PzGZOfCbSdSmcKTP7Qs86Ej/1hEpelaV6IMdT5ayu2+nT9tmnnO746XbLxE8t0qOrYtJWhmk9bvaLfsrotRVw1PnR+bcafSUKZ6Mps7smobybJLH2R6WqRkJa1DHV0UmbfUcksiSF0HExSpp+uY0zbTklMaCm7blzEtg8h1rNMXNaYi05ZXsbC75sQ/4+aUxFV2jL50Q3jE0rK2rVtN09By8OHoo1vH2LPSdE323mr2sdu0pUZiDkWLRKWnfeQY6taKzHF9n/GPv8jd/0/egiRvYMR24fU79iY3s9Qva9RlYR8n8HHtq9fMcT1HRWfdZXiHd9YInt/iI4PTaf+BimXKvdXYU+3hlRpHzs2dVK/cxhDn+xs0I2jzxjL5kpXz1VU72aLtkK/97sALKyQqu25SshvG6h08/cLrlKswRklKXvvXfa+pZt+y8nah5YUv2Oo/ap/X2URdRfico9K69hcp6r6XaCz5Wo/hs/iNTGF6N6tV92/9ZS0Wba9SlT3pKF/e6W674+x9ly+VRL73cPU8ygb31D3eSqfVd+iqET0y3YMYojoO11XqrTt2nPxmeq1HYeqxkmUMt8DiesjpoTSr+qDrD+qPZDiOZxMdH0pRPX8MFUfQtv0Xbs+a1a1NnRryNZ/2+tsaPG5ZoX0RXZei88yZGdo4UMPj/cwv/kMJboxLISuQbE+1VW12Mx7FWOrW3M9Hv7Y+uxyraPSo8B2TGPuLdOeZha+hBKf8Sjsm/oR+7pmsx/oeOraFWdXleeV6oyl41zm+mgSuq9C6ox1TsU8D+m4dwMmf8v2nz7Tm+fYfj7HV1K/x1HWjquvY+2dllxM64ue87Su772zzbXIVC+WxLZTRR9MdkMTypZNH1z6G0tUvoccwxA+hfLNdV+a7MaQqscztMi+7QnxDZXvd1dldWQOyMbApb1Jd2h91Ffx+y9Xfb7tClokboOvrRhrbVpFFO8z+65t2/u4su9MUx028znH01/TGVDmHAj13W1o+1USw+eUfYtpO+b82rRNsb6oPpV+1fdBqddB6n3WDXvdJDZrJ0QfQp6bsc/kqq4BIddHWXGdN1pmWveh58F1zYUW1zmOITHXWOg1XrZvZSWUf77tq1ofqear6muaT1lIQp3bofabSafJVlnfYo9B6LGr8uzz2Xchvzfw+T9PlgiV/A8=";function xwe(e){if(typeof Buffer<"u")return Buffer.from(e,"base64");let t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<n.length;++r)n[r]=t.charCodeAt(r);return n}var Swe=new _we(xwe(wwe)),PE=15,IE=0,Ewe=48,Cwe=4,kwe=0,I6=1,O6=2,OE=3,Twe=4,nS=5,rS=6,iS=7,fL=8,sS=9,hL=10,Rwe=11,Awe=32;function pL(e){return(e&Ewe)>>Cwe}function Nwe(e,t){let n=(e&PE)>>IE,r=(t&PE)>>IE;return Mwe(n,r)?r===OE?Awe:r+16:r-16}function Mwe(e,t){return e>=nS&&e<=sS&&(e==nS&&(t==nS||t==rS||t==fL||t==sS)||(e==fL||e==rS)&&(t==rS||t==iS)||(e==sS||e==iS)&&t==iS)||t==O6||t==hL||e==I6||t==Twe||e==hL&&t==Rwe||t==OE&&e==OE}function mL(e){return Swe.get(e)}var L6=class D6{constructor(t=!0){this.ambiguousCharsAreWide=!1,this.version=t?"15-graphemes":"15",this.handleGraphemes=t}charProperties(t,n){if(t>=32&&t<127&&n>>3===0)return D6._plainNarrowProperties;let r=mL(t),i=pL(r),s=!1;if(i>=2?i=i===3||this.ambiguousCharsAreWide||t===65039?2:1:i=1,n!==0){let o=Vd.extractWidth(n);this.handleGraphemes?r=Nwe(Vd.extractCharKind(n),r):r=i===0?1:0,s=r>0,s&&(o>i?i=o:r===32&&(i=2))}return Vd.createPropertyValue(r,i,s)}wcwidth(t){let n=mL(t),r=pL(n),i=(n&PE)>>IE;return i===O6||i===I6?0:r>=2&&(r===3||this.ambiguousCharsAreWide)?2:1}};L6._plainNarrowProperties=Vd.createPropertyValue(kwe,1,!1);var gL=L6,Pwe=class{constructor(){this._oldVersion=""}activate(e){this._provider15||(this._provider15=new gL(!1)),this._provider15Graphemes||(this._provider15Graphemes=new gL(!0));let t=e.unicode;this._unicode=t,t.register(this._provider15),t.register(this._provider15Graphemes),this._oldVersion=t.activeVersion,t.activeVersion="15-graphemes"}dispose(){this._unicode&&(this._unicode.activeVersion=this._oldVersion)}};const Iwe={background:"#1E1E1E",foreground:"#D4D4D4",cursor:"#D4D4D4",cursorAccent:"#1E1E1E",selectionBackground:"#264F78",selectionForeground:void 0,black:"#000000",red:"#CD3131",green:"#0DBC79",yellow:"#E5E510",blue:"#2472C8",magenta:"#BC3FBC",cyan:"#11A8CD",white:"#E5E5E5",brightBlack:"#666666",brightRed:"#F14C4C",brightGreen:"#23D18B",brightYellow:"#F5F543",brightBlue:"#3B8EEA",brightMagenta:"#D670D6",brightCyan:"#29B8DB",brightWhite:"#E5E5E5"},LE={matchBackground:"#264F78",matchBorder:"#3B8EEA",matchOverviewRuler:"#3B8EEA",activeMatchBackground:"#7A4E00",activeMatchBorder:"#F5F543",activeMatchColorOverviewRuler:"#F5F543"},Owe="─│╭╮╰╯›·•";function Lwe(e){const t=e.options.fontFamily;e.options.fontFamily=`${t} `,e.options.fontFamily=t,e.refresh(0,e.rows-1)}function Dwe(e={}){return{scrollback:5e3,fontFamily:Jz,fontSize:e.fontSize??Gd,cursorBlink:!0,cursorStyle:"block",cursorInactiveStyle:"none",disableStdin:!1,scrollOnUserInput:!1,altClickMovesCursor:!1,rightClickSelectsWord:!1,theme:Iwe,allowProposedApi:!0}}async function B6(e,t={}){await v5(window.location.origin,{preloadPowerline:!0}),await document.fonts.ready;const n=t.fontSize??Gd;try{await document.fonts.load(`${n}px "Sarasa Fixed SC"`,Owe)}catch{}const r=new y_e(Dwe(t)),i=new S_e,s=new N_e,o=new Pwe;r.loadAddon(i),r.loadAddon(s),r.loadAddon(o),e.replaceChildren(),r.open(e);const l=()=>{Lwe(r)},u=()=>{document.visibilityState==="visible"&&r.refresh(0,r.rows-1)},d=()=>{r.refresh(0,r.rows-1)},f=()=>{r.refresh(0,r.rows-1)};return document.fonts.addEventListener("loadingdone",l),document.addEventListener("visibilitychange",u),window.addEventListener("pageshow",d),window.addEventListener("focus",f),{terminal:r,serializeAddon:i,dispose:()=>{document.fonts.removeEventListener("loadingdone",l),document.removeEventListener("visibilitychange",u),window.removeEventListener("pageshow",d),window.removeEventListener("focus",f),r.dispose()}}}function Bwe(e,t,n){return e.options.fontSize===t?!1:(e.options.fontSize=t,requestAnimationFrame(()=>n==null?void 0:n()),!0)}function o_(e,t){const n=e.querySelector(".xterm-screen");return!n||t.cols<=0||t.rows<=0?null:{cellW:n.clientWidth/t.cols,cellH:n.clientHeight/t.rows}}function zwe(e,t){for(let n=t-1;n>=0;n--){const r=e.baseY+n;if(r<0||r>=e.length)continue;const i=e.getLine(r);if(i&&i.translateToString(!0).trimEnd().length>0)return n}return-1}const eb=2,tb=1;function jwe(e,t){if(typeof t=="object"){const n=t.axis==="cols"?eb:tb,r=t.axis==="cols"?iu:su;return!Number.isInteger(t.value)||t.value<n||t.value>r?e:{cols:t.axis==="cols"?t.value:e.cols,rows:t.axis==="rows"?t.value:e.rows}}return{cols:t==="increase-cols"&&e.cols<iu?e.cols+1:t==="decrease-cols"&&e.cols>eb?e.cols-1:e.cols,rows:t==="increase-rows"&&e.rows<su?e.rows+1:t==="decrease-rows"&&e.rows>tb?e.rows-1:e.rows}}function Fwe(e,t,n){const r=o_(t,n);if(!r)return null;const i=getComputedStyle(e),s=u=>Number.parseFloat(u)||0,o=e.clientWidth-s(i.paddingLeft)-s(i.paddingRight),l=e.clientHeight-s(i.paddingTop)-s(i.paddingBottom);return[o,l,r.cellW,r.cellH].every(u=>Number.isFinite(u)&&u>0)?{cols:Math.min(iu,Math.max(eb,Math.floor(o/r.cellW))),rows:Math.min(su,Math.max(tb,Math.floor(l/r.cellH)))}:null}function $we(e){let t=!1,n=0,r=null,i=0,s=0,o=0,l=null;const u=()=>{l==null||l.dispose(),l=null;const _=r;r=null,_==null||_.dispose()},d=()=>{if(t||r||e.buffer.active.type!=="normal")return;const _=e.buffer.normal,w=_.length-1;if(w<0)return;const S=_.baseY+_.cursorY,x=e.registerMarker(w-S);if(!x||x.isDisposed||x.line<0){x==null||x.dispose();return}r=x,i=x.line,s=_.length,o=_.baseY,l=x.onDispose(()=>{t||r!==x||(l=null,r=null)})},f=()=>{u(),d()},h=()=>{if(e.buffer.active.type==="normal"){if(r&&!r.isDisposed){const _=r.line-i;_<0&&(n+=_)}f()}},y=()=>{if(e.buffer.active.type!=="normal")return;if(!r||r.isDisposed){f();return}const _=e.buffer.normal,w=r.line-i,S=_.length-s,x=_.baseY-o;w===0&&S===0&&x===0||(w<0&&w===S&&w===x&&(n+=w),f())};d();const g=[e.onScroll(h),e.onWriteParsed(y),e.onResize(f),e.buffer.onBufferChange(_=>{_.type==="normal"&&f()})];return{getOffset:()=>(y(),n),dispose:()=>{if(!t){t=!0;for(const _ of g)_.dispose();u()}}}}const oS=3,vL=4;function z6(e,t){const n=Math.max(0,Math.min(e.length,t)),r=new Uint32Array(n+1),i=new Uint8Array(n),s=new Array(n);let o=0,l=0,u;for(let h=0;h<n;h+=1){const y=e.getCell(h,u);y&&(u=y);const g=(y==null?void 0:y.getChars())??"",_=((y==null?void 0:y.getWidth())??1)&oS,w=g.length>0;r[h]=o,s[h]=_===0?"":w?g:" ",o+=s[h].length,r[h+1]=o,i[h]=_|(w?vL:0),w&&(l=h+_)}const d=s.join(""),f=h=>{if(!Number.isInteger(h)||h<0||h>=n)return;const y=i[h],g=y&vL?d.slice(r[h],r[h+1]):"",_=y&oS;return{getChars:()=>g,getWidth:()=>_}};return{length:n,isWrapped:e.isWrapped,getCell:f,translateToString:(h=!1,y=0,g=n)=>{const _=Math.max(0,Math.min(n,y)),w=Math.max(_,Math.min(n,g)),S=h?Math.min(w,l):w;if(!Number.isInteger(_)||!Number.isInteger(S)||S<=_)return"";let x=_;for(;x<S&&(i[x]&oS)===0;)x+=1;const k=x-_,R=d.slice(r[x],r[S]);return k>0?`${" ".repeat(k)}${R}`:R}}}function $h(e,t){if(!Number.isInteger(t)||t===0)return new Map(e);const n=new Map;for(const[r,i]of e){const s=r+t;s>=0&&n.set(s,i)}return n}const Hwe="pty-live-backfill",cT=new WeakMap,Uwe=new Map;function j6(e){return e.querySelector('.xterm-screen [data-slot="pty-live-backfill"]')}function F6(e){var r;const n=(((r=e.getCurrentRowIdentityOffset)==null?void 0:r.call(e))??e.capturedRowIdentityOffset)-e.capturedRowIdentityOffset;return Number.isInteger(n)?n:0}function uT(e){const t=j6(e),n=t?cT.get(t):void 0;if(!t||!n)return null;const r=F6(n),i=Number(t.dataset.startLine)+r,s=Number(t.dataset.endLine)+r;return!Number.isInteger(i)||!Number.isInteger(s)?null:{element:t,startLine:i,endLine:s}}function $6(e){const t=j6(e),n=t?cT.get(t):void 0;if(!n)return Uwe;const r=F6(n);if(r===0)return n.lines;if(n.rebasedDelta===r&&n.rebasedLines)return n.rebasedLines;const i=new Map;for(const[s,o]of n.lines){const l=s+r;l>=0&&i.set(l,o)}return n.rebasedDelta=r,n.rebasedLines=i,i}function nb(e,t){return $6(e).get(t)??null}function Wwe(e){return Array.from(e.children).find(t=>t instanceof HTMLElement&&t.classList.contains("xterm-rows"))??null}function qwe(e,t,n,r,i,s){const o=document.createElement("div");return o.dataset.slot=Hwe,o.dataset.startLine=String(r),o.dataset.endLine=String(i),o.dataset.rowIdentityOffset=String(s),o.setAttribute("aria-hidden","true"),Object.assign(o.style,{position:"absolute",top:`${n}px`,right:"0",left:"0",height:t.style.height||"100%",overflow:"hidden",pointerEvents:"auto",touchAction:"pan-x pan-y",backgroundColor:getComputedStyle(e).backgroundColor}),o.append(t),o}function Vwe(e,t,n){var r;for(const[i,s]of Array.from(e.children).entries()){if(!(s instanceof HTMLElement))continue;let o=0;for(const l of Array.from(s.children)){if(!(l instanceof HTMLElement))continue;const u=((r=l.textContent)==null?void 0:r.length)??0;let d=(n==null?void 0:n(t+i,o))??null;for(;(d==null?void 0:d.text.length)===0;)o+=1,d=(n==null?void 0:n(t+i,o))??null;const f=l.style.opacity;if(f&&f!=="1")if(d!=null&&d.isDim&&d.isRenderedFgRGB)l.style.removeProperty("opacity");else{l.style.removeProperty("opacity");const y=document.createElement("span");y.style.opacity=f,y.append(...Array.from(l.childNodes)),l.append(y)}let h=0;for(;h<u;){const y=(n==null?void 0:n(t+i,o))??null;if(!y)break;h+=y.text.length,o+=1}}}}function Ywe(e){let t="";for(const n of Array.from(e.children)){if(!(n instanceof HTMLElement))continue;const r=Array.from(n.children).filter(l=>l instanceof HTMLSpanElement),i=r[0];if(!i)continue;!(i.textContent===""&&r.length>1)&&!i.hasAttribute("style")&&t&&(i.style.cssText=t);const o=r.at(-1);o&&(t=o.getAttribute("style")??"")}}function Kwe(e,t,n,r,i){const o=new DOMParser().parseFromString(e,"text/html").querySelector("pre > div");if(!o)return null;const l=document.importNode(o,!0);l.className=t.className,l.removeAttribute("id"),Ywe(l),Vwe(l,r,i);const u=getComputedStyle(t),d=l.childElementCount;Object.assign(l.style,{position:"absolute",top:"0",left:"0",width:"100%",height:`${d*n}px`,fontFamily:u.fontFamily,fontSize:u.fontSize,fontWeight:u.fontWeight,fontVariantLigatures:u.fontVariantLigatures,letterSpacing:u.letterSpacing,whiteSpace:"pre"});for(const f of Array.from(l.children))f instanceof HTMLElement&&Object.assign(f.style,{height:`${n}px`,lineHeight:`${n}px`,overflow:"hidden",whiteSpace:"pre"});return l}function Gwe(e,t={}){let n=null;const r=e.style.overflow,i=l=>{const u=e.querySelector(".xterm-screen");if(!u)return;const d=Array.from(u.children).find(f=>f instanceof HTMLElement&&f.classList.contains("xterm-selection"));u.insertBefore(l,d??null),n==null||n.remove(),n=l,e.style.overflow="visible"},s=()=>{n==null||n.remove(),n=null,e.style.overflow=r};return{render:l=>{var w;if(!l)return s(),!0;const u=e.querySelector(".xterm-screen"),d=u?Wwe(u):null;if(!u||!d||!t.serializeRangeAsHtml||l.endLine<l.startLine||l.rowHeight<=0)return!1;const f=t.serializeRangeAsHtml(l.startLine,l.endLine),h=Kwe(f,d,l.rowHeight,l.startLine,t.getSerializedCell);if(!h)return!1;const y=((w=t.getBufferRowIdentityOffset)==null?void 0:w.call(t))??0,g=qwe(u,h,l.topOffset,l.startLine,l.endLine,y),_=new Map;if(t.getSelectionLine)for(let S=l.startLine;S<=l.endLine;S+=1){const x=t.getSelectionLine(S);x&&_.set(S,z6(x,x.length))}return cT.set(g,{capturedRowIdentityOffset:y,getCurrentRowIdentityOffset:t.getBufferRowIdentityOffset,lines:_}),i(g),!0},dispose:s}}const Xwe="pty-managed-selection-overlay",Zwe="pty-managed-selection-segment",Qwe="#264f78",Jwe="0.62";function yL(e,t){if(!e||t<=0||[e.start.x,e.start.y,e.end.x,e.end.y].some(u=>!Number.isInteger(u)||u<0)||e.start.x>t||e.end.x>t)return null;const r=e.start.y*t+e.start.x,i=e.end.y*t+e.end.x;if(i<=r)return null;const s=i-1,o={row:Math.floor(r/t),column:r%t},l={row:Math.floor(s/t),column:s%t};return{anchor:o,focus:l,columnMode:!1}}function bL(e){return Number.isInteger(e.row)&&e.row>=0&&Number.isInteger(e.column)&&e.column>=0}function exe(e){return{anchor:{row:e.anchor.row,column:e.anchor.column},focus:{row:e.focus.row,column:e.focus.column},columnMode:e.columnMode}}function txe(e,t){return e.row===t.row?e.column-t.column:e.row-t.row}function Lv(e,t,n){var s,o;let r=Math.max(0,Math.min(n-1,t));for(;r>0&&((s=e==null?void 0:e.getCell(r))==null?void 0:s.getWidth())===0;)r-=1;const i=Math.max(1,((o=e==null?void 0:e.getCell(r))==null?void 0:o.getWidth())??1);return{start:r,end:Math.min(n,r+i)}}function H6(e,t){const n=e.at(-1);if(n&&n.lastRow+1===t.firstRow&&n.firstColumn===t.firstColumn&&n.columnCount===t.columnCount){e[e.length-1]={...n,lastRow:t.lastRow};return}e.push(t)}function nxe(e,t,n,r){if(t<=0||!bL(e.anchor)||!bL(e.focus))return[];const[i,s]=txe(e.anchor,e.focus)<=0?[e.anchor,e.focus]:[e.focus,e.anchor],o=Lv(n==null?void 0:n(i.row),i.column,t),l=Lv(n==null?void 0:n(s.row),s.column,t);if(e.columnMode){const d=Math.max(Math.min(e.anchor.row,e.focus.row),(r==null?void 0:r.first)??0),f=Math.min(Math.max(e.anchor.row,e.focus.row),(r==null?void 0:r.last)??Number.MAX_SAFE_INTEGER);if(f<d)return[];const h=Math.min(e.anchor.column,e.focus.column),y=Math.max(e.anchor.column,e.focus.column),g=[];for(let _=d;_<=f;_+=1){const w=n==null?void 0:n(_),S=Lv(w,h,t).start,x=Lv(w,y,t).end;H6(g,{firstRow:_,lastRow:_,firstColumn:S,columnCount:Math.max(0,x-S)})}return g}if(i.row===s.row)return[{firstRow:i.row,lastRow:s.row,firstColumn:o.start,columnCount:l.end-o.start}];const u=[{firstRow:i.row,lastRow:i.row,firstColumn:o.start,columnCount:t-o.start}];return s.row-i.row>1&&u.push({firstRow:i.row+1,lastRow:s.row-1,firstColumn:0,columnCount:t}),u.push({firstRow:s.row,lastRow:s.row,firstColumn:0,columnCount:l.end}),u}function rxe(e,t,n){if(n<t)return[];const r=[];for(const i of e){const s=Math.max(i.firstRow,t),o=Math.min(i.lastRow,n);o<s||H6(r,{...i,firstRow:s,lastRow:o})}return r}function ixe(e,t){const n=e.ownerDocument.createElement("div");return n.dataset.slot=t,n.setAttribute("aria-hidden","true"),Object.assign(n.style,{position:"absolute",inset:"0",overflow:"visible",pointerEvents:"none",zIndex:"3"}),e.append(n),n}function U6({terminal:e,container:t,selectionBackground:n,getLine:r,resolveRange:i,projectionOnly:s=!1,overlaySlot:o=Xwe,segmentSlot:l=Zwe,opacity:u=Jwe,borderColor:d}){let f=null,h=null,y=null,g=!1;const _=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>x());_==null||_.observe(t);const w=()=>{var P;const T=((P=e.element)==null?void 0:P.querySelector(".xterm-screen"))??null;return T===h||(h&&(_==null||_.unobserve(h)),y==null||y.remove(),y=null,h=T,h&&(_==null||_.observe(h))),h},S=()=>{y==null||y.remove(),y=null};function x(){var q;const T=f&&i?i():f;if(g||!T){S();return}const P=w();if(!P||e.cols<=0||e.rows<=0){S();return}const z=P.getBoundingClientRect(),Y={cellW:z.width/e.cols,cellH:z.height/e.rows};if(Y.cellW<=0||Y.cellH<=0){S();return}const U=t.getBoundingClientRect(),G=t.clientHeight>0?t.clientHeight:U.height,I=U.top+(t.clientHeight>0?t.clientTop:0)-z.top,N=I+G;if(!Number.isFinite(I)||!Number.isFinite(N)||G<=0)return;const L=e.element?uT(e.element):null;if(s&&!L){S();return}const B=(L==null?void 0:L.startLine)??e.buffer.active.viewportY,O=L?L.element.getBoundingClientRect().top-z.top:0;if(!Number.isFinite(O)){S();return}const D={first:B+Math.floor((I-O)/Y.cellH),last:B+Math.ceil((N-O)/Y.cellH)-1};s&&L&&(D.first=Math.max(D.first,L.startLine),D.last=Math.min(D.last,L.endLine));const V=((K,$)=>rxe(nxe(T,e.cols,r,{first:K,last:$}),K,$))(D.first,D.last);if(V.length===0){S();return}!y||y.ownerDocument!==P.ownerDocument?(S(),y=ixe(P,o)):y.parentElement!==P&&P.append(y),y.replaceChildren(),y.dataset.anchorRow=String(T.anchor.row),y.dataset.anchorColumn=String(T.anchor.column),y.dataset.focusRow=String(T.focus.row),y.dataset.focusColumn=String(T.focus.column);const j=n??((q=e.options.theme)==null?void 0:q.selectionBackground)??Qwe;for(const K of V){const $=O+(K.firstRow-B)*Y.cellH,te=O+(K.lastRow-B+1)*Y.cellH,J=Math.max($,I),ne=Math.min(te,N);if(ne<=J||K.columnCount<=0)continue;const Q=P.ownerDocument.createElement("div");Q.dataset.slot=l,Q.dataset.firstRow=String(K.firstRow),Q.dataset.lastRow=String(K.lastRow),Q.dataset.firstColumn=String(K.firstColumn),Q.dataset.columnCount=String(K.columnCount),Object.assign(Q.style,{position:"absolute",left:`${K.firstColumn*Y.cellW}px`,top:`${J}px`,width:`${K.columnCount*Y.cellW}px`,height:`${ne-J}px`,backgroundColor:j,opacity:u,boxShadow:d?`inset 0 0 0 1px ${d}`:"",pointerEvents:"none"}),y.append(Q)}}const k=()=>x();t.addEventListener("scroll",k,{passive:!0});const R=e.onScroll(k),A=e.onRender(k),M=e.onResize(k);return{render:T=>{g||(f=T?exe(T):null,x())},dispose:()=>{g||(g=!0,t.removeEventListener("scroll",k),R.dispose(),A.dispose(),M.dispose(),_==null||_.disconnect(),f=null,h=null,S())}}}const sxe=16,oxe=16,axe=16;function W6(e){const t=Array.from(e);return t.length!==1?!1:/^[\p{P}\p{S}]$/u.test(t[0])}function lxe(e){if(e.length!==1)return!1;const t=e.charCodeAt(0);return t>=48&&t<=57}function cxe(e){for(const t of e){const n=t.codePointAt(0);if(n!==void 0&&n>127)return!0}return!1}function uxe(e,t){return t.physicalKeyboardMode!==!0||e.length===0?!1:e===" "||cxe(e)?!0:Array.from(e).every(W6)}function dxe(e,t={}){return e.type!=="keydown"||e.ctrlKey||e.metaKey||e.altKey||e.isComposing||t.imeComposing?!1:W6(e.key)||t.physicalKeyboardMode===!0&&(e.key===" "||lxe(e.key))}function fxe(e){return e.type!=="keydown"||!e.ctrlKey||e.metaKey||e.altKey||e.shiftKey?!1:e.key===" "||e.key==="Spacebar"||e.code==="Space"}function hxe(e){return e.type!=="keydown"?!1:e.metaKey}function pxe(e){return e.type!=="keydown"||e.key.toLowerCase()!=="v"||e.altKey?!1:typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/u.test(navigator.platform||navigator.userAgent)?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function q6(e){return{inputMode:e.getAttribute("inputmode"),enterKeyHint:e.getAttribute("enterkeyhint"),autocapitalize:e.getAttribute("autocapitalize"),autocomplete:e.getAttribute("autocomplete"),autocorrect:e.getAttribute("autocorrect"),spellcheck:e.spellcheck,colorScheme:e.style.colorScheme}}function V6(e,t){t.inputMode===null?e.removeAttribute("inputmode"):e.setAttribute("inputmode",t.inputMode),t.enterKeyHint===null?e.removeAttribute("enterkeyhint"):e.setAttribute("enterkeyhint",t.enterKeyHint),t.autocapitalize===null?e.removeAttribute("autocapitalize"):e.setAttribute("autocapitalize",t.autocapitalize),t.autocomplete===null?e.removeAttribute("autocomplete"):e.setAttribute("autocomplete",t.autocomplete),t.autocorrect===null?e.removeAttribute("autocorrect"):e.setAttribute("autocorrect",t.autocorrect),e.spellcheck=t.spellcheck,e.style.colorScheme=t.colorScheme}function mxe(){if(typeof window>"u"||typeof document>"u")return null;const e=window.getComputedStyle(document.documentElement).colorScheme;return e.includes("dark")?"dark":e.includes("light")?"light":null}function gxe(e){const t=q6(e),n=mxe();return e.setAttribute("autocapitalize","off"),e.setAttribute("autocomplete","off"),e.setAttribute("autocorrect","off"),e.spellcheck=!1,n&&(e.style.colorScheme=n),()=>V6(e,t)}function vxe(e){const t=q6(e);return e.setAttribute("enterkeyhint","send"),()=>{V6(e,t)}}function Ul(e){e.helpers&&(e.helpers.style.top=e.previousHelpersTop??""),e.helpers=void 0,e.previousHelpersTop=void 0}function _L(e,t){var S,x;const{textarea:n,element:r,buffer:i,cols:s,rows:o}=e;if(!n||!r||!i||!s||!o){Ul(t);return}const l=r.querySelector(".xterm-screen"),u=l==null?void 0:l.querySelector(".xterm-helpers");if(!l||!u||l.clientWidth<=0||l.clientHeight<=0){Ul(t);return}const d=l.clientWidth/s,f=l.clientHeight/o;if(!Number.isFinite(d)||!Number.isFinite(f)){Ul(t);return}const h=i.active,y=Math.max(0,Math.min(h.cursorX,s-1)),g=Math.max(0,Math.min(h.cursorY,o-1)),_=h.baseY+g-h.viewportY;if(_<0||_>=o){Ul(t);return}const w=Math.max(1,((x=(S=h.getLine(h.baseY+g))==null?void 0:S.getCell(y))==null?void 0:x.getWidth())??1);t.helpers!==u&&(Ul(t),t.helpers=u,t.previousHelpersTop=u.style.top),u.style.top=`${(h.baseY-h.viewportY)*f}px`,n.style.left=`${y*d}px`,n.style.top=`${g*f}px`,n.style.width=`${w*d}px`,n.style.height=`${f}px`,n.style.lineHeight=`${f}px`,n.style.zIndex="-5"}function yxe(e,t,n={}){var F,V,j,q,K,$;let r,i,s,o=!1,l;const u={},d=()=>{var te;return((te=n.isPhysicalKeyboardMode)==null?void 0:te.call(n))??n.physicalKeyboardMode===!0},f=()=>{var te;return((te=n.getPlainEnterBehavior)==null?void 0:te.call(n))??n.plainEnterBehavior??"submit"},h=e.textarea?gxe(e.textarea):void 0,y=d()&&e.textarea?vxe(e.textarea):void 0,g=()=>{const te=e.textarea;!te||l||(l=setTimeout(()=>{l=void 0,o||(te.value="")},0))},_=te=>{var J;if(n.isInputEnabled&&!n.isInputEnabled()){g();return}Mo(t,te),(J=n.onRawInput)==null||J.call(n,te),g()},w=te=>{_(te)},S=()=>{i&&(clearTimeout(i.timer),i=void 0)},x=()=>{s&&(clearTimeout(s.timer),s=void 0)},k=te=>{if(x(),!te)return;const J={data:te,timer:setTimeout(()=>{s===J&&(s=void 0)},axe)};s=J},R=te=>{k(`${(s==null?void 0:s.data)??""}${te}`)},A=te=>!s||!te||!s.data.startsWith(te)?!1:(k(s.data.slice(te.length)),!0),M=(te,J)=>{S();const ne={data:te,keydownText:J,timer:setTimeout(()=>{i===ne&&(i=void 0)},oxe)};i=ne},T=(te,J)=>{const ne=te.startsWith(J.data)?J.data:te.startsWith(J.keydownText)?J.keydownText:"";return ne?te.slice(ne.length):te},P=(te,J,ne)=>T(te,{data:ne,keydownText:J.keydownText}),z=(te,J)=>{let ne=!1;for(const Q of te.bufferedXtermData){let ce=Q;if(!ne){const re=P(Q,te,J);re!==Q&&(ce=re,ne=!0)}ce&&w(ce)}},Y=te=>{const J=r;J&&(r=void 0,clearTimeout(J.timer),_(te),M(te,J.keydownText),z(J,te))},U=te=>{r&&Y(r.keydownText),S();const J={bufferedXtermData:[],keydownText:te,timer:setTimeout(()=>{r===J&&Y(te)},sxe)};r=J},G=te=>uxe(te,{physicalKeyboardMode:d()})?A(te)?(g(),!0):(_(te),M(te,te),!0):!1,I=te=>{const J=te,ne=J.data??"";if(!J.isComposing&&r&&ne){Y(ne);return}J.isComposing||J.inputType!=="insertText"&&J.inputType!=="insertCompositionText"||G(ne)},N=()=>{_L(e,u),o=!0,l&&(clearTimeout(l),l=void 0);const te=e.textarea;te&&(te.value="")},L=()=>{_L(e,u)},B=te=>{Ul(u),o=!1,r&&te.data&&Y(te.data)},O=()=>{Ul(u)},D=e.onData(te=>{if(r){r.bufferedXtermData.push(te);return}if(i){const J=T(te,i);S(),J&&w(J);return}w(te),R(te)});return(F=e.textarea)==null||F.addEventListener("input",I),(V=e.textarea)==null||V.addEventListener("compositionstart",N,!0),(j=e.textarea)==null||j.addEventListener("compositionupdate",L,!0),(q=e.textarea)==null||q.addEventListener("compositionend",B),(K=e.textarea)==null||K.addEventListener("blur",O),($=e.attachCustomKeyEventHandler)==null||$.call(e,te=>pxe(te)||d()&&(fxe(te)||hxe(te))?!1:dxe(te,{physicalKeyboardMode:d(),imeComposing:o})?(U(te.key),!1):te.type!=="keydown"||te.key!=="Enter"?!0:f()==="linefeed"!==te.shiftKey?(_(`
731
+ `))}},K_e=class extends Error{constructor(t,n){super(t),this.name="ListenerLeakError",this.stack=n}},G_e=class extends Error{constructor(t,n){super(t),this.name="ListenerRefusalError",this.stack=n}},X_e=0,J0=class{constructor(t){this.value=t,this.id=X_e++}},Z_e=2,Q_e,Ol=class{constructor(e){var t,n,r,i;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new V_e((e==null?void 0:e.onListenerError)??Q0,((n=this._options)==null?void 0:n.leakWarningThreshold)??q_e):void 0,this._perfMon=(r=this._options)!=null&&r._profName?new W_e(this._options._profName):void 0,this._deliveryQueue=(i=this._options)==null?void 0:i.deliveryQueue}dispose(){var e,t,n,r;this._disposed||(this._disposed=!0,((e=this._deliveryQueue)==null?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(n=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||n.call(t),(r=this._leakageMon)==null||r.dispose())}get event(){return this._event??(this._event=(e,t,n)=>{var o,l,u,d,f;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let h=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(h);let y=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],g=new G_e(`${h}. HINT: Stack shows most frequent listener (${y[1]}-times)`,y[0]);return(((o=this._options)==null?void 0:o.onListenerError)||Q0)(g),Jy.None}if(this._disposed)return Jy.None;t&&(e=e.bind(t));let r=new J0(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=Y_e.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof J0?(this._deliveryQueue??(this._deliveryQueue=new J_e),this._listeners=[this._listeners,r]):this._listeners.push(r):((u=(l=this._options)==null?void 0:l.onWillAddFirstListener)==null||u.call(l,this),this._listeners=r,(f=(d=this._options)==null?void 0:d.onDidAddFirstListener)==null||f.call(d,this)),this._size++;let s=b6(()=>{i==null||i(),this._removeListener(r)});return n instanceof iT?n.add(s):Array.isArray(n)&&n.push(s),s}),this._event}_removeListener(e){var i,s,o,l;if((s=(i=this._options)==null?void 0:i.onWillRemoveListener)==null||s.call(i,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(l=(o=this._options)==null?void 0:o.onDidRemoveLastListener)==null||l.call(o,this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*Z_e<=t.length){let u=0;for(let d=0;d<t.length;d++)t[d]?t[u++]=t[d]:r&&(this._deliveryQueue.end--,u<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=u}}_deliver(e,t){var r;if(!e)return;let n=((r=this._options)==null?void 0:r.onListenerError)||Q0;if(!n){e.value(t);return}try{e.value(t)}catch(i){n(i)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,n,r,i;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(n=this._perfMon)==null||n.stop()),(r=this._perfMon)==null||r.start(this._size),this._listeners)if(this._listeners instanceof J0)this._deliver(this._listeners,e);else{let s=this._deliveryQueue;s.enqueue(this,e,this._listeners.length),this._deliverQueue(s)}(i=this._perfMon)==null||i.stop()}hasListeners(){return this._size>0}},J_e=class{constructor(){this.i=-1,this.end=0}enqueue(t,n,r){this.i=0,this.end=r,this.current=t,this.value=n}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Vd=class yy{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Ol,this.onChange=this._onChange.event;let t=new I_e;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,n,r=!1){return(t&16777215)<<3|(n&3)<<1|(r?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let n=0,r=0,i=t.length;for(let s=0;s<i;++s){let o=t.charCodeAt(s);if(55296<=o&&o<=56319){if(++s>=i)return n+this.wcwidth(o);let d=t.charCodeAt(s);56320<=d&&d<=57343?o=(o-55296)*1024+d-56320+65536:n+=this.wcwidth(d)}let l=this.charProperties(o,r),u=yy.extractWidth(l);yy.extractShouldJoin(l)&&(u-=yy.extractWidth(r)),n+=u,r=l}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},sT=0,k6=-3,Jp=class{constructor(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}},ewe=class{constructor(e,t){this.tag=0,this.bitcount=0,this.destLen=0,this.sourceIndex=0,this.source=e,this.dest=t,this.ltree=new Jp,this.dtree=new Jp}},T6=new Jp,R6=new Jp,oT=new Uint8Array(30),aT=new Uint16Array(30),A6=new Uint8Array(30),N6=new Uint16Array(30),twe=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),lL=new Jp,Vo=new Uint8Array(320);function M6(e,t,n,r){var i,s;for(i=0;i<n;++i)e[i]=0;for(i=0;i<30-n;++i)e[i+n]=i/n|0;for(s=r,i=0;i<30;++i)t[i]=s,s+=1<<e[i]}function nwe(e,t){var n;for(n=0;n<7;++n)e.table[n]=0;for(e.table[7]=24,e.table[8]=152,e.table[9]=112,n=0;n<24;++n)e.trans[n]=256+n;for(n=0;n<144;++n)e.trans[24+n]=n;for(n=0;n<8;++n)e.trans[168+n]=280+n;for(n=0;n<112;++n)e.trans[176+n]=144+n;for(n=0;n<5;++n)t.table[n]=0;for(t.table[5]=32,n=0;n<32;++n)t.trans[n]=n}var cL=new Uint16Array(16);function eS(e,t,n,r){var i,s;for(i=0;i<16;++i)e.table[i]=0;for(i=0;i<r;++i)e.table[t[n+i]]++;for(e.table[0]=0,s=0,i=0;i<16;++i)cL[i]=s,s+=e.table[i];for(i=0;i<r;++i)t[n+i]&&(e.trans[cL[t[n+i]]++]=i)}function rwe(e){e.bitcount--||(e.tag=e.source[e.sourceIndex++],e.bitcount=7);var t=e.tag&1;return e.tag>>>=1,t}function ea(e,t,n){if(!t)return n;for(;e.bitcount<24;)e.tag|=e.source[e.sourceIndex++]<<e.bitcount,e.bitcount+=8;var r=e.tag&65535>>>16-t;return e.tag>>>=t,e.bitcount-=t,r+n}function ME(e,t){for(;e.bitcount<24;)e.tag|=e.source[e.sourceIndex++]<<e.bitcount,e.bitcount+=8;var n=0,r=0,i=0,s=e.tag;do r=2*r+(s&1),s>>>=1,++i,n+=t.table[i],r-=t.table[i];while(r>=0);return e.tag=s,e.bitcount-=i,t.trans[n+r]}function iwe(e,t,n){var r,i,s,o,l,u;for(r=ea(e,5,257),i=ea(e,5,1),s=ea(e,4,4),o=0;o<19;++o)Vo[o]=0;for(o=0;o<s;++o){var d=ea(e,3,0);Vo[twe[o]]=d}for(eS(lL,Vo,0,19),l=0;l<r+i;){var f=ME(e,lL);switch(f){case 16:var h=Vo[l-1];for(u=ea(e,2,3);u;--u)Vo[l++]=h;break;case 17:for(u=ea(e,3,3);u;--u)Vo[l++]=0;break;case 18:for(u=ea(e,7,11);u;--u)Vo[l++]=0;break;default:Vo[l++]=f;break}}eS(t,Vo,0,r),eS(n,Vo,r,i)}function uL(e,t,n){for(;;){var r=ME(e,t);if(r===256)return sT;if(r<256)e.dest[e.destLen++]=r;else{var i,s,o,l;for(r-=257,i=ea(e,oT[r],aT[r]),s=ME(e,n),o=e.destLen-ea(e,A6[s],N6[s]),l=o;l<o+i;++l)e.dest[e.destLen++]=e.dest[l]}}}function swe(e){for(var t,n,r;e.bitcount>8;)e.sourceIndex--,e.bitcount-=8;if(t=e.source[e.sourceIndex+1],t=256*t+e.source[e.sourceIndex],n=e.source[e.sourceIndex+3],n=256*n+e.source[e.sourceIndex+2],t!==(~n&65535))return k6;for(e.sourceIndex+=4,r=t;r;--r)e.dest[e.destLen++]=e.source[e.sourceIndex++];return e.bitcount=0,sT}function owe(e,t){var n=new ewe(e,t),r,i,s;do{switch(r=rwe(n),i=ea(n,2,0),i){case 0:s=swe(n);break;case 1:s=uL(n,T6,R6);break;case 2:iwe(n,n.ltree,n.dtree),s=uL(n,n.ltree,n.dtree);break;default:s=k6}if(s!==sT)throw new Error("Data error")}while(!r);return n.destLen<n.dest.length?typeof n.dest.slice=="function"?n.dest.slice(0,n.destLen):n.dest.subarray(0,n.destLen):n.dest}nwe(T6,R6);M6(oT,aT,4,3);M6(A6,N6,2,1);oT[28]=0;aT[28]=258;var dL=owe,lT=11,nu=5,awe=lT-nu,lwe=65536>>lT,cwe=1<<awe,uwe=cwe-1,by=2,dwe=1<<nu,tS=dwe-1,P6=65536>>nu,fwe=1024>>nu,hwe=P6+fwe,pwe=hwe,mwe=32,gwe=pwe+mwe,vwe=1<<by,ywe=new Uint8Array(new Uint32Array([305419896]).buffer)[0]===18,bwe=class{constructor(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength);this.highStart=t.getUint32(0,!0),this.errorValue=t.getUint32(4,!0);let n=t.getUint32(8,!0);if(e=e.subarray(12),e=dL(e,new Uint8Array(n)),e=dL(e,new Uint8Array(n)),ywe){let r=e.length;for(let i=0;i<r;i+=4){let s=e[i];e[i]=e[i+3],e[i+3]=s;let o=e[i+1];e[i+1]=e[i+2],e[i+2]=o}}this.data=new Uint32Array(e.buffer)}get(e){let t;return e<0||e>1114111?this.errorValue:e<55296||e>56319&&e<=65535?(t=(this.data[e>>nu]<<by)+(e&tS),this.data[t]):e<=65535?(t=(this.data[P6+(e-55296>>nu)]<<by)+(e&tS),this.data[t]):e<this.highStart?(t=this.data[gwe-lwe+(e>>lT)],t=this.data[t+(e>>nu&uwe)],t=(t<<by)+(e&tS),this.data[t]):this.data[this.data.length-vwe]}},_we=bwe,wwe="AAARAAAAAABwxwAAAb4LQfTtmw+sVmUdx58LL/ffe/kjzNBV80gW1F3yR+6CvbJiypoZa0paWmAWSluErSBbFtYkkuZykq6QamGJ4WRqo2kFGy6dYWtEq6G1MFAJbRbOVTQr+x7f5+x97q/n/3me87wXzm/3s+f/7/d7/p7znnvOlvGMbQM7wIPgEbAPHABPgcPgefAS+BfYwuv/F/Q2OulBxKcK6TMRPxu8FcwFbwcjYCFYDC4Cl4ArwNXgGvBJsA58UdBDwy+jbBO4La8DtoEd4H7wkNBuN+KPgn3gADgIngaHwFHwF/AyeAWMm4C+TGi3LdiJ/EnIex04A2RgFpgD5oKFYDG4CLwHXAo+IKSvAqt4/evA9bz9jWA6+Cq3dyvCP8HWNwX93wF38/ROcD94SCjP2+1B+BiPP4HwgOD/7xD/I08fRniMx48jPAFeBeuF+n29jE0G08FZvaPHYWZvh9mcEfAOjlhXx/qGfd2QvLO3zccmtMnzliC9lPt+GenD1nyMiK/LNf1cycs+gfAzPJ6vtxe4jhuQtx5sBLeA28G3eb3v8/Beif4HkPewxu5G6N/rMP4qfgEdvwZPgj+AZ8Cx3nYfxiE8Dk6AV0FfH/YEOB28AbwJDIPzQAtcAC4Gl/Z19F+J+NVCehWPr0b46b7RvixvdPg8yr7U10l/BfFN4La8DdgGdoAHwU/AI2AfOACeAofB8+AlcAKwfvyBKeCM/o7NrF9PXmdWv9/Ynot2I7ztIg8dF5I2a8i63CjZU+9Fm2Wcy4U4ZQVYyeOrwVoev57UuxHcJKRvFuJXgnU8/nUebtbYrKmpCUOx31P7UVNTU1NTU1NTU1OGLTz8Xr/77+W7+9vP0or0MxPMbXaizY8FW3sQ3wseB/t5/kGEh8DR/vbzwL8i/Af4Dy8fP8BYE0weaKenI/wV/DhrQG97JspngzlgLpgHzgPzwUhdVpfVZXVZXRa87HxwAVgQ4Pn5WEd85l5TUzOasvezFw/E3b/LoP9D4CpwrcTWWsGXNQOj748/G9k3G56d1KYxmbELwQbwKFiJvBM8nDWlHa5E+AOwCzwLzjkNeeB28NvTeB1OYyr0gQ1g99R23nGE50xj7MPgc+A+8K5Bxj4FHgB/G2z/T9XEzCZjd/S0WYX4Pc3/r/Nn5I0f6qQXIP5x8ENwBMyYyNhHJ3b0pOCuLrBvM941NTU1JyNHEp+BrC8dMyalt1/m3uWfhmeULzRGp9d3wf0WZSN8+prCr60Wz09tuNmx35sl9Y825HXvRN39KNveaL8flb9f913kbec67kHeTsR3gYcH2uV7ED4m2HhCYi/X9ZuBzvuXv0f8iKIfx5B/XCg7gTgbVPdvAsomCuWnD45eK28UyvL3Jt+s0fU2TVnOXJQvJHUWIb0ELAWXgCt4+UcMumSsEtpch/g6ouMGpG/ieZsc9N/q4YsLd3D9WyPbsWEbfNgO7hN82TWY/n8xKbmsC3xQsYKf+7sjrx2TH+u4H3vhx+OO6+X9hmtXN7C/4r15EPaeBs9J7L7YBeeED/k7wn8fbIf/Rji+yVizmd4vW6bB19cb/PU9w7MxMA60bzPHgM8+zG623+OnzOf55yNc3Gw/k303wveBy3nZcoTXgNVgLfiCRNcG5N3SbIebwZ08fhe4l8d/BH7K4yI/4+HPwS/BAfBks+PzIaHuc3x+ivSL4GUyZ68I6fwZYRNMG2qnz+Th2QjfMtTx/1zE5w61nyN+Q7C3aKgdin1dgrylYBn4INdhGn/Z2FfFiqH01/SUXMvnPD+jC+j85N/RqRhR/DYaS6T+P09K1mD+vzW+5zVqqeVUl0wTz2lK8odJHRGXfBufdGLSoSo3+ZFJ6sl0qvJVNmhI4z4i06mrZ6uT1le1z5h5HE3tMiHPtQ5javu+ItMXUr/MXpmwmyRL3D6U7UwIMyYfczGu0qdqb2pbhcw4xQkhWQBMerrZ/liXrGTbsQwTwrEu4zSczKLrd7fCSKiKn+zSo8BWXMe8myXWOivrUxWi60OPoQ7VIasbQ0S/Ukk3rZVullNhHEL1rYoxUF0PTfm6elWJzq54ZsU4z11ohOy0oxT2izFqCNj4TesXcWZo6+Jfqr1O+1O1beqDagypj2J9F1u2daucj3Eknmq/6PaHrK7Mb1o35DiW1a/a76LuhlDXZX25SOz11S33ErKxDb2/fc/bFKI6axskn+4/W90u9mOtbRf7smsoTdvOfwoRz0t6DaP9k81v6P7Re5aUQudTd303rX+bZzBl97/KR7E+Xbux9lLI+aNr1PfaYLpPDiW2/vrYTX1drMIeXbMye6HXlw8292Jl7ZXxLxRlxXbcaH9drjFlxfa3Qozx8NWRi834lPVZbD+SmN7EJPzc9TVCSVXXDps9L+513b2J7fMu176V2YOhx1A3JrJ8KrLxUumpcu5j/lYT+2tzLRVDZmhjO442a1Clu0ox9VPVXzE/lcS4V0k1D6LI1pJsz8fct9SGbO5l/rmKzTlvsxdj3IvRtC2uv0t1fotltvd2VaCy5Sp5m0EhnZG4CCNxXZrWp/VUIrOjapfnNw11ZNI0V/GWzKNuxtzGKKTEtJeR0NVmpojbtBuW5On0u0is9ZMxvU8ZM+8vEyadtu10oqtP9Q4rcJEm85+Two/QkpGwjI6YkgkhtUfzZOW6fFVexuRri+qj9TJJHZkdmW5abiu0rs6uj2TMfmx06bISUj9tZ9Lja8dVQtox6WpxTJKfW3M4MSTmvU4sWy1CU6BF4jIfdNeDjHWuO1lCWIm2Jr2ixNZvklD2fP0Q6+vsmO4hqN1hJvfDtV5G8mTlsvau4qPP1a64L1skT6QYEzEtq0PzGZOfCbSdSmcKTP7Qs86Ej/1hEpelaV6IMdT5ayu2+nT9tmnnO746XbLxE8t0qOrYtJWhmk9bvaLfsrotRVw1PnR+bcafSUKZ6Mps7smobybJLH2R6WqRkJa1DHV0UmbfUcksiSF0HExSpp+uY0zbTklMaCm7blzEtg8h1rNMXNaYi05ZXsbC75sQ/4+aUxFV2jL50Q3jE0rK2rVtN09By8OHoo1vH2LPSdE323mr2sdu0pUZiDkWLRKWnfeQY6taKzHF9n/GPv8jd/0/egiRvYMR24fU79iY3s9Qva9RlYR8n8HHtq9fMcT1HRWfdZXiHd9YInt/iI4PTaf+BimXKvdXYU+3hlRpHzs2dVK/cxhDn+xs0I2jzxjL5kpXz1VU72aLtkK/97sALKyQqu25SshvG6h08/cLrlKswRklKXvvXfa+pZt+y8nah5YUv2Oo/ap/X2URdRfico9K69hcp6r6XaCz5Wo/hs/iNTGF6N6tV92/9ZS0Wba9SlT3pKF/e6W674+x9ly+VRL73cPU8ygb31D3eSqfVd+iqET0y3YMYojoO11XqrTt2nPxmeq1HYeqxkmUMt8DiesjpoTSr+qDrD+qPZDiOZxMdH0pRPX8MFUfQtv0Xbs+a1a1NnRryNZ/2+tsaPG5ZoX0RXZei88yZGdo4UMPj/cwv/kMJboxLISuQbE+1VW12Mx7FWOrW3M9Hv7Y+uxyraPSo8B2TGPuLdOeZha+hBKf8Sjsm/oR+7pmsx/oeOraFWdXleeV6oyl41zm+mgSuq9C6ox1TsU8D+m4dwMmf8v2nz7Tm+fYfj7HV1K/x1HWjquvY+2dllxM64ue87Su772zzbXIVC+WxLZTRR9MdkMTypZNH1z6G0tUvoccwxA+hfLNdV+a7MaQqscztMi+7QnxDZXvd1dldWQOyMbApb1Jd2h91Ffx+y9Xfb7tClokboOvrRhrbVpFFO8z+65t2/u4su9MUx028znH01/TGVDmHAj13W1o+1USw+eUfYtpO+b82rRNsb6oPpV+1fdBqddB6n3WDXvdJDZrJ0QfQp6bsc/kqq4BIddHWXGdN1pmWveh58F1zYUW1zmOITHXWOg1XrZvZSWUf77tq1ofqear6muaT1lIQp3bofabSafJVlnfYo9B6LGr8uzz2Xchvzfw+T9PlgiV/A8=";function xwe(e){if(typeof Buffer<"u")return Buffer.from(e,"base64");let t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<n.length;++r)n[r]=t.charCodeAt(r);return n}var Swe=new _we(xwe(wwe)),PE=15,IE=0,Ewe=48,Cwe=4,kwe=0,I6=1,O6=2,OE=3,Twe=4,nS=5,rS=6,iS=7,fL=8,sS=9,hL=10,Rwe=11,Awe=32;function pL(e){return(e&Ewe)>>Cwe}function Nwe(e,t){let n=(e&PE)>>IE,r=(t&PE)>>IE;return Mwe(n,r)?r===OE?Awe:r+16:r-16}function Mwe(e,t){return e>=nS&&e<=sS&&(e==nS&&(t==nS||t==rS||t==fL||t==sS)||(e==fL||e==rS)&&(t==rS||t==iS)||(e==sS||e==iS)&&t==iS)||t==O6||t==hL||e==I6||t==Twe||e==hL&&t==Rwe||t==OE&&e==OE}function mL(e){return Swe.get(e)}var L6=class D6{constructor(t=!0){this.ambiguousCharsAreWide=!1,this.version=t?"15-graphemes":"15",this.handleGraphemes=t}charProperties(t,n){if(t>=32&&t<127&&n>>3===0)return D6._plainNarrowProperties;let r=mL(t),i=pL(r),s=!1;if(i>=2?i=i===3||this.ambiguousCharsAreWide||t===65039?2:1:i=1,n!==0){let o=Vd.extractWidth(n);this.handleGraphemes?r=Nwe(Vd.extractCharKind(n),r):r=i===0?1:0,s=r>0,s&&(o>i?i=o:r===32&&(i=2))}return Vd.createPropertyValue(r,i,s)}wcwidth(t){let n=mL(t),r=pL(n),i=(n&PE)>>IE;return i===O6||i===I6?0:r>=2&&(r===3||this.ambiguousCharsAreWide)?2:1}};L6._plainNarrowProperties=Vd.createPropertyValue(kwe,1,!1);var gL=L6,Pwe=class{constructor(){this._oldVersion=""}activate(e){this._provider15||(this._provider15=new gL(!1)),this._provider15Graphemes||(this._provider15Graphemes=new gL(!0));let t=e.unicode;this._unicode=t,t.register(this._provider15),t.register(this._provider15Graphemes),this._oldVersion=t.activeVersion,t.activeVersion="15-graphemes"}dispose(){this._unicode&&(this._unicode.activeVersion=this._oldVersion)}};const Iwe={background:"#1E1E1E",foreground:"#D4D4D4",cursor:"#D4D4D4",cursorAccent:"#1E1E1E",selectionBackground:"#264F78",selectionForeground:void 0,black:"#000000",red:"#CD3131",green:"#0DBC79",yellow:"#E5E510",blue:"#2472C8",magenta:"#BC3FBC",cyan:"#11A8CD",white:"#E5E5E5",brightBlack:"#666666",brightRed:"#F14C4C",brightGreen:"#23D18B",brightYellow:"#F5F543",brightBlue:"#3B8EEA",brightMagenta:"#D670D6",brightCyan:"#29B8DB",brightWhite:"#E5E5E5"},LE={matchBackground:"#264F78",matchBorder:"#3B8EEA",matchOverviewRuler:"#3B8EEA",activeMatchBackground:"#7A4E00",activeMatchBorder:"#F5F543",activeMatchColorOverviewRuler:"#F5F543"},Owe="─│╭╮╰╯›·•";function Lwe(e){const t=e.options.fontFamily;e.options.fontFamily=`${t} `,e.options.fontFamily=t,e.refresh(0,e.rows-1)}function Dwe(e={}){return{scrollback:5e3,fontFamily:Jz,fontSize:e.fontSize??Gd,cursorBlink:!0,cursorStyle:"block",cursorInactiveStyle:"none",disableStdin:!1,scrollOnUserInput:!1,altClickMovesCursor:!1,rightClickSelectsWord:!1,theme:Iwe,allowProposedApi:!0}}async function B6(e,t={}){await v5(window.location.origin,{preloadPowerline:!0}),await document.fonts.ready;const n=t.fontSize??Gd;try{await document.fonts.load(`${n}px "Sarasa Fixed SC"`,Owe)}catch{}const r=new y_e(Dwe(t)),i=new S_e,s=new N_e,o=new Pwe;r.loadAddon(i),r.loadAddon(s),r.loadAddon(o),e.replaceChildren(),r.open(e);const l=()=>{Lwe(r)},u=()=>{document.visibilityState==="visible"&&r.refresh(0,r.rows-1)},d=()=>{r.refresh(0,r.rows-1)},f=()=>{r.refresh(0,r.rows-1)};return document.fonts.addEventListener("loadingdone",l),document.addEventListener("visibilitychange",u),window.addEventListener("pageshow",d),window.addEventListener("focus",f),{terminal:r,serializeAddon:i,dispose:()=>{document.fonts.removeEventListener("loadingdone",l),document.removeEventListener("visibilitychange",u),window.removeEventListener("pageshow",d),window.removeEventListener("focus",f),r.dispose()}}}function Bwe(e,t,n){return e.options.fontSize===t?!1:(e.options.fontSize=t,requestAnimationFrame(()=>n==null?void 0:n()),!0)}function o_(e,t){const n=e.querySelector(".xterm-screen");return!n||t.cols<=0||t.rows<=0?null:{cellW:n.clientWidth/t.cols,cellH:n.clientHeight/t.rows}}function zwe(e,t){for(let n=t-1;n>=0;n--){const r=e.baseY+n;if(r<0||r>=e.length)continue;const i=e.getLine(r);if(i&&i.translateToString(!0).trimEnd().length>0)return n}return-1}const eb=2,tb=1;function jwe(e,t){if(typeof t=="object"){const n=t.axis==="cols"?eb:tb,r=t.axis==="cols"?iu:su;return!Number.isInteger(t.value)||t.value<n||t.value>r?e:{cols:t.axis==="cols"?t.value:e.cols,rows:t.axis==="rows"?t.value:e.rows}}return{cols:t==="increase-cols"&&e.cols<iu?e.cols+1:t==="decrease-cols"&&e.cols>eb?e.cols-1:e.cols,rows:t==="increase-rows"&&e.rows<su?e.rows+1:t==="decrease-rows"&&e.rows>tb?e.rows-1:e.rows}}function Fwe(e,t,n){const r=o_(t,n);if(!r)return null;const i=getComputedStyle(e),s=u=>Number.parseFloat(u)||0,o=e.clientWidth-s(i.paddingLeft)-s(i.paddingRight),l=e.clientHeight-s(i.paddingTop)-s(i.paddingBottom);return[o,l,r.cellW,r.cellH].every(u=>Number.isFinite(u)&&u>0)?{cols:Math.min(iu,Math.max(eb,Math.floor(o/r.cellW))),rows:Math.min(su,Math.max(tb,Math.floor(l/r.cellH)))}:null}function $we(e){let t=!1,n=0,r=null,i=0,s=0,o=0,l=null;const u=()=>{l==null||l.dispose(),l=null;const _=r;r=null,_==null||_.dispose()},d=()=>{if(t||r||e.buffer.active.type!=="normal")return;const _=e.buffer.normal,w=_.length-1;if(w<0)return;const S=_.baseY+_.cursorY,x=e.registerMarker(w-S);if(!x||x.isDisposed||x.line<0){x==null||x.dispose();return}r=x,i=x.line,s=_.length,o=_.baseY,l=x.onDispose(()=>{t||r!==x||(l=null,r=null)})},f=()=>{u(),d()},h=()=>{if(e.buffer.active.type==="normal"){if(r&&!r.isDisposed){const _=r.line-i;_<0&&(n+=_)}f()}},y=()=>{if(e.buffer.active.type!=="normal")return;if(!r||r.isDisposed){f();return}const _=e.buffer.normal,w=r.line-i,S=_.length-s,x=_.baseY-o;w===0&&S===0&&x===0||(w<0&&w===S&&w===x&&(n+=w),f())};d();const g=[e.onScroll(h),e.onWriteParsed(y),e.onResize(f),e.buffer.onBufferChange(_=>{_.type==="normal"&&f()})];return{getOffset:()=>(y(),n),dispose:()=>{if(!t){t=!0;for(const _ of g)_.dispose();u()}}}}const oS=3,vL=4;function z6(e,t){const n=Math.max(0,Math.min(e.length,t)),r=new Uint32Array(n+1),i=new Uint8Array(n),s=new Array(n);let o=0,l=0,u;for(let h=0;h<n;h+=1){const y=e.getCell(h,u);y&&(u=y);const g=(y==null?void 0:y.getChars())??"",_=((y==null?void 0:y.getWidth())??1)&oS,w=g.length>0;r[h]=o,s[h]=_===0?"":w?g:" ",o+=s[h].length,r[h+1]=o,i[h]=_|(w?vL:0),w&&(l=h+_)}const d=s.join(""),f=h=>{if(!Number.isInteger(h)||h<0||h>=n)return;const y=i[h],g=y&vL?d.slice(r[h],r[h+1]):"",_=y&oS;return{getChars:()=>g,getWidth:()=>_}};return{length:n,isWrapped:e.isWrapped,getCell:f,translateToString:(h=!1,y=0,g=n)=>{const _=Math.max(0,Math.min(n,y)),w=Math.max(_,Math.min(n,g)),S=h?Math.min(w,l):w;if(!Number.isInteger(_)||!Number.isInteger(S)||S<=_)return"";let x=_;for(;x<S&&(i[x]&oS)===0;)x+=1;const k=x-_,R=d.slice(r[x],r[S]);return k>0?`${" ".repeat(k)}${R}`:R}}}function $h(e,t){if(!Number.isInteger(t)||t===0)return new Map(e);const n=new Map;for(const[r,i]of e){const s=r+t;s>=0&&n.set(s,i)}return n}const Hwe="pty-live-backfill",cT=new WeakMap,Uwe=new Map;function j6(e){return e.querySelector('.xterm-screen [data-slot="pty-live-backfill"]')}function F6(e){var r;const n=(((r=e.getCurrentRowIdentityOffset)==null?void 0:r.call(e))??e.capturedRowIdentityOffset)-e.capturedRowIdentityOffset;return Number.isInteger(n)?n:0}function uT(e){const t=j6(e),n=t?cT.get(t):void 0;if(!t||!n)return null;const r=F6(n),i=Number(t.dataset.startLine)+r,s=Number(t.dataset.endLine)+r;return!Number.isInteger(i)||!Number.isInteger(s)?null:{element:t,startLine:i,endLine:s}}function $6(e){const t=j6(e),n=t?cT.get(t):void 0;if(!n)return Uwe;const r=F6(n);if(r===0)return n.lines;if(n.rebasedDelta===r&&n.rebasedLines)return n.rebasedLines;const i=new Map;for(const[s,o]of n.lines){const l=s+r;l>=0&&i.set(l,o)}return n.rebasedDelta=r,n.rebasedLines=i,i}function nb(e,t){return $6(e).get(t)??null}function Wwe(e){return Array.from(e.children).find(t=>t instanceof HTMLElement&&t.classList.contains("xterm-rows"))??null}function qwe(e,t,n,r,i,s){const o=document.createElement("div");return o.dataset.slot=Hwe,o.dataset.startLine=String(r),o.dataset.endLine=String(i),o.dataset.rowIdentityOffset=String(s),o.setAttribute("aria-hidden","true"),Object.assign(o.style,{position:"absolute",top:`${n}px`,right:"0",left:"0",height:t.style.height||"100%",overflow:"hidden",pointerEvents:"auto",touchAction:"pan-x pan-y",backgroundColor:getComputedStyle(e).backgroundColor}),o.append(t),o}function Vwe(e,t,n){var r;for(const[i,s]of Array.from(e.children).entries()){if(!(s instanceof HTMLElement))continue;let o=0;for(const l of Array.from(s.children)){if(!(l instanceof HTMLElement))continue;const u=((r=l.textContent)==null?void 0:r.length)??0;let d=(n==null?void 0:n(t+i,o))??null;for(;(d==null?void 0:d.text.length)===0;)o+=1,d=(n==null?void 0:n(t+i,o))??null;const f=l.style.opacity;if(f&&f!=="1")if(d!=null&&d.isDim&&d.isRenderedFgRGB)l.style.removeProperty("opacity");else{l.style.removeProperty("opacity");const y=document.createElement("span");y.style.opacity=f,y.append(...Array.from(l.childNodes)),l.append(y)}let h=0;for(;h<u;){const y=(n==null?void 0:n(t+i,o))??null;if(!y)break;h+=y.text.length,o+=1}}}}function Ywe(e){let t="";for(const n of Array.from(e.children)){if(!(n instanceof HTMLElement))continue;const r=Array.from(n.children).filter(l=>l instanceof HTMLSpanElement),i=r[0];if(!i)continue;!(i.textContent===""&&r.length>1)&&!i.hasAttribute("style")&&t&&(i.style.cssText=t);const o=r.at(-1);o&&(t=o.getAttribute("style")??"")}}function Kwe(e,t,n,r,i){const o=new DOMParser().parseFromString(e,"text/html").querySelector("pre > div");if(!o)return null;const l=document.importNode(o,!0);l.className=t.className,l.removeAttribute("id"),Ywe(l),Vwe(l,r,i);const u=getComputedStyle(t),d=l.childElementCount;Object.assign(l.style,{position:"absolute",top:"0",left:"0",width:"100%",height:`${d*n}px`,fontFamily:u.fontFamily,fontSize:u.fontSize,fontWeight:u.fontWeight,fontVariantLigatures:u.fontVariantLigatures,letterSpacing:u.letterSpacing,whiteSpace:"pre"});for(const f of Array.from(l.children))f instanceof HTMLElement&&Object.assign(f.style,{height:`${n}px`,lineHeight:`${n}px`,overflow:"hidden",whiteSpace:"pre"});return l}function Gwe(e,t={}){let n=null;const r=e.style.overflow,i=l=>{const u=e.querySelector(".xterm-screen");if(!u)return;const d=Array.from(u.children).find(f=>f instanceof HTMLElement&&f.classList.contains("xterm-selection"));u.insertBefore(l,d??null),n==null||n.remove(),n=l,e.style.overflow="visible"},s=()=>{n==null||n.remove(),n=null,e.style.overflow=r};return{render:l=>{var w;if(!l)return s(),!0;const u=e.querySelector(".xterm-screen"),d=u?Wwe(u):null;if(!u||!d||!t.serializeRangeAsHtml||l.endLine<l.startLine||l.rowHeight<=0)return!1;const f=t.serializeRangeAsHtml(l.startLine,l.endLine),h=Kwe(f,d,l.rowHeight,l.startLine,t.getSerializedCell);if(!h)return!1;const y=((w=t.getBufferRowIdentityOffset)==null?void 0:w.call(t))??0,g=qwe(u,h,l.topOffset,l.startLine,l.endLine,y),_=new Map;if(t.getSelectionLine)for(let S=l.startLine;S<=l.endLine;S+=1){const x=t.getSelectionLine(S);x&&_.set(S,z6(x,x.length))}return cT.set(g,{capturedRowIdentityOffset:y,getCurrentRowIdentityOffset:t.getBufferRowIdentityOffset,lines:_}),i(g),!0},dispose:s}}const Xwe="pty-managed-selection-overlay",Zwe="pty-managed-selection-segment",Qwe="#264f78",Jwe="0.62";function yL(e,t){if(!e||t<=0||[e.start.x,e.start.y,e.end.x,e.end.y].some(u=>!Number.isInteger(u)||u<0)||e.start.x>t||e.end.x>t)return null;const r=e.start.y*t+e.start.x,i=e.end.y*t+e.end.x;if(i<=r)return null;const s=i-1,o={row:Math.floor(r/t),column:r%t},l={row:Math.floor(s/t),column:s%t};return{anchor:o,focus:l,columnMode:!1}}function bL(e){return Number.isInteger(e.row)&&e.row>=0&&Number.isInteger(e.column)&&e.column>=0}function exe(e){return{anchor:{row:e.anchor.row,column:e.anchor.column},focus:{row:e.focus.row,column:e.focus.column},columnMode:e.columnMode}}function txe(e,t){return e.row===t.row?e.column-t.column:e.row-t.row}function Lv(e,t,n){var s,o;let r=Math.max(0,Math.min(n-1,t));for(;r>0&&((s=e==null?void 0:e.getCell(r))==null?void 0:s.getWidth())===0;)r-=1;const i=Math.max(1,((o=e==null?void 0:e.getCell(r))==null?void 0:o.getWidth())??1);return{start:r,end:Math.min(n,r+i)}}function H6(e,t){const n=e.at(-1);if(n&&n.lastRow+1===t.firstRow&&n.firstColumn===t.firstColumn&&n.columnCount===t.columnCount){e[e.length-1]={...n,lastRow:t.lastRow};return}e.push(t)}function nxe(e,t,n,r){if(t<=0||!bL(e.anchor)||!bL(e.focus))return[];const[i,s]=txe(e.anchor,e.focus)<=0?[e.anchor,e.focus]:[e.focus,e.anchor],o=Lv(n==null?void 0:n(i.row),i.column,t),l=Lv(n==null?void 0:n(s.row),s.column,t);if(e.columnMode){const d=Math.max(Math.min(e.anchor.row,e.focus.row),(r==null?void 0:r.first)??0),f=Math.min(Math.max(e.anchor.row,e.focus.row),(r==null?void 0:r.last)??Number.MAX_SAFE_INTEGER);if(f<d)return[];const h=Math.min(e.anchor.column,e.focus.column),y=Math.max(e.anchor.column,e.focus.column),g=[];for(let _=d;_<=f;_+=1){const w=n==null?void 0:n(_),S=Lv(w,h,t).start,x=Lv(w,y,t).end;H6(g,{firstRow:_,lastRow:_,firstColumn:S,columnCount:Math.max(0,x-S)})}return g}if(i.row===s.row)return[{firstRow:i.row,lastRow:s.row,firstColumn:o.start,columnCount:l.end-o.start}];const u=[{firstRow:i.row,lastRow:i.row,firstColumn:o.start,columnCount:t-o.start}];return s.row-i.row>1&&u.push({firstRow:i.row+1,lastRow:s.row-1,firstColumn:0,columnCount:t}),u.push({firstRow:s.row,lastRow:s.row,firstColumn:0,columnCount:l.end}),u}function rxe(e,t,n){if(n<t)return[];const r=[];for(const i of e){const s=Math.max(i.firstRow,t),o=Math.min(i.lastRow,n);o<s||H6(r,{...i,firstRow:s,lastRow:o})}return r}function ixe(e,t){const n=e.ownerDocument.createElement("div");return n.dataset.slot=t,n.setAttribute("aria-hidden","true"),Object.assign(n.style,{position:"absolute",inset:"0",overflow:"visible",pointerEvents:"none",zIndex:"3"}),e.append(n),n}function U6({terminal:e,container:t,selectionBackground:n,getLine:r,resolveRange:i,projectionOnly:s=!1,overlaySlot:o=Xwe,segmentSlot:l=Zwe,opacity:u=Jwe,borderColor:d}){let f=null,h=null,y=null,g=!1;const _=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>x());_==null||_.observe(t);const w=()=>{var P;const T=((P=e.element)==null?void 0:P.querySelector(".xterm-screen"))??null;return T===h||(h&&(_==null||_.unobserve(h)),y==null||y.remove(),y=null,h=T,h&&(_==null||_.observe(h))),h},S=()=>{y==null||y.remove(),y=null};function x(){var q;const T=f&&i?i():f;if(g||!T){S();return}const P=w();if(!P||e.cols<=0||e.rows<=0){S();return}const z=P.getBoundingClientRect(),Y={cellW:z.width/e.cols,cellH:z.height/e.rows};if(Y.cellW<=0||Y.cellH<=0){S();return}const U=t.getBoundingClientRect(),G=t.clientHeight>0?t.clientHeight:U.height,I=U.top+(t.clientHeight>0?t.clientTop:0)-z.top,N=I+G;if(!Number.isFinite(I)||!Number.isFinite(N)||G<=0)return;const L=e.element?uT(e.element):null;if(s&&!L){S();return}const B=(L==null?void 0:L.startLine)??e.buffer.active.viewportY,O=L?L.element.getBoundingClientRect().top-z.top:0;if(!Number.isFinite(O)){S();return}const D={first:B+Math.floor((I-O)/Y.cellH),last:B+Math.ceil((N-O)/Y.cellH)-1};s&&L&&(D.first=Math.max(D.first,L.startLine),D.last=Math.min(D.last,L.endLine));const V=((K,$)=>rxe(nxe(T,e.cols,r,{first:K,last:$}),K,$))(D.first,D.last);if(V.length===0){S();return}!y||y.ownerDocument!==P.ownerDocument?(S(),y=ixe(P,o)):y.parentElement!==P&&P.append(y),y.replaceChildren(),y.dataset.anchorRow=String(T.anchor.row),y.dataset.anchorColumn=String(T.anchor.column),y.dataset.focusRow=String(T.focus.row),y.dataset.focusColumn=String(T.focus.column);const j=n??((q=e.options.theme)==null?void 0:q.selectionBackground)??Qwe;for(const K of V){const $=O+(K.firstRow-B)*Y.cellH,te=O+(K.lastRow-B+1)*Y.cellH,J=Math.max($,I),ne=Math.min(te,N);if(ne<=J||K.columnCount<=0)continue;const Q=P.ownerDocument.createElement("div");Q.dataset.slot=l,Q.dataset.firstRow=String(K.firstRow),Q.dataset.lastRow=String(K.lastRow),Q.dataset.firstColumn=String(K.firstColumn),Q.dataset.columnCount=String(K.columnCount),Object.assign(Q.style,{position:"absolute",left:`${K.firstColumn*Y.cellW}px`,top:`${J}px`,width:`${K.columnCount*Y.cellW}px`,height:`${ne-J}px`,backgroundColor:j,opacity:u,boxShadow:d?`inset 0 0 0 1px ${d}`:"",pointerEvents:"none"}),y.append(Q)}}const k=()=>x();t.addEventListener("scroll",k,{passive:!0});const R=e.onScroll(k),A=e.onRender(k),M=e.onResize(k);return{render:T=>{g||(f=T?exe(T):null,x())},dispose:()=>{g||(g=!0,t.removeEventListener("scroll",k),R.dispose(),A.dispose(),M.dispose(),_==null||_.disconnect(),f=null,h=null,S())}}}const sxe=16,oxe=16,axe=16;function W6(e){const t=Array.from(e);return t.length!==1?!1:/^[\p{P}\p{S}]$/u.test(t[0])}function lxe(e){if(e.length!==1)return!1;const t=e.charCodeAt(0);return t>=48&&t<=57}function cxe(e){for(const t of e){const n=t.codePointAt(0);if(n!==void 0&&n>127)return!0}return!1}function uxe(e,t){return t.physicalKeyboardMode!==!0||e.length===0?!1:e===" "||cxe(e)?!0:Array.from(e).every(W6)}function dxe(e,t={}){return e.type!=="keydown"||e.ctrlKey||e.metaKey||e.altKey||e.isComposing||t.imeComposing?!1:W6(e.key)||t.physicalKeyboardMode===!0&&(e.key===" "||lxe(e.key))}function fxe(e){return e.type!=="keydown"||!e.ctrlKey||e.metaKey||e.altKey||e.shiftKey?!1:e.key===" "||e.key==="Spacebar"||e.code==="Space"}function hxe(e){return e.type!=="keydown"?!1:e.metaKey}function pxe(e){return e.type!=="keydown"||e.key.toLowerCase()!=="v"||e.altKey?!1:typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/u.test(navigator.platform||navigator.userAgent)?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function q6(e){return{inputMode:e.getAttribute("inputmode"),enterKeyHint:e.getAttribute("enterkeyhint"),autocapitalize:e.getAttribute("autocapitalize"),autocomplete:e.getAttribute("autocomplete"),autocorrect:e.getAttribute("autocorrect"),spellcheck:e.spellcheck,colorScheme:e.style.colorScheme}}function V6(e,t){t.inputMode===null?e.removeAttribute("inputmode"):e.setAttribute("inputmode",t.inputMode),t.enterKeyHint===null?e.removeAttribute("enterkeyhint"):e.setAttribute("enterkeyhint",t.enterKeyHint),t.autocapitalize===null?e.removeAttribute("autocapitalize"):e.setAttribute("autocapitalize",t.autocapitalize),t.autocomplete===null?e.removeAttribute("autocomplete"):e.setAttribute("autocomplete",t.autocomplete),t.autocorrect===null?e.removeAttribute("autocorrect"):e.setAttribute("autocorrect",t.autocorrect),e.spellcheck=t.spellcheck,e.style.colorScheme=t.colorScheme}function mxe(){if(typeof window>"u"||typeof document>"u")return null;const e=window.getComputedStyle(document.documentElement).colorScheme;return e.includes("dark")?"dark":e.includes("light")?"light":null}function gxe(e){const t=q6(e),n=mxe();return e.setAttribute("autocapitalize","off"),e.setAttribute("autocomplete","off"),e.setAttribute("autocorrect","off"),e.spellcheck=!1,n&&(e.style.colorScheme=n),()=>V6(e,t)}function vxe(e){const t=q6(e);return e.setAttribute("enterkeyhint","send"),()=>{V6(e,t)}}function Ul(e){e.helpers&&(e.helpers.style.top=e.previousHelpersTop??""),e.helpers=void 0,e.previousHelpersTop=void 0}function _L(e,t){var S,x;const{textarea:n,element:r,buffer:i,cols:s,rows:o}=e;if(!n||!r||!i||!s||!o){Ul(t);return}const l=r.querySelector(".xterm-screen"),u=l==null?void 0:l.querySelector(".xterm-helpers");if(!l||!u||l.clientWidth<=0||l.clientHeight<=0){Ul(t);return}const d=l.clientWidth/s,f=l.clientHeight/o;if(!Number.isFinite(d)||!Number.isFinite(f)){Ul(t);return}const h=i.active,y=Math.max(0,Math.min(h.cursorX,s-1)),g=Math.max(0,Math.min(h.cursorY,o-1)),_=h.baseY+g-h.viewportY;if(_<0||_>=o){Ul(t);return}const w=Math.max(1,((x=(S=h.getLine(h.baseY+g))==null?void 0:S.getCell(y))==null?void 0:x.getWidth())??1);t.helpers!==u&&(Ul(t),t.helpers=u,t.previousHelpersTop=u.style.top),u.style.top=`${(h.baseY-h.viewportY)*f}px`,n.style.left=`${y*d}px`,n.style.top=`${g*f}px`,n.style.width=`${w*d}px`,n.style.height=`${f}px`,n.style.lineHeight=`${f}px`,n.style.zIndex="-5"}function yxe(e,t,n={}){var F,V,j,q,K,$;let r,i,s,o=!1,l;const u={},d=()=>{var te;return((te=n.isPhysicalKeyboardMode)==null?void 0:te.call(n))??n.physicalKeyboardMode===!0},f=()=>{var te;return((te=n.getPlainEnterBehavior)==null?void 0:te.call(n))??n.plainEnterBehavior??"submit"},h=e.textarea?gxe(e.textarea):void 0,y=d()&&e.textarea?vxe(e.textarea):void 0,g=()=>{const te=e.textarea;!te||l||(l=setTimeout(()=>{l=void 0,o||(te.value="")},0))},_=te=>{var J;if(n.isInputEnabled&&!n.isInputEnabled()){g();return}Mo(t,te),(J=n.onRawInput)==null||J.call(n,te),g()},w=te=>{_(te)},S=()=>{i&&(clearTimeout(i.timer),i=void 0)},x=()=>{s&&(clearTimeout(s.timer),s=void 0)},k=te=>{if(x(),!te)return;const J={data:te,timer:setTimeout(()=>{s===J&&(s=void 0)},axe)};s=J},R=te=>{k(`${(s==null?void 0:s.data)??""}${te}`)},A=te=>!s||!te||!s.data.startsWith(te)?!1:(k(s.data.slice(te.length)),!0),M=(te,J)=>{S();const ne={data:te,keydownText:J,timer:setTimeout(()=>{i===ne&&(i=void 0)},oxe)};i=ne},T=(te,J)=>{const ne=te.startsWith(J.data)?J.data:te.startsWith(J.keydownText)?J.keydownText:"";return ne?te.slice(ne.length):te},P=(te,J,ne)=>T(te,{data:ne,keydownText:J.keydownText}),z=(te,J)=>{let ne=!1;for(const Q of te.bufferedXtermData){let ce=Q;if(!ne){const re=P(Q,te,J);re!==Q&&(ce=re,ne=!0)}ce&&w(ce)}},Y=te=>{const J=r;J&&(r=void 0,clearTimeout(J.timer),_(te),M(te,J.keydownText),z(J,te))},U=te=>{r&&Y(r.keydownText),S();const J={bufferedXtermData:[],keydownText:te,timer:setTimeout(()=>{r===J&&Y(te)},sxe)};r=J},G=te=>uxe(te,{physicalKeyboardMode:d()})?A(te)?(g(),!0):(_(te),M(te,te),!0):!1,I=te=>{const J=te,ne=J.data??"";if(!J.isComposing&&r&&ne){Y(ne);return}J.isComposing||J.inputType!=="insertText"&&J.inputType!=="insertCompositionText"||G(ne)},N=()=>{_L(e,u),o=!0,l&&(clearTimeout(l),l=void 0);const te=e.textarea;te&&(te.value="")},L=()=>{_L(e,u)},B=te=>{Ul(u),o=!1,r&&te.data&&Y(te.data)},O=()=>{Ul(u)},D=e.onData(te=>{if(r){r.bufferedXtermData.push(te);return}if(i){const J=T(te,i);S(),J&&w(J);return}w(te),R(te)});return(F=e.textarea)==null||F.addEventListener("input",I),(V=e.textarea)==null||V.addEventListener("compositionstart",N,!0),(j=e.textarea)==null||j.addEventListener("compositionupdate",L,!0),(q=e.textarea)==null||q.addEventListener("compositionend",B),(K=e.textarea)==null||K.addEventListener("blur",O),($=e.attachCustomKeyEventHandler)==null||$.call(e,te=>pxe(te)||d()&&(fxe(te)||hxe(te))?!1:dxe(te,{physicalKeyboardMode:d(),imeComposing:o})?(U(te.key),!1):te.type!=="keydown"||te.key!=="Enter"?!0:f()==="linefeed"!==te.shiftKey?(_(`
732
732
  `),te.preventDefault(),!1):!0),{dispose:()=>{var te,J,ne,Q,ce;D.dispose(),(te=e.textarea)==null||te.removeEventListener("input",I),(J=e.textarea)==null||J.removeEventListener("compositionstart",N,!0),(ne=e.textarea)==null||ne.removeEventListener("compositionupdate",L,!0),(Q=e.textarea)==null||Q.removeEventListener("compositionend",B),(ce=e.textarea)==null||ce.removeEventListener("blur",O),Ul(u),r&&(clearTimeout(r.timer),r=void 0),l&&(clearTimeout(l),l=void 0),y==null||y(),h==null||h(),S(),x()}}}const Tp="\x1B[";function wL(e){if(e==="")return!1;let t=e;for(;t.length>0;){const n=_xe(t)||bxe(t);if(n===0)return!1;t=t.slice(n)}return!0}function bxe(e){return e.startsWith(`${Tp}I`)||e.startsWith(`${Tp}O`)?3:0}function _xe(e){if(e.startsWith(`${Tp}M`))return e.length>=6?6:0;if(e.startsWith(`${Tp}<`)){const t=e.slice(3).match(/^\d+;\d+;\d+[mM]/);return t!=null&&t[0]?3+t[0].length:0}if(e.startsWith(Tp)){const t=e.slice(2).match(/^\d+;\d+;\d+M/);return t!=null&&t[0]?2+t[0].length:0}return 0}function Y6(e){const t=Math.round(e),n=Number.EPSILON*Math.max(1,Math.abs(e));return Math.abs(e-t)<=n?t:e}function K6(e,t){if(e.cellH<=0||e.cellW<=0||e.rows<=0||e.cols<=0)return null;const n=e.rows*e.cellH,r=e.bufferLength<=e.rows,i=Math.max(0,e.visibleContentHeight??0),s=i>0?Math.min(n,i):n,o=e.cursorY===void 0?-1:Math.max(0,Math.min(e.rows-1,e.cursorY)),l=Math.max(-1,Math.min(e.rows-1,t)),u=Math.max(1,Math.max(o,l)+1),d=r?Math.max(0,s-u*e.cellH):0,h=Math.max(0,e.bufferLength-e.rows)*e.cellH+i;return i>0&&e.cursorY!==void 0?{spacerHeight:G6({bufferLength:e.bufferLength,baseY:e.baseY,rows:e.rows,cursorY:e.cursorY,liveLastY:t,cellH:e.cellH,visibleContentHeight:i,hostPaddingTop:d}).scrollTop+i,spacerWidth:e.cols*e.cellW,hostWidth:e.cols*e.cellW,hostHeight:n,hostPaddingTop:d}:{spacerHeight:Math.max(e.bufferLength*e.cellH,h),spacerWidth:e.cols*e.cellW,hostWidth:e.cols*e.cellW,hostHeight:n,hostPaddingTop:d}}function G6({bufferLength:e,baseY:t,rows:n,cursorY:r,liveLastY:i,cellH:s,visibleContentHeight:o,hostPaddingTop:l=0}){const u=Math.max(0,Math.min(e,t));if(n<=0||s<=0)return{scrollTop:0,viewportY:u,liveTailY:0};const d=Math.max(0,Math.min(n-1,r)),f=i<0?d:Math.max(0,Math.min(n-1,i)),h=Math.max(d,f),y=n*s,g=o>0&&o<y?Y6(o/s):n,_=l/s,w=_+u+d,S=_+u+h+1,x=Math.max(0,Math.min(S-g,w)),k=x*s,R=Math.max(0,Math.min(u,Math.floor(x)));return{scrollTop:k,viewportY:R,liveTailY:h}}function dT(e){const t=e.rows*e.cellH,n=e.cellH>0&&t<e.visibleContentHeight?e.visibleContentHeight-t:0,r=e.paddingTop+n+e.hostPaddingTop+e.cursorBufferRow*e.cellH,i=e.containerScrollTop+e.paddingTop,s=e.containerScrollTop+e.containerClientHeight-e.paddingBottom,o=Math.max(1,e.atBottomThreshold),l=e.cursorBufferRow>=e.viewportY&&e.cursorBufferRow<e.viewportY+e.rows,u=e.cellH>0&&l&&r>=i-o&&r+e.cellH<=s+o,d=Math.max(0,e.bufferLength-e.rows),f=Math.max(0,e.containerScrollHeight-e.containerClientHeight),h=G6({bufferLength:e.bufferLength,baseY:e.baseY,rows:e.rows,cursorY:e.cursorBufferRow-e.baseY,liveLastY:e.liveLastY,cellH:e.cellH,visibleContentHeight:e.visibleContentHeight,hostPaddingTop:e.hostPaddingTop}),y=e.cellH>0?h.scrollTop:f,g=e.cellH>0?h.viewportY:d;return{isAtBottom:Math.abs(e.containerScrollTop-y)<=e.atBottomThreshold&&(e.cellH<=0||u),bottomScrollTop:y,bottomViewportY:g,cursorInViewport:u}}function Ed(e){if(e.cellH<=0)return 0;const t=e.rows*e.cellH,n=e.visibleContentHeight!==void 0&&t<e.visibleContentHeight?e.visibleContentHeight-t:0;return Math.max(0,e.ydisp*e.cellH+n)}function wxe(e){if(e.cellH<=0||e.rows<=0||e.ydisp<=0)return null;if(e.visibleTopLine!==void 0){const l=Math.max(0,Math.floor(e.visibleTopLine)),u=Math.floor(e.ydisp)-1;return u<l?null:{startLine:l,endLine:u,rowCount:u-l+1,rowHeight:e.cellH,topOffset:(l-e.ydisp)*e.cellH}}const t=Math.max(0,e.visibleContentHeight??0),n=e.rows*e.cellH,r=Math.max(0,t-n);if(r<=0)return null;const i=Math.ceil(r/e.cellH),s=Math.min(i,Math.floor(e.ydisp));if(s<=0)return null;const o=Math.floor(e.ydisp)-1;return{startLine:o-s+1,endLine:o,rowCount:s,rowHeight:e.cellH,topOffset:-s*e.cellH}}function xxe(e){if(e.cellH<=0||e.rows<=0||e.bufferLength<=0||e.visibleContentHeight<=0)return null;const t=Math.max(0,e.visibleTopLine),n=Y6(t+e.visibleContentHeight/e.cellH),r=Math.min(e.bufferLength-1,Math.floor(t)),i=Math.min(e.bufferLength-1,Math.max(r,Math.ceil(n)-1));return{startLine:r,endLine:i,rowCount:i-r+1,rowHeight:e.cellH,topOffset:(r-e.ydisp)*e.cellH}}function Sxe(e,t){if(t.cellH<=0)return{ydisp:t.viewportY};const n=Math.max(0,t.bufferLength-t.rows),r=n*t.cellH;if(e>=r)return{ydisp:n};const i=Math.max(0,Math.floor(e/t.cellH));return{ydisp:Math.min(i,n)}}function Exe(e,t){return t<=0?0:Math.max(0,e)*t}function Cxe(){return{intent:!1,resumeWhenCursorVisible:!1,lastUserInputAt:null,unmarkedOriginLeft:null,lastSeenLeft:0,pendingFollowLeft:null}}function kxe(e,t){return{...e,intent:t,unmarkedOriginLeft:t?e.unmarkedOriginLeft:null}}function yp(e,t){return{state:{...kxe(e,!1),resumeWhenCursorVisible:!1,lastUserInputAt:null,pendingFollowLeft:null,...t.scrollLeft!==void 0?{lastSeenLeft:t.scrollLeft}:{}},trace:e.intent?{kind:"clear",details:t.details}:null}}function Txe(e,t){return{state:{...e,intent:!0,resumeWhenCursorVisible:t.resumeWhenCursorVisible??!1,lastUserInputAt:t.now,unmarkedOriginLeft:null},trace:e.intent?null:{kind:"set",details:t.details}}}function Rxe(e,t){return{...e,pendingFollowLeft:t}}function Axe(e,t){if(!t.hasOverflow)return{...yp(e,{details:`reason=not-scrollable scrollLeft=${t.scrollLeft}`,scrollLeft:0}),resetScrollLeft:t.scrollLeft!==0};if(t.scrollLeft===e.lastSeenLeft)return{state:e,trace:null,resetScrollLeft:!1};const n=t.pendingFollowTolerancePx??1,r=t.recentUserInputMs??500;if(e.pendingFollowLeft!==null&&Math.abs(t.scrollLeft-e.pendingFollowLeft)<=n)return{state:{...e,pendingFollowLeft:null,unmarkedOriginLeft:null,lastSeenLeft:t.scrollLeft},trace:null,resetScrollLeft:!1};if(e.lastUserInputAt!==null&&t.now-e.lastUserInputAt<=r){const u=`site=onContainerScroll prev=${e.lastSeenLeft} next=${t.scrollLeft}`;return{state:{...e,intent:!0,resumeWhenCursorVisible:!1,pendingFollowLeft:null,unmarkedOriginLeft:null,lastSeenLeft:t.scrollLeft},trace:e.intent?null:{kind:"set",details:u},resetScrollLeft:!1}}const o=e.unmarkedOriginLeft===null?e.lastSeenLeft:e.unmarkedOriginLeft,l=Math.abs(t.scrollLeft-o);if(l>=t.nativeIntentThresholdPx){const u=`site=onContainerScroll-native prev=${o} next=${t.scrollLeft} delta=${l}`;return{state:{...e,intent:!0,resumeWhenCursorVisible:!1,pendingFollowLeft:null,unmarkedOriginLeft:null,lastSeenLeft:t.scrollLeft},trace:e.intent?null:{kind:"set",details:u},resetScrollLeft:!1}}return{state:{...e,pendingFollowLeft:null,unmarkedOriginLeft:o,lastSeenLeft:t.scrollLeft},trace:{kind:"ignore",details:`site=onContainerScroll prev=${e.lastSeenLeft} next=${t.scrollLeft} nativeDelta=${l}`},resetScrollLeft:!1}}function Nxe({syncingExternal:e,effectiveScrollTop:t,pendingFollowTop:n,pendingProgrammaticTop:r,atBottom:i,canPassiveFollow:s,tolerancePx:o=1}){return e?{action:"external-sync",nextPendingFollowTop:n,nextPendingProgrammaticTop:r}:n!==null&&Math.abs(t-n)<=o?{action:"programmatic-follow",nextPendingFollowTop:null,nextPendingProgrammaticTop:null}:r!==null&&Math.abs(t-r)<=o&&s?i?{action:"programmatic-bottom",nextPendingFollowTop:null,nextPendingProgrammaticTop:null}:{action:"programmatic-drift",nextPendingFollowTop:null,nextPendingProgrammaticTop:null}:{action:"continue",nextPendingFollowTop:null,nextPendingProgrammaticTop:null}}function Mxe(e){return!e.force&&e.reviewing?{action:"blocked-by-review"}:!e.reviewing&&e.viewportY===e.expectedYdisp&&(Math.abs(e.scrollTop-e.bottomScrollTop)<=1||!e.force&&e.atBottom)?{action:"noop"}:{action:"follow"}}function fT({reviewing:e,referenceScrollTop:t,bottomScrollTop:n,domMaxScrollTop:r,atBottomThreshold:i}){return e&&t>n+i?r:Math.min(r,n)}function Pxe({reviewing:e,deltaY:t,currentScrollTop:n,bottomScrollTop:r,atBottomThreshold:i}){return!e||t<=0||n>r+i?!1:n+t>=r-i}function Ixe(e){const t=fT(e);return e.rawScrollTop<=t+1?{action:"keep",scrollTop:e.rawScrollTop}:{action:"clamp",scrollTop:t}}function Oxe({container:e,term:t,onWheel:n,onTouchStart:r,onTouchMove:i,onTouchEnd:s,onTouchCancel:o,onContainerScroll:l,onTermScroll:u,onRender:d,onRelayout:f,onWriteParsed:h}){var S;e.addEventListener("wheel",n,{passive:!1,capture:!0}),e.addEventListener("touchstart",r,{passive:!0}),e.addEventListener("touchmove",i,{passive:!0}),e.addEventListener("touchend",s,{passive:!0}),e.addEventListener("touchcancel",o,{passive:!0}),e.addEventListener("scroll",l,{passive:!0});const y=t.onScroll(u),g=t.onRender(d),_=h?(S=t.onWriteParsed)==null?void 0:S.call(t,h):void 0,w=new ResizeObserver(f);return w.observe(e),{dispose:()=>{e.removeEventListener("scroll",l),e.removeEventListener("wheel",n,{capture:!0}),e.removeEventListener("touchstart",r),e.removeEventListener("touchmove",i),e.removeEventListener("touchend",s),e.removeEventListener("touchcancel",o),y.dispose(),g.dispose(),_==null||_.dispose(),w.disconnect()}}}function Lxe({container:e,host:t,term:n,atBottomThreshold:r,getDims:i,getVerticalInsets:s,getLiveLastY:o,getPrevCursorBufferRow:l,getPendingProgrammaticScrollTop:u,getPendingFollowCursorScrollTop:d,getPendingFollowCursorScrollLeft:f,getPendingContainerSyncRetry:h,getHorizontalIntent:y,getVerticalIntent:g,getUserHasVerticalScrollIntent:_}){var P,z;let w=null,S=null;const x=()=>{var B;const Y=document.activeElement;if(!Y)return null;const U=Y.getAttribute("aria-label")??"",G=Y.tagName,I=typeof Y.closest=="function"?((B=Y.closest("[data-slot]"))==null?void 0:B.getAttribute("data-slot"))??"":"",N=Y.id?`#${Y.id}`:"",L=typeof Y.className=="string"&&Y.className?"."+Y.className.split(/\s+/).filter(Boolean).slice(0,2).join("."):"";return U?`${U}|${G}${N}${L}{${I}}`:`${G}${N}${L}{${I}}`},k=(Y,U={})=>{if(!P0())return;const G=e.getBoundingClientRect(),I=t.getBoundingClientRect(),N=window.visualViewport,{cellH:L,cellW:B}=i(),{paddingTop:O,paddingBottom:D}=s(),F=Math.max(0,e.clientHeight-O-D),V=n.buffer.active,j=V.baseY+V.cursorY,q=dT({rows:n.rows,cellH:L,bufferLength:V.length,baseY:V.baseY,viewportY:V.viewportY,cursorBufferRow:j,liveLastY:o(),visibleContentHeight:F,paddingTop:O,paddingBottom:D,hostPaddingTop:Hs(t.style.paddingTop),containerScrollTop:e.scrollTop,containerScrollHeight:e.scrollHeight,containerClientHeight:e.clientHeight,atBottomThreshold:r}),K=l(),$=K===null?null:j-K,te=U.cursorDeltaRows!==void 0?U.cursorDeltaRows:$,J=U.scrollDeltaToAnchor!==void 0?U.scrollDeltaToAnchor:e.scrollTop-q.bottomScrollTop,ne=Hs(t.style.top),Q=L>0?Ed({ydisp:V.viewportY,rows:n.rows,cellH:L,visibleContentHeight:F}):0,ce=Hs(t.style.height),re=e.scrollTop,le=re+e.clientHeight,we=ne+ce,Ce=Math.max(0,Math.min(le,we)-Math.max(re,ne)),ye=g();tge({t:performance.now(),event:Y,scope:U.scope,action:U.action,reason:U.reason,scrollTop:e.scrollTop,scrollLeft:e.scrollLeft,scrollHeight:e.scrollHeight,scrollWidth:e.scrollWidth,clientHeight:e.clientHeight,clientWidth:e.clientWidth,innerHeight:window.innerHeight,visualViewportHeight:N==null?void 0:N.height,visualViewportOffsetTop:N==null?void 0:N.offsetTop,containerTop:G.top,containerBottom:G.bottom,hostRectTop:I.top,hostRectBottom:I.bottom,viewportY:V.viewportY,bufferLength:V.length,hostTop:t.style.top,cellH:L,cellW:B,cursorX:V.cursorX,cursorY:V.cursorY,cursorBufferRow:j,cursorDeltaRows:te,cursorInViewport:q.cursorInViewport,anchorBottomScrollTop:q.bottomScrollTop,scrollDeltaToAnchor:J,pendingProgrammaticScrollTop:u(),pendingFollowCursorScrollTop:d(),pendingFollowCursorScrollLeft:f(),pendingContainerSyncRetry:h(),horizontalIntent:y(),intentMode:ye.mode,intentSource:ye.source,intentTransition:ye.lastTransitionId,prevCursorBufferRow:K,hostTopDrift:ne-Q,viewportHostCoverage:e.clientHeight>0?Ce/e.clientHeight:0,focus:x(),atBottom:q.isAtBottom,touchActive:ye.touchActive,userIntent:_(),...U})},R=Y=>{if(!P0())return;const U=window.visualViewport;if(!U)return;const G=w===null?0:U.height-w,I=S===null?0:U.offsetTop-S;w=U.height,S=U.offsetTop,k(Y,{vvHeightDelta:G,vvOffsetDelta:I})},A=()=>R("vv:resize"),M=()=>R("vv:scroll"),T=Y=>{var B;if(!P0())return;const U=Y.target,G=U===e||U instanceof Node&&e.contains(U),I=U&&typeof U.closest=="function"?((B=U.closest("[data-slot]"))==null?void 0:B.getAttribute("data-slot"))??"":"",N=(U==null?void 0:U.tagName)??"",L=U&&typeof U.className=="string"&&U.className?"."+U.className.split(/\s+/).filter(Boolean).slice(0,2).join("."):"";k(`wheel:window deltaY=${Math.round(Y.deltaY)} reachesContainer=${G?1:0} prevented=${Y.defaultPrevented?1:0} target=${N}${L}{${I}}`)};return(P=window.visualViewport)==null||P.addEventListener("resize",A),(z=window.visualViewport)==null||z.addEventListener("scroll",M),window.addEventListener("wheel",T,{passive:!0,capture:!0}),{trace:k,dispose:()=>{var Y,U;(Y=window.visualViewport)==null||Y.removeEventListener("resize",A),(U=window.visualViewport)==null||U.removeEventListener("scroll",M),window.removeEventListener("wheel",T,{capture:!0})}}}function X6(e){return{mode:e!=null&&e.initialIntent?"reviewing":"following",source:e!=null&&e.initialIntent?"initial":"none",touchActive:!1,touchStartY:null,touchStartScrollTop:null,touchReviewNotified:!1,lastScrollTop:(e==null?void 0:e.scrollTop)??0,lastTransitionId:e!=null&&e.initialIntent?"attach.reviewing":"attach.following"}}const Rp=e=>e.mode==="reviewing",gd=e=>e.mode==="following"&&!e.touchActive;function Dxe(e,t){return e==="following"&&t==="reviewing"?"set":e==="reviewing"&&t==="following"?"clear":"keep"}function Yi(e,t,n,r=!1){const i=e.mode!==t.mode;return{state:t,changed:e!==t,outputPausedChanged:i,notifyTouchReviewStart:r,trace:{id:t.lastTransitionId,action:Dxe(e.mode,t.mode),reason:n}}}function Hh(e,t,n,r){return{...e,mode:"reviewing",source:t,lastScrollTop:n,lastTransitionId:r}}function xL(e,t,n,r){return{...e,mode:"following",source:t,lastScrollTop:n,lastTransitionId:r}}function Bxe(e){throw new Error(`Unhandled PTY vertical intent event: ${JSON.stringify(e)}`)}function zxe(e,t,n){const r=t.type==="touch-end"?"touch.end":"touch.cancel",i=e.touchStartScrollTop!==null&&t.scrollTop>e.touchStartScrollTop,s=e.touchStartScrollTop===null||t.scrollTop>=e.touchStartScrollTop-n,o={...e,touchActive:!1,touchStartY:null,touchStartScrollTop:null,touchReviewNotified:!1,lastScrollTop:t.scrollTop};return e.mode==="reviewing"&&t.atCursorAwareBottom&&(i||s||t.releaseOnSemanticBottom===!0)?Yi(e,{...o,mode:"following",source:"none",lastTransitionId:`${r}.bottom-down`},`scrollTop=${t.scrollTop} atBottom=true`):Yi(e,{...o,lastTransitionId:`${r}.not-bottom`},`scrollTop=${t.scrollTop} atBottom=${t.atCursorAwareBottom}`)}function jxe(e,t,n={}){const r=n.atBottomThreshold??8;switch(t.type){case"attach":{const i=X6({initialIntent:t.initialIntent,scrollTop:t.scrollTop});return Yi(e,i,`initialIntent=${t.initialIntent}`)}case"scroll-to-bottom":return t.force?Yi(e,xL({...e,touchActive:!1,touchStartY:null,touchStartScrollTop:null,touchReviewNotified:!1},"programmatic-bottom",e.lastScrollTop,"bottom.force"),`reason=${t.reason} force=true`):Yi(e,{...e,lastTransitionId:`bottom.passive.${e.mode}`},`reason=${t.reason} force=false`);case"scroll-to-ratio":return Yi(e,Hh(e,"ratio-scroll",t.scrollTop,"ratio.reviewing"),`ratio=${t.ratio}`);case"mark-review":return Yi(e,Hh(e,t.source,t.scrollTop,"selection-autoscroll.reviewing"),`source=${t.source} reason=${t.reason}`);case"wheel":return t.nextScrollTop===t.previousScrollTop?Yi(e,{...e,lastTransitionId:"wheel.clamped",lastScrollTop:t.nextScrollTop},`delta=${t.deltaY}`):t.deltaY<0?Yi(e,Hh(e,"wheel",t.nextScrollTop,"wheel.up"),`delta=${t.deltaY}`):t.deltaY>0&&t.reachedCursorAwareBottom?Yi(e,xL(e,"none",t.nextScrollTop,"wheel.down.bottom"),`delta=${t.deltaY}`):Yi(e,Hh(e,"wheel",t.nextScrollTop,"wheel.down.not-bottom"),`delta=${t.deltaY}`);case"container-scroll":return Yi(e,{...e,lastScrollTop:t.scrollTop,lastTransitionId:`container.${t.source}`},`source=${t.source} scrollTop=${t.scrollTop}`);case"touch-start":return Yi(e,{...e,touchActive:!0,touchStartY:t.clientY,touchStartScrollTop:t.scrollTop,touchReviewNotified:!1,lastScrollTop:t.scrollTop,lastTransitionId:"touch.start"},`clientY=${t.clientY??"null"}`);case"touch-move":{const i=e.touchStartY===null||t.clientY===null?0:Math.abs(t.clientY-e.touchStartY);return i>=t.reviewThresholdPx&&!e.touchReviewNotified?Yi(e,{...Hh(e,"touch",e.lastScrollTop,"touch.move.review"),touchReviewNotified:!0},`movement=${i} threshold=${t.reviewThresholdPx}`,!0):i>=t.reviewThresholdPx?Yi(e,{...e,lastTransitionId:"touch.move.reviewing"},`movement=${i} threshold=${t.reviewThresholdPx}`):Yi(e,{...e,lastTransitionId:"touch.move.below-threshold"},`movement=${i} threshold=${t.reviewThresholdPx}`)}case"touch-end":case"touch-cancel":return zxe(e,t,r);default:return Bxe(t)}}const Ki={bottom:{defaultThresholdPx:8},horizontal:{nativeIntentThresholdPx:48,cursorFollowRightMarginColumns:8},touch:{scrollJumpMinThresholdPx:512,hostTopJumpMinThresholdPx:64,gestureSlopPx:16,horizontalGestureSlopPx:6,horizontalLockRatio:1,verticalLockRatio:1.25,nativeScrollRecentMs:500}};function Fxe({reviewing:e,cellH:t,rows:n,visibleContentHeight:r,cursorBufferRow:i,prevCursorBufferRow:s,cursorInViewport:o,targetScrollTop:l,currentScrollTop:u}){if(e)return{action:"skip",reason:"intent",nextPrevCursorBufferRow:null,cursorDeltaRows:null};if(t<=0)return{action:"skip",reason:"cellH=0",nextPrevCursorBufferRow:s,cursorDeltaRows:null};if(n*t<=r)return{action:"skip",reason:"shortHost",nextPrevCursorBufferRow:null,cursorDeltaRows:null};if(s===i&&o)return{action:"skip",reason:"same-row",nextPrevCursorBufferRow:s,cursorDeltaRows:0};const d=s===null?null:i-s;return o?{action:"skip",reason:"inViewport",nextPrevCursorBufferRow:i,cursorDeltaRows:d}:Math.abs(l-u)<=1?{action:"skip",reason:"aligned",nextPrevCursorBufferRow:i,cursorDeltaRows:d}:{action:"follow",reason:"cursor-outside",nextPrevCursorBufferRow:i,cursorDeltaRows:d,targetScrollTop:l}}function $xe({startX:e,startY:t,currentX:n,currentY:r}){if(t===null||r===null)return null;const i=e!==null&&n!==null?n-e:0,s=r-t;return{dx:i,dy:s,absDx:Math.abs(i),absDy:Math.abs(s),distance:Math.hypot(i,s),startY:t}}function Hxe({touchActive:e,touchStartScrollTop:t,touchStartY:n,currentY:r,touchStartedAtCursorAwareBottom:i,bottomScrollTop:s,maxScrollTop:o}){if(!e||t===null||n===null||r===null)return!1;const l=o,u=i?s:t,d=Math.max(0,Math.min(l,u+(n-r)));return{touchStartScrollTop:t,touchStartY:n,currentY:r,gestureBaseScrollTop:u,expectedScrollTop:d,cursorAwareMaxScrollTop:l,touchDeltaY:r-n}}function Uxe({touchActive:e,touchStartClientX:t,touchStartScrollLeft:n,currentX:r,maxScrollLeft:i}){if(!e||t===null||n===null||r===null)return!1;const s=Math.max(0,Math.min(i,n+(t-r)));return{touchStartX:t,currentX:r,touchStartScrollLeft:n,expectedScrollLeft:s,maxScrollLeft:i,touchDeltaX:r-t}}function Wxe({touchStartScrollTop:e,liveScrollTop:t,atBottomThreshold:n,touchStartedAtCursorAwareBottom:r,anchorIsAtBottom:i,reviewedDuringTouch:s}){const o=e===null||t>=e-n;return{atCursorAwareBottomForIntent:!s&&i||r&&!s&&o,releaseOnSemanticBottom:r&&i&&!s}}function qxe(){const e=new WeakMap;return{set(t,n,r){let i=e.get(t);i||(i=new Map,e.set(t,i)),i.get(n)!==r&&(i.set(n,r),t.style[n]=r)}}}function Vxe(){return{startedAtCursorAwareBottom:!1,startClientX:null,startScrollLeft:null,lastClientY:null,lastGestureAt:null,gestureMode:null,verticalDirection:null}}function Yxe(e,t){return{...e,startedAtCursorAwareBottom:t.startedAtCursorAwareBottom,startClientX:t.startClientX,startScrollLeft:t.startScrollLeft,lastClientY:t.startClientY,lastGestureAt:t.now,gestureMode:t.startClientY===null?null:"pending",verticalDirection:null}}function Kxe(e,t){return{...e,lastGestureAt:t}}function Gxe(e,t){return{...e,lastClientY:t.currentY,lastGestureAt:t.now}}function Xxe(e,t){return!t.touchActive||e.gestureMode!==null||t.currentY===null?e:{...e,gestureMode:"pending"}}function Zxe(e,t){return e.gestureMode===t?e:{...e,gestureMode:t}}function Qxe(e,t){return{...e,gestureMode:"vertical",verticalDirection:t}}function Jxe(e){return{...e,startedAtCursorAwareBottom:!1,startClientX:null,startScrollLeft:null,lastClientY:null,gestureMode:null,verticalDirection:null}}function e0e({container:e,atBottomThreshold:t,trace:n,getPageResumePending:r,getVerticalIntent:i,dispatchVerticalIntent:s,getCurrentAnchor:o,getLastSeenScrollTop:l,hasHorizontalOverflow:u,clearHorizontalIntentIfUnscrollable:d,markHorizontalUserInput:f,notifyAtBottom:h,flushPendingTouchScrollNotify:y}){let g=Vxe(),_=!1;const w=U=>(U==null?void 0:U.target)instanceof Element&&U.target.closest('[data-slot="pty-selection-handle"]')!==null,S=U=>{const G=U??g.lastClientY,I=o(),N=Math.max(0,e.scrollHeight-e.clientHeight),L=i(),B=fT({reviewing:Rp(L),referenceScrollTop:L.touchStartScrollTop??e.scrollTop,bottomScrollTop:I.bottomScrollTop,domMaxScrollTop:N,atBottomThreshold:t});return Hxe({touchActive:L.touchActive,touchStartScrollTop:L.touchStartScrollTop,touchStartY:L.touchStartY,currentY:G,touchStartedAtCursorAwareBottom:g.startedAtCursorAwareBottom,bottomScrollTop:I.bottomScrollTop,maxScrollTop:B})},x=(U,G)=>$xe({startX:g.startClientX,startY:i().touchStartY,currentX:U,currentY:G}),k=U=>{const G=Math.max(0,e.scrollWidth-e.clientWidth);return Uxe({touchActive:i().touchActive,touchStartClientX:g.startClientX,touchStartScrollLeft:g.startScrollLeft,currentX:U,maxScrollLeft:G})},R=(U,G,I,N,L)=>U?[`raw=${Math.round(G)}`,`effective=${Math.round(I)}`,`prev=${Math.round(N)}`,`delta=${Math.round(L)}`,`expected=${Math.round(U.expectedScrollTop)}`,`startScroll=${Math.round(U.touchStartScrollTop)}`,`base=${Math.round(U.gestureBaseScrollTop)}`,`startY=${Math.round(U.touchStartY)}`,`currentY=${Math.round(U.currentY)}`,`touchDeltaY=${Math.round(U.touchDeltaY)}`,`max=${Math.round(U.cursorAwareMaxScrollTop)}`].join(" "):null,A=()=>i().touchActive||g.lastGestureAt!==null&&performance.now()-g.lastGestureAt<=Ki.touch.nativeScrollRecentMs,M=U=>{var O;if(_=w(U),_){n("touchstart:selection-handle");return}if(r()){n("touchstart:page-resume-pending");return}const G=((O=U.touches)==null?void 0:O[0])??null,I=(G==null?void 0:G.clientX)??null,N=(G==null?void 0:G.clientY)??null;d("touchstart");const L=o(),B=Rp(i());g=Yxe(g,{startedAtCursorAwareBottom:L.isAtBottom,startClientX:I,startClientY:N,startScrollLeft:e.scrollLeft,now:performance.now()}),s({type:"touch-start",clientY:N,scrollTop:e.scrollTop}),n("touchstart",{details:[`startX=${I??"null"}`,`startY=${N??"null"}`,`startScroll=${Math.round(e.scrollTop)}`,`bottom=${Math.round(L.bottomScrollTop)}`,`atBottom=${L.isAtBottom?1:0}`,`reviewing=${B?1:0}`].join(" ")})},T=U=>{var j;if(_||w(U))return;if(r()){n("touchmove:page-resume-pending");return}const G=((j=U.touches)==null?void 0:j[0])??null,I=(G==null?void 0:G.clientX)??null,N=(G==null?void 0:G.clientY)??null,L=performance.now();g=Gxe(g,{currentY:N,now:L});const B=x(I,N);n("touchmove",{details:N===null?"currentY=null":R(S(N),e.scrollTop,e.scrollTop,l(),e.scrollTop-l())??[`mode=${g.gestureMode??"none"}`,`currentY=${Math.round(N)}`,B?`dx=${Math.round(B.dx)} dy=${Math.round(B.dy)} distance=${Math.round(B.distance)}`:null].filter(Boolean).join(" ")});const O=u();if(O||d("touchmove"),g=Xxe(g,{touchActive:i().touchActive,currentY:N}),g.gestureMode==="pending"&&B){const q=O&&B.absDx>=Ki.touch.horizontalGestureSlopPx&&B.absDx>B.absDy*Ki.touch.horizontalLockRatio,K=B.absDy>=Ki.touch.gestureSlopPx&&(!O||B.absDy>B.absDx*Ki.touch.verticalLockRatio);if(q)g=Zxe(g,"horizontal"),n("touchmove:horizontal-lock",{details:`dx=${Math.round(B.dx)} dy=${Math.round(B.dy)} distance=${Math.round(B.distance)}`});else if(K)g=Qxe(g,B.dy<0?"toward-live":"toward-history"),n("touchmove:vertical-lock",{details:`dx=${Math.round(B.dx)} dy=${Math.round(B.dy)} distance=${Math.round(B.distance)} threshold=${Ki.touch.gestureSlopPx} direction=${g.verticalDirection}`});else{n("touchmove:pending",{details:[`dx=${Math.round(B.dx)}`,`dy=${Math.round(B.dy)}`,`distance=${Math.round(B.distance)}`,`hThreshold=${Ki.touch.horizontalGestureSlopPx}`,`vThreshold=${Ki.touch.gestureSlopPx}`].join(" ")}),B.absDy<Ki.touch.gestureSlopPx&&s({type:"touch-move",clientY:N,reviewThresholdPx:Ki.touch.gestureSlopPx});return}}if(g.gestureMode==="horizontal"){const q=k(I);if(!O||!q){d("touchmove-horizontal"),n("touchmove:horizontal-native",{details:B?`blocked dx=${Math.round(B.dx)} dy=${Math.round(B.dy)} distance=${Math.round(B.distance)}`:"blocked movement=null"});return}B&&f(`site=touchmove-horizontal dx=${Math.round(B.absDx)} dy=${Math.round(B.absDy)}`),e.scrollLeft=q.expectedScrollLeft,n("touchmove:horizontal-native",{details:[`scrollLeft=${Math.round(e.scrollLeft)}`,`expected=${Math.round(q.expectedScrollLeft)}`,`startScrollLeft=${Math.round(q.touchStartScrollLeft)}`,`startX=${Math.round(q.touchStartX)}`,`currentX=${Math.round(q.currentX)}`,`touchDeltaX=${Math.round(q.touchDeltaX)}`,`max=${Math.round(q.maxScrollLeft)}`].join(" ")});return}if(g.gestureMode!=="vertical")return;const D=S(N);if(D&&n("touchmove:vertical-native",{details:[`scrollTop=${Math.round(e.scrollTop)}`,`expected=${Math.round(D.expectedScrollTop)}`,`startScroll=${Math.round(D.touchStartScrollTop)}`,`base=${Math.round(D.gestureBaseScrollTop)}`,`startY=${Math.round(D.touchStartY)}`,`currentY=${Math.round(D.currentY)}`,`touchDeltaY=${Math.round(D.touchDeltaY)}`].join(" ")}),D&&g.startedAtCursorAwareBottom&&D.expectedScrollTop>=D.cursorAwareMaxScrollTop-t&&N!==null&&N<=D.touchStartY){n("touchmove:bottom-boundary-follow");return}s({type:"touch-move",clientY:N,reviewThresholdPx:Ki.touch.gestureSlopPx}).notifyTouchReviewStart&&n("touchmove:review")},P=U=>{const G=e.scrollTop,I=o(),N=Wxe({touchStartScrollTop:i().touchStartScrollTop,liveScrollTop:G,atBottomThreshold:t,touchStartedAtCursorAwareBottom:g.startedAtCursorAwareBottom,anchorIsAtBottom:I.isAtBottom,reviewedDuringTouch:i().touchReviewNotified});g=Jxe(g),s({type:U,scrollTop:G,atCursorAwareBottom:N.atCursorAwareBottomForIntent,releaseOnSemanticBottom:N.releaseOnSemanticBottom}),g=Kxe(g,performance.now()),y(),h()};return{onTouchStart:M,onTouchMove:T,onTouchEnd:U=>{if(_||w(U)){_=!1,n("touchend:selection-handle");return}if(r()){n("touchend:page-resume-pending");return}P("touch-end"),n("touchend")},onTouchCancel:U=>{if(_||w(U)){_=!1,n("touchcancel:selection-handle");return}if(r()){n("touchcancel:page-resume-pending");return}P("touch-cancel"),n("touchcancel")},isRecentNativeScroll:A,getScrollExpectation:S,describeScrollExpectation:R,getState:()=>g}}function t0e(e){let t=null;const n=i=>Math.max(0,Math.min(e.cols-1,i)),r=[...["G","`","H","f"].map(i=>e.parser.registerCsiHandler({final:i},s=>{const o=s[i==="H"||i==="f"?1:0];return t=n((typeof o=="number"&&o>0?o:1)-1),!1})),...["C","D","a"].map(i=>e.parser.registerCsiHandler({final:i},s=>{const o=s[0],l=typeof o=="number"&&o>0?o:1;return t=n(n(e.buffer.active.cursorX)+(i==="D"?-l:l)),!1}))];return{reset:()=>{t=null},canFollow:()=>{var s,o;return e.modes.synchronizedOutputMode?!1:((o=(s=e._core)==null?void 0:s.coreService)==null?void 0:o.isCursorHidden)!==!0||e.buffer.active.cursorX===t},dispose:()=>{for(const i of r)i.dispose()}}}function n0e(e){const{container:t,spacer:n,host:r,term:i,hasNewFrame:s,consumeNewFrame:o,hasNewFramesWhileAway:l,setNewFramesWhileAway:u,onAtBottomChange:d,onScrollStateChange:f,initialUserHasVerticalScrollIntent:h=!1,onUserVerticalScrollIntentChange:y,onTouchReviewStart:g,onHistoryProjectionChange:_,getBufferRowIdentityOffset:w=()=>0,atBottomThreshold:S=Ki.bottom.defaultThresholdPx}=e,x=()=>o_(r,i)??{cellH:0,cellW:0},k=()=>{const he=getComputedStyle(t);return{paddingTop:Hs(he.paddingTop),paddingBottom:Hs(he.paddingBottom)}},R=qxe(),A=(he,Ee,Ne)=>{R.set(he,Ee,Ne)},M={external:!1,internal:!1};let T=null,P="",z=X6({initialIntent:h,scrollTop:t.scrollTop}),Y=null,U=null,G=!1,I=null,N=Cxe(),L="idle";const B=t0e(i);let O=0,D=!1,F=null,V=null,j=null,q=null,K=null,$=!1,te=null,J=null,ne=null,Q=!1,ce=i.buffer.active.type,re=!1,le=!1,we=!1;const Ce=()=>Rp(z),ye=Lxe({container:t,host:r,term:i,atBottomThreshold:S,getDims:x,getVerticalInsets:k,getLiveLastY:()=>at(),getPrevCursorBufferRow:()=>F,getPendingProgrammaticScrollTop:()=>Y,getPendingFollowCursorScrollTop:()=>I,getPendingFollowCursorScrollLeft:()=>N.pendingFollowLeft,getPendingContainerSyncRetry:()=>G,getHorizontalIntent:()=>N.intent,getVerticalIntent:()=>z,getUserHasVerticalScrollIntent:()=>Ce()}),Re=ye.trace,Rt=he=>{D&&(Re("page-resume:cancel",{details:`reason=${he}`}),D=!1)},Ke=he=>{if(he){if(he.kind==="ignore"){Re("horizontal-intent:ignore",{details:he.details});return}Re(`horizontal-intent:${he.kind}`,{details:he.details})}},et=()=>t.scrollWidth>t.clientWidth+S,$e=he=>{if(et())return!1;const Ee=yp(N,{details:`site=${he} reason=not-scrollable scrollWidth=${t.scrollWidth} clientWidth=${t.clientWidth}`,scrollLeft:t.scrollLeft});return N=Ee.state,Ke(Ee.trace),t.scrollLeft!==0&&(t.scrollLeft=0,N={...N,lastSeenLeft:0}),!0},Fe=(he,Ee={})=>{if(Rt(`horizontal:${he}`),!et()){$e("markHorizontalUserInput");return}const Ne=Txe(N,{now:performance.now(),details:he,...Ee});N=Ne.state,Ke(Ne.trace)},xt=()=>({scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,scrollHeight:t.scrollHeight,scrollWidth:t.scrollWidth,clientHeight:t.clientHeight,clientWidth:t.clientWidth,scrollable:t.scrollHeight>t.clientHeight+S,horizontalScrollable:et()}),_t=()=>{if(!f)return;const he=xt(),Ee=[he.scrollTop,he.scrollLeft,he.scrollHeight,he.scrollWidth,he.clientHeight,he.clientWidth,he.scrollable,he.horizontalScrollable].join(":");Ee!==P&&(P=Ee,f(he))},st=()=>{const{cellH:he}=x(),{paddingTop:Ee,paddingBottom:Ne}=k(),it=i.buffer.active,rt=Math.max(0,t.clientHeight-Ee-Ne),gt=it.baseY+it.cursorY,Mt=dT({rows:i.rows,cellH:he,bufferLength:it.length,baseY:it.baseY,viewportY:it.viewportY,cursorBufferRow:gt,liveLastY:at(),visibleContentHeight:rt,paddingTop:Ee,paddingBottom:Ne,hostPaddingTop:Hs(r.style.paddingTop),containerScrollTop:t.scrollTop,containerScrollHeight:t.scrollHeight,containerClientHeight:t.clientHeight,atBottomThreshold:S});return{cellH:he,visibleContentHeight:rt,viewportY:it.viewportY,cursorBufferRow:gt,anchor:Mt}},Ae=()=>st().anchor,ut=()=>{const he=Ae().isAtBottom;T!==he&&(T=he,d==null||d(he))},mt=()=>{ut(),_t()},ge=()=>{V!==null&&(j==null||j(V),V=null,j=null)},Ye=()=>{if(V!==null)return;const he=()=>{V=null,j=null,mt()};if(typeof window.requestAnimationFrame=="function"){V=window.requestAnimationFrame(he),j=typeof window.cancelAnimationFrame=="function"?Ee=>window.cancelAnimationFrame(Ee):null;return}V=window.setTimeout(he,16),j=Ee=>window.clearTimeout(Ee)},ve=()=>{V!==null&&(ge(),mt())},Je=(he="rawInput")=>{Re(`rawInputFollow:scheduled[${he}]`)},dt=()=>{Re("rawInputFollow:fire")},Ot=()=>{J==null||J.marker.dispose(),J=null},Lt=he=>{const{paddingTop:Ee,paddingBottom:Ne}=k(),it=Math.max(0,t.clientHeight-Ee-Ne);return{geometryOrigin:Ed({ydisp:0,rows:i.rows,cellH:he,visibleContentHeight:it}),visibleContentHeight:it}},sn=()=>{if(!Ce()){Ot();return}const{cellH:he}=x(),Ee=i.buffer.active;if(he<=0||Ee.length<=0||Ee.type==="alternate"){Ot();return}const{geometryOrigin:Ne}=Lt(he),it=Math.max(0,(t.scrollTop-Ne)/he),rt=Math.min(Ee.length-1,it),gt=Math.floor(rt),Mt=Ee.baseY+Ee.cursorY,Jn=i.registerMarker(gt-Mt);Ot(),J={marker:Jn,fractionalRowOffset:rt-gt,lastLine:Jn.line,rowIdentityOffset:w(),scrollTopAtCapture:t.scrollTop}},Gt=(he,Ee={})=>{if(!Ce()||he<=0)return;const Ne=i.buffer.active;if(Ne.type==="alternate"){Ot();return}const it=J;if(!it){sn();return}const{geometryOrigin:rt,visibleContentHeight:gt}=Lt(he),Mt=w(),Jn=Mt-it.rowIdentityOffset,Dn=it.marker.isDisposed||it.marker.line<0,Yr=Math.max(0,Math.min(Math.max(0,Ne.length-1),Dn?it.lastLine+Math.min(0,Jn):it.marker.line)),bi=Ee.includeDomDelta?t.scrollTop-it.scrollTopAtCapture:0,ui=Math.max(0,rt+(Yr+it.fractionalRowOffset)*he+bi);if(Math.abs(t.scrollTop-ui)>.5&&(Q?En(ne??i.buffer.active.viewportY,he,gt,ui):Fn(i.buffer.active.viewportY,he,gt,ui),t.scrollTop=ui,O=t.scrollTop),Dn||Ee.includeDomDelta){Ot(),sn();return}it.lastLine=Yr,it.rowIdentityOffset=Mt,it.scrollTopAtCapture=ui};function on(he){const Ee=Math.round(he),Ne=Number.EPSILON*Math.max(1,Math.abs(he))*8;return Math.abs(he-Ee)<=Ne?Ee:he}function Ct(he){return[he.kind,Be,he.startLine,he.endLine,he.rowHeight,he.topOffset].join(":")}function gn(he,Ee={}){if(!he)return te&&(_==null||_(null)),te=null,!0;const Ne=Ct(he);return!Ee.force&&(te==null?void 0:te.key)===Ne?!0:(_==null?void 0:_(he))===!0?(te={kind:he.kind,key:Ne},!0):(te&&(_==null||_(null)),te=null,!1)}const zt=he=>{const Ee=Rp(z),Ne=jxe(z,he,{atBottomThreshold:S});z=Ne.state,Ne.trace&&Re(`intent:${Ne.trace.action}`,{details:`id=${Ne.trace.id} reason=${Ne.trace.reason}`});const it=Rp(z);return Ee!==it&&(y==null||y(it),it?sn():Ot()),Ne.notifyTouchReviewStart&&(Rt("touch-review"),g==null||g()),Ne},nn=(he,Ee,Ne,it)=>{const rt=Ed({ydisp:0,rows:i.rows,cellH:Ee,visibleContentHeight:Ne}),gt=wxe({ydisp:he,rows:i.rows,cellH:Ee,visibleContentHeight:Ne,visibleTopLine:Math.max(0,(it-rt)/Ee)});if(!gt){gn(null);return}gn({kind:"live-backfill",startLine:gt.startLine,endLine:gt.endLine,rowHeight:gt.rowHeight,topOffset:gt.topOffset})},En=(he,Ee,Ne,it)=>{const rt=Ed({ydisp:0,rows:i.rows,cellH:Ee,visibleContentHeight:Ne}),gt=xxe({ydisp:he,rows:i.rows,cellH:Ee,bufferLength:i.buffer.active.length,visibleContentHeight:Ne,visibleTopLine:Math.max(0,(it-rt)/Ee)});if(!gt){gn(null);return}const Mt=Number.parseFloat(r.style.top),Jn=Number.isFinite(Mt)?Mt:Ed({ydisp:he,rows:i.rows,cellH:Ee,visibleContentHeight:Ne}),Dn=rt+gt.startLine*Ee-Jn;gn({kind:"live-backfill",startLine:gt.startLine,endLine:gt.endLine,rowHeight:gt.rowHeight,topOffset:Dn})},Fn=(he,Ee,Ne,it=t.scrollTop)=>{if(Ee<=0)return;const rt=Ne??(()=>{const{paddingTop:Dn,paddingBottom:Yr}=k();return Math.max(0,t.clientHeight-Dn-Yr)})(),gt=Ed({ydisp:he,rows:i.rows,cellH:Ee,visibleContentHeight:rt}),Mt=r.style.top,Jn=`${gt}px`;A(r,"position","absolute"),A(r,"left","0px"),A(r,"top",Jn),ne=he,Q=!1,nn(he,Ee,rt,it),Mt!==Jn&&Re("host-position",{ydisp:he,details:`${Mt||"0px"}->${Jn}`})};function Xn(he){he.cellH>0&&Fn(he.viewportY,he.cellH,he.visibleContentHeight,he.scrollTop),M.internal=!0;try{i.buffer.active.viewportY!==he.viewportY&&i.scrollToLine(he.viewportY)}finally{M.internal=!1}return t.scrollTop=he.scrollTop,t.scrollTop}const Nn=(he,Ee)=>{Ee==="programmatic-bottom"?(I=null,Y=he.scrollTop):(Y=null,I=he.scrollTop);let Ne;try{Ne=Xn(he)}catch(it){throw Ee==="programmatic-bottom"?Y=null:I=null,it}Ee==="programmatic-bottom"?Y!==null&&(Y=Ne):I!==null&&(I=Ne),O=Ne,F=he.cursorBufferRow},W=(he="internal",Ee={})=>{Ee.force&&Rt(`scroll-to-bottom:${he}`);const Ne=st(),it=Ne.anchor,rt=it.bottomViewportY,gt=Mxe({force:Ee.force??!1,reviewing:Ce()||z.touchActive,viewportY:Ne.viewportY,expectedYdisp:rt,scrollTop:t.scrollTop,bottomScrollTop:it.bottomScrollTop,atBottom:it.isAtBottom}).action;if(gt!=="blocked-by-review"){if(gt==="noop"){G=!1;return}Re(`scroll-to-bottom:start[${he}]`),zt({type:"scroll-to-bottom",force:Ee.force??!1,reason:he}),Nn({viewportY:rt,scrollTop:it.bottomScrollTop,cellH:Ne.cellH,visibleContentHeight:Ne.visibleContentHeight,cursorBufferRow:Ne.cursorBufferRow},"programmatic-bottom"),mt(),G=!1,Re("scroll-to-bottom:end",{ydisp:rt})}},ie=(he,Ee={})=>{const Ne=i.buffer.active.type;if(Ne===ce&&!Ee.forceBoundary)return!1;const it=ce,rt=Ee.crossedTypeBoundary===!0||Ne!==it,Mt=!rt&&Ne===it&&Ne==="normal"&&Ce();if(ce=Ne,Ot(),gn(null),Q=!1,ne=null,G=!1,L="idle",Re("buffer-switch",{details:`${it}->${Ne} site=${he} forced=${Ee.forceBoundary?1:0} crossed=${rt?1:0}`}),Tt(),Mt){F=null,Y=null,I=null,we=!0;const{cellH:Jn,visibleContentHeight:Dn}=st();return Jn>0?(O=Xn({viewportY:0,scrollTop:0,cellH:Jn,visibleContentHeight:Dn}),sn()):(t.scrollTop=0,O=t.scrollTop,G=!0),mt(),!0}return we=!1,rt&&de(`bufferSwitch:${it}->${Ne}`),W(`bufferSwitch:${it}->${Ne}`,{force:!0}),!0},oe=()=>{D=!0,Re("page-resume:prepare")},ue=()=>{oe(),Tt(),W("pageResume",{force:!0}),de("pageResume"),D=!1},be=he=>{Rt("vertical-ratio"),Re("scroll-to-ratio:start");const Ee=Math.max(0,t.scrollHeight-t.clientHeight),Ne=Math.max(0,Math.min(1,he));if(Ne===1){W("scrollToRatio",{force:!0});return}const it=Ee*Ne;zt({type:"scroll-to-ratio",ratio:Ne,scrollTop:it}),t.scrollTop=it,rn()},X=he=>{if(he===0)return;Rt("vertical-wheel"),Re("wheel");const Ee=Ae(),Ne=t.scrollTop;if(Pxe({reviewing:Ce(),deltaY:he,currentScrollTop:Ne,bottomScrollTop:Ee.bottomScrollTop,atBottomThreshold:S})){Re("wheel:semantic-bottom"),W("wheel",{force:!0});return}const rt=Math.max(0,t.scrollHeight-t.clientHeight),gt=fT({reviewing:Ce(),referenceScrollTop:Ne,bottomScrollTop:Ee.bottomScrollTop,domMaxScrollTop:rt,atBottomThreshold:S});if(gt<=0){Re("wheel:max-zero");return}const Mt=Math.max(0,Math.min(gt,Ne+he));if(Mt===Ne){Re("wheel:clamped"),mt();return}he<0&&zt({type:"wheel",deltaY:he,previousScrollTop:Ne,nextScrollTop:Mt,reachedCursorAwareBottom:!1}),t.scrollTop=Mt,O=Mt,rn(),he>0&&zt({type:"wheel",deltaY:he,previousScrollTop:Ne,nextScrollTop:Mt,reachedCursorAwareBottom:Mt>=Ee.bottomScrollTop-S&&Ae().isAtBottom})},se=he=>{if(!et()){$e("scrollToXRatio"),mt();return}const Ee=Math.max(0,t.scrollWidth-t.clientWidth),Ne=Math.max(0,Math.min(1,he));t.scrollLeft=Ee*Ne,Fe(`site=scrollToXRatio ratio=${Ne}`),N={...N,lastSeenLeft:t.scrollLeft},mt()},de=(he="external",Ee={})=>{L="idle";const Ne=t.scrollLeft,it=yp(N,{details:`site=resetHorizontalScroll reason=${he}`,scrollLeft:0});N=it.state,Ke(it.trace),Ne!==0&&(t.scrollLeft=0),Ee.holdUntilCursorVisible&&Fe(`site=resetHorizontalScroll-hold reason=${he}`,{resumeWhenCursorVisible:!0}),Re(`horizontal-scroll-reset[${he}]`,{details:`scrollLeft=${Ne}->${t.scrollLeft}`}),mt()},pe=(he="input")=>{const Ee=yp(N,{details:`site=resumeHorizontalCursorFollow reason=${he}`,scrollLeft:t.scrollLeft});N=Ee.state,Ke(Ee.trace)},Z=(he="external")=>{Fe(`site=${he}`)},ae=()=>{L="parsing"},fe=(he="selection-autoscroll")=>{Rt(`vertical:${he}`),zt({type:"mark-review",source:"selection-autoscroll",scrollTop:t.scrollTop,reason:he})};let Be=0,Ge=null,lt=-1;const at=()=>{const he=i.buffer.active,Ee=`${he.type}:${Be}:${he.baseY}:${he.length}:${i.rows}`;return Ee===Ge||(lt=zwe(he,i.rows),Ge=Ee),lt},Tt=(he={})=>{const{cellH:Ee,cellW:Ne}=x();if(Ee===0||Ne===0)return;const{paddingTop:it,paddingBottom:rt}=k(),gt=Math.max(0,t.clientHeight-it-rt),Mt=i.buffer.active,Jn=at(),Dn=K6({bufferLength:Mt.length,baseY:Mt.baseY,rows:i.rows,cols:i.cols,viewportY:Mt.viewportY,cursorY:Mt.cursorY,cellH:Ee,cellW:Ne,visibleContentHeight:gt},Jn);if(!Dn)return;const Yr=z.touchActive?t.scrollTop+gt:0,bi=Math.max(Dn.spacerHeight,Yr);if(A(n,"overflow","hidden"),A(n,"height",`${bi}px`),A(n,"width",`${Dn.spacerWidth}px`),A(r,"width",`${Dn.hostWidth}px`),A(r,"height",`${Dn.hostHeight}px`),A(r,"paddingTop",`${Dn.hostPaddingTop}px`),U=performance.now(),Q&&!he.commitDeferredPaint){En(ne??Mt.viewportY,Ee,gt,t.scrollTop);return}Fn(Mt.viewportY,Ee,gt)},Et=(he,Ee,Ne={})=>{if(Ne.deferHostUntilRender===!0||Q||z.touchActive){const{visibleContentHeight:rt}=Lt(Ee),gt=ne??i.buffer.active.viewportY,Mt=!Q&&gt===i.buffer.active.viewportY;if(he===i.buffer.active.viewportY&&Mt){Fn(he,Ee,rt);return}if(En(gt,Ee,rt,t.scrollTop),Q=!0,he===i.buffer.active.viewportY)return;M.internal=!0;try{i.scrollToLine(he)}finally{M.internal=!1}return}if(he===i.buffer.active.viewportY){Fn(he,Ee);return}M.internal=!0;try{Fn(he,Ee),i.scrollToLine(he)}finally{M.internal=!1}},yt=()=>s()?z.touchActive&&!Ce()?"deferred":(o(),gd(z)?(W("pendingFrame"),"followed"):(l()||u(!0),"marked")):"none";function Qt(he,Ee){const Ne=i.buffer.active;if(Ce()){const{geometryOrigin:it,visibleContentHeight:rt}=Lt(Ee),gt=Math.max(0,(he-it)/Ee),Mt=on(gt+rt/Ee);return Math.max(0,Math.min(Ne.baseY,Math.ceil(Mt)-i.rows))}return Sxe(he,{bufferLength:Ne.length,rows:i.rows,cols:i.cols,viewportY:Ne.viewportY,cellH:Ee}).ydisp}function It(he,Ee){if(gd(z)){const Ne=Ae();if(Math.abs(he-Ne.bottomScrollTop)<=S)return Ne.bottomViewportY}return Qt(he,Ee)}const rn=(he={})=>{ge(),Re("container-sync:start");const{cellH:Ee}=x();if(Ee===0){G=!0;return}G=!1,Ce()&&Gt(Ee,{includeDomDelta:!0});const Ne=It(t.scrollTop,Ee);Et(Ne,Ee,{deferHostUntilRender:he.deferHostUntilRender}),Ce()&&sn(),mt(),Re("container-sync:end",{ydisp:Ne})},hn=()=>z.touchActive||Ie.isRecentNativeScroll(),Ln=()=>{if(!hn())return!1;const{cellH:he}=x();if(he===0)return!1;Ce()&&Gt(he,{includeDomDelta:!0});const Ee=t.scrollTop,Ne=It(Ee,he);return Ne!==i.buffer.active.viewportY?!1:(Et(Ne,he,{deferHostUntilRender:hn()}),Ye(),Re("container-sync:skip[same-row-touch]",{ydisp:Ne,details:`scrollTop=${Math.round(Ee)} viewportY=${i.buffer.active.viewportY}`}),!0)},Cn=(he,Ee)=>{const Ne=Math.max(0,t.scrollHeight-t.clientHeight),it=Ae(),rt=Ixe({rawScrollTop:he,referenceScrollTop:Ee,bottomScrollTop:it.bottomScrollTop,domMaxScrollTop:Ne,reviewing:Ce(),atBottomThreshold:S});return rt.action==="keep"||(Re("container-scroll:clamp-cursor-bottom",{details:`prev=${he} next=${rt.scrollTop} domMax=${Ne}`}),t.scrollTop=rt.scrollTop,Y=null,I=null),rt.scrollTop},Ie=e0e({container:t,atBottomThreshold:S,trace:Re,getPageResumePending:()=>D,getVerticalIntent:()=>z,dispatchVerticalIntent:zt,getCurrentAnchor:Ae,getLastSeenScrollTop:()=>O,hasHorizontalOverflow:et,clearHorizontalIntentIfUnscrollable:$e,markHorizontalUserInput:Fe,notifyAtBottom:ut,flushPendingTouchScrollNotify:ve}),We=he=>{const Ee=Ie.getScrollExpectation();if(!Ee)return!1;const{touchStartScrollTop:Ne,touchStartY:it,currentY:rt,gestureBaseScrollTop:gt,expectedScrollTop:Mt}=Ee,Jn=Math.abs(rt-it)>.5,Dn=he<=S&&gt>t.clientHeight,Yr=parseFloat(r.style.top||"0"),bi=Ae(),ar=Ie.getState().startedAtCursorAwareBottom&&Number.isFinite(Yr)&&Math.abs(he-Yr)<=S&&Math.abs(bi.bottomScrollTop-Yr)<=t.clientHeight+S&&Math.abs(Mt-he)>Ki.touch.hostTopJumpMinThresholdPx;if(!Jn&&!Dn&&!ar)return!1;const Zn=Math.max(Ki.touch.scrollJumpMinThresholdPx,t.clientHeight*1.25);return!ar&&Math.abs(he-Mt)<=Zn?!1:(Re("container-scroll:restore-touch-impossible-jump",{details:[`scrollTop=${Math.round(he)}`,`expected=${Math.round(Mt)}`,`diff=${Math.round(he-Mt)}`,`threshold=${Math.round(Zn)}`,`touchStart=${Math.round(Ne)}`,ar?"hostTop=1":null,`startY=${Math.round(it)}`,`currentY=${Math.round(rt)}`].filter(Boolean).join(" ")}),t.scrollTop=Mt,O=Mt,rn({deferHostUntilRender:!0}),!0)},ot=()=>{if(Re("container-scroll"),ie("containerScroll"))return;const he=Axe(N,{hasOverflow:et(),scrollLeft:t.scrollLeft,now:performance.now(),nativeIntentThresholdPx:Ki.horizontal.nativeIntentThresholdPx});N=he.state,Ke(he.trace),he.resetScrollLeft&&(t.scrollLeft=0);const Ee=t.scrollTop,Ne=O,it=Ee-O,rt=Cn(Ee,Ne);if(z.touchActive){const Jn=Ie.getScrollExpectation();Re("container-scroll:touch-active",{details:Ie.describeScrollExpectation(Jn,Ee,rt,Ne,it)??`raw=${Math.round(Ee)} effective=${Math.round(rt)}`})}O=rt;const gt=Nxe({syncingExternal:M.external,effectiveScrollTop:rt,pendingFollowTop:I,pendingProgrammaticTop:Y,atBottom:Ae().isAtBottom,canPassiveFollow:gd(z)});if(I=gt.nextPendingFollowTop,Y=gt.nextPendingProgrammaticTop,gt.action==="external-sync"){zt({type:"container-scroll",source:"external-sync",scrollTop:rt}),mt();return}if(gt.action==="programmatic-follow"){zt({type:"container-scroll",source:"programmatic-follow",scrollTop:rt}),mt();return}if(gt.action==="programmatic-bottom"){zt({type:"container-scroll",source:"programmatic-bottom",scrollTop:rt}),mt();return}const Mt=Ae().isAtBottom;if(gt.action==="programmatic-drift"){zt({type:"container-scroll",source:"programmatic-bottom",scrollTop:rt}),W("programmaticDrift");return}if(!We(rt)){if(D){Re("container-scroll:page-resume-pending",{details:`scrollTop=${rt} bottom=${Ae().bottomScrollTop}`}),mt();return}if(Ce()&&hn()&&it>0&&rt>=Ae().bottomScrollTop-S){W("touchSemanticBottom",{force:!0});return}if(gd(z)){Mt||Re("container-scroll:canonical-follow",{details:`scrollTop=${rt} bottom=${Ae().bottomScrollTop} delta=${it}`}),Tt(),W("containerBrowserSync");return}if(Ln()){Ce()&&it!==0&&sn();return}rn({deferHostUntilRender:hn()})}},St=()=>{if(Re("term-scroll"),!ie("termScroll")){M.external=!0;try{Tt();const he=yt();if(he==="followed")return;if(he==="none"&&gd(z)){W("termScroll");return}const{cellH:Ee}=x();if(Ee!==0){Ce()&&Gt(Ee);const Ne=It(t.scrollTop,Ee);Et(Ne,Ee)}mt()}finally{M.external=!1}}},Se=()=>{q!==null&&(K==null||K(q),q=null,K=null)},ct=()=>{if(!(M.internal||$||q!==null)){if(typeof window.requestAnimationFrame!="function"){St();return}q=window.requestAnimationFrame(()=>{q=null,K=null,!$&&St()}),K=typeof window.cancelAnimationFrame=="function"?he=>window.cancelAnimationFrame(he):null}},wt=()=>{if(ie("relayout"))return;Tt();const he=yt();if(he==="followed")return;if(he==="none"&&gd(z)){W("relayout");return}if(Ce()){const{cellH:Ne}=x();if(Ne<=0){G=!0,mt();return}if(G){Re("pending-sync-retry-fire"),rn();return}Gt(Ne),Et(It(t.scrollTop,Ne),Ne),mt();return}const{cellH:Ee}=x();if(Ee!==0)if(G)Re("pending-sync-retry-fire"),rn();else{const Ne=It(t.scrollTop,Ee),it=Exe(i.buffer.active.viewportY,Ee);Ne!==i.buffer.active.viewportY?t.scrollTop=it:Math.abs(t.scrollTop-it)>1&&Re("relayout:preserve-host-offset",{details:`scrollTop=${Math.round(t.scrollTop)} viewportTop=${Math.round(it)} ydisp=${Ne}`}),Fn(i.buffer.active.viewportY,Ee)}mt()},Oe=()=>{const he=st(),{cellH:Ee,visibleContentHeight:Ne,cursorBufferRow:it,anchor:rt}=he,gt=F,Mt=Fxe({reviewing:Ce()||z.touchActive,cellH:Ee,rows:i.rows,visibleContentHeight:Ne,cursorBufferRow:it,prevCursorBufferRow:F,cursorInViewport:rt.cursorInViewport,targetScrollTop:rt.bottomScrollTop,currentScrollTop:t.scrollTop});if(Mt.reason==="intent"){F=Mt.nextPrevCursorBufferRow,Re("followCursorY:skip",{details:Mt.reason});return}if(Mt.reason==="cellH=0"){Re("followCursorY:skip",{details:Mt.reason});return}if(Mt.reason==="shortHost"){F=Mt.nextPrevCursorBufferRow,Re("followCursorY:skip",{details:Mt.reason});return}if(Mt.reason==="same-row"){Re("followCursorY:skip[same-row]",{cursorDeltaRows:Mt.cursorDeltaRows,details:`cursorRow=${it} same-row`});return}if(F=Mt.nextPrevCursorBufferRow,Mt.reason==="inViewport"){Re("followCursorY:skip",{cursorDeltaRows:Mt.cursorDeltaRows,details:`cursorRow=${gt??"null"}->${it} inViewport`});return}if(Mt.reason==="aligned"){Re("followCursorY:skip",{cursorDeltaRows:Mt.cursorDeltaRows,details:`cursorRow=${gt??"null"}->${it} aligned`});return}if(Mt.action!=="follow")return;const Jn=t.scrollTop;Nn({viewportY:rt.bottomViewportY,scrollTop:Mt.targetScrollTop,cellH:Ee,visibleContentHeight:Ne,cursorBufferRow:it},"follow-cursor"),Re("followCursorY:hit",{cursorDeltaRows:Mt.cursorDeltaRows,scrollDeltaToAnchor:Jn-Mt.targetScrollTop,details:`cursorRow=${gt??"null"}->${it} scrollTop=${Math.round(Jn)}->${Math.round(Mt.targetScrollTop)}`})},ht=he=>{if(!et())return $e("followCursorX"),!0;if(!B.canFollow())return Re("followCursorX:skip",{details:"paintCursor"}),!1;const{cellW:Ee}=x();if(Ee<=0)return!1;const Ne=i.buffer.active.cursorX*Ee,it=t.scrollLeft,rt=it+t.clientWidth,gt=Ne>=it&&Ne<=rt;if(N.resumeWhenCursorVisible&&gt){const Zn=yp(N,{details:`site=followCursorX cursorPx=${Ne} viewport=${it}..${rt}`,scrollLeft:t.scrollLeft});if(N=Zn.state,Ke(Zn.trace),Zn.trace)return Re("followCursorX:skip",{details:"cursorInViewport"}),!0}if(N.intent)return Re("followCursorX:skip",{details:`horizontalIntent cursorPx=${Ne} viewport=${it}..${rt}`}),!0;const Mt=Math.min(t.clientWidth/2,Ki.horizontal.cursorFollowRightMarginColumns*Ee),Jn=rt-Mt,Dn=Ne<it||Ne>=rt;if(!(Dn||he&&Ne>=Jn))return Re("followCursorX:skip",{details:`cursorSafe cursorPx=${Ne} viewport=${it}..${rt} rightBoundary=${Jn} lookahead=${he?1:0}`}),!0;const bi=Math.max(0,Ne-t.clientWidth/2),ui=Math.max(0,t.scrollWidth-t.clientWidth),ar=Math.min(ui,bi);return N=Rxe(N,ar),t.scrollLeft=ar,Re("followCursorX:hit",{details:`cursorPx=${Ne} viewport=${it}..${rt} rightBoundary=${Jn} target=${ar} trigger=${Dn?"offscreen":"live-lookahead"}`}),!0},Dt=()=>{if(Re("render"),ie("render"))return;Tt({commitDeferredPaint:!0}),G&&(Re("pending-sync-retry-fire"),rn()),yt();const he=L;if(ht(he!=="idle")&&he==="parsed"&&L===he&&(L="idle"),Oe(),Ce()){const{cellH:Ee}=x();Ee>0&&(Gt(Ee),Et(It(t.scrollTop,Ee),Ee))}mt()};Tt(),Ce()?(sn(),O=t.scrollTop,mt()):W("init");const dn=Oxe({container:t,term:i,onWheel:he=>{et()&&Math.abs(he.deltaX)>0&&Math.abs(he.deltaX)>=Math.abs(he.deltaY)&&Fe(`site=wheel deltaX=${he.deltaX}`),he.deltaY!==0&&(Re("wheel:enter"),he.preventDefault(),he.stopPropagation(),X(he.deltaY))},onTouchStart:Ie.onTouchStart,onTouchMove:Ie.onTouchMove,onTouchEnd:he=>{Ie.onTouchEnd(he),wt()},onTouchCancel:he=>{Ie.onTouchCancel(he),wt()},onContainerScroll:ot,onTermScroll:ct,onRender:Dt,onRelayout:wt,onWriteParsed:()=>{if(Be+=1,L==="parsing"&&(L="parsed"),!we||(we=!1,!Ce()||i.buffer.active.type!=="normal"))return;const{cellH:he}=x();if(he<=0){G=!0;return}Gt(he),Et(It(t.scrollTop,he),he)}}),Ht=i.buffer.onBufferChange(()=>{B.reset(),Be+=1,i.buffer.active.type!==ce&&(le=!0),!re&&(re=!0,queueMicrotask(()=>{if(re=!1,$)return;const he=le;le=!1,ie("bufferChange",{forceBoundary:!0,crossedTypeBoundary:he})}))});return{dispose:()=>{$=!0,B.dispose(),Se(),Ht.dispose(),dn.dispose(),ye.dispose(),ge(),Ot(),gn(null)},relayout:wt,scrollToBottom:W,preparePageResumeRestore:oe,restorePageResume:ue,scrollToRatio:be,scrollToXRatio:se,resetHorizontalScroll:de,resumeHorizontalCursorFollow:pe,markHorizontalLiveFramePending:ae,markSelectionAutoscrollIntent:fe,markHorizontalScrollIntent:Z,traceRawInputFollowScheduled:Je,traceRawInputFollowFire:dt,getDebugProbe:()=>{const{cellH:he,cellW:Ee}=x(),{paddingTop:Ne,paddingBottom:it}=k();return{cellH:he,cellW:Ee,paddingTop:Ne,paddingBottom:it,liveLastY:he>0&&Ee>0?at():-1,userHasVerticalScrollIntent:Ce(),verticalIntentMode:z.mode,verticalIntentSource:z.source,verticalIntentTransitionId:z.lastTransitionId,userHasHorizontalScrollIntent:N.intent,pendingProgrammaticScrollTop:Y,pendingFollowCursorScrollTop:I,pendingFollowCursorScrollLeft:N.pendingFollowLeft,prevCursorBufferRow:F,lastSeenScrollTop:O,lastSeenScrollLeft:N.lastSeenLeft,touchScrollActive:z.touchActive,touchScrollGestureMode:Ie.getState().gestureMode,syncingInternal:M.internal,syncingExternal:M.external,atBottomThreshold:S,lastSpacerUpdateAt:U,pendingContainerSyncRetry:G}}}}const r0e=256*1024;function i0e(e){const t=e.writes[0];if(e.writes.length===1&&t)return t.data;const n=new Uint8Array(e.byteLength);let r=0;for(const i of e.writes)n.set(i.data,r),r+=i.data.byteLength;return n}function s0e(e,t={}){const{onFramePending:n,onFrameWritten:r,schedule:i=S=>requestAnimationFrame(S),cancel:s=S=>cancelAnimationFrame(S),maxBatchBytes:o=r0e}=t;if(!Number.isSafeInteger(o)||o<1)throw new RangeError("maxBatchBytes must be a positive safe integer");let l=!1,u=!1,d=null,f=null,h=[];const y=()=>{if(l||u||d!==null||h.length===0)return;const S=h[0];if(S.kind==="binary"){f=S,d=i(()=>{if(l||f!==S||h[0]!==S)return;d=null,f=null,h.shift(),u=!0;let R=!1;const A=()=>{R||(R=!0,u=!1,y())};try{e.write(i0e(S),()=>{var M;try{if(!l){for(const T of S.writes)(M=T.callback)==null||M.call(T);r==null||r()}}finally{A()}})}catch(M){throw A(),M}});return}h.shift(),u=!0;let x=!1;const k=()=>{x||(x=!0,u=!1,y())};switch(S.kind){case"string":try{e.write(S.data,()=>{var R;try{l||(R=S.callback)==null||R.call(S)}finally{k()}})}catch(R){throw k(),R}break;case"reset":try{e.reset()}finally{k()}break;case"resize":try{e.resize(S.cols,S.rows)}finally{k()}break;case"barrier":if(e.barrier)try{e.barrier(()=>{try{l||S.callback()}finally{k()}})}catch(R){throw k(),R}else try{l||S.callback()}finally{k()}break;case"fence":try{l||S.callback()}finally{k()}break}},g=S=>{l||(h.push(S),y())},_=(S,x)=>{if(l)return;const k=h.at(-1);if((k==null?void 0:k.kind)==="binary"&&k.byteLength<=o&&S.byteLength<=o-k.byteLength){k.writes.push({data:S,...x?{callback:x}:{}}),k.byteLength+=S.byteLength;return}const A={kind:"binary",writes:[{data:S,...x?{callback:x}:{}}],byteLength:S.byteLength};h.push(A),n==null||n(),y()},w=()=>{h=[],f=null,d!==null&&(s(d),d=null)};return{target:{reset:()=>g({kind:"reset"}),resize:(S,x)=>g({kind:"resize",cols:S,rows:x}),write:(S,x)=>{if(typeof S=="string"){g({kind:"string",data:S,...x?{callback:x}:{}});return}_(S,x)},barrier:S=>g({kind:"barrier",callback:S}),...e.getDimensions?{getDimensions:e.getDimensions}:{}},clear:w,fence:S=>g({kind:"fence",callback:S}),dispose:()=>{l||(l=!0,w())}}}const SL=5e3,EL=1e3;function o0e(){var t;const e=new Uint32Array(4);return(t=globalThis.crypto)!=null&&t.getRandomValues?(globalThis.crypto.getRandomValues(e),Array.from(e,n=>n.toString(16).padStart(8,"0")).join("")):`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}const a0e=o0e();let l0e=0;function c0e(e={}){let t=0;const n=`${a0e}-${++l0e}`,r=e.requestIdFactory??(()=>`pty-snapshot-${n}-${++t}`);let i=null,s=!1,o=[],l=null;const u=new Map;let d=!1,f=0,h=null,y=null,g=null,_=0,w=!1;const S=(T,P)=>{if(T.barrier){T.barrier(P);return}P()},x=(T,P)=>{if(T.kind==="write"){P.write(T.data);return}P.resize(T.cols,T.rows),h=T.cols,y=T.rows},k=T=>{let P=0,z=f+1;for(;u.has(z);){const Y=u.get(z);u.delete(z),f=z,x(Y,T),P+=1,z+=1}return P},R=()=>u.size>0||d,A=()=>{if(u.size<=EL)return;d=!0;const T=[...u.keys()].sort((z,Y)=>Y-z),P=u.size-EL;for(let z=0;z<P;z+=1){const Y=T[z];Y!==void 0&&u.delete(Y)}},M=(T,P)=>{if(!s){if(o.push(T),o.length>SL){const Y=o.splice(0,o.length-SL);for(const U of Y)l=Math.max(l??U.outputSeq,U.outputSeq)}return{written:!1,hasGap:!1}}if(T.outputSeq<=f)return{written:!1,hasGap:R()};u.set(T.outputSeq,T);const z=k(P)>0;return A(),{written:z,hasGap:R()}};return{startSnapshotRequest(T={}){T.preserveTargetIfUnchanged&&s&&h!==null&&y!==null?g={outputSeq:f,cols:h,rows:y}:T.preserveTargetIfUnchanged||(g=null);const P=r();return i=P,s=!1,o=[],l=null,u.clear(),d=!1,_+=1,P},hasAppliedSnapshot(){return s},hasPendingGap(){return s&&R()},handleBinaryFrame(T,P){return M({kind:"write",...T},P)},handleResize(T,P){return M({kind:"resize",...T},P)},applySnapshot(T,P,z){var L;if(!i)return{applied:!1,reason:"no_active_request"};if(T.requestId!==i)return{applied:!1,reason:"stale_snapshot"};u.clear(),i=null,_+=1;const Y=_,U=o.filter(B=>B.outputSeq>T.outputSeq).sort((B,O)=>B.outputSeq-O.outputSeq),G=((L=P.getDimensions)==null?void 0:L.call(P))??null,I=g!==null&&g.outputSeq===T.outputSeq&&g.cols===T.cols&&g.rows===T.rows&&(G==null?void 0:G.cols)===T.cols&&G.rows===T.rows&&(l===null||l<=T.outputSeq)&&U.length===0;if(g=null,I)return o=[],l=null,s=!0,f=T.outputSeq,h=T.cols,y=T.rows,z==null||z(!1),{applied:!0,replayedEvents:0};const N=()=>{Y===_&&(w=!0,P.reset(),P.resize(T.cols,T.rows),P.write(T.data,()=>{if(Y!==_)return;const B=o.filter(O=>O.outputSeq>T.outputSeq).sort((O,D)=>O.outputSeq-D.outputSeq);o=[],s=!0,f=T.outputSeq,h=T.cols,y=T.rows,d=l!==null&&l>T.outputSeq,l=null;for(const O of B)u.set(O.outputSeq,O);k(P),A(),z==null||z(R())}))};return w?S(P,N):N(),{applied:!0,replayedEvents:U.length}}}}function u0e(e){const{sessionId:t,ws:n,relay:r,target:i,retryDelayMs:s=3e4,slowNoticeDelayMs:o=1e4,gapRecoveryDelayMs:l=2e3,scheduleReady:u=le=>requestAnimationFrame(le),scheduleFrameFlush:d,cancelFrameFlush:f,onFramePending:h,onFrameWritten:y,onReady:g,onSubscribeDelayed:_,onSubscribeStarted:w,onGapRecovery:S}=e,x=c0e(),R=s0e({reset:()=>i.reset(),resize:(le,we)=>i.resize(le,we),write:(le,we)=>{i.write(le,()=>{le instanceof Uint8Array&&ppe(t,le.byteLength),we==null||we()})},barrier:le=>i.write("",le),getDimensions:()=>{var Ce;const le=(Ce=i.getDimensions)==null?void 0:Ce.call(i);if(le)return le;const we=i;return typeof we.cols=="number"&&typeof we.rows=="number"?{cols:we.cols,rows:we.rows}:null}},{onFramePending:h,onFrameWritten:y,schedule:d,cancel:f});let A=!1,M=!1,T=!1,P=null,z=null,Y=null,U=!1,G=null,I=0,N=0,L=!1,B=!1;const O=()=>{P&&(clearTimeout(P),P=null)},D=()=>{z&&(clearTimeout(z),z=null)},F=()=>{Y&&(clearTimeout(Y),Y=null)},V=()=>{I+=1,N+=1,L=!1,B=!1},j=()=>{N+=1,B=!1},q=()=>{if(A||M||!L||B||!x.hasAppliedSnapshot()||x.hasPendingGap())return;B=!0;const le=I,we=++N;R.fence(()=>{if(!(A||M||le!==I||we!==N||!L)){if(x.hasPendingGap()){B=!1;return}u(()=>{if(!(A||M||le!==I||we!==N||!L)){if(x.hasPendingGap()){B=!1;return}B=!1,L=!1,g==null||g()}})}})},K=()=>{Y||(Y=setTimeout(()=>{Y=null,!(A||!x.hasPendingGap())&&(S==null||S(),ne())},l))},$=()=>{const le=x.startSnapshotRequest({preserveTargetIfUnchanged:T});return G=le,n.send(JSON.stringify({type:"session_subscribe",sessionId:t,requestId:le})),le},te=le=>{P=setTimeout(()=>{P=null,!(A||M||x.hasAppliedSnapshot()||G!==le)&&(n.send(JSON.stringify({type:"session_subscribe",sessionId:t,requestId:le})),te(le))},s)},J=()=>{z=setTimeout(()=>{z=null,!(A||x.hasAppliedSnapshot()||U)&&(U=!0,_==null||_())},o)},ne=(le=!1)=>{if(A||M)return;V(),O(),D(),F(),le||R.clear(),T=le,U=!1,w==null||w();const we=$();te(we),J()},Q=le=>{if(le.hasGap){L&&B&&j(),K();return}F(),q()},ce=n.subscribeBinary(t,(le,we)=>{if(A||M)return;hpe(t,le,we);const Ce=x.handleBinaryFrame({data:le,outputSeq:we},R.target);Q(Ce)}),re=r.onMessage(le=>{if(A||M||le.sessionId!==t)return;if(le.type==="terminal_resize"){if(typeof le.cols!="number"||typeof le.rows!="number"||typeof le.outputSeq!="number")return;const Ce=x.handleResize({cols:le.cols,rows:le.rows,outputSeq:le.outputSeq},R.target);Q(Ce);return}le.type!=="session_snapshot"||typeof le.requestId!="string"||!x.applySnapshot({requestId:le.requestId,cols:le.cols,rows:le.rows,data:le.data,outputSeq:le.outputSeq},R.target,Ce=>{A||M||(L=!0,Ce?(j(),K()):(F(),q()),D())}).applied||(G=null,O())});return ne(),{pause:()=>{A||M||(M=!0,G=null,V(),O(),D(),F())},resume:()=>{A||!M||(M=!1,ne(!0))},dispose:()=>{A=!0,M=!0,G=null,V(),O(),D(),F(),R.dispose(),ce(),re()}}}function d0e(e){const{host:t,sessionId:n,ws:r,relay:i,createTerminal:s,attachRawInput:o,attachTransport:l=u0e,scheduleAutoFocus:u=I=>requestAnimationFrame(I),onTerminalReady:d,onFramePending:f,onFrameWritten:h,onRawInput:y,isInputEnabled:g,canFocus:_=()=>!0,onReady:w,onSubscribeStarted:S,onSubscribeDelayed:x,connectTransportInitially:k=!0,onError:R}=e;let A=!1,M=null,T=null,P=null,z=null,Y=k,U=null;const G=()=>{var I;if(!(A||!z)){if(!Y){P!=null&&P.pause?P.pause():(P==null||P.dispose(),P=null);return}if(P){(I=P.resume)==null||I.call(P);return}P=l({sessionId:n,ws:r,relay:i,target:z,onFramePending:f,onFrameWritten:h,onReady:w,onSubscribeStarted:S,onSubscribeDelayed:x})}};return(async()=>{try{const I=await s(t);if(A){I.dispose();return}M=I.dispose,z=I.terminal,T=o(I.terminal,n,{onRawInput:y,...g?{isInputEnabled:g}:{}}).dispose;const N=L=>{L!=null&&L.metaKey||L!=null&&L.ctrlKey||_()&&I.terminal.focus()};t.addEventListener("pointerdown",N,{passive:!0}),U=()=>t.removeEventListener("pointerdown",N),d==null||d(I.terminal),u(()=>{A||N()}),G()}catch(I){console.error("[pty-terminal-controller] initialization failed",I),R==null||R(I)}})(),{setTransportActive:I=>{Y=I,G()},dispose:()=>{A=!0,Y=!1,P==null||P.dispose(),P=null,U==null||U(),T==null||T(),M==null||M(),z=null}}}function f0e(e={}){const{schedule:t=l=>requestAnimationFrame(l),cancel:n=l=>cancelAnimationFrame(l)}=e,r=new Map;let i=null,s=!1;const o=()=>{s||i!==null||r.size===0||(i=t(()=>{if(i=null,s)return;const l=r.entries().next().value;if(!l)return;const[u,d]=l;r.delete(u),d.attach(),o()}))};return{enqueue(l,u,d){if(s)return()=>{};const f=Symbol(l);return r.delete(l),u==="active"?(d(),()=>{}):(r.set(l,{attach:d,token:f}),o(),()=>{const h=r.get(l);(h==null?void 0:h.token)===f&&r.delete(l)})},dispose(){s=!0,r.clear(),i!==null&&n(i),i=null}}}let CL=null;function h0e(e,t,n){return CL??(CL=f0e()),CL.enqueue(e,t,n)}function hT(e){if(/^[a-z][a-z0-9+.-]*:\/\//i.test(e))return!1;const t=e.indexOf(":");if(t<=0)return!1;const n=e.slice(0,t),r=e.slice(t+1);return!r.includes("/")||!/^[A-Za-z0-9._~-]+(?:@[A-Za-z0-9.-]+)?$/.test(n)||!(n.includes("@")?n.slice(n.lastIndexOf("@")+1):n).includes(".")?!1:/^[A-Za-z0-9._~%+-]+(?:\/[A-Za-z0-9._~%+-]+)+$/.test(r)}const p0e=new RegExp("(?<![\\p{L}\\p{N}@:/.-])(?:~\\/|[^\\s`\"'<>,。;:!?、@])[^\\s`\"'<>,。;:!?、@]*?\\.(?:png|jpe?g|webp|gif)(?=$|[\\s`\"'<>),;:!?,。;:!?、]|\\.(?:$|[\\s`\"'<>),;:!?,。;:!?、]))","giu"),m0e=new RegExp("(?<![A-Za-z0-9._+-])@(?:~\\/|[^\\s`\"'<>,。;:!?、@])[^\\s`\"'<>,。;:!?、@]*?\\.(?:png|jpe?g|webp|gif)(?=$|[\\s`\"'<>),;:!?,。;:!?、]|\\.(?:$|[\\s`\"'<>),;:!?,。;:!?、]))","giu"),g0e=/\.(?:png|jpe?g|webp|gif)$/i;function Z6(e){return e.replace(/^@/,"").replace(/^[([{]+/,"").replace(/[)\].,;:!?,。;:!?、]+$/u,"")}function v0e(e){if(/[\\/]/.test(e))return!0;const t=e.replace(/\.(?:png|jpe?g|webp|gif)$/i,""),n=t.split(/[\\/]/).pop()??t;return n.length<2?!1:/[\p{L}_-]/u.test(n)}function pT(e){const t=Z6(e);return/^[a-z][a-z0-9+.-]*:\/\//i.test(t)||hT(t)||!g0e.test(t)?!1:v0e(t)}function Q6(e){const t=[];for(const n of[m0e,p0e])for(const r of e.matchAll(n)){const i=r[0]??"",s=r.index??-1;if(s<0)continue;const o=Z6(i);pT(o)&&t.push({path:o,start:s,end:s+i.length})}return t.sort((n,r)=>n.start-r.start)}function y0e(e){const t=new Set,n=[];for(const{path:r}of Q6(e))t.has(r)||(t.add(r),n.push(r));return n}const DE=16;function J6(e,t,n){const r=_0e(e,t);if(!r)return[];const i=new Set,s=r.parts.map(o=>o.text).join("");return b0e(s,n).map(o=>{const l=x0e(r.parts,o.startIndex),u=S0e(r.parts,o.endIndex);return!l||!u?null:{path:o.path,startLineNumber:l.lineNumber,startColumn:l.column,endLineNumber:u.lineNumber,endColumn:u.column,segments:E0e(r.parts,o.startIndex,o.endIndex)}}).filter(o=>o!==null).filter(o=>t>=o.startLineNumber&&t<=o.endLineNumber).filter(o=>{const l=`${o.path}:${o.startLineNumber}:${o.startColumn}:${o.endLineNumber}:${o.endColumn}`;return i.has(l)?!1:(i.add(l),!0)})}function eH(e){return e.segments.length>0?e.segments.map(t=>({start:{x:t.startColumn,y:t.lineNumber},end:{x:t.endColumn,y:t.lineNumber}})):[{start:{x:e.startColumn,y:e.startLineNumber},end:{x:e.endColumn,y:e.endLineNumber}}]}function b0e(e,t){const n=t(e),r=[];let i=0;for(const s of n){const o=e.indexOf(s,i);if(o<0)continue;const l=o>0&&e[o-1]==="@"?o-1:o,u=o+s.length;r.push({path:s,startIndex:l,endIndex:u}),i=o+s.length}return r}function _0e(e,t){const n=e.buffer.active;let r=t,i=t;for(let s=0;s<DE;s+=1){const o=n.getLine(r-1);if(!(o!=null&&o.isWrapped)||r<=1)break;r-=1}for(let s=0;s<DE;s+=1){const o=n.getLine(i);if(!(o!=null&&o.isWrapped))break;i+=1}return w0e(e,r,i)}function w0e(e,t,n){const r=e.buffer.active;let i=n??t;if(n===void 0)for(let o=0;o<DE;o+=1){const l=r.getLine(i);if(!(l!=null&&l.isWrapped))break;i+=1}const s=[];for(let o=t;o<=i;o+=1){const l=r.getLine(o-1);if(!l)return null;const u=l.translateToString(!0);s.push({lineNumber:o,sourceText:u,sourceStartIndex:0,text:u})}return{startLineNumber:t,endLineNumber:i,parts:s}}function x0e(e,t){let n=t;for(let r=0;r<e.length;r+=1){const i=e[r];if(i){if(n<i.text.length)return{lineNumber:i.lineNumber,column:BE(i.sourceText,i.sourceStartIndex+n)};if(n===i.text.length&&r<e.length-1){const s=e[r+1];return s?{lineNumber:s.lineNumber,column:BE(s.sourceText,s.sourceStartIndex)}:null}n-=i.text.length}}return null}function S0e(e,t){let n=t-1;for(const r of e){if(n<r.text.length)return{lineNumber:r.lineNumber,column:mT(r.sourceText.slice(0,r.sourceStartIndex+n+1))};n-=r.text.length}return null}function E0e(e,t,n){const r=[];let i=0;for(const s of e){const o=i+s.text.length,l=Math.max(t,i),u=Math.min(n,o);if(l<u){const d=l-i,f=u-i;r.push({lineNumber:s.lineNumber,startColumn:BE(s.sourceText,s.sourceStartIndex+d),endColumn:mT(s.sourceText.slice(0,s.sourceStartIndex+f))})}i=o}return r}function BE(e,t){return mT(e.slice(0,t))+1}function mT(e){let t=0;for(const n of e)t+=C0e(n.codePointAt(0)??0);return t}function C0e(e){return e===0||e<32||e>=127&&e<160||k0e(e)?0:T0e(e)?2:1}function k0e(e){return e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071}function T0e(e){return e>=4352&&(e<=4447||e===9001||e===9002||e>=11904&&e<=42191&&e!==12351||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=127744&&e<=128591||e>=129280&&e<=129535||e>=131072&&e<=262141)}function tH(e,t){return J6(e,t,y0e)}function R0e(e){var n,r;if(e.metaKey||e.ctrlKey)return!0;const t="pointerType"in e?String(e.pointerType):"";return t==="touch"||t==="pen"?!0:((r=(n=window.matchMedia)==null?void 0:n.call(window,"(pointer: coarse), (hover: none)"))==null?void 0:r.matches)??!1}function A0e(e,t){const n={provideLinks(i,s){const o=tH(e,i);if(o.length===0){s(void 0);return}const l=o.reduce((u,d)=>{for(const f of eH(d))f.start.y!==i||f.end.y!==i||u.push({text:d.path,range:f,decorations:{underline:!0,pointerCursor:!0},activate:h=>{R0e(h)&&t(d.path)}});return u},[]);s(l.length>0?l:void 0)}},r=e.registerLinkProvider(n);return{dispose:()=>r.dispose(),provider:n}}const N0e=new Set(["ai","app","biz","cloud","cn","co","com","de","dev","fr","in","info","io","jp","me","net","nl","online","org","ru","site","tech","tools","top","uk","us","xyz"]);function gT(e){const n=(e.split(/[/?#]/,1)[0]??"").split(".");if(n.length<2)return!1;const r=(n.at(-1)??"").toLowerCase();return N0e.has(r)?n.every(i=>/^[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?$/.test(i)):!1}const M0e=new RegExp("(?<![\\p{L}\\p{N}@:/.-])(?:~\\/|[^\\s`\"'<>,。;:!?、@])[^\\s`\"'<>,。;:!?、@]*\\.[\\p{L}\\p{N}]{1,16}(?=[\\s`\"'<>),.;:!?,。;:!?、]|$)","giu"),P0e=new RegExp("(?<![A-Za-z0-9._+-])@(?:~\\/|[^\\s`\"'<>,。;:!?、@])[^\\s`\"'<>,。;:!?、@]*\\.[\\p{L}\\p{N}]{1,16}(?=[\\s`\"'<>),.;:!?,。;:!?、]|$)","giu"),I0e=/\.(?:png|jpe?g|webp|gif)$/i,O0e=/\.[\p{L}\p{N}]{1,16}$/u,L0e=new Set(["cargo.toml","composer.json","eslint.config.js","eslint.config.mjs","gemfile.lock","go.mod","go.sum","package-lock.json","package.json","pnpm-lock.yaml","prettier.config.js","pyproject.toml","readme.md","requirements.txt","tailwind.config.js","tailwind.config.ts","tsconfig.json","vite.config.ts","vitest.config.ts","yarn.lock"]);function nH(e){return e.replace(/^@/,"").replace(/^[([{]+/,"").replace(/[)\].,;:!?,。;:!?、]+$/u,"")}function D0e(e){const t=e.split(/[\\/]/).pop()??e;if(/^\d+(?:\.\d+)+$/.test(t))return!1;if(/[\\/]/.test(e))return!0;const n=e.replace(/\.[\p{L}\p{N}]{1,16}$/u,""),r=n.split(/[\\/]/).pop()??n;return r.length<2?!1:/[\p{L}_-]/u.test(r)}function B0e(e){return/[\\/]/.test(e)?!1:gT(e)}function z0e(e){return/[\\/]/.test(e)}function j0e(e,t){return z0e(e)||t?!0:L0e.has(e.toLowerCase())}function vT(e,t={}){const n=nH(e);return/^[a-z][a-z0-9+.-]*:\/\//i.test(n)||hT(n)||!t.allowBare&&B0e(n)||I0e.test(n)||!O0e.test(n)||!j0e(n,t.allowBare===!0)||n.split(/[\\/]/).includes("...")?!1:D0e(n)}function rH(e){const t=[];for(const n of[P0e,M0e])for(const r of e.matchAll(n)){const i=r[0]??"",s=r.index??-1;if(s<0)continue;const o=nH(i);vT(o,{allowBare:i.startsWith("@")})&&t.push({path:o,start:s,end:s+i.length})}return t.sort((n,r)=>n.start-r.start)}function F0e(e){const t=new Set,n=[];for(const{path:r}of rH(e))t.has(r)||(t.add(r),n.push(r));return n}const $0e=750;function iH(e,t){return J6(e,t,F0e)}function H0e(e){return e.metaKey||e.ctrlKey}function U0e(e,t){let n=null;const r=(o,l)=>{if(!H0e(l))return;const u=performance.now();(n==null?void 0:n.path)===o&&u-n.at<$0e||(n={path:o,at:u},t(o))},i={provideLinks(o,l){const u=iH(e,o);if(u.length===0){l(void 0);return}const d=u.reduce((f,h)=>{for(const y of eH(h))y.start.y!==o||y.end.y!==o||f.push({text:h.path,range:y,decorations:{underline:!1,pointerCursor:!0},hover:()=>{W0e(e,h)},leave:()=>{_y(e)},dispose:()=>{_y(e)},activate:g=>{r(h.path,g)}});return f},[]);l(d.length>0?d:void 0)}},s=e.registerLinkProvider(i);return{dispose:()=>{_y(e),s.dispose()},provider:i}}function W0e(e,t){const n=e.element;if(!n)return;const r=n.querySelector(".xterm-screen");if(!r||e.cols<=0||e.rows<=0)return;const i=n.getBoundingClientRect(),s=r.getBoundingClientRect(),o=(r.clientWidth||s.width)/e.cols,l=(r.clientHeight||s.height)/e.rows;if(!Number.isFinite(o)||!Number.isFinite(l)||o<=0||l<=0)return;_y(e),q0e(n);const u=document.createElement("div");u.dataset.slot="pty-file-link-hover-overlay",u.style.position="absolute",u.style.inset="0",u.style.pointerEvents="none",u.style.zIndex="4",n.append(u);const d=s.left-i.left,f=s.top-i.top,h=e.buffer.active.viewportY;for(const y of t.segments){const g=y.lineNumber-h;if(g<1||g>e.rows)continue;const _=document.createElement("div");_.dataset.slot="pty-file-link-hover-segment",_.dataset.range=`${y.lineNumber}:${y.startColumn}-${y.endColumn}`,_.style.position="absolute",_.style.left=`${d+(y.startColumn-1)*o}px`,_.style.top=`${f+(g-1)*l+l-2}px`,_.style.width=`${Math.max(1,y.endColumn-y.startColumn+1)*o}px`,_.style.height="2px",_.style.background="currentColor",_.style.opacity="0.8",u.append(_)}}function _y(e){var t;(t=e.element)==null||t.querySelectorAll('[data-slot="pty-file-link-hover-overlay"]').forEach(n=>n.remove())}function q0e(e){window.getComputedStyle(e).position==="static"&&(e.style.position="relative")}function Ll(e,t={}){const n=window.__ccTestPtyTouchLinkActivations;n&&(n.push({event:e,t:performance.now(),...t}),n.length>200&&n.splice(0,n.length-200))}function zE(e,t,n){const r=e.range.start.y*n+e.range.start.x,i=e.range.end.y*n+e.range.end.x,s=t.y*n+t.x;return r<=s&&s<=i}function V0e(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}function kL(e){const t=e._core;return!t||typeof t!="object"?null:t}function Y0e(e,t){return e.composedPath().includes(t)}function TL(e,t,n){const r=t.screenElement,i=t._mouseService;if(!r||!i||!Y0e(n,r))return null;let s;try{s=i.getCoords(n,r,e.cols,e.rows)}catch{return null}return s?{x:s[0],y:s[1]+e.buffer.active.viewportY}:null}function RL(e){var n,r;const t=(n=e.linkifier)==null?void 0:n.currentLink;return((r=t==null?void 0:t.state)==null?void 0:r.isHovered)===!0?t.link:null}function K0e(e,t){if(t.type!=="mousedown"||t.button!==0)return null;const n=kL(e);if(!n)return null;const r=RL(n),i=TL(e,n,t);if(!r||!i||!zE(r,i,e.cols))return null;let s=!1;return{text:r.text,range:{start:{...r.range.start},end:{...r.range.end}},activateOnMouseUp:o=>{if(s||(s=!0,o.type!=="mouseup"||o.button!==0))return!1;const l=kL(e);if(!l)return!1;const u=RL(l),d=TL(e,l,o);return!u||!d||!V0e(r,u)||!zE(u,d,e.cols)?!1:(u.activate(o,u.text),!0)}}}function G0e(e){const t=new MouseEvent("mouseup",{bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey});return Object.defineProperty(t,"pointerType",{configurable:!0,value:e.pointerType??"touch"}),t}function sH(e,t,n){if(t.length===0)return Ll("skip",{reason:"no-providers",point:n}),null;const r=e.element,i=r==null?void 0:r.querySelector(".xterm-screen"),s=(r==null?void 0:r.parentElement)??r;if(!i||!s)return Ll("skip",{reason:"missing-elements",hasScreen:!!i,hasMetricHost:!!s,point:n}),null;const o=o_(s,e);if(!o||o.cellW<=0||o.cellH<=0)return Ll("skip",{reason:"missing-metrics",metrics:o,point:n}),null;const l=i.getBoundingClientRect(),u=Math.floor((n.clientX-l.left)/o.cellW)+1,d=Math.floor((n.clientY-l.top)/o.cellH)+1;if(u<1||u>e.cols||d<1||d>e.rows)return Ll("skip",{reason:"point-out-of-range",point:n,viewportX:u,viewportY:d,cols:e.cols,rows:e.rows,rect:{left:l.left,top:l.top,width:l.width,height:l.height},metrics:o}),null;const f=e.buffer.active.viewportY+d,h={x:u,y:f};Ll("probe",{point:n,viewportX:u,viewportY:d,bufferLineNumber:f,providers:t.length,metrics:o});for(const y of t){let g=null;if(y.provideLinks(f,_=>{Ll("links",{bufferLineNumber:f,position:h,count:(_==null?void 0:_.length)??0,links:_==null?void 0:_.map(S=>({text:S.text,range:S.range}))});const w=_==null?void 0:_.find(S=>zE(S,h,e.cols));w&&(g=w)}),g)return g}return Ll("miss",{position:h,point:n,bufferLineNumber:f}),null}function X0e(e,t,n){return sH(e,t,n)!==null}function Z0e(e,t,n){const r=sH(e,t,n);return r?(r.activate(G0e(n),r.text),Ll("activate",{text:r.text,range:r.range,point:n}),!0):!1}const Q0e=2*1024*1024,J0e=2560,AL=.82,eSe=.9,tSe=new Set(["image/jpeg","image/png","image/webp"]),oH=new Map([["image/jpeg","jpg"],["image/png","png"],["image/webp","webp"]]);function aH(e){return e.size>Q0e&&tSe.has(e.type)}function nSe(e,t,n=J0e){const r=Math.max(e,t);if(!Number.isFinite(r)||r<=0)throw new Error("图片尺寸无效");const i=Math.min(1,n/r);return{width:Math.max(1,Math.round(e*i)),height:Math.max(1,Math.round(t*i))}}function rSe(e,t){const n=oH.get(t);return n?`${e.replace(/\.(?:jpe?g|png|webp)$/iu,"")||"image"}.${n}`:e}function iSe(){return typeof createImageBitmap!="function"||typeof document>"u"?null:{async decode(e){const t=await createImageBitmap(e,{imageOrientation:"from-image"});return{source:t,width:t.width,height:t.height,close:()=>t.close()}},async encode(e,t,n,r,i){const s=document.createElement("canvas");s.width=t,s.height=n;const o=s.getContext("2d");if(!o)throw new Error("浏览器无法创建图片压缩画布");return o.imageSmoothingEnabled=!0,o.imageSmoothingQuality="high",o.drawImage(e.source,0,0,t,n),new Promise(l=>s.toBlob(l,r,i))}}}async function lH(e,t=iSe()){var r;if(!aH(e)||!t)return e;let n=null;try{n=await t.decode(e);const i=nSe(n.width,n.height);let s=await t.encode(n,i.width,i.height,"image/webp",AL);return(s==null?void 0:s.type)!=="image/webp"&&e.type==="image/jpeg"&&(s=await t.encode(n,i.width,i.height,"image/jpeg",AL)),!s||!oH.has(s.type)||s.size>=e.size*eSe?e:new File([s],rSe(e.name,s.type),{type:s.type,lastModified:e.lastModified})}catch{return e}finally{(r=n==null?void 0:n.close)==null||r.call(n)}}async function em(e){const t=aH(e.file),n=Ue.loading(t?`正在压缩并上传 ${e.file.name} ...`:`上传 ${e.file.name} ...`);try{const r=await lH(e.file),i=await e.relay.uploadFile(e.sessionId,r);return!i.success||!i.path?(Ue.error(i.error??"上传失败",{id:n}),null):(e.successLabel===null?Ue.dismiss(n):Ue.success(e.successLabel??`已上传 ${i.path}`,{id:n}),i.path)}catch(r){return Ue.error(r instanceof Error?r.message:String(r),{id:n}),null}}function NL(e){let t=null,n=!1;const r=()=>{t=null,n||e()};return{schedule:()=>{n||t!==null||(t=requestAnimationFrame(r))},dispose:()=>{n=!0,t!==null&&(cancelAnimationFrame(t),t=null)}}}const ML="--dev-visual-viewport-height",sSe=.3,PL=100,oSe=1e4;function cH({layoutViewportHeight:e,visualViewportHeight:t,visualViewportOffsetTop:n,baselineViewportHeight:r,allowBaselineFallback:i=!0,subtractVisualViewportOffsetTop:s=!0}){const o=s?n:0,l=e-t-o,u=r-t-o,d=IL(l,e),f=i?IL(u,r):0;return Math.max(d,f)}function aSe({layoutViewportHeight:e,visualViewportHeight:t,visualViewportOffsetTop:n,baselineViewportHeight:r=e,allowBaselineFallback:i=!1,softKeyboardOpen:s=!1}){return s?Math.max(e-t-n,0):cH({layoutViewportHeight:e,visualViewportHeight:t,visualViewportOffsetTop:n,baselineViewportHeight:r,allowBaselineFallback:i})}function IL(e,t){const n=Math.max(e,0);return n<=0?0:n/Math.max(t,1)>=sSe?n:0}function lSe(){b.useEffect(()=>{const e=window.visualViewport;let t=0;const n=()=>{cancelAnimationFrame(t),t=requestAnimationFrame(()=>{const r=(e==null?void 0:e.height)??window.innerHeight;document.documentElement.style.setProperty(ML,`${r}px`)})};return n(),window.addEventListener("resize",n),e==null||e.addEventListener("resize",n),e==null||e.addEventListener("scroll",n),()=>{cancelAnimationFrame(t),window.removeEventListener("resize",n),e==null||e.removeEventListener("resize",n),e==null||e.removeEventListener("scroll",n),document.documentElement.style.removeProperty(ML)}},[])}function OL(){const e=document.documentElement,t=document.body;return window.scrollX!==0||window.scrollY!==0||e.scrollLeft!==0||e.scrollTop!==0||t.scrollLeft!==0||t.scrollTop!==0?(window.scrollTo(0,0),e.scrollLeft=0,e.scrollTop=0,t.scrollLeft=0,t.scrollTop=0,!0):!1}function cSe(){b.useEffect(()=>{const e=window.visualViewport;let t=0;const n=()=>{OL(),cancelAnimationFrame(t),t=requestAnimationFrame(()=>{t=0,OL()})};return n(),window.addEventListener("scroll",n,{passive:!0}),window.addEventListener("resize",n),e==null||e.addEventListener("scroll",n,{passive:!0}),e==null||e.addEventListener("resize",n),()=>{cancelAnimationFrame(t),window.removeEventListener("scroll",n),window.removeEventListener("resize",n),e==null||e.removeEventListener("scroll",n),e==null||e.removeEventListener("resize",n)}},[])}function uSe(){return yT().bottomOffset}function yT(){const[e,t]=b.useState({bottomOffset:0,layoutBottomInset:0}),n=b.useRef(0),r=b.useRef(0);return b.useEffect(()=>{const i=window.visualViewport;if(!i)return;const s=dSe();let o=0,l;const u=()=>{const g=i.height,_=i.offsetTop,w=i.width,S=Math.max(window.innerHeight,g+_);!n.current||Math.abs(w-r.current)>1?(n.current=S,r.current=w):n.current=Math.max(n.current,S);const x=window.innerHeight,k=fSe(),R=!s||k,A=s&&k,M=cH({layoutViewportHeight:x,visualViewportHeight:g,visualViewportOffsetTop:_,baselineViewportHeight:n.current,allowBaselineFallback:R,subtractVisualViewportOffsetTop:s}),T={bottomOffset:Math.round(M),layoutBottomInset:Math.round(aSe({layoutViewportHeight:x,visualViewportHeight:g,visualViewportOffsetTop:_,baselineViewportHeight:n.current,allowBaselineFallback:A,softKeyboardOpen:M>0}))};return t(P=>P.bottomOffset===T.bottomOffset&&P.layoutBottomInset===T.layoutBottomInset?P:T),T.bottomOffset},d=()=>{cancelAnimationFrame(o),o=requestAnimationFrame(()=>{o=0,u()})},f=()=>{l!==void 0&&clearTimeout(l),l=void 0},h=()=>{f(),d();const g=performance.now()+oSe,_=()=>{if(u()>0||performance.now()>=g){l=void 0;return}l=setTimeout(_,PL)};l=setTimeout(_,PL)};d(),window.addEventListener("resize",d),i.addEventListener("resize",d),i.addEventListener("scroll",d),document.addEventListener("focusin",h,!0);const y=()=>{setTimeout(d,300)};return window.addEventListener("focusout",y),()=>{cancelAnimationFrame(o),f(),window.removeEventListener("resize",d),i.removeEventListener("resize",d),i.removeEventListener("scroll",d),document.removeEventListener("focusin",h,!0),window.removeEventListener("focusout",y)}},[]),e}function dSe(){if(typeof navigator>"u")return!1;const e=navigator.userAgent??"",t=navigator.platform??"",n=navigator.maxTouchPoints??0;return/iPad|iPhone|iPod/.test(e)||t==="MacIntel"&&n>1&&(e.includes("Mac OS X")||e.includes("Macintosh"))}function fSe(){const e=document.activeElement;return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}const hSe=new Set(["\x1B[A","\x1B[B","\x1B[C","\x1B[D"]);function bp(e,t){return!(t!=null&&t.applicationCursorKeysMode)||!hSe.has(e)?e:`\x1BO${e.at(-1)}`}function pSe(e){window.__devAnywherePtyTerminal=e}function mSe(){window.__devAnywherePtyTerminal&&delete window.__devAnywherePtyTerminal}function gSe(e){window.__devAnywherePtyDebug=e}function vSe(){window.__devAnywherePtyDebug&&delete window.__devAnywherePtyDebug}function ySe(e,t){const n=e(),{container:r,spacer:i,host:s,term:o}=t,{cellH:l,cellW:u,paddingTop:d,paddingBottom:f,liveLastY:h}=n,y=Math.max(0,r.clientHeight-d-f),g=o.buffer.active;let _=0;if(l>0&&u>0){const L=K6({bufferLength:g.length,baseY:g.baseY,rows:o.rows,cols:o.cols,viewportY:g.viewportY,cursorY:g.cursorY,cellH:l,cellW:u,visibleContentHeight:y},h),B=(L==null?void 0:L.spacerHeight)??0;_=n.userHasVerticalScrollIntent||n.touchScrollActive?Math.max(B,r.scrollTop+y):B}const w=Hs(i.style.height),S=Hs(s.style.top),x=Hs(s.style.height),k=Hs(s.style.width),R=Hs(s.style.paddingTop),A=Hs(i.style.width);let M=0;if(l>0){const L=o.rows*l,B=L>0&&L<y?y-L:0;M=Math.max(0,g.viewportY*l+B)}const T=S-M,P=r.scrollTop,z=P+r.clientHeight,Y=S+x,U=Math.max(0,Math.min(z,Y)-Math.max(P,S)),G=r.clientHeight>0?U/r.clientHeight:0,I=g.baseY+g.cursorY,N=dT({rows:o.rows,cellH:l,bufferLength:g.length,baseY:g.baseY,viewportY:g.viewportY,cursorBufferRow:I,liveLastY:h,visibleContentHeight:y,paddingTop:d,paddingBottom:f,hostPaddingTop:R,containerScrollTop:r.scrollTop,containerScrollHeight:r.scrollHeight,containerClientHeight:r.clientHeight,atBottomThreshold:n.atBottomThreshold});return{ts:performance.now(),container:{scrollTop:r.scrollTop,scrollLeft:r.scrollLeft,scrollHeight:r.scrollHeight,scrollWidth:r.scrollWidth,clientHeight:r.clientHeight,clientWidth:r.clientWidth,paddingTop:d,paddingBottom:f},spacer:{height:w,width:A},host:{top:S,height:x,width:k,paddingTop:R,expectedTop:M,topDrift:T},term:{rows:o.rows,cols:o.cols,bufferLength:g.length,viewportY:g.viewportY,baseY:g.baseY,cursorX:g.cursorX,cursorY:g.cursorY},cell:{h:l,w:u},visibleContentHeight:y,anchor:{atBottom:N.isAtBottom,cursorInViewport:N.cursorInViewport,cursorBufferRow:I,bottomScrollTop:N.bottomScrollTop,scrollTopDeltaToBottom:r.scrollTop-N.bottomScrollTop},intent:{vertical:n.userHasVerticalScrollIntent,horizontal:n.userHasHorizontalScrollIntent},verticalIntent:{mode:n.verticalIntentMode,source:n.verticalIntentSource,transitionId:n.verticalIntentTransitionId},pinned:!n.userHasVerticalScrollIntent,pendingProgrammaticScrollTop:n.pendingProgrammaticScrollTop,pendingFollowCursorScrollTop:n.pendingFollowCursorScrollTop,pendingFollowCursorScrollLeft:n.pendingFollowCursorScrollLeft,prevCursorBufferRow:n.prevCursorBufferRow,lastSeenScrollTop:n.lastSeenScrollTop,lastSeenScrollLeft:n.lastSeenScrollLeft,touchScrollActive:n.touchScrollActive,touchScrollGestureMode:n.touchScrollGestureMode,syncing:{internal:n.syncingInternal,external:n.syncingExternal},pending:{programmaticScrollTop:n.pendingProgrammaticScrollTop,followCursorScrollTop:n.pendingFollowCursorScrollTop,followCursorScrollLeft:n.pendingFollowCursorScrollLeft,containerSyncRetry:n.pendingContainerSyncRetry},expectedSpacerHeight:_,spacerDrift:w-_,lastSpacerUpdateAt:n.lastSpacerUpdateAt,viewportHostCoverage:G,pendingContainerSyncRetry:n.pendingContainerSyncRetry}}const a_={enabled:!1,phase:"idle",error:null,lastSpokenText:"",approvalRequestId:null,activityLevel:0,waveform:[],resumeRequestSeq:0};function bSe(e){return Number.isFinite(e)?Math.max(0,Math.min(1,e)):0}function ko(e,t,n){const r=e.bySessionId[t]??a_;return{bySessionId:{...e.bySessionId,[t]:n(r)}}}const An=Ka()(Ga(e=>({bySessionId:{},enable:t=>e(n=>ko(n,t,r=>({...r,enabled:!0,phase:"starting",error:null,waveform:[]}))),disable:t=>e(n=>ko(n,t,r=>({...r,enabled:!1,phase:"idle",error:null,approvalRequestId:null,activityLevel:0,waveform:[]}))),requestResume:t=>e(n=>ko(n,t,r=>({...r,resumeRequestSeq:r.resumeRequestSeq+1}))),setPhase:(t,n)=>e(r=>ko(r,t,i=>({...i,phase:n,error:n==="error"?i.error:null}))),setError:(t,n)=>e(r=>ko(r,t,i=>({...i,phase:"error",error:n,activityLevel:0,waveform:[]}))),clearError:t=>e(n=>ko(n,t,r=>({...r,error:null,phase:r.enabled&&r.phase==="error"?"starting":r.phase}))),setLastSpokenText:(t,n)=>e(r=>ko(r,t,i=>({...i,lastSpokenText:n}))),setApproval:(t,n)=>e(r=>ko(r,t,i=>({...i,approvalRequestId:n}))),setActivityLevel:(t,n)=>e(r=>ko(r,t,i=>({...i,activityLevel:bSe(n)}))),appendWaveform:(t,n)=>{n.length!==0&&e(r=>ko(r,t,i=>({...i,waveform:[...i.waveform,...n].slice(-P1)})))},clearWaveform:t=>e(n=>ko(n,t,r=>({...r,waveform:[]}))),resetAll:()=>e({bySessionId:{}})}),{name:"voice-pilot-store"}));function _Se(){const[e,t]=b.useState(!1),[n,r]=b.useState(!1),[i,s]=b.useState(!1);b.useEffect(()=>{if(e){r(!1);return}const y=setTimeout(()=>r(!0),300);return()=>clearTimeout(y)},[e]);const o=b.useCallback(()=>{t(!0),s(!1)},[]),l=b.useCallback(()=>{t(!1),s(!1)},[]),u=b.useCallback(()=>{s(!0)},[]),d=b.useCallback(()=>{t(!1),s(!1)},[]),f=b.useMemo(()=>({connecting:n,subscribeDelayed:i}),[n,i]),h=b.useMemo(()=>({onReady:o,onSubscribeStarted:l,onSubscribeDelayed:u}),[o,u,l]);return{ready:e,overlay:f,transport:h,markDisconnected:d}}const wSe=900;function LL(e,t=document.activeElement){return e?t===null||t===document.body||t===document.documentElement||e.contains(t)||t.closest('[data-slot="pty-host"], [data-slot="session-row-select"]')!==null:!1}function xSe(){var t;const e=navigator.virtualKeyboard;(t=e==null?void 0:e.show)==null||t.call(e)}function SSe(e){const{containerEl:t,xtermHostRef:n,terminalRef:r}=e,[i,s]=b.useState(!1),o=b.useRef(0),l=b.useCallback(()=>{const g=document.activeElement;!t||!(g instanceof HTMLElement)||!t.contains(g)||g.blur()},[t]),u=b.useCallback(()=>{const g=n.current,_=document.activeElement,w=!!(g&&_ instanceof HTMLElement&&g.contains(_));s(w),w&&xSe()},[n]),d=b.useCallback((g={})=>{o.current=performance.now()+wSe,(g.blur??!0)&&(l(),s(!1))},[l]),f=b.useCallback(g=>{if(performance.now()<=o.current){g.target instanceof HTMLElement&&g.target.blur(),window.setTimeout(u,0);return}u()},[u]),h=b.useCallback(()=>{window.setTimeout(u,0)},[u]),y=b.useCallback(()=>{var g;o.current=0,(g=r.current)==null||g.focus(),window.setTimeout(u,0)},[u,r]);return{ptyInputFocused:i,suppressPtyFocus:d,focusPtyInput:y,handleFocusCapture:f,handleBlurCapture:h}}function ESe(){const[e,t]=b.useState(!0),[n,r]=b.useState(!1),i=b.useRef(n);b.useEffect(()=>{i.current=n},[n]);const s=b.useCallback(l=>{t(l),l&&r(!1)},[]),o=b.useCallback(()=>{r(!1)},[]);return{isAtBottom:e,hasNewFramesWhileAway:n,hasNewFramesWhileAwayRef:i,setHasNewFramesWhileAway:r,handleAtBottomChange:s,clearNewFramesWhileAway:o}}const CSe=28,kSe=14;function Dv(e,t,n){const r=Math.min(1,Math.max(0,1-e/t));return Math.ceil(n*r)}function uH({pointerX:e,pointerY:t,rect:n,scrollLeft:r,scrollTop:i,scrollWidth:s,scrollHeight:o,clientWidth:l,clientHeight:u,edgePx:d=CSe,maxSpeedPx:f=kSe}){let h=0;const y=e-n.left,g=n.right-e;if(y<d&&r>0)h=-Dv(y,d,f);else if(g<d){const x=Math.max(0,s-l);r<x&&(h=Dv(g,d,f))}let _=0;const w=t-n.top,S=n.bottom-t;if(w<d&&i>0)_=-Dv(w,d,f);else if(S<d){const x=Math.max(0,o-u);i<x&&(_=Dv(S,d,f))}return{dx:h,dy:_}}const TSe=new Intl.Segmenter("zh-CN",{granularity:"word"}),RSe=/^[./:@_+~=-]+$/u,ASe=/[a-z0-9]/iu;function dH({terminal:e,host:t,cellWidth:n,cellHeight:r}){if(n&&r)return{cellW:n,cellH:r};const i=t.querySelector(".xterm-screen"),s=i==null?void 0:i.getBoundingClientRect();return s&&s.width>0&&s.height>0&&e.cols>0&&e.rows>0?{cellW:s.width/e.cols,cellH:s.height/e.rows}:o_(t,e)}function pu(e,t){var r;let n=t;for(;n>0&&((r=e==null?void 0:e.getCell(n))==null?void 0:r.getWidth())===0;)n-=1;return n}function DL(e,t,n){var s;const r=pu(e,t),i=Math.max(1,((s=e==null?void 0:e.getCell(r))==null?void 0:s.getWidth())??1);return Math.min(n,r+i)}function BL(e,t,n){const r=nb(t,n.row)??e.buffer.active.getLine(n.row);return{...n,column:pu(r,n.column)}}function NSe(e,t){const n=Math.min(e.length,t),r=[];let i="";for(let o=0;o<n;o+=1){const l=e.getCell(o),u=(l==null?void 0:l.getWidth())??1;if(u===0)continue;const d=(l==null?void 0:l.getChars())||" ",f=i.length;i+=d,r.push({textStart:f,textEnd:i.length,cellStart:o,cellEnd:Math.min(n-1,o+Math.max(1,u)-1)})}const s=e.translateToString(!0,0,n);return{text:i.slice(0,s.length),spans:r.filter(o=>o.textStart<s.length)}}function zL(e){return RSe.test(e.segment)}function jE(e){return e.isWordLike===!0&&ASe.test(e.segment)}function MSe(e,t){let n=t,r=t;for(;n>0;){let o=n-1;for(;o>=0&&zL(e[o]);)o-=1;if(o===n-1)break;if(o>=0&&jE(e[o])){n=o;continue}n=o+1;break}for(;r+1<e.length;){let o=r+1;for(;o<e.length&&zL(e[o]);)o+=1;if(o===r+1||o>=e.length||!jE(e[o]))break;r=o}const i=e[n].index,s=e[r];return{start:i,end:s.index+s.segment.length}}function PSe(e){const t=Array.from(TSe.segment(e)),n=[],r=new Set,i=s=>{const o=`${s.start}:${s.end}`;r.has(o)||(r.add(o),n.push(s))};for(let s=0;s<t.length;s+=1){const o=t[s];o.isWordLike&&i(jE(o)?MSe(t,s):{start:o.index,end:o.index+o.segment.length})}for(const s of t){if(s.isWordLike||!s.segment.trim())continue;const o={start:s.index,end:s.index+s.segment.length};n.some(l=>l.start<=o.start&&l.end>=o.end)||i(o)}return n.sort((s,o)=>s.start-o.start||s.end-o.end)}function ISe(e,t){return e.row<t.row||e.row===t.row&&e.column<=t.column?{start:e,end:t}:{start:t,end:e}}function OSe(e,t,n,r=!1){if(r){const s=Math.min(t.row,n.row),o=Math.max(t.row,n.row),l=Math.min(t.column,n.column),u=Math.max(t.column,n.column),d=[];for(let f=s;f<=o;f+=1){const h=e.buffer.active.getLine(f);if(!h)continue;const y=pu(h,l),g=DL(h,u,e.cols);d.push(h.translateToString(!0,y,g).replace(/\u00a0/g," "))}return d.join(`
733
733
  `)}const i=[];for(let s=t.row;s<=n.row;s+=1){const o=e.buffer.active.getLine(s);if(!o)continue;const l=s===t.row?pu(o,t.column):0,u=s===n.row?DL(o,n.column,e.cols):e.cols,d=o.translateToString(!0,l,u).replace(/\u00a0/g," ");s>t.row&&o.isWrapped&&i.length>0?i[i.length-1]+=d:i.push(d)}return i.join(`
734
734
  `)}function l_({terminal:e,anchor:t,focus:n,columnMode:r=!1}){if(t.row<0||n.row<0||t.row>=e.buffer.active.length||n.row>=e.buffer.active.length||t.column<0||n.column<0||t.column>=e.cols||n.column>=e.cols)return null;const i={...t,column:pu(e.buffer.active.getLine(t.row),t.column)},s={...n,column:pu(e.buffer.active.getLine(n.row),n.column)},{start:o,end:l}=ISe(i,s),u=OSe(e,r?i:o,r?s:l,r);return{anchor:i,focus:s,text:u,columnMode:r}}function LSe({terminal:e,host:t,clientX:n,clientY:r,cellWidth:i,cellHeight:s,clampToBuffer:o=!1}){const l=t.querySelector(".xterm-screen");if(!l)return null;const u=dH({terminal:e,host:t,cellWidth:i,cellHeight:s});if(!(u!=null&&u.cellW)||!u.cellH)return null;const d=l.getBoundingClientRect(),f=uT(t),h=f==null?void 0:f.element.getBoundingClientRect(),y=(f==null?void 0:f.startLine)??e.buffer.active.viewportY,g=(h==null?void 0:h.top)??d.top,_=y+Math.floor((r-g)/u.cellH),w=Math.floor((n-d.left)/u.cellW);if(o)return e.buffer.active.length<=0||e.cols<=0?null:BL(e,t,{row:Math.max(0,Math.min(e.buffer.active.length-1,_)),column:Math.max(0,Math.min(e.cols-1,w))});if(w<0||w>=e.cols)return null;if(f&&h){const S=h.top+(f.endLine-f.startLine+1)*u.cellH,x=d.top+e.rows*u.cellH,k=r>=h.top&&r<S,R=r>=d.top&&r<x;if(!k&&!R)return null}else{const S=Math.floor((r-d.top)/u.cellH);if(S<0||S>=e.rows)return null}return _<0||_>=e.buffer.active.length?null:BL(e,t,{row:_,column:w})}function jL({terminal:e,host:t,point:n,affinity:r="before",cellWidth:i,cellHeight:s,getLine:o}){var S;const l=t.querySelector(".xterm-screen");if(!l)return null;const u=dH({terminal:e,host:t,cellWidth:i,cellHeight:s});if(!(u!=null&&u.cellW)||!u.cellH)return null;const d=n.row-e.buffer.active.viewportY;if(n.row<0||n.row>=e.buffer.active.length||n.column<0||n.column>=e.cols)return null;const f=l.getBoundingClientRect(),h=(o==null?void 0:o(n.row))??e.buffer.active.getLine(n.row),y=pu(h,n.column),g=Math.max(1,((S=h==null?void 0:h.getCell(y))==null?void 0:S.getWidth())??1),_=r==="after"?y+g:y,w=uT(t);if(w){const x=w.element.getBoundingClientRect();return{left:f.left+_*u.cellW,top:x.top+(n.row-w.startLine+1)*u.cellH}}return{left:f.left+_*u.cellW,top:f.top+(d+1)*u.cellH}}function aS({terminal:e,point:t}){var y,g;const n=e.buffer.active;if(!n.getLine(t.row))return null;let r=t.row,i=t.row;for(;r>0&&((y=n.getLine(r))!=null&&y.isWrapped);)r-=1;for(;i+1<n.length&&((g=n.getLine(i+1))!=null&&g.isWrapped);)i+=1;const s=[];let o="";for(let _=r;_<=i;_+=1){const w=n.getLine(_);if(!w)continue;const{text:S,spans:x}=NSe(w,e.cols),k=o.length;o+=S,s.push(...x.map(R=>({...R,row:_,textStart:R.textStart+k,textEnd:R.textEnd+k})))}const l=s.find(_=>_.row===t.row&&t.column>=_.cellStart&&t.column<=_.cellEnd);if(!l)return null;let u=PSe(o).find(_=>_.start<l.textEnd&&_.end>l.textStart);if(!u){const _=s.indexOf(l),w=o.slice(l.textStart,l.textEnd);if(_<0||w.trim().length>0)return null;let S=_,x=_;for(;S>0&&o.slice(s[S-1].textStart,s[S-1].textEnd).trim().length===0;)S-=1;for(;x+1<s.length&&o.slice(s[x+1].textStart,s[x+1].textEnd).trim().length===0;)x+=1;u={start:s[S].textStart,end:s[x].textEnd}}const d=s.filter(_=>_.textStart<u.end&&_.textEnd>u.start),f=d[0],h=d.at(-1);return!f||!h?null:l_({terminal:e,anchor:{row:f.row,column:f.cellStart},focus:{row:h.row,column:h.cellEnd}})}function DSe({terminal:e,point:t}){var s,o;const n=e.buffer.active;if(!n.getLine(t.row))return null;let r=t.row,i=t.row;for(;r>0&&((s=n.getLine(r))!=null&&s.isWrapped);)r-=1;for(;i+1<n.length&&((o=n.getLine(i+1))!=null&&o.isWrapped);)i+=1;return l_({terminal:e,anchor:{row:r,column:0},focus:{row:i,column:Math.max(0,e.cols-1)}})}function lS({terminal:e,point:t}){const n=t.row+1,r=t.column+1,i=[...tH(e,n).map(o=>({match:o,pathAction:{kind:"image-preview",path:o.path}})),...iH(e,n).map(o=>({match:o,pathAction:{kind:"file-download",path:o.path}}))].find(({match:o})=>!(n<o.startLineNumber||n>o.endLineNumber||n===o.startLineNumber&&r<o.startColumn||n===o.endLineNumber&&r>o.endColumn));if(!i)return null;const s=l_({terminal:e,anchor:{row:i.match.startLineNumber-1,column:i.match.startColumn-1},focus:{row:i.match.endLineNumber-1,column:i.match.endColumn-1}});return s?{...s,pathAction:i.pathAction}:null}const c_={phase:"idle"};function BSe(){return c_}function Wi(e){switch(e.phase){case"idle":return null;case"pressed":return e.resolvedPressRange??e.selectionBeforePress;case"selecting":case"selected":case"handle-drag":return e.range}}function FE(e){return(e.phase==="selecting"||e.phase==="handle-drag"&&e.hasRealMovement)&&Fa(e.range.anchor)}function Fa(e){return e!==null&&Number.isInteger(e.row)&&e.row>=0&&Number.isInteger(e.column)&&e.column>=0}function cS(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)}function Uh(e){return Fa(e.anchor)&&Fa(e.focus)}function $a(e){return{row:e.row,column:e.column}}function vd(e){return{x:e.x,y:e.y}}function Dl(e){return{anchor:$a(e.anchor),focus:$a(e.focus),columnMode:e.columnMode}}function za(e,t){if(!Number.isInteger(t))return null;const n=e.anchor.row+t,r=e.focus.row+t;return n<0||r<0?null:{anchor:{...e.anchor,row:n},focus:{...e.focus,row:r},columnMode:e.columnMode}}function zSe(e,t){if(!e)return null;const n=e.row+t;return n<0?null:{...e,row:n}}function jSe(e,t){if(!Number.isInteger(t)||t===0||e.phase==="idle")return e;if(e.phase==="selected")return Yl(za(e.range,t));if(e.phase==="pressed"){const i=zSe(e.press.bufferPoint,t),s=e.selectionBeforePress?za(e.selectionBeforePress,t):null,o=e.resolvedPressRange?za(e.resolvedPressRange,t):null;return e.press.bufferPoint&&!i?Yl(s):{...e,press:{...e.press,bufferPoint:i},selectionBeforePress:s,resolvedPressRange:o}}if(e.phase==="selecting"){const i=e.selectionBeforePress?za(e.selectionBeforePress,t):null,s=za(e.range,t);return s?{...e,selectionBeforePress:i,range:s}:Yl(i)}const n=za(e.rangeBeforeDrag,t),r=za(e.range,t);return r&&n?{...e,rangeBeforeDrag:n,range:r}:Yl(n)}function Bv(e,t){return e.x!==t.x||e.y!==t.y}function Yl(e){return e?{phase:"selected",range:Dl(e)}:c_}function FL(e,t,n){return t==="anchor"?{anchor:$a(n),focus:e.focus,columnMode:e.columnMode}:{anchor:e.anchor,focus:$a(n),columnMode:e.columnMode}}function uS(e,t){switch(e.phase){case"pressed":return e.press.pointerId===t;case"selecting":case"handle-drag":return e.pointerId===t;case"idle":case"selected":return!1}}function FSe(e,t){if(t==="clear-on-click")return c_;if(t==="preserve-selection")switch(e.phase){case"pressed":case"selecting":return Yl(e.selectionBeforePress);case"handle-drag":return Yl(e.rangeBeforeDrag);case"idle":case"selected":return e}switch(e.phase){case"pressed":return Yl(e.resolvedPressRange??e.selectionBeforePress);case"selecting":case"handle-drag":return Yl(e.range);case"idle":case"selected":return e}}function La(e,t){var n,r;switch(t.type){case"pointer-press":{if(e.phase!=="idle"&&e.phase!=="selected"||!Number.isFinite(t.candidate.pointerId)||!cS(t.candidate.client))return e;const i=e.phase==="selected"?Dl(e.range):null;return{phase:"pressed",press:{pointerId:t.candidate.pointerId,client:vd(t.candidate.client),bufferPoint:Fa(t.candidate.bufferPoint)?$a(t.candidate.bufferPoint):null,columnMode:t.candidate.columnMode},selectionBeforePress:i,resolvedPressRange:null}}case"resolve-press-range":return e.phase!=="pressed"||e.press.pointerId!==t.pointerId||!e.press.bufferPoint||!Uh(t.range)?e:{...e,resolvedPressRange:Dl(t.range)};case"pointer-move":{if(!cS(t.client)||!uS(e,t.pointerId))return e;if(e.phase==="pressed"){if(!Bv(e.press.client,t.client))return e;const i=((n=e.resolvedPressRange)==null?void 0:n.anchor)??e.press.bufferPoint;if(!Fa(i)||!Fa(t.bufferPoint))return e;const s=t.range&&Uh(t.range)?Dl(t.range):null;return{phase:"selecting",pointerId:e.press.pointerId,pressClient:e.press.client,lastClient:vd(t.client),selectionBeforePress:e.selectionBeforePress,range:s??{anchor:$a(i),focus:$a(t.bufferPoint),columnMode:((r=e.resolvedPressRange)==null?void 0:r.columnMode)??e.press.columnMode}}}if(e.phase==="selecting")return Bv(e.lastClient,t.client)?{...e,lastClient:vd(t.client),range:t.range&&Uh(t.range)?Dl(t.range):Fa(t.bufferPoint)?{anchor:e.range.anchor,focus:$a(t.bufferPoint),columnMode:e.range.columnMode}:e.range}:e;if(e.phase==="handle-drag"){if(!Bv(e.lastClient,t.client))return e;const i=e.hasRealMovement||Bv(e.pressClient,t.client);return{...e,lastClient:vd(t.client),hasRealMovement:i,range:i&&Fa(t.bufferPoint)?FL(e.range,e.handle,t.bufferPoint):e.range}}return e}case"selection-autoscroll":return!uS(e,t.pointerId)||!FE(e)||!Fa(t.bufferPoint)?e:e.phase==="selecting"?{...e,range:t.range&&Uh(t.range)?Dl(t.range):{anchor:e.range.anchor,focus:$a(t.bufferPoint),columnMode:e.range.columnMode}}:e.phase==="handle-drag"?{...e,range:FL(e.range,e.handle,t.bufferPoint)}:e;case"handle-drag-start":{if(e.phase!=="selected"||!Number.isFinite(t.pointerId)||!cS(t.client))return e;const i=Dl(e.range);return{phase:"handle-drag",pointerId:t.pointerId,handle:t.handle,pressClient:vd(t.client),lastClient:vd(t.client),hasRealMovement:!1,rangeBeforeDrag:i,range:i}}case"gesture-finish":return uS(e,t.pointerId)?FSe(e,t.result):e;case"viewport-scroll":return e;case"set-selection":return Uh(t.range)?{phase:"selected",range:Dl(t.range)}:e;case"clear-selection":return c_}}function $L(e,t,n){return t>n?(t+n)/2:Math.min(Math.max(e,t),n)}const $Se=64;function fH({clientX:e,clientY:t,viewportWidth:n,viewportHeight:r,viewportOffsetLeft:i=0,viewportOffsetTop:s=0}){const o=i+56,l=i+n-56,u=s+56,d=s+r-$Se;return{left:$L(e,o,l),top:$L(t-48,u,d)}}function HSe({hasManagedSelection:e,eventType:t,pointerType:n,targetIsScrollSurface:r}){return!e||!r?!1:t==="touchstart"?!0:t!=="pointerdown"?!1:n==="touch"||n==="pen"||n==="mouse"}function USe(e){return e==="tap"||e==="link"}function WSe(e){return{visualSize:Math.round(Math.min(12,Math.max(8,e*.55))),stemSize:Math.round(Math.min(11,Math.max(7,e*.5))),touchSize:44}}function qSe({terminal:e,host:t,coordinateSpace:n,anchor:r,focus:i,columnMode:s=!1,getLine:o}){const l=s?r.column<=i.column:r.row<i.row||r.row===i.row&&r.column<=i.column,u=jL({terminal:e,host:t,point:r,affinity:l?"before":"after",getLine:o}),d=jL({terminal:e,host:t,point:i,affinity:l?"after":"before",getLine:o});if(!u||!d)return null;if(!n)return{anchor:u,focus:d};const f=n.getBoundingClientRect(),h=y=>({left:y.left-f.left,top:y.top-f.top});return{anchor:h(u),focus:h(d)}}function VSe({handles:e,viewportWidth:t,viewportHeight:n,viewportOffsetLeft:r=0,viewportOffsetTop:i=0}){return fH({clientX:(e.anchor.left+e.focus.left)/2,clientY:Math.min(e.anchor.top,e.focus.top),viewportWidth:t,viewportHeight:n,viewportOffsetLeft:r,viewportOffsetTop:i})}const YSe=/\.(?:png|jpe?g|webp|gif)$/i,hH=/\.[\p{L}\p{N}]{1,16}$/u;function KSe(e){return e.trim().replace(/^@/,"").replace(/^[([{]+/,"").replace(/[)\].,;:!?,。;:!?、]+$/u,"")}function GSe(e){const t=e.trim();if(!t||t.includes(`
@@ -736,7 +736,7 @@ WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){t
736
736
  `:"\r":e.key==="Backspace"?"":e.key==="Tab"?e.shiftKey?"\x1B[Z":" ":e.key==="Escape"?"\x1B":e.key==="ArrowUp"?bp("\x1B[A",t):e.key==="ArrowDown"?bp("\x1B[B",t):e.key==="ArrowRight"?bp("\x1B[C",t):e.key==="ArrowLeft"?bp("\x1B[D",t):e.key==="Delete"?"\x1B[3~":e.key==="Home"?"\x1B[H":e.key==="End"?"\x1B[F":null}function E1e(e){const{sessionId:t,active:n=!0,containerEl:r,spacerRef:i,xtermHostRef:s,selectionHandleLayerRef:o,mobileControlsHeight:l}=e,u=_Se(),d=u.markDisconnected,f=ESe(),h=d1e(),{openImagePreview:y}=Wk(),g=b.useRef(null),_=b.useRef([]),w=b.useRef(null),S=b.useRef(null),x=b.useRef(!1),k=b.useRef([]),R=b.useRef(null),A=b.useRef(null),M=b.useRef(n),T=b.useRef(n),P=b.useRef(!1),z=b.useRef(!1),Y=b.useRef(!1),U=b.useRef(!1),G=b.useRef(null),I=b.useRef(null),N=b.useRef(null),L=b.useRef(null),B=b.useRef({keyboardOpen:!1,controlsVisible:!1}),O=b.useRef(!1),D=b.useRef(!1),F=b.useRef(!1),V=b.useRef({keyboardOffset:0,hasSeenSoftKeyboard:!1,showMobilePtyControls:!1,touchEditingSurface:!1,ptyInputFocused:!1,containerPaddingBottom:0,mobileControlsBottomInset:0}),[j,q]=b.useState({scrollTop:0,scrollLeft:0,scrollHeight:0,scrollWidth:0,clientHeight:0,clientWidth:0,scrollable:!1,horizontalScrollable:!1}),[K,$]=b.useState(!1),[te,J]=b.useState(!1),[ne,Q]=b.useState({resultIndex:-1,resultCount:0}),ce=Me(Ie=>Ie.connected),re=Me(Ie=>Ie.proxyOnline),le=Me(Ie=>Ie.ptyFontSize),we=Me(Ie=>Ie.inputModePreference),Ce=Me(Ie=>Ie.adaptiveInputModality),ye=Me(Ie=>Ie.setAdaptiveInputModality),Re=Ce==="hardware",Rt=yo("(pointer: coarse), (hover: none)"),{bottomOffset:Ke,layoutBottomInset:et}=yT(),$e=we==="hardware",Fe=b1e({touchEditingSurface:Rt,inputModePreference:we,detectedPhysicalKeyboard:Re,softKeyboardDetected:Ke>0}),xt=Rt&&!Fe,_t=Fe?0:Ke,st=_t>0,Ae=Fe?0:et,[ut,mt]=b.useState(()=>ce&&re);O.current=Fe,M.current=n,P.current=u.ready,z.current=ce&&re;const ge=b.useCallback(()=>M.current&&P.current&&z.current,[]),Ye=b.useCallback(Ie=>{const We=Ut.getState().sessions.find(Oe=>Oe.sessionId===t);if((We==null?void 0:We.mode)!=="pty"||We.ptyOwner!=="proxy-hosted")return;const ot=g.current,St=s.current,Se=$t;if(!ge()||!ot||!St||!r||!Se){Ue.error("终端尚未就绪");return}const ct=_.current.at(-1)??ot,wt=Ie==="fit"?Fwe(r,St,ot):jwe(ct,Ie);if(!wt){Ue.error("无法获取终端显示区域的尺寸");return}wt.cols===ct.cols&&wt.rows===ct.rows||(Se.sendControl({type:"terminal_resize_request",sessionId:t,...wt})?(_.current.push(wt),Ut.getState().setPtyGeometry(t,wt)):Ue.error("终端尺寸调整失败,请检查连接"))},[ge,r,t,s]);b.useEffect(()=>{(!n||!u.ready||!ce||!re)&&(_.current=[]);const Ie=_.current.at(-1)??g.current;Ut.getState().setPtyGeometry(t,u.ready&&ce&&re&&Ie?{cols:Ie.cols,rows:Ie.rows}:null)},[n,u.ready,ce,re,t]),b.useEffect(()=>{ce&&re&&mt(!0)},[ce,re]),b.useEffect(()=>{_t>0&&$(!0)},[_t]);const ve=SSe({containerEl:r,xtermHostRef:s,terminalRef:g}),{ptyInputFocused:Je,suppressPtyFocus:dt,focusPtyInput:Ot,handleFocusCapture:Lt,handleBlurCapture:sn}=ve,Gt=v1e({softKeyboardEditingSurface:xt,ptyInputFocused:Je,keyboardOpen:st});V.current={keyboardOffset:_t,hasSeenSoftKeyboard:K,showMobilePtyControls:Gt,touchEditingSurface:Rt,ptyInputFocused:Je,containerPaddingBottom:V.current.containerPaddingBottom,mobileControlsBottomInset:Ae};const on=f.clearNewFramesWhileAway;I.current||(I.current=NL(()=>{var Ie;(Ie=A.current)==null||Ie.relayout()}));const Ct=b.useCallback(()=>{F.current=!1},[]);N.current||(N.current=NL(()=>{var We,ot;const Ie=L.current??{reason:"rawInput",force:!1};L.current=null,Ie.force&&Ct(),(We=A.current)==null||We.traceRawInputFollowFire(),(ot=A.current)==null||ot.scrollToBottom(Ie.reason,Ie.force?{force:!0}:void 0),on()}));const gn=b.useCallback(()=>{if(F.current)return;const Ie=A.current;Ie&&Ie.preparePageResumeRestore(),F.current=!0},[]),zt=b.useCallback(()=>{if(!F.current||document.visibilityState==="hidden"||!M.current||!P.current)return;const Ie=A.current;Ie&&(Ie.restorePageResume(),on(),F.current=!1)},[on]);b.useEffect(()=>()=>{var Ie,We;(Ie=I.current)==null||Ie.dispose(),(We=N.current)==null||We.dispose(),I.current=null,N.current=null},[]),b.useEffect(()=>{const Ie=()=>{gn()},We=()=>{if(document.visibilityState==="hidden"){Ie();return}zt()};return document.addEventListener("visibilitychange",We),window.addEventListener("pagehide",Ie),window.addEventListener("pageshow",zt),window.addEventListener("focus",zt),()=>{document.removeEventListener("visibilitychange",We),window.removeEventListener("pagehide",Ie),window.removeEventListener("pageshow",zt),window.removeEventListener("focus",zt)}},[gn,zt]),b.useLayoutEffect(()=>{const Ie=T.current;if(T.current=n,!n){Ie&&gn();return}(!Ie||F.current)&&u.ready&&zt()},[n,u.ready,gn,zt]);const nn=b.useCallback((Ie="rawInput",We)=>{var Se,ct;const ot=L.current,St=(ot==null?void 0:ot.force)===!0||(We==null?void 0:We.force)===!0;L.current={reason:(We==null?void 0:We.force)===!0||!ot?Ie:ot.reason,force:St},(Se=A.current)==null||Se.traceRawInputFollowScheduled(Ie),(ct=N.current)==null||ct.schedule()},[]),En=b.useCallback((Ie,We)=>{var ot,St;!Ie||wL(Ie)||((ot=A.current)==null||ot.resumeHorizontalCursorFollow(We),!(!Ie.includes("\r")&&!Ie.includes(`
737
737
  `))&&((St=A.current)==null||St.resetHorizontalScroll(We,{holdUntilCursorVisible:!0})))},[]),Fn=b.useCallback(()=>O.current?"submit":"linefeed",[]),Xn=b.useCallback(()=>O.current,[]);b.useEffect(()=>{if(!n||we!=="auto"||!Rt)return;const Ie=ot=>{const St=s.current,Se=r;return ot instanceof Node?St!=null&&St.contains(ot)||ot===document.body||ot===document.documentElement?!0:Se!=null&&Se.contains(ot)?ot instanceof HTMLElement?ot.closest('a,button,input,textarea,select,[contenteditable="true"],[role="button"],[role="textbox"]')===null:!0:!1:ot===window},We=ot=>{var ct,wt;if(!_1e({active:M.current,touchEditingSurface:Rt,key:ot.key,code:ot.code,altKey:ot.altKey,ctrlKey:ot.ctrlKey,metaKey:ot.metaKey,isComposing:ot.isComposing,targetAcceptsPtyInput:Ie(ot.target)}))return;ye("hardware"),O.current=!0,(ct=g.current)==null||ct.focus();const St=s.current;if(ot.target instanceof Node&&(St!=null&&St.contains(ot.target)))return;const Se=S1e(ot,(wt=g.current)==null?void 0:wt.modes);!Se||!ge()||(ot.preventDefault(),ot.stopPropagation(),Mo(t,Se),nn("physicalKeyboard"),En(Se,"physicalKeyboardEnter"))};return window.addEventListener("keydown",We,!0),()=>window.removeEventListener("keydown",We,!0)},[n,ge,r,we,En,nn,t,ye,Rt,s]);const Nn=b.useCallback(Ie=>{const We=$t;if(!We){Ue.error("请先连接开发机");return}const ot=Ue.loading(`下载 ${Ie} ...`);Uk({relay:We,sessionId:t,path:Ie}).then(St=>{St.ok?Ue.success(`已开始下载 ${Ie}`,{id:ot}):Ue.error(St.error,{id:ot})}).catch(St=>{Ue.error(St instanceof Error?St.message:String(St),{id:ot})})},[t]),W=b.useCallback(Ie=>{const We=g.current;return We?Z0e(We,k.current,Ie):!1},[]),ie=b.useCallback(Ie=>{const We=g.current;return We?X0e(We,k.current,Ie):!1},[]),oe=u1e({terminalRef:g,xtermHostRef:s,selectionHandleLayerRef:o,scrollControllerRef:A,containerEl:r,keyboardOffset:_t,ptyFontSize:le,suppressPtyFocus:dt,focusPtyInput:Ot,onTap:W,isTapCandidate:ie,onDownloadPath:Nn,onPreviewPath:y}),ue=oe.clearManagedPtySelection,be=oe.clearPtySelection;D.current=oe.hasPtySelection();const X=b.useCallback(()=>{const Ie=g.current,We=S.current,ot=x.current&&Ie?yL(Ie.getSelectionPosition(),Ie.cols):null;We==null||We.render(ot)},[]),se=m1e({sessionId:t,terminalRef:g,onAfterPaste:()=>nn("paste")}),de=b.useCallback(Ie=>{if(!ge()){Ie.preventDefault();return}se(Ie)},[ge,se]),[pe,Z]=b.useState(!1),ae=b.useCallback(Ie=>{Ie.dataTransfer.types.includes("Files")&&(Ie.preventDefault(),Z(We=>We||!0))},[]),fe=b.useCallback(Ie=>{Ie.currentTarget.contains(Ie.relatedTarget)||Z(!1)},[]),Be=b.useCallback(async Ie=>{var Se,ct;const We=(Se=Ie.dataTransfer.files)==null?void 0:Se[0];if(!We||(Ie.preventDefault(),Z(!1),!ge()))return;const ot=$t;if(!ot){Ue.error("请先连接开发机");return}const St=await em({relay:ot,sessionId:t,file:We});St&&(Mo(t,`@${St} `),(ct=A.current)==null||ct.resumeHorizontalCursorFollow("dropUpload"),nn("dropUpload"))},[ge,nn,t]),Ge=b.useCallback(Ie=>{var ot;if(!ge()){Ie.preventDefault();return}const We=Ie.target;We instanceof Element&&We.closest(".xterm")||(Ie.preventDefault(),(ot=g.current)==null||ot.focus())},[ge]);b.useEffect(()=>{if(!ut)return;const Ie=s.current,We=Ua,ot=$t,St=r,Se=i.current;if(!Ie||!We||!ot||!St||!Se)return;let ct=null,wt=null,Oe=null,ht=null,Dt=null,an=null,dn=null,Ht=null,wn=null;const it=d0e({host:Ie,sessionId:t,ws:We,relay:ot,scheduleAutoFocus:xt?()=>{}:rt=>{requestAnimationFrame(()=>{LL(s.current)&&rt()})},createTerminal:async rt=>{const gt=await B6(rt,{fontSize:Me.getState().ptyFontSize});return wn=gt.serializeAddon,gt},attachRawInput:(rt,gt,Mt)=>yxe(rt,gt,{...Mt,getPlainEnterBehavior:Fn,isPhysicalKeyboardMode:Xn,physicalKeyboardMode:$e}),isInputEnabled:ge,canFocus:ge,onTerminalReady:rt=>{be();const gt=rt;g.current=gt,_.current=[],dn=gt.onResize(({cols:Zn,rows:_i})=>{const qt=_.current,Jr=qt.findIndex(yr=>yr.cols===Zn&&yr.rows===_i);_.current=Jr>=0?qt.slice(Jr+1):[],P.current&&z.current&&Ut.getState().setPtyGeometry(t,_.current.at(-1)??{cols:Zn,rows:_i})});const Mt=new cve({highlightLimit:1e3});gt.loadAddon(Mt),w.current=Mt,Dt=Mt.onDidChangeResults(Zn=>{Q(Zn),X()}),J(!0);const Jn=A0e(gt,y);ct=Jn.dispose;const Dn=U0e(gt,Nn);wt=Dn.dispose,k.current=[Jn.provider,Dn.provider],pSe(()=>g.current);const Yr=$we(gt),bi=Gwe(Ie,{serializeRangeAsHtml:(Zn,_i)=>(wn==null?void 0:wn.serializeAsHTML({range:{startLine:Zn,endLine:Math.min(_i,Math.max(0,gt.buffer.active.length-1)),startCol:0},includeGlobalBackground:!0,onlySelection:!1,scrollback:0}))??"",getSerializedCell:(Zn,_i)=>{var Jr;const qt=(Jr=gt.buffer.active.getLine(Zn))==null?void 0:Jr.getCell(_i);return qt?{text:qt.getWidth()===0?"":qt.getChars()||" ",isDim:!!qt.isDim(),isRenderedFgRGB:qt.isInverse()?qt.isBgRGB():qt.isFgRGB()}:null},getSelectionLine:Zn=>gt.buffer.active.getLine(Zn)??null,getBufferRowIdentityOffset:Yr.getOffset});ht=()=>{bi.dispose(),Yr.dispose()};const ui=F.current;ui&&(U.current=!1);const ar=n0e({container:St,spacer:Se,host:Ie,term:gt,hasNewFrame:()=>Y.current,consumeNewFrame:()=>{Y.current=!1},hasNewFramesWhileAway:()=>f.hasNewFramesWhileAwayRef.current,setNewFramesWhileAway:f.setHasNewFramesWhileAway,onAtBottomChange:f.handleAtBottomChange,onScrollStateChange:q,initialUserHasVerticalScrollIntent:ui?!1:U.current,onUserVerticalScrollIntentChange:Zn=>{U.current=Zn},onTouchReviewStart:dt,onHistoryProjectionChange:Zn=>{const _i=bi.render(Zn);return _i&&X(),_i},getBufferRowIdentityOffset:Yr.getOffset});A.current=ar,Oe=ar.dispose,Ht=U6({terminal:gt,container:St,getLine:Zn=>nb(Ie,Zn)??gt.buffer.active.getLine(Zn)??null,resolveRange:()=>x.current?yL(gt.getSelectionPosition(),gt.cols):null,projectionOnly:!0,overlaySlot:"pty-search-selection-overlay",segmentSlot:"pty-search-selection-segment",selectionBackground:LE.activeMatchBackground,borderColor:LE.activeMatchBorder,opacity:"0.62"}),S.current=Ht,an=gt.onSelectionChange(X),X(),ui&&(ar.restorePageResume(),on(),F.current=!1),gSe(()=>{var xo;const Zn=Ys=>{if(!Ys)return null;const Ks=Ys.getBoundingClientRect();return{top:Ks.top,bottom:Ks.bottom,height:Ks.height,left:Ks.left,right:Ks.right,width:Ks.width}},_i=document.querySelector('[data-slot="pty-mobile-controls"]'),qt=document.querySelector("[data-keyboard-offset]"),Jr=window.visualViewport,yr=Zn(_i),rr=(Jr==null?void 0:Jr.height)??window.innerHeight;return{...ySe(ar.getDebugProbe,{container:St,spacer:Se,host:Ie,term:gt}),mobileLayout:{...V.current,window:{innerHeight:window.innerHeight,outerHeight:window.outerHeight,documentClientHeight:document.documentElement.clientHeight},visualViewport:Jr?{height:Jr.height,width:Jr.width,offsetTop:Jr.offsetTop,pageTop:Jr.pageTop,scale:Jr.scale}:null,chatRoot:{dataKeyboardOffset:(qt==null?void 0:qt.getAttribute("data-keyboard-offset"))??null,rect:Zn(qt)},ptyViewRect:Zn(St.parentElement),containerRect:Zn(St),controlsRect:yr,controlsOverflowBelowVisualViewport:yr===null?null:yr.bottom-rr,activeElement:document.activeElement instanceof HTMLElement?{tag:document.activeElement.tagName,ariaLabel:document.activeElement.getAttribute("aria-label"),slot:(xo=document.activeElement.closest("[data-slot]"))==null?void 0:xo.getAttribute("data-slot")}:null},frame:{lastWriteAt:G.current,pendingNewFrame:Y.current}}})},onFramePending:()=>{var rt;Y.current=!0,(rt=A.current)==null||rt.markHorizontalLiveFramePending(),U.current&&!f.hasNewFramesWhileAwayRef.current&&f.setHasNewFramesWhileAway(!0)},onFrameWritten:()=>{var rt;G.current=performance.now(),(rt=I.current)==null||rt.schedule()},onRawInput:rt=>{wL(rt)||(nn("rawInput",{force:!0}),En(rt,"rawInputEnter"))},onError:rt=>{const gt=rt instanceof Error?rt.message:String(rt);Ue.error(`终端初始化失败:${gt}`)},connectTransportInitially:ce&&re,...u.transport,onReady:()=>{_.current=[];const rt=g.current;rt&&Ut.getState().setPtyGeometry(t,{cols:rt.cols,rows:rt.rows}),u.transport.onReady()}});return R.current=it,()=>{x.current=!1,an==null||an.dispose(),dn==null||dn.dispose(),_.current=[],Ut.getState().setPtyGeometry(t,null),Ht==null||Ht.dispose(),S.current===Ht&&(S.current=null),be(),Oe==null||Oe(),ht==null||ht(),Dt==null||Dt.dispose(),vSe(),ct==null||ct(),wt==null||wt(),k.current=[],mSe(),w.current=null,J(!1),Q({resultIndex:-1,resultCount:0}),it.dispose(),g.current=null,A.current=null,R.current=null}},[t,ut,r,i,s,u.transport,f.handleAtBottomChange,f.hasNewFramesWhileAwayRef,f.setHasNewFramesWhileAway,ge,$e,Fn,Xn,Nn,y,dt,nn,En,be,X]),b.useEffect(()=>{if(!ut)return;const Ie=R.current;if(Ie){if(!ce||!re){d(),Ie.setTransportActive(!1);return}return h0e(t,n?"active":"background",()=>{var We;(We=R.current)==null||We.setTransportActive(!0)})}},[n,ce,d,re,t,ut]),b.useEffect(()=>{const Ie=g.current,We=A.current;!Ie||!We||Bwe(Ie,le,We.relayout)},[le]),b.useEffect(()=>{if(!n||!u.ready||xt)return;const Ie=requestAnimationFrame(()=>{var We;LL(s.current)&&((We=g.current)==null||We.focus())});return()=>cancelAnimationFrame(Ie)},[n,u.ready,xt,s]);const lt=b.useCallback((Ie="viewExternal",We)=>{var ot;We!=null&&We.force&&Ct(),(ot=A.current)==null||ot.scrollToBottom(Ie,We)},[Ct]),at=b.useCallback(Ie=>{var We;(We=A.current)==null||We.scrollToRatio(Ie)},[]),Tt=b.useCallback(Ie=>{var We;(We=A.current)==null||We.scrollToXRatio(Ie)},[]),Et=b.useCallback(Ie=>{var wt;const We=g.current,ot=We==null?void 0:We.getSelectionPosition();if(!We||!ot)return;const St=ot.start.y;if(St>=Ie&&St<Ie+We.rows)return;const Se=Math.max(0,We.buffer.active.length-We.rows);if(Se===0)return;const ct=Math.max(0,Math.min(Se,St-Math.floor(We.rows/2)));(wt=A.current)==null||wt.scrollToRatio(ct/Se)},[]),yt=b.useCallback((Ie,We=!1)=>{const ot=g.current,St=w.current;if(!ot||!St||!Ie)return Ie||(x.current=!1,St==null||St.clearDecorations(),ot==null||ot.clearSelection(),ue(),X(),Q({resultIndex:-1,resultCount:0})),!1;ue(),x.current=!0;const Se=ot.buffer.active.viewportY,ct=St.findNext(Ie,{...WL,incremental:We});return ct&&Et(Se),X(),ct},[ue,X,Et]),Qt=b.useCallback(Ie=>{const We=g.current,ot=w.current;if(!We||!ot||!Ie)return!1;ue(),x.current=!0;const St=We.buffer.active.viewportY,Se=ot.findPrevious(Ie,WL);return Se&&Et(St),X(),Se},[ue,X,Et]),It=b.useCallback(()=>{var Ie,We;x.current=!1,(Ie=w.current)==null||Ie.clearDecorations(),(We=g.current)==null||We.clearSelection(),ue(),X(),Q({resultIndex:-1,resultCount:0})},[ue,X]),rn=b.useCallback(Ie=>{var ot,St;if(!ge())return;const We=bp(Ie,(ot=g.current)==null?void 0:ot.modes);Mo(t,We),nn("mobileControl",{force:!0}),En(Ie,"mobileControlEnter"),(St=g.current)==null||St.focus()},[ge,En,nn,t]),hn=b.useCallback(()=>{var We,ot,St;if(!ge())return;const Ie=(ot=(We=navigator.clipboard)==null?void 0:We.readText)==null?void 0:ot.bind(navigator.clipboard);if(!window.isSecureContext||!Ie){Ue.error("无法读取剪贴板"),(St=g.current)==null||St.focus();return}Ie().then(Se=>{if(!Se)return;const ct=g.current;if(ct){ct.paste(Se);return}Mo(t,Se),nn("paste"),En(Se,"pasteEnter")}).catch(Se=>{const ct=Se instanceof Error&&Se.message?Se.message:"无法读取剪贴板";Ue.error(ct)}).finally(()=>{var Se;return(Se=g.current)==null?void 0:Se.focus()})},[ge,En,nn,t]),Ln=x1e({showMobilePtyControls:Gt,horizontalScrollable:j.horizontalScrollable,mobileControlsHeight:l});V.current.containerPaddingBottom=Ln,b.useEffect(()=>{var ot,St;D.current?(ot=A.current)==null||ot.relayout():(St=I.current)==null||St.schedule();const Ie=B.current,We=y1e({controlsVisible:Gt,keyboardOpen:st,previous:Ie});B.current={keyboardOpen:st,controlsVisible:Gt},Gt&&(D.current?on():We&&nn("keyboardOffset",{force:!0}))},[_t,st,Gt,Ln,on,nn]);const Cn=b.useMemo(()=>({onFocusCapture:Lt,onBlurCapture:sn}),[Lt,sn]);return{scrollState:j,isAtBottom:f.isAtBottom,hasNewFramesWhileAway:f.hasNewFramesWhileAway,ptyInputFocused:Je,showMobilePtyControls:Gt,touchEditingSurface:Rt,keyboardOffset:_t,physicalKeyboardMode:Fe,softKeyboardEditingSurface:xt,mobileControlsBottomInset:Ae,connectionReady:u.ready,connectionOverlay:u.overlay,containerPaddingBottom:Ln,traceEnabled:h,findReady:te,findResultIndex:ne.resultIndex,findResultCount:ne.resultCount,findNext:yt,findPrevious:Qt,clearFind:It,resizeTerminal:Ye,scrollToBottom:lt,scrollToRatio:at,scrollToXRatio:Tt,clearNewFramesWhileAway:on,sendMobileInput:rn,pasteMobileClipboard:hn,handleTerminalContainerMouseDown:Ge,handlePasteCapture:de,pointerHandlers:oe.pointerHandlers,focusHandlers:Cn,ptySelectionToolbar:oe.ptySelectionToolbar,ptySelectionHandles:oe.ptySelectionHandles,ptySelectionPathAction:oe.ptySelectionPathAction,ptySelectionHandleMetrics:oe.ptySelectionHandleMetrics,copyPtySelection:oe.copyPtySelection,openPtySelectionPathAction:oe.openPtySelectionPathAction,handlePtySelectionHandlePointerDown:oe.handlePtySelectionHandlePointerDown,handlePtySelectionHandleTouchStart:oe.handlePtySelectionHandleTouchStart,isPtyDragOver:pe,handlePtyDragOver:ae,handlePtyDragLeave:fe,handlePtyDrop:Be}}function C1e({sessionId:e,sessionKind:t,provider:n,active:r=!0,findRequest:i,resizeRequest:s}){const o=Ut(D=>{const F=D.sessions.find(V=>V.sessionId===e);return(F==null?void 0:F.kind)==="terminal"?F.shellFamily:void 0}),[l,u]=b.useState(null),[d,f]=b.useState(0),[h,y]=b.useState(!1),[g,_]=b.useState(""),w=b.useRef(null),S=b.useRef(null),x=b.useRef(null),k=E1e({sessionId:e,active:r,containerEl:l,spacerRef:w,xtermHostRef:S,selectionHandleLayerRef:x,mobileControlsHeight:d}),R=k.ptySelectionHandleMetrics,{clearFind:A,findNext:M,findPrevious:T,findReady:P,findResultCount:z,findResultIndex:Y}=k,U=b.useRef(s==null?void 0:s.requestId),{resizeTerminal:G}=k;b.useEffect(()=>{s===void 0||s.requestId===U.current||(U.current=s.requestId,r&&G(s.action))},[r,s,G]);const I=b.useCallback(()=>{T(g)},[T,g]),N=b.useCallback(()=>{M(g)},[M,g]),L=b.useCallback(()=>y(!0),[]),B=b.useCallback(()=>{y(!1),A()},[A]),O=h$({enabled:r,open:h,openRequest:i,onOpen:L,onClose:B,onPrevious:I,onNext:N});return b.useEffect(()=>{!h||!P||(g?M(g,!0):A())},[A,M,h,g,P]),m.jsxs("div",{className:"flex flex-col h-full relative","data-slot":"chat-pty-view","data-connection-ready":k.connectionReady?"true":"false","aria-busy":!k.connectionReady,children:[h?m.jsx(B1,{query:g,resultIndex:Y,resultCount:z,focusRequest:O.focusRequest,loading:!!g&&!P,onQueryChange:_,onPrevious:I,onNext:N,onClose:O.closeFind}):null,m.jsxs("div",{ref:u,className:"relative flex-1 min-h-0 overflow-auto overscroll-contain bg-background px-3 pt-2",style:{paddingBottom:`calc(env(safe-area-inset-bottom) + ${k.containerPaddingBottom}px)`,touchAction:"pan-x pan-y",overflowAnchor:"none"},onMouseDownCapture:k.handleTerminalContainerMouseDown,onPointerDownCapture:D=>{k.pointerHandlers.onPointerDownCapture(D)},onPointerMoveCapture:k.pointerHandlers.onPointerMoveCapture,onPointerUpCapture:k.pointerHandlers.onPointerUpCapture,onPointerCancelCapture:k.pointerHandlers.onPointerCancelCapture,onTouchStartCapture:k.pointerHandlers.onTouchStartCapture,onTouchMoveCapture:k.pointerHandlers.onTouchMoveCapture,onTouchEndCapture:k.pointerHandlers.onTouchEndCapture,onTouchCancelCapture:k.pointerHandlers.onTouchCancelCapture,onContextMenuCapture:k.pointerHandlers.onContextMenuCapture,onPasteCapture:k.handlePasteCapture,onDragOver:k.handlePtyDragOver,onDragLeave:k.handlePtyDragLeave,onDrop:k.handlePtyDrop,onFocusCapture:k.focusHandlers.onFocusCapture,onBlurCapture:k.focusHandlers.onBlurCapture,"data-slot":"pty-terminal","data-drag-over":k.isPtyDragOver?"true":void 0,children:[m.jsx("div",{ref:w,style:{position:"relative",overflowAnchor:"none"},"data-slot":"pty-spacer",children:m.jsx("div",{ref:S,style:{position:"absolute",left:0,top:0,overflow:"hidden",overflowAnchor:"none",boxSizing:"border-box"},"data-slot":"pty-host"})}),m.jsx("div",{ref:x,"data-slot":"pty-selection-handle-layer",style:{position:"absolute",left:0,top:0,width:0,height:0,contain:"layout size",overflow:"visible",pointerEvents:"none",zIndex:11}})]}),m.jsx(c$,{visible:!k.isAtBottom,hasNewMessages:k.hasNewFramesWhileAway,className:h?"top-14":"top-10",onClick:()=>{k.scrollToBottom("backToBottomBtn",{force:!0}),k.clearNewFramesWhileAway()}}),k.showMobilePtyControls?m.jsx(wge,{sessionKind:t,provider:n,shellFamily:o,bottomInset:k.mobileControlsBottomInset,onInput:k.sendMobileInput,onPaste:k.pasteMobileClipboard,onHeightChange:f}):null,k.ptySelectionHandles&&x.current?xu.createPortal(m.jsxs(m.Fragment,{children:[m.jsx(VL,{kind:"anchor",metrics:R,"aria-label":"调整选区起点",onPointerDown:D=>k.handlePtySelectionHandlePointerDown("anchor",D),onTouchStart:D=>k.handlePtySelectionHandleTouchStart("anchor",D)}),m.jsx(VL,{kind:"focus",metrics:R,"aria-label":"调整选区终点",onPointerDown:D=>k.handlePtySelectionHandlePointerDown("focus",D),onTouchStart:D=>k.handlePtySelectionHandleTouchStart("focus",D)})]}),x.current):null,k.ptySelectionToolbar?m.jsxs("div",{className:"fixed z-50 flex -translate-x-1/2 gap-1 rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-lg",style:{left:k.ptySelectionToolbar.left,top:k.ptySelectionToolbar.top},"data-slot":"pty-selection-toolbar",children:[m.jsx("button",{type:"button",className:"min-w-14 whitespace-nowrap rounded px-3 py-1.5 text-center text-sm font-medium leading-none hover:bg-accent active:bg-accent/80",onPointerDown:D=>D.preventDefault(),onClick:k.copyPtySelection,"aria-label":"复制终端选区",children:"复制"}),k.ptySelectionPathAction?m.jsx("button",{type:"button",className:"min-w-14 whitespace-nowrap rounded px-3 py-1.5 text-center text-sm font-medium leading-none hover:bg-accent active:bg-accent/80",onPointerDown:D=>D.preventDefault(),onClick:k.openPtySelectionPathAction,"aria-label":k.ptySelectionPathAction.kind==="image-preview"?"预览终端选区图片":"下载终端选区文件",children:k.ptySelectionPathAction.kind==="image-preview"?"预览":"下载"}):null]}):null,m.jsx(Age,{state:k.scrollState,scrollContainer:l,onScrollRatio:k.scrollToRatio}),m.jsx(Nge,{state:k.scrollState,onScrollRatio:k.scrollToXRatio}),m.jsx(sge,{...k.connectionOverlay}),m.jsx(age,{ptyInputFocused:k.ptyInputFocused,touchEditingSurface:k.touchEditingSurface,softKeyboardEditingSurface:k.softKeyboardEditingSurface,physicalKeyboardMode:k.physicalKeyboardMode,keyboardOffset:k.keyboardOffset,showMobilePtyControls:k.showMobilePtyControls,mobileControlsBottomInset:k.mobileControlsBottomInset}),k.traceEnabled?m.jsx(k1e,{}):null]})}function VL({kind:e,metrics:t,"aria-label":n,onPointerDown:r,onTouchStart:i}){const s=t.touchSize/2,o=2,l=t.visualSize,u=Math.max(t.stemSize+2,l+1),d=s-o/2,f=s,h=e==="anchor"?d-l+o:d,y=f+u-l+o,g=e==="anchor"?{borderTopLeftRadius:l,borderBottomLeftRadius:l,borderTopRightRadius:2,borderBottomRightRadius:l}:{borderTopLeftRadius:2,borderBottomLeftRadius:l,borderTopRightRadius:l,borderBottomRightRadius:l};return m.jsxs("button",{type:"button",className:"absolute z-50 touch-none rounded-full bg-transparent p-0 pointer-events-auto focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring",style:{left:0,top:0,width:t.touchSize,height:t.touchSize,transform:"translate3d(0, 0, 0) translate(-50%, -50%)",visibility:"hidden",willChange:"transform"},"data-slot":"pty-selection-handle","data-kind":e,"aria-label":n,onPointerDown:r,onTouchStart:i,children:[m.jsx("span",{className:"pointer-events-none absolute rounded-full bg-primary",style:{left:d,top:f,width:o,height:u},"data-slot":"pty-selection-handle-stem"}),m.jsx("span",{className:"pointer-events-none absolute border-2 border-primary bg-background shadow-sm shadow-black/30",style:{left:h,top:y,width:l,height:l,...g},"data-slot":"pty-selection-handle-dot"})]})}function k1e(){const[e,t]=b.useState(!1);async function n(){const r=rge();try{await navigator.clipboard.writeText(r),t(!0),window.setTimeout(()=>t(!1),1200)}catch{window.prompt("Copy PTY scroll trace",r)}}return m.jsx("button",{type:"button",className:"absolute left-3 top-3 z-30 rounded border border-border bg-popover/90 px-2 py-1 text-[11px] text-muted-foreground",onPointerDown:r=>r.preventDefault(),onClick:n,"data-slot":"pty-scroll-trace-copy",children:e?"Copied":"Trace"})}const T1e=1024,R1e=720,jv=.5,gH=b.createContext(null);function A1e({children:e}){const[t,n]=b.useState([]),[r,i]=b.useState(null),[s,o]=b.useState(null),l=Me(R=>R.selectedProxyId),u=Ut(R=>R.sessions),d=Ut(R=>R.sessionListLoaded),f=b.useRef(l),h=b.useRef(null),y=b.useMemo(()=>u.filter(R=>R.mode==="pty").map(R=>R.sessionId).sort().join(`
738
738
  `),[u]),g=b.useCallback(R=>{h.current=R.sessionId,i(R),n(A=>Tpe(A,R.sessionId).map(T=>T.sessionId===R.sessionId?{...T,sessionKind:R.sessionKind,provider:R.provider}:T))},[]),_=b.useCallback(R=>{h.current===R&&(h.current=null),i(A=>(A==null?void 0:A.sessionId)===R?null:A),o(A=>h.current===null?null:A)},[]),w=b.useCallback((R,A)=>{h.current===R&&o(M=>!A||M&&P1e(M,A)?M:A)},[]),S=b.useCallback((R,A)=>{A!==void 0&&n(M=>M.map(T=>T.sessionId===R?{...T,findRequest:A}:T))},[]),x=b.useCallback((R,A)=>{A===void 0||h.current!==R||n(M=>M.map(T=>T.sessionId===R?{...T,resizeRequest:A}:T))},[]);b.useEffect(()=>{if(!d)return;const R=new Set(y?y.split(`
739
- `):[]);n(A=>A.filter(M=>R.has(M.sessionId))),i(A=>A&&R.has(A.sessionId)?A:null),h.current&&!R.has(h.current)&&(h.current=null,o(null))},[y,d]),b.useEffect(()=>{const R=f.current;f.current=l,!(!R||R===l)&&(h.current=null,n([]),i(null),o(null))},[l]);const k=b.useMemo(()=>({activate:g,deactivate:_,updateFindRequest:S,updateResizeRequest:x,updateViewportRect:w}),[g,_,S,x,w]);return m.jsxs(gH.Provider,{value:k,children:[e,m.jsx(M1e,{entries:t,activeView:r,viewportRect:s})]})}function N1e({sessionId:e,sessionKind:t,provider:n,findRequest:r,resizeRequest:i}){const s=b.useContext(gH),o=b.useRef(null);if(!s)throw new Error("PtyKeepAliveViewport must be used within PtyKeepAliveProvider");const{activate:l,deactivate:u,updateFindRequest:d,updateResizeRequest:f,updateViewportRect:h}=s;return b.useLayoutEffect(()=>(l({sessionId:e,sessionKind:t,provider:n}),()=>u(e)),[l,u,e,t,n]),b.useLayoutEffect(()=>{d(e,r)},[r,e,d]),b.useLayoutEffect(()=>{f(e,i)},[i,e,f]),b.useLayoutEffect(()=>{const y=o.current;if(!y)return;const g=()=>{const w=y.getBoundingClientRect();h(e,{top:w.top,left:w.left,width:w.width,height:w.height})};g();const _=new ResizeObserver(g);return _.observe(y),window.addEventListener("resize",g),()=>{_.disconnect(),window.removeEventListener("resize",g)}},[e,h]),m.jsx("div",{ref:o,className:"h-full w-full bg-background","data-slot":"pty-keepalive-viewport","data-session-id":e})}function M1e({entries:e,activeView:t,viewportRect:n}){return e.length===0?null:m.jsx("div",{className:"fixed inset-0 z-10 pointer-events-none","data-slot":"pty-keepalive-layer",children:e.map(r=>{const i=(t==null?void 0:t.sessionId)===r.sessionId&&n!==null,s=i?n:{top:-1e5,left:0,width:(n==null?void 0:n.width)??T1e,height:(n==null?void 0:n.height)??R1e};return m.jsx("div",{className:"absolute overflow-hidden bg-background","data-slot":"pty-keepalive-entry","data-session-id":r.sessionId,"data-active":i?"true":"false","aria-hidden":!i,style:{top:s.top,left:s.left,width:s.width,height:s.height,pointerEvents:i?"auto":"none",visibility:i?"visible":"hidden"},children:m.jsx(l$,{sessionId:r.sessionId,children:m.jsx(C1e,{sessionId:r.sessionId,sessionKind:r.sessionKind,provider:r.provider,active:i,findRequest:r.findRequest,resizeRequest:r.resizeRequest})})},r.sessionId)})})}function P1e(e,t){return Math.abs(e.top-t.top)<=jv&&Math.abs(e.left-t.left)<=jv&&Math.abs(e.width-t.width)<=jv&&Math.abs(e.height-t.height)<=jv}function I1e(){const e=Ut(r=>r.codexActiveWriterConflict),t=Ut(r=>r.setCodexActiveWriterConflict),n=()=>t(null);return m.jsx(es,{open:e!==null,onOpenChange:r=>!r&&n(),children:m.jsxs(ts,{focusSurfaceOnOpen:!0,className:"min-w-0 sm:max-w-md",children:[m.jsxs(ns,{children:[m.jsx($i,{children:"该 Codex 会话仍在运行"}),m.jsxs(Es,{className:"space-y-2 text-left leading-6",children:[m.jsxs("span",{className:"block",children:["另一个 Codex 进程正在使用此会话",e!=null&&e.activeWriterPid?m.jsxs(m.Fragment,{children:["(PID"," ",m.jsx("span",{className:"font-mono text-foreground",children:e.activeWriterPid}),")"]}):null,"。"]}),m.jsx("span",{className:"block",children:"它可能来自本机终端、Codex App 或另一条 DEV Anywhere 会话。请先回到或结束原会话后再重试。"}),m.jsx("span",{className:"block text-muted-foreground/80",children:"DEV Anywhere 不会自动终止该进程。"})]})]}),m.jsx(qs,{children:m.jsx(vt,{type:"button",onClick:n,autoFocus:!0,children:"知道了"})})]})})}function wT({route:e,surface:t,proxiesLength:n,proxyListLoaded:r,hasProxy:i,relayClientAuthIssue:s=null}){return s==="missing_client_token"?"Relay 需要 client token,请在设置中填写":s==="invalid_client_token"?"client token 无效或已过期,请在设置中更新":r?n===0?"在开发机上启动 DEV Anywhere,本页会显示可连接的开发机":t==="mobile"&&e==="proxy-select"||!i?"选择要连接的开发机":null:null}function O1e(e){const t=t5(e);return t.osName!=="iPad"?{supported:!0}:e.standalone||t.browserName==="Safari"?{supported:!0}:{supported:!1,reason:"ipad-safari-required",browserName:t.browserName}}function xy(){if(typeof window>"u"||typeof navigator>"u")return!1;const e=typeof window.matchMedia=="function"&&(window.matchMedia("(display-mode: standalone)").matches||window.matchMedia("(display-mode: fullscreen)").matches),t=!!navigator.standalone;return e||t}function L1e(){return typeof navigator>"u"?{supported:!0}:O1e({userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints,standalone:xy()})}function D1e(){lSe(),cSe();const e=ds(),t=Cs(),n=e.pathname.startsWith("/chat/"),r=e.pathname.startsWith("/preview/device/"),i=n||r,s=e.pathname==="/"||e.pathname==="/sessions",[o,l]=b.useState(!1),[u,d]=b.useState(()=>xy()),f=Me(I=>I.proxies.length),h=Me(I=>I.proxyListLoaded),y=Me(I=>I.relayClientAuthIssue),g=Me(I=>I.relayConnectionIssue),_=Me(I=>!!I.selectedProxyId),w=Me(I=>I.selectedProxyId),S=Me(I=>I.selectedProxyName),x=Me(I=>{var N;return(N=I.proxies.find(L=>L.proxyId===I.selectedProxyId))==null?void 0:N.osName});Ut(I=>I.sessions.length);const k=Me(I=>I.pendingToast),R=Me(I=>I.setPendingToast),A=e.pathname==="/"?"proxy-select":"sessions",M=g!==null&&y===null,T=wT({route:A,surface:"mobile",proxiesLength:f,proxyListLoaded:h,hasProxy:_,relayClientAuthIssue:y}),P=S??w,Y=e.pathname==="/sessions"&&h&&f>0?m.jsxs(vt,{variant:"ghost",size:"sm",className:"h-auto min-h-11 max-w-full justify-start rounded-md border border-border/70 bg-background/35 px-3 py-2 text-left text-muted-foreground hover:border-primary/45 hover:bg-accent/70 hover:text-foreground","data-slot":"mobile-switch-proxy","aria-label":P?`切换开发机,当前 ${P}`:"切换开发机",onClick:()=>t("/"),children:[m.jsx(Tz,{className:"size-4 text-primary","aria-hidden":"true"}),m.jsx(Ep,{name:P??"切换开发机",osName:x,nameClassName:"text-foreground"})]}):null;b.useEffect(()=>{if(!k)return;({error:Ue.error,info:Ue.info,success:Ue.success})[k.kind](k.message),R(null)},[k,R]),b.useEffect(()=>{if(typeof window.matchMedia!="function"){d(xy());return}const I=window.matchMedia("(display-mode: standalone)"),N=window.matchMedia("(display-mode: fullscreen)"),L=()=>d(xy());return L(),I.addEventListener("change",L),N.addEventListener("change",L),()=>{I.removeEventListener("change",L),N.removeEventListener("change",L)}},[]);const U=b.useRef(!1);b.useEffect(()=>{if(U.current)return;U.current=!0;const I=Sie({pathname:e.pathname,alreadyRestored:kie(),lastRoute:Eie()});Tie(),I&&(Rie(I),t(I,{replace:!0}))},[]);const G=b.useRef(!1);return b.useEffect(()=>{n?(G.current=!0,Cie(`${e.pathname}${e.search}`)):G.current&&(G.current=!1,Dy())},[n,e.pathname,e.search]),m.jsxs(Ede,{blocked:M,children:[m.jsxs("div",{className:"flex flex-col bg-background text-foreground",style:{height:"var(--dev-app-shell-height, max(100dvh, var(--dev-visual-viewport-height, 100dvh)))"},"data-slot":"app-shell","data-standalone-display":u?"true":void 0,inert:M?!0:void 0,"aria-hidden":M?!0:void 0,children:[!i&&m.jsx(vt,{variant:"ghost",size:"icon",className:"dev-mobile-settings-trigger group fixed right-4 z-30 size-11 rounded-full border-0 bg-transparent p-0 text-muted-foreground shadow-none hover:bg-transparent hover:text-foreground md:hidden","aria-label":"设置","data-slot":"mobile-settings-trigger",onClick:()=>l(!0),children:m.jsx("span",{"data-slot":"mobile-settings-trigger-visual",className:"flex size-7 items-center justify-center rounded-full border border-border/80 bg-card/90 shadow-lg backdrop-blur transition-colors group-hover:border-primary/45 group-hover:bg-accent",children:m.jsx(Nz,{className:"size-4","aria-hidden":"true"})})}),!i&&m.jsx(Ahe,{subtitle:T,action:Y}),m.jsx(kpe,{}),m.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[m.jsx(khe,{className:"hidden md:flex"}),m.jsx("main",{className:"relative flex-1 overflow-hidden",role:"main",children:m.jsx(A1e,{children:m.jsx("div",{className:qe("h-full",!s&&"animate-in fade-in-0 duration-200 motion-reduce:animate-none"),"data-slot":"route-content",children:m.jsx(R7,{})},s?"top-level":e.pathname)})})]}),m.jsx(O1,{open:o,onOpenChange:l}),m.jsx(I1e,{}),m.jsx(npe,{}),m.jsx(zhe,{}),m.jsx(Gre,{})]}),M&&g?m.jsx("div",{className:"fixed inset-0 z-[60] bg-background",children:m.jsx(spe,{issue:g})}):null]})}function vH({subtitle:e,action:t}){return m.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-6 px-6 text-center",children:[m.jsx(RF,{texts:AF,className:"text-2xl md:text-3xl font-bold"}),e?m.jsx("p",{className:"max-w-md text-sm text-muted-foreground",children:e}):null,t&&m.jsx("div",{children:t})]})}function B1e(){const e=Me(o=>o.proxies),t=Me(o=>o.proxyListLoaded),n=Me(o=>!!o.selectedProxyId),r=Me(o=>o.relayClientAuthIssue);Ut(o=>o.sessions.length);const i=wT({route:"proxy-select",surface:"desktop",proxiesLength:e.length,proxyListLoaded:t,hasProxy:n,relayClientAuthIssue:r}),s=r==="missing_client_token"?"client-token-missing":r==="invalid_client_token"?"client-token-invalid":null;return m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"h-full md:hidden",children:m.jsx(oF,{layout:"page"})}),m.jsx("div",{className:"hidden md:block h-full",children:s?m.jsx(Jc,{variant:s}):m.jsx(vH,{subtitle:i})})]})}function z1e(){const e=Me(o=>o.proxies),t=Me(o=>o.proxyListLoaded),n=Me(o=>!!o.selectedProxyId),r=Me(o=>o.relayClientAuthIssue);Ut(o=>o.sessions.length);const i=Ni("local",_n.proxyId)!==null;if(!n&&!i)return m.jsx(T7,{to:"/",replace:!0});const s=wT({route:"sessions",surface:"desktop",proxiesLength:e.length,proxyListLoaded:t,hasProxy:n,relayClientAuthIssue:r});return m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"h-full md:hidden",children:m.jsx(bF,{layout:"page"})}),m.jsx("div",{className:"hidden md:block h-full",children:m.jsx(vH,{subtitle:s})})]})}function yH(){if(!(typeof navigator>"u"))return navigator.wakeLock}function j1e(e,t){return e===!1?"insecure-context":t?null:"unsupported"}function bH(){var t;const e=typeof window>"u"?void 0:window.isSecureContext;return j1e(e,typeof((t=yH())==null?void 0:t.request)=="function")}function F1e(e){return e==="insecure-context"?"屏幕常亮需要 HTTPS":"当前浏览器不支持屏幕常亮"}function $1e(){const e=yH();if(typeof(e==null?void 0:e.request)!="function")throw new Error(F1e(bH()));return e.request("screen")}function H1e(e){return e instanceof Error&&e.message.trim()?e.message:"无法开启屏幕常亮"}class U1e{constructor(t={}){je(this,"activeScopes",new Set);je(this,"pendingScopes",new Set);je(this,"listeners",new Map);je(this,"sentinel",null);je(this,"requestInFlight",null);je(this,"requestWakeLock");je(this,"documentRef");je(this,"windowRef");je(this,"unavailableReason");je(this,"handleVisibilityChange",()=>{var t,n;if(((t=this.documentRef)==null?void 0:t.visibilityState)==="hidden"){this.releaseSentinel().catch(()=>{});return}((n=this.documentRef)==null?void 0:n.visibilityState)==="visible"&&this.ensureWakeLock().catch(()=>{})});je(this,"handlePageHide",()=>{this.releaseSentinel().catch(()=>{})});var n,r;this.requestWakeLock=t.request??$1e,this.unavailableReason=typeof t.request=="function"?null:bH(),this.documentRef=t.document??(typeof document>"u"?void 0:document),this.windowRef=t.window??(typeof window>"u"?void 0:window),(n=this.documentRef)==null||n.addEventListener("visibilitychange",this.handleVisibilityChange),(r=this.windowRef)==null||r.addEventListener("pagehide",this.handlePageHide)}isSupported(){return this.unavailableReason===null}getSnapshot(t){return{active:this.activeScopes.has(t),pending:this.pendingScopes.has(t),supported:this.isSupported(),unavailableReason:this.unavailableReason}}subscribe(t,n){const r=this.listeners.get(t)??new Set;return r.add(n),this.listeners.set(t,r),n(this.getSnapshot(t)),()=>{r.delete(n),r.size===0&&this.listeners.delete(t)}}async enable(t){this.activeScopes.add(t),this.pendingScopes.add(t),this.notify(t);try{await this.ensureWakeLock()}catch(n){throw this.activeScopes.delete(t),new Error(H1e(n),{cause:n})}finally{this.pendingScopes.delete(t),this.notify(t)}}async disable(t){const n=this.activeScopes.delete(t);this.pendingScopes.delete(t),this.notify(t),!(!n||this.activeScopes.size>0)&&await this.releaseSentinel()}async toggle(t){this.activeScopes.has(t)?await this.disable(t):await this.enable(t)}dispose(){var t,n;(t=this.documentRef)==null||t.removeEventListener("visibilitychange",this.handleVisibilityChange),(n=this.windowRef)==null||n.removeEventListener("pagehide",this.handlePageHide),this.activeScopes.clear(),this.pendingScopes.clear(),this.releaseSentinel().catch(()=>{});for(const r of this.listeners.keys())this.notify(r)}async ensureWakeLock(){var t;if(this.activeScopes.size!==0&&((t=this.documentRef)==null?void 0:t.visibilityState)!=="hidden"&&!(this.sentinel&&!this.sentinel.released))return this.requestInFlight?this.requestInFlight:(this.requestInFlight=this.requestWakeLock().then(async n=>{var r;if(this.activeScopes.size===0||((r=this.documentRef)==null?void 0:r.visibilityState)==="hidden"){n.released||await n.release();return}this.sentinel=n,n.addEventListener("release",()=>{var i;this.sentinel===n&&(this.sentinel=null),this.activeScopes.size>0&&((i=this.documentRef)==null?void 0:i.visibilityState)!=="hidden"&&this.ensureWakeLock().catch(()=>{})},{once:!0})}).finally(()=>{this.requestInFlight=null}),this.requestInFlight)}async releaseSentinel(){const t=this.sentinel;this.sentinel=null,!(!t||t.released)&&await t.release()}notify(t){var r;const n=this.getSnapshot(t);(r=this.listeners.get(t))==null||r.forEach(i=>i(n))}}const jl=new U1e;function _H(e){const[t,n]=b.useState(()=>jl.getSnapshot(e));b.useEffect(()=>jl.subscribe(e,n),[e]),b.useEffect(()=>()=>{jl.disable(e).catch(()=>{})},[e]);const r=b.useCallback(()=>jl.enable(e),[e]),i=b.useCallback(()=>jl.disable(e),[e]),s=b.useCallback(()=>jl.toggle(e),[e]);return{...t,enable:r,disable:i,toggle:s}}function W1e({axis:e,label:t,value:n,min:r,max:i,disabled:s,onCommit:o}){const[l,u]=b.useState(null),[d,f]=b.useState(!1),[h,y]=b.useState(!1);function g(){u(null),f(!1),y(!1)}function _(w){if(s||!d||l===null){g();return}const S=l.trim(),x=Number(S);if(!/^\d+$/.test(S)||!Number.isSafeInteger(x)||x<r||x>i){Ue.error(`请输入 ${r}–${i} 之间的整数`),w?y(!0):g();return}g(),x!==n&&o(x)}return m.jsx("input",{type:"text",inputMode:"numeric",enterKeyHint:"done",pattern:"[0-9]*","aria-label":`设置${t}`,"aria-invalid":h,"data-slot":`chat-menu-${e}-value`,"data-terminal-dimension-input":"","data-editing":l!==null?"true":"false",className:qe("h-[22px] w-9 rounded-[5px] border border-transparent bg-transparent px-0.5 text-center text-sm font-medium leading-none tabular-nums text-foreground outline-none hover:bg-muted/45 focus:border-ring focus:bg-background disabled:cursor-not-allowed disabled:opacity-50 [@media(pointer:coarse)]:focus:text-base",h&&"border-destructive focus:border-destructive"),disabled:s,value:l??(n==null?void 0:n.toString())??"",placeholder:"—",autoComplete:"off",spellCheck:!1,onFocus:w=>{u(w.currentTarget.value),f(!1),w.currentTarget.select()},onChange:w=>{u(w.currentTarget.value),f(!0),y(!1)},onBlur:()=>_(!1),onKeyDown:w=>{w.stopPropagation(),!w.nativeEvent.isComposing&&(w.key==="Enter"?(w.preventDefault(),_(!0)):w.key==="Escape"&&(w.preventDefault(),g()))}})}function q1e(){return new AudioContext}class V1e{constructor(t=q1e){je(this,"context",null);this.createContext=t}get(){return this.context??(this.context=this.createContext()),this.context}async prepare(){const t=this.get();if(t.state!=="running"&&t.state!=="closed"&&await t.resume(),t.state!=="running")throw new Error("浏览器未允许播放 Voice Pilot 提示音");return t}async reactivateAfterCapture(){const t=this.get();if(t.state==="closed")throw new Error("Voice Pilot 播放上下文已关闭");if(t.state==="running"&&await t.suspend(),t.state!=="running"&&await t.resume(),t.state!=="running")throw new Error("浏览器未能恢复 Voice Pilot 音频输出");return t}}const Sy=new V1e,YL=400,jd=[];let wH=1;function Y1e(){return typeof performance>"u"?0:Math.round(performance.now()*10)/10}function wp(e){const t={sequence:wH++,timestamp:new Date().toISOString(),monotonicMs:Y1e(),sessionId:e.sessionId,scope:e.scope,event:e.event,...e.attemptId?{attemptId:e.attemptId}:{},...e.requestId?{requestId:e.requestId}:{},...e.details?{details:{...e.details}}:{}};jd.push(t),jd.length>YL&&jd.splice(0,jd.length-YL)}function K1e(){return jd.map(e=>({...e,...e.details?{details:{...e.details}}:{}}))}function G1e(){jd.length=0,wH=1}typeof window<"u"&&(window.__devAnywhereVoicePilotDiagnostics={snapshot:K1e,clear:G1e});function xH(e){return`voice-pilot:${e}`}function X1e(e){const t=new Int16Array(e.length);for(let n=0;n<e.length;n+=1){const r=Math.max(-1,Math.min(1,e[n]??0));t[n]=r<0?Math.round(r*32768):Math.floor(r*32767)}return new Uint8Array(t.buffer)}const Z1e="modulepreload",Q1e=function(e){return"/"+e},KL={},SH=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){let o=function(d){return Promise.all(d.map(f=>Promise.resolve(f).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),u=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));i=o(n.map(d=>{if(d=Q1e(d),d in KL)return;KL[d]=!0;const f=d.endsWith(".css"),h=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${h}`))return;const y=document.createElement("link");if(y.rel=f?"stylesheet":Z1e,f||(y.as="script"),y.crossOrigin="",y.href=d,u&&y.setAttribute("nonce",u),document.head.appendChild(y),f)return new Promise((g,_)=>{y.addEventListener("load",g),y.addEventListener("error",()=>_(new Error(`Unable to preload CSS for ${d}`)))})}))}function s(o){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=o,window.dispatchEvent(l),!l.defaultPrevented)throw o}return i.then(o=>{for(const l of o||[])l.status==="rejected"&&s(l.reason);return t().catch(s)})},J1e="/assets/fvad-DYxbW2my.wasm",uf=16e3,eEe=20,Fl=uf*eEe/1e3,fS=Fl*Int16Array.BYTES_PER_ELEMENT;let GL=null;async function tEe(){return GL??(GL=SH(async()=>{const{default:e}=await import("./fvad-Dc_d2dDu.js");return{default:e}},[]).then(({default:e})=>e({locateFile:t=>t.endsWith(".wasm")?J1e:t}))),GL}class xT{constructor(t,n,r){je(this,"destroyed",!1);this.module=t,this.handle=n,this.framePointer=r}static async create(t=3){const n=await tEe(),r=n._fvad_new();if(!r)throw new Error("无法初始化浏览器语音活动检测器");const i=n._malloc(fS);if(!i)throw n._fvad_free(r),new Error("无法分配浏览器语音活动检测缓冲区");if(n._fvad_set_sample_rate(r,uf)!==0)throw n._free(i),n._fvad_free(r),new Error("浏览器语音活动检测器不支持 16 kHz 音频");if(n._fvad_set_mode(r,t)!==0)throw n._free(i),n._fvad_free(r),new Error("无法配置浏览器语音活动检测器");return new xT(n,r,i)}process(t){if(this.destroyed)throw new Error("浏览器语音活动检测器已释放");if(t.byteLength!==fS)throw new Error(`语音活动检测帧必须为 ${fS} 字节`);this.module.HEAPU8.set(t,this.framePointer);const n=this.module._fvad_process(this.handle,this.framePointer,Fl);if(n<0)throw new Error("浏览器语音活动检测失败");return n===1}reset(){this.destroyed||this.module._fvad_reset(this.handle)}destroy(){this.destroyed||(this.destroyed=!0,this.module._free(this.framePointer),this.module._fvad_free(this.handle))}}class nEe{constructor(t={}){je(this,"startSpeechFrames");je(this,"endSilenceFrames");je(this,"active",!1);je(this,"speechFrames",0);je(this,"silenceFrames",0);if(this.startSpeechFrames=t.startSpeechFrames??10,this.endSilenceFrames=t.endSilenceFrames??30,this.startSpeechFrames<1||this.endSilenceFrames<1)throw new Error("Invalid voice activity gate configuration")}push(t){return this.active?t?(this.silenceFrames=0,"none"):(this.silenceFrames+=1,this.silenceFrames<this.endSilenceFrames?"none":(this.active=!1,this.silenceFrames=0,"speech-end")):(this.speechFrames=t?this.speechFrames+1:0,this.speechFrames>=this.startSpeechFrames?(this.active=!0,this.speechFrames=0,this.silenceFrames=0,"speech-start"):"none")}reset(){this.active=!1,this.speechFrames=0,this.silenceFrames=0}}class rEe{constructor(){je(this,"pending",new Float32Array(Fl));je(this,"pendingLength",0)}push(t,n){let r=0;if(this.pendingLength>0){const i=Fl-this.pendingLength,s=Math.min(i,t.length);this.pending.set(t.subarray(0,s),this.pendingLength),this.pendingLength+=s,r+=s,this.pendingLength===Fl&&(n(this.pending.slice()),this.pendingLength=0)}for(;r+Fl<=t.length;)n(t.slice(r,r+Fl)),r+=Fl;if(r<t.length){const i=t.subarray(r);this.pending.set(i,0),this.pendingLength=i.length}}reset(){this.pendingLength=0}}const iEe="/__dev_anywhere_debug/voice-fixture",sEe=uf*SF/1e3;function oEe(){return xT.create(3)}const aEe={createVad:oEe,getUserMedia:e=>navigator.mediaDevices.getUserMedia(e),createAudioContext:e=>new AudioContext(e),fetch:e=>fetch(e)};function lEe(e){if(e.length===0)return 0;let t=0;for(const n of e)t+=n*n;return Math.min(1,Math.sqrt(t/e.length)*10)}function cEe(e){for(const t of e.getTracks())t.stop()}function EH(e){const t=e.createAudioContext({sampleRate:uf});if(t.sampleRate!==uf)throw t.close().catch(()=>{}),new Error("浏览器无法提供 Voice Pilot 所需的 16 kHz 音频输入");return t}async function uEe(e){const t=EH(e);let n;try{n=await e.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0,sampleRate:uf}})}catch(i){throw await t.close().catch(()=>{}),i}const r=t.createMediaStreamSource(n);return{context:t,input:r,async start(){t.state==="suspended"&&await t.resume()},async stop(){r.disconnect(),cEe(n),t.state!=="closed"&&await t.close()}}}async function dEe(e,t){const n=EH(t);try{const r=await t.fetch(e);if(!r.ok)throw new Error(`测试录音读取失败 (${r.status})`);const i=await n.decodeAudioData(await r.arrayBuffer()),s=n.createBufferSource();s.buffer=i;let o=!1,l=!1;return{context:n,input:s,async start(){o||l||(o=!0,n.state==="suspended"&&await n.resume(),s.start())},async stop(){if(!l){if(l=!0,o)try{s.stop()}catch{}s.disconnect(),n.state!=="closed"&&await n.close()}}}}catch(r){throw await n.close().catch(()=>{}),r}}function CH(e=window.location.search,t=!1){return t&&new URLSearchParams(e).get("voice-fixture")==="default"?{kind:"fixture",url:iEe}:{kind:"microphone"}}async function fEe(e,t=aEe){const n=await t.createVad();let r;try{r=e.source.kind==="fixture"?await dEe(e.source.url,t):await uEe(t)}catch(f){throw n.destroy(),f}const i=new nEe,s=new rEe,o=r.context.createScriptProcessor(sEe,1,1);let l=!1,u=null,d=null;return o.onaudioprocess=f=>{l&&s.push(f.inputBuffer.getChannelData(0),h=>{const y=X1e(h),g=n.process(y);e.onFrame({pcm:y,speechProbability:g?1:0,activityLevel:lEe(h)});const _=i.push(g);_==="speech-start"&&e.onSpeechStart(),_==="speech-end"&&e.onSpeechEnd()})},r.input.connect(o),o.connect(r.context.destination),{source:e.source.kind,start(){return d?Promise.reject(new Error("语音采集已停止")):(u??(u=(async()=>{l=!0,await r.start()})()),u)},stop(){return d??(d=(async()=>{l=!1,o.onaudioprocess=null,o.disconnect(),i.reset(),s.reset(),n.reset(),n.destroy(),await r.stop()})()),d}}}function kH(e=pf().osName){return{mediaAccept:"image/*,video/*",fileAccept:e==="Android"?"application/*,text/*":void 0}}function hEe(e){const[t,n,...r]=Array.from(e);return t&&n===" "&&r.length>0?{indicator:t,label:r.join("")}:{label:e}}function pEe({title:e,isPtyTitle:t}){if(!t)return m.jsx(m.Fragment,{children:e});const{indicator:n,label:r}=hEe(e);return m.jsxs("span",{className:"inline-flex items-center justify-center max-w-full min-w-0 font-mono font-normal",children:[n&&m.jsx("span",{className:"inline-block w-[1.25ch] shrink-0 text-center","aria-hidden":"true",children:n}),m.jsx("span",{className:"truncate",children:n?` ${r}`:r})]})}function mEe(e){const t=e instanceof Error?e.name:"";return t==="NotAllowedError"||t==="SecurityError"?"没有麦克风权限,请在浏览器里允许访问麦克风。":t==="NotFoundError"||t==="DevicesNotFoundError"?"未检测到可用麦克风。":t==="NotReadableError"||t==="TrackStartError"?"麦克风正在被其他应用占用。":e instanceof Error?e.message:"无法访问麦克风。"}async function gEe(){var t;if(!((t=navigator.mediaDevices)!=null&&t.getUserMedia))throw new Error("当前浏览器不支持麦克风访问。");let e=null;try{e=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(n){throw new Error(mEe(n),{cause:n})}finally{e==null||e.getTracks().forEach(n=>n.stop())}}const Ml="min-h-9 gap-2.5",Fv="px-2 pb-1 pt-2 text-xs font-semibold text-muted-foreground",vEe=[{axis:"cols",label:"列数",unit:"列",Icon:GV,min:eb,max:iu},{axis:"rows",label:"行数",unit:"行",Icon:rK,min:tb,max:su}];function Bs({children:e,className:t}){return m.jsx("span",{"aria-hidden":"true","data-slot":"chat-menu-icon",className:qe("inline-flex size-5 shrink-0 items-center justify-center text-muted-foreground [&_svg]:size-4",t),children:e})}function yEe({label:e}){return m.jsxs(Bs,{className:"relative",children:[m.jsx(SC,{className:"size-4","aria-hidden":"true"}),m.jsx("span",{className:"absolute -right-1.5 -top-1 flex h-3 min-w-4 items-center justify-center rounded-[3px] border border-border bg-popover px-0.5 font-mono text-[7px] leading-none text-muted-foreground shadow-sm",children:e})]})}function bEe({sessionId:e,mode:t,onFind:n,onResizeTerminal:r}){const i=qr(ve=>ve.homePath),s=kH(),o=Cs(),l=Ut(ve=>ve.sessions.find(Je=>Je.sessionId===e)),u=Ut(ve=>ve.ptyTitles[e]),d=Ut(ve=>ve.ptyGeometryBySessionId[e]),f=Me(ve=>ve.ptyFontSize),h=Me(ve=>ve.chatContentFontSize),y=Me(ve=>ve.selectedProxyId),g=Me(ve=>ve.connected),_=Me(ve=>ve.proxyOnline),w=Me(ve=>ve.adjustPtyFontSize),S=Me(ve=>ve.adjustChatContentFontSize),x=Me(ve=>ve.setChatContentFontSize),k=Me(ve=>ve.resetPtyFontSize),R=Me(ve=>ve.resetChatContentFontSize),A=Me(ve=>ve.inputModePreference==="hardware"),M=Ut(ve=>ve.renameSession),T=WC(y,e),P=(l==null?void 0:l.provider)!=="codex",z=Ut(ve=>P&&T?!!ve.ptyAutoYesBySessionKey[T]:!1),Y=Ut(ve=>ve.setPtyAutoYes),G=yo("(pointer: coarse), (hover: none)")&&!A,I=t==="pty"||(l==null?void 0:l.mode)==="pty",N=d$(l??{}).menu,L=b.useRef(null),B=b.useRef(null),O=b.useRef(!1),[D,F]=b.useState(!1),V=(l==null?void 0:l.kind)==="terminal",j=_H(e),q=An(ve=>ve.bySessionId[e]??a_),K=An(ve=>ve.enable),$=An(ve=>ve.disable),te=!!(l!=null&&l.nameLocked&&(l!=null&&l.name)),J=QC(l,i),ne=te&&(l==null?void 0:l.name)||J||I&&u||(l==null?void 0:l.name)||e.slice(0,8),Q=!!(I&&!V&&u&&!te),ce=I?f:AC(h,G),re=!I&&G?Qz:Xz,le=I?k:R,[we,Ce]=b.useState(!1),[ye,Re]=b.useState(!1),Rt=q.enabled,Ke=j.active||Rt,et=j.pending||!j.supported||Rt;function $e(ve){if(I){w(ve);return}if(G){x(ce+ve);return}S(ve)}function Fe(){j.toggle().catch(ve=>{Ue.error(ve instanceof Error?ve.message:String(ve))})}async function xt(ve){var dt;if(I||V){Ue.info("Voice Pilot 目前适用于聊天会话。");return}if(ve!==!0){$(e);return}const Je=$t;if(!Je){Ue.error("请先连接开发机");return}try{if(!((dt=(await Je.requestVoiceConfig()).config)!=null&&dt.configured)){Ue.info("请先在设置里配置 Voice Pilot。");return}Ce(!0)}catch(Ot){Ue.error(Ot instanceof Error?Ot.message:String(Ot))}}async function _t(){var Ot;Re(!0);let ve=null,Je=!1;const dt=xH(e);try{wp({sessionId:e,scope:"runtime",event:"wake-lock-requested",details:{userActivationActive:((Ot=navigator.userActivation)==null?void 0:Ot.isActive)??!1,visibilityState:document.visibilityState,secureContext:window.isSecureContext}});const Lt=jl.enable(dt).then(()=>{wp({sessionId:e,scope:"runtime",event:"wake-lock-acquired"})},Ct=>{throw wp({sessionId:e,scope:"runtime",event:"wake-lock-failed",details:{error:Ct instanceof Error?Ct.message:String(Ct)}}),new Error("屏幕常亮请求被浏览器拒绝,Voice Pilot 未开启。",{cause:Ct})});ve=Pk.acquire("capture");const sn=Sy.prepare(),on=CH().kind==="microphone"?gEe():Promise.resolve();await Promise.all([Lt,sn,on]),K(e),Je=!0,Ce(!1)}catch(Lt){wp({sessionId:e,scope:"runtime",event:"startup-failed",details:{error:Lt instanceof Error?Lt.message:String(Lt)}}),Ue.error(Lt instanceof Error?Lt.message:String(Lt))}finally{ve==null||ve.release(),Je||await jl.disable(dt).catch(()=>{}),Re(!1)}}const st=b.useRef(null),Ae=b.useRef(null),[ut,mt]=b.useState(!1);async function ge(ve){var Lt;const Je=(Lt=ve.target.files)==null?void 0:Lt[0];if(ve.target.value="",!Je)return;const dt=$t;if(!dt){Ue.error("请先连接开发机");return}const Ot=await em({relay:dt,sessionId:e,file:Je});Ot&&Mo(e,`@${Ot} `)}async function Ye(ve,Je){const dt=$t;if(!dt)throw new Error("请先连接开发机");const Ot=await dt.renameSession(ve,Je);if(!Ot.success)throw new Error(Ot.error??"重命名失败");M(ve,Ot.name??Je),Ue.success("已重命名会话")}return m.jsxs("div",{className:"border-b border-border bg-card pt-[env(safe-area-inset-top)] shrink-0","data-slot":"chat-header",children:[m.jsx("div",{className:"dev-chat-shell-rail-inset","data-slot":"chat-header-rail-inset",children:m.jsxs("div",{className:"grid min-h-12 w-full grid-cols-[2.25rem_minmax(0,1fr)_2.25rem] items-center","data-slot":"chat-header-rail",children:[m.jsx("div",{className:"flex justify-start",children:m.jsx(vt,{variant:"ghost",size:"icon-sm",className:"md:hidden",onClick:()=>o("/sessions"),"aria-label":"返回会话列表","data-slot":"chat-back-button",children:m.jsx(ff,{"aria-hidden":"true"})})}),m.jsx("span",{className:"text-sm font-semibold truncate text-center px-2","data-slot":"chat-session-title",children:m.jsx(pEe,{title:ne,isPtyTitle:Q})}),m.jsxs(_f,{modal:!1,onOpenChange:ve=>{ve?O.current=!1:F(!1)},children:[m.jsx(wf,{asChild:!0,children:m.jsx(vt,{ref:L,variant:"ghost",size:"icon-sm",className:"justify-self-end","aria-label":"会话操作","data-slot":"chat-overflow-trigger",onPointerDownCapture:ve=>{if(ve.currentTarget.getAttribute("data-state")==="open")return;const Je=document.activeElement,dt=Je==null?void 0:Je.closest('[data-slot="pty-keepalive-entry"]');B.current=I&&Je instanceof HTMLTextAreaElement&&Je.matches('[data-slot="pty-host"] .xterm-helper-textarea')&&(dt==null?void 0:dt.getAttribute("data-session-id"))===e&&dt.getAttribute("data-active")==="true"?Je:null},onKeyDownCapture:ve=>{["Enter"," ","ArrowDown"].includes(ve.key)&&(B.current=null)},children:m.jsx(iY,{"aria-hidden":"true"})})}),m.jsxs(xf,{align:"end",className:"w-max min-w-44 max-w-[calc(100vw-1rem)] data-[state=open]:animate-none","data-slot":"chat-overflow-menu",onEscapeKeyDown:ve=>{if(ve.target instanceof HTMLElement&&ve.target.matches('[data-terminal-dimension-input][data-editing="true"]')){ve.preventDefault();return}O.current=!0},onInteractOutside:()=>{const ve=document.activeElement;ve instanceof HTMLInputElement&&ve.hasAttribute("data-terminal-dimension-input")&&ve.blur()},onCloseAutoFocus:ve=>{const Je=B.current,dt=O.current;B.current=null,O.current=!1;const Ot=Je==null?void 0:Je.closest('[data-slot="pty-keepalive-entry"]'),Lt=document.activeElement;ve.defaultPrevented||!dt||!I||!(Je!=null&&Je.isConnected)||(Ot==null?void 0:Ot.getAttribute("data-session-id"))!==e||Ot.getAttribute("data-active")!=="true"||Lt!==document.body&&Lt!==document.documentElement&&Lt!==L.current&&Lt!==Je&&!(Lt!=null&&Lt.closest('[data-slot="chat-overflow-menu"]'))||(ve.preventDefault(),Je.focus({preventScroll:!0}))},children:[m.jsx(vv,{className:Fv,children:"会话"}),m.jsxs(Zr,{className:Ml,"data-slot":"chat-menu-find",onSelect:n,children:[m.jsx(Bs,{children:m.jsx(ky,{"aria-hidden":"true"})}),"在会话中查找"]}),m.jsxs(Zr,{className:Ml,"data-slot":"chat-menu-rename",onSelect:()=>mt(!0),children:[m.jsx(Bs,{children:m.jsx(KY,{"aria-hidden":"true"})}),"重命名"]}),m.jsxs(v0,{checked:Ke,className:qe("min-h-9 justify-start gap-2.5 pl-2 pr-8 [&>span:first-child]:left-auto [&>span:first-child]:right-2",!j.supported&&!Ke&&"pr-2"),disabled:et,"data-slot":"chat-menu-screen-wake-lock-item",onCheckedChange:Fe,children:[m.jsx(Bs,{children:m.jsx(AY,{"aria-hidden":"true"})}),m.jsx("span",{className:"min-w-0 flex-1",children:j.supported?Rt?"屏幕常亮(Voice Pilot 控制)":"屏幕常亮":j.unavailableReason==="insecure-context"?"屏幕常亮(需要 HTTPS)":"屏幕常亮(浏览器不支持)"})]}),I&&!V&&P&&m.jsxs(v0,{checked:z,className:"min-h-9 justify-start gap-2.5 pl-2 pr-8 [&>span:first-child]:left-auto [&>span:first-child]:right-2",disabled:!T,"data-slot":"chat-menu-pty-auto-yes-item",onCheckedChange:ve=>{T&&Y(T,ve===!0)},children:[m.jsx(Bs,{children:m.jsx(PK,{"aria-hidden":"true"})}),m.jsx("span",{className:"min-w-0 flex-1",children:"Always yes"})]}),!I&&!V&&m.jsxs(v0,{checked:q.enabled,className:"min-h-9 justify-start gap-2.5 pl-2 pr-8 [&>span:first-child]:left-auto [&>span:first-child]:right-2","data-slot":"chat-menu-voice-pilot-item",onCheckedChange:xt,children:[m.jsx(Bs,{children:m.jsx(BY,{"aria-hidden":"true"})}),m.jsx("span",{className:"min-w-0 flex-1",children:"Voice Pilot"})]}),m.jsx(Gc,{}),(l==null?void 0:l.mode)==="pty"&&l.ptyOwner==="proxy-hosted"&&r&&m.jsxs(m.Fragment,{children:[m.jsx(vv,{className:Fv,children:"终端尺寸"}),m.jsxs(Zr,{className:Ml,"data-slot":"chat-menu-fit-terminal",disabled:!g||!_||l.state==="error",onSelect:()=>r("fit"),children:[m.jsx(Bs,{children:m.jsx(OY,{"aria-hidden":"true"})}),"按窗口调整终端尺寸"]}),vEe.map(({axis:ve,label:Je,unit:dt,Icon:Ot,min:Lt,max:sn})=>{const Gt=d==null?void 0:d[ve],on=!g||!_||l.state==="error"||Gt===void 0;return m.jsxs("div",{role:"group","aria-label":Je,className:"flex min-h-9 items-center gap-2.5 px-2 text-sm","data-slot":`chat-menu-${ve}-control`,children:[m.jsx(Bs,{children:m.jsx(Ot,{"aria-hidden":"true"})}),m.jsx("span",{children:Je}),m.jsxs("div",{className:"inline-flex shrink-0 items-center gap-2",children:[m.jsx(vt,{variant:"ghost",size:"icon-sm",className:"size-[22px] rounded-[5px] bg-muted/45 text-muted-foreground hover:bg-accent hover:text-accent-foreground",disabled:on||Gt!==void 0&&Gt<=Lt,"aria-label":`减少${dt}`,"data-slot":`chat-menu-decrease-${ve}`,onClick:Ct=>{Ct.stopPropagation(),r(`decrease-${ve}`)},children:m.jsx(uP,{"aria-hidden":"true"})}),m.jsx(W1e,{axis:ve,label:Je,value:Gt,min:Lt,max:sn,disabled:on,onCommit:Ct=>r({axis:ve,value:Ct})},`${e}-${ve}`),m.jsx(vt,{variant:"ghost",size:"icon-sm",className:"size-[22px] rounded-[5px] bg-muted/45 text-muted-foreground hover:bg-accent hover:text-accent-foreground",disabled:on||Gt!==void 0&&Gt>=sn,"aria-label":`增加${dt}`,"data-slot":`chat-menu-increase-${ve}`,onClick:Ct=>{Ct.stopPropagation(),r(`increase-${ve}`)},children:m.jsx(dP,{"aria-hidden":"true"})})]})]},ve)}),m.jsx(Gc,{})]}),I&&m.jsxs(m.Fragment,{children:[m.jsxs(Rde,{open:D,onOpenChange:F,children:[m.jsxs(Ade,{className:qe(Ml,"[&>svg:last-child]:ml-0"),"data-slot":"chat-menu-shortcuts-trigger",onClick:ve=>{D&&(ve.preventDefault(),F(!1))},children:[m.jsx(Bs,{children:m.jsx(SC,{"aria-hidden":"true"})}),"发送快捷键"]}),m.jsx(Tde,{children:m.jsx(Nde,{className:qe("min-w-44 max-w-[calc(100vw-1rem)] max-h-(--radix-dropdown-menu-content-available-height) overflow-y-auto","data-[side=left]:translate-x-[max(0px,calc(100%-var(--radix-dropdown-menu-content-available-width)))]","data-[side=right]:-translate-x-[max(0px,calc(100%-var(--radix-dropdown-menu-content-available-width)))]"),sideOffset:4,collisionPadding:8,"data-slot":"chat-menu-shortcuts",children:N.map(ve=>m.jsxs(Zr,{className:Ml,"data-slot":`chat-menu-send-${ve.id}`,disabled:!g||!_||(l==null?void 0:l.mode)!=="pty"||l.state==="error",onSelect:()=>Mo(e,ve.data),children:[m.jsx(yEe,{label:ve.display}),"发送 ",ve.key]},ve.id))})})]}),m.jsx(Gc,{})]}),I&&!V?m.jsxs(m.Fragment,{children:[m.jsx(vv,{className:Fv,children:"文件"}),m.jsxs(Zr,{className:Ml,"data-slot":"chat-menu-upload-image",onClick:()=>{var ve;return(ve=Ae.current)==null?void 0:ve.click()},children:[m.jsx(Bs,{children:m.jsx(cm,{"aria-hidden":"true"})}),"上传照片或视频"]}),m.jsxs(Zr,{className:Ml,"data-slot":"chat-menu-upload-file",onClick:()=>{var ve;return(ve=st.current)==null?void 0:ve.click()},children:[m.jsx(Bs,{children:m.jsx(Pz,{"aria-hidden":"true"})}),"上传文件"]}),m.jsx(Gc,{})]}):null,m.jsx(vv,{className:Fv,children:"字号"}),m.jsx("div",{className:"px-2 pb-1","data-slot":"chat-menu-font-control",children:m.jsxs("div",{className:"inline-grid min-h-9 grid-cols-[1.25rem_auto] items-center gap-x-2.5 py-1","data-slot":"chat-menu-font-row",children:[m.jsx(Bs,{children:m.jsx(xK,{"aria-hidden":"true"})}),m.jsxs("div",{className:"col-start-2 inline-flex w-fit shrink-0 items-center gap-2","data-slot":"chat-menu-font-stepper",children:[m.jsx(vt,{variant:"ghost",size:"icon-sm",className:"size-[22px] rounded-[5px] bg-muted/45 text-muted-foreground hover:bg-accent hover:text-accent-foreground",disabled:ce<=re,"aria-label":"字号变小","data-slot":"chat-menu-font-smaller",onClick:ve=>{ve.stopPropagation(),$e(-1)},children:m.jsx(uP,{"aria-hidden":"true"})}),m.jsxs("span",{className:"flex h-[22px] min-w-11 items-center justify-center px-1 text-sm font-medium leading-none tabular-nums text-foreground","data-slot":"chat-menu-font-size",children:[ce,"px"]}),m.jsx(vt,{variant:"ghost",size:"icon-sm",className:"size-[22px] rounded-[5px] bg-muted/45 text-muted-foreground hover:bg-accent hover:text-accent-foreground",disabled:ce>=Zz,"aria-label":"字号变大","data-slot":"chat-menu-font-larger",onClick:ve=>{ve.stopPropagation(),$e(1)},children:m.jsx(dP,{"aria-hidden":"true"})})]})]})}),m.jsxs(Zr,{className:Ml,"data-slot":"chat-menu-font-reset",onClick:le,children:[m.jsx(Bs,{children:m.jsx(JY,{"aria-hidden":"true"})}),m.jsx("span",{"data-slot":"chat-menu-font-reset-label",children:"恢复默认"})]})]})]})]})}),m.jsx(cp,{open:ut,sessionId:e,initialName:l==null?void 0:l.name,onOpenChange:mt,onRename:Ye}),m.jsx(es,{open:we&&!q.enabled,onOpenChange:ve=>{ye||Ce(ve)},children:m.jsxs(ts,{className:"sm:max-w-md","data-slot":"voice-pilot-wake-lock-dialog",focusSurfaceOnOpen:!0,children:[m.jsxs(ns,{children:[m.jsx($i,{children:"开启 Voice Pilot?"}),m.jsx(Es,{children:"开启后会持续聆听并保持屏幕常亮,停止后自动恢复。"})]}),m.jsxs(qs,{children:[m.jsx(vt,{type:"button",variant:"outline",disabled:ye,onClick:()=>Ce(!1),children:"取消"}),m.jsx(vt,{type:"button","data-slot":"voice-pilot-confirm-start",disabled:ye,onClick:()=>{_t()},children:ye?"正在开启...":"开启 Voice Pilot"})]})]})}),I?m.jsxs(m.Fragment,{children:[m.jsx("input",{ref:Ae,type:"file",accept:s.mediaAccept,className:"hidden","data-slot":"chat-menu-upload-image-input",onChange:ve=>{ge(ve)}}),m.jsx("input",{ref:st,type:"file",accept:s.fileAccept,className:"hidden","data-slot":"chat-menu-upload-file-input",onChange:ve=>{ge(ve)}})]}):null]})}function _d(e,t,n){let r=n.initialDeps??[],i,s=!0;function o(){var l,u,d;let f;n.key&&((l=n.debug)!=null&&l.call(n))&&(f=Date.now());const h=e();if(!(h.length!==r.length||h.some((_,w)=>r[w]!==_)))return i;r=h;let g;if(n.key&&((u=n.debug)!=null&&u.call(n))&&(g=Date.now()),i=t(...h),n.key&&((d=n.debug)!=null&&d.call(n))){const _=Math.round((Date.now()-f)*100)/100,w=Math.round((Date.now()-g)*100)/100,S=w/16,x=(k,R)=>{for(k=String(k);k.length<R;)k=" "+k;return k};console.info(`%c⏱ ${x(w,5)} /${x(_,5)} ms`,`
739
+ `):[]);n(A=>A.filter(M=>R.has(M.sessionId))),i(A=>A&&R.has(A.sessionId)?A:null),h.current&&!R.has(h.current)&&(h.current=null,o(null))},[y,d]),b.useEffect(()=>{const R=f.current;f.current=l,!(!R||R===l)&&(h.current=null,n([]),i(null),o(null))},[l]);const k=b.useMemo(()=>({activate:g,deactivate:_,updateFindRequest:S,updateResizeRequest:x,updateViewportRect:w}),[g,_,S,x,w]);return m.jsxs(gH.Provider,{value:k,children:[e,m.jsx(M1e,{entries:t,activeView:r,viewportRect:s})]})}function N1e({sessionId:e,sessionKind:t,provider:n,findRequest:r,resizeRequest:i}){const s=b.useContext(gH),o=b.useRef(null);if(!s)throw new Error("PtyKeepAliveViewport must be used within PtyKeepAliveProvider");const{activate:l,deactivate:u,updateFindRequest:d,updateResizeRequest:f,updateViewportRect:h}=s;return b.useLayoutEffect(()=>(l({sessionId:e,sessionKind:t,provider:n}),()=>u(e)),[l,u,e,t,n]),b.useLayoutEffect(()=>{d(e,r)},[r,e,d]),b.useLayoutEffect(()=>{f(e,i)},[i,e,f]),b.useLayoutEffect(()=>{const y=o.current;if(!y)return;const g=()=>{const w=y.getBoundingClientRect();h(e,{top:w.top,left:w.left,width:w.width,height:w.height})};g();const _=new ResizeObserver(g);return _.observe(y),window.addEventListener("resize",g),()=>{_.disconnect(),window.removeEventListener("resize",g)}},[e,h]),m.jsx("div",{ref:o,className:"h-full w-full bg-background","data-slot":"pty-keepalive-viewport","data-session-id":e})}function M1e({entries:e,activeView:t,viewportRect:n}){return e.length===0?null:m.jsx("div",{className:"fixed inset-0 z-10 pointer-events-none","data-slot":"pty-keepalive-layer",children:e.map(r=>{const i=(t==null?void 0:t.sessionId)===r.sessionId&&n!==null,s=i?n:{top:-1e5,left:0,width:(n==null?void 0:n.width)??T1e,height:(n==null?void 0:n.height)??R1e};return m.jsx("div",{className:"absolute overflow-hidden bg-background","data-slot":"pty-keepalive-entry","data-session-id":r.sessionId,"data-active":i?"true":"false","aria-hidden":!i,style:{top:s.top,left:s.left,width:s.width,height:s.height,pointerEvents:i?"auto":"none",visibility:i?"visible":"hidden"},children:m.jsx(l$,{sessionId:r.sessionId,children:m.jsx(C1e,{sessionId:r.sessionId,sessionKind:r.sessionKind,provider:r.provider,active:i,findRequest:r.findRequest,resizeRequest:r.resizeRequest})})},r.sessionId)})})}function P1e(e,t){return Math.abs(e.top-t.top)<=jv&&Math.abs(e.left-t.left)<=jv&&Math.abs(e.width-t.width)<=jv&&Math.abs(e.height-t.height)<=jv}function I1e(){const e=Ut(r=>r.codexActiveWriterConflict),t=Ut(r=>r.setCodexActiveWriterConflict),n=()=>t(null);return m.jsx(es,{open:e!==null,onOpenChange:r=>!r&&n(),children:m.jsxs(ts,{focusSurfaceOnOpen:!0,className:"min-w-0 sm:max-w-md",children:[m.jsxs(ns,{children:[m.jsx($i,{children:"该 Codex 会话仍在运行"}),m.jsxs(Es,{className:"space-y-2 text-left leading-6",children:[m.jsxs("span",{className:"block",children:["另一个 Codex 进程正在使用此会话",e!=null&&e.activeWriterPid?m.jsxs(m.Fragment,{children:["(PID"," ",m.jsx("span",{className:"font-mono text-foreground",children:e.activeWriterPid}),")"]}):null,"。"]}),m.jsx("span",{className:"block",children:"它可能来自本机终端、Codex App 或另一条 DEV Anywhere 会话。请先回到或结束原会话后再重试。"}),m.jsx("span",{className:"block text-muted-foreground/80",children:"DEV Anywhere 不会自动终止该进程。"})]})]}),m.jsx(qs,{children:m.jsx(vt,{type:"button",onClick:n,autoFocus:!0,children:"知道了"})})]})})}function wT({route:e,surface:t,proxiesLength:n,proxyListLoaded:r,hasProxy:i,relayClientAuthIssue:s=null}){return s==="missing_client_token"?"Relay 需要 client token,请在设置中填写":s==="invalid_client_token"?"client token 无效或已过期,请在设置中更新":r?n===0?"在开发机上启动 DEV Anywhere,本页会显示可连接的开发机":t==="mobile"&&e==="proxy-select"||!i?"选择要连接的开发机":null:null}function O1e(e){const t=t5(e);return t.osName!=="iPad"?{supported:!0}:e.standalone||t.browserName==="Safari"?{supported:!0}:{supported:!1,reason:"ipad-safari-required",browserName:t.browserName}}function xy(){if(typeof window>"u"||typeof navigator>"u")return!1;const e=typeof window.matchMedia=="function"&&(window.matchMedia("(display-mode: standalone)").matches||window.matchMedia("(display-mode: fullscreen)").matches),t=!!navigator.standalone;return e||t}function L1e(){return typeof navigator>"u"?{supported:!0}:O1e({userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints,standalone:xy()})}function D1e(){lSe(),cSe();const e=ds(),t=Cs(),n=e.pathname.startsWith("/chat/"),r=e.pathname.startsWith("/preview/device/"),i=n||r,s=e.pathname==="/"||e.pathname==="/sessions",[o,l]=b.useState(!1),[u,d]=b.useState(()=>xy()),f=Me(I=>I.proxies.length),h=Me(I=>I.proxyListLoaded),y=Me(I=>I.relayClientAuthIssue),g=Me(I=>I.relayConnectionIssue),_=Me(I=>!!I.selectedProxyId),w=Me(I=>I.selectedProxyId),S=Me(I=>I.selectedProxyName),x=Me(I=>{var N;return(N=I.proxies.find(L=>L.proxyId===I.selectedProxyId))==null?void 0:N.osName});Ut(I=>I.sessions.length);const k=Me(I=>I.pendingToast),R=Me(I=>I.setPendingToast),A=e.pathname==="/"?"proxy-select":"sessions",M=g!==null&&y===null,T=wT({route:A,surface:"mobile",proxiesLength:f,proxyListLoaded:h,hasProxy:_,relayClientAuthIssue:y}),P=S??w,Y=e.pathname==="/sessions"&&h&&f>0?m.jsxs(vt,{variant:"ghost",size:"sm",className:"h-auto min-h-11 max-w-full justify-start rounded-md border border-border/70 bg-background/35 px-3 py-2 text-left text-muted-foreground hover:border-primary/45 hover:bg-accent/70 hover:text-foreground","data-slot":"mobile-switch-proxy","aria-label":P?`切换开发机,当前 ${P}`:"切换开发机",onClick:()=>t("/"),children:[m.jsx(Tz,{className:"size-4 text-primary","aria-hidden":"true"}),m.jsx(Ep,{name:P??"切换开发机",osName:x,nameClassName:"text-foreground"})]}):null;b.useEffect(()=>{if(!k)return;({error:Ue.error,info:Ue.info,success:Ue.success})[k.kind](k.message),R(null)},[k,R]),b.useEffect(()=>{if(typeof window.matchMedia!="function"){d(xy());return}const I=window.matchMedia("(display-mode: standalone)"),N=window.matchMedia("(display-mode: fullscreen)"),L=()=>d(xy());return L(),I.addEventListener("change",L),N.addEventListener("change",L),()=>{I.removeEventListener("change",L),N.removeEventListener("change",L)}},[]);const U=b.useRef(!1);b.useEffect(()=>{if(U.current)return;U.current=!0;const I=Sie({pathname:e.pathname,alreadyRestored:kie(),lastRoute:Eie()});Tie(),I&&(Rie(I),t(I,{replace:!0}))},[]);const G=b.useRef(!1);return b.useEffect(()=>{n?(G.current=!0,Cie(`${e.pathname}${e.search}`)):G.current&&(G.current=!1,Dy())},[n,e.pathname,e.search]),m.jsxs(Ede,{blocked:M,children:[m.jsxs("div",{className:"flex flex-col bg-background text-foreground",style:{height:"var(--dev-app-shell-height, max(100dvh, var(--dev-visual-viewport-height, 100dvh)))"},"data-slot":"app-shell","data-standalone-display":u?"true":void 0,inert:M?!0:void 0,"aria-hidden":M?!0:void 0,children:[!i&&m.jsx(vt,{variant:"ghost",size:"icon",className:"dev-mobile-settings-trigger group fixed right-4 z-30 size-11 rounded-full border-0 bg-transparent p-0 text-muted-foreground shadow-none hover:bg-transparent hover:text-foreground md:hidden","aria-label":"设置","data-slot":"mobile-settings-trigger",onClick:()=>l(!0),children:m.jsx("span",{"data-slot":"mobile-settings-trigger-visual",className:"flex size-7 items-center justify-center rounded-full border border-border/80 bg-card/90 shadow-lg backdrop-blur transition-colors group-hover:border-primary/45 group-hover:bg-accent",children:m.jsx(Nz,{className:"size-4","aria-hidden":"true"})})}),!i&&m.jsx(Ahe,{subtitle:T,action:Y}),m.jsx(kpe,{}),m.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[m.jsx(khe,{className:"hidden md:flex"}),m.jsx("main",{className:"relative flex-1 overflow-hidden",role:"main",children:m.jsx(A1e,{children:m.jsx("div",{className:qe("h-full",!s&&"animate-in fade-in-0 duration-200 motion-reduce:animate-none"),"data-slot":"route-content",children:m.jsx(R7,{})},s?"top-level":e.pathname)})})]}),m.jsx(O1,{open:o,onOpenChange:l}),m.jsx(I1e,{}),m.jsx(npe,{}),m.jsx(zhe,{}),m.jsx(Gre,{})]}),M&&g?m.jsx("div",{className:"fixed inset-0 z-[60] bg-background",children:m.jsx(spe,{issue:g})}):null]})}function vH({subtitle:e,action:t}){return m.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-6 px-6 text-center",children:[m.jsx(RF,{texts:AF,className:"text-2xl md:text-3xl font-bold"}),e?m.jsx("p",{className:"max-w-md text-sm text-muted-foreground",children:e}):null,t&&m.jsx("div",{children:t})]})}function B1e(){const e=Me(o=>o.proxies),t=Me(o=>o.proxyListLoaded),n=Me(o=>!!o.selectedProxyId),r=Me(o=>o.relayClientAuthIssue);Ut(o=>o.sessions.length);const i=wT({route:"proxy-select",surface:"desktop",proxiesLength:e.length,proxyListLoaded:t,hasProxy:n,relayClientAuthIssue:r}),s=r==="missing_client_token"?"client-token-missing":r==="invalid_client_token"?"client-token-invalid":null;return m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"h-full md:hidden",children:m.jsx(oF,{layout:"page"})}),m.jsx("div",{className:"hidden md:block h-full",children:s?m.jsx(Jc,{variant:s}):m.jsx(vH,{subtitle:i})})]})}function z1e(){const e=Me(o=>o.proxies),t=Me(o=>o.proxyListLoaded),n=Me(o=>!!o.selectedProxyId),r=Me(o=>o.relayClientAuthIssue);Ut(o=>o.sessions.length);const i=Ni("local",_n.proxyId)!==null;if(!n&&!i)return m.jsx(T7,{to:"/",replace:!0});const s=wT({route:"sessions",surface:"desktop",proxiesLength:e.length,proxyListLoaded:t,hasProxy:n,relayClientAuthIssue:r});return m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"h-full md:hidden",children:m.jsx(bF,{layout:"page"})}),m.jsx("div",{className:"hidden md:block h-full",children:m.jsx(vH,{subtitle:s})})]})}function yH(){if(!(typeof navigator>"u"))return navigator.wakeLock}function j1e(e,t){return e===!1?"insecure-context":t?null:"unsupported"}function bH(){var t;const e=typeof window>"u"?void 0:window.isSecureContext;return j1e(e,typeof((t=yH())==null?void 0:t.request)=="function")}function F1e(e){return e==="insecure-context"?"屏幕常亮需要 HTTPS":"当前浏览器不支持屏幕常亮"}function $1e(){const e=yH();if(typeof(e==null?void 0:e.request)!="function")throw new Error(F1e(bH()));return e.request("screen")}function H1e(e){return e instanceof Error&&e.message.trim()?e.message:"无法开启屏幕常亮"}class U1e{constructor(t={}){je(this,"activeScopes",new Set);je(this,"pendingScopes",new Set);je(this,"listeners",new Map);je(this,"sentinel",null);je(this,"requestInFlight",null);je(this,"requestWakeLock");je(this,"documentRef");je(this,"windowRef");je(this,"unavailableReason");je(this,"handleVisibilityChange",()=>{var t,n;if(((t=this.documentRef)==null?void 0:t.visibilityState)==="hidden"){this.releaseSentinel().catch(()=>{});return}((n=this.documentRef)==null?void 0:n.visibilityState)==="visible"&&this.ensureWakeLock().catch(()=>{})});je(this,"handlePageHide",()=>{this.releaseSentinel().catch(()=>{})});var n,r;this.requestWakeLock=t.request??$1e,this.unavailableReason=typeof t.request=="function"?null:bH(),this.documentRef=t.document??(typeof document>"u"?void 0:document),this.windowRef=t.window??(typeof window>"u"?void 0:window),(n=this.documentRef)==null||n.addEventListener("visibilitychange",this.handleVisibilityChange),(r=this.windowRef)==null||r.addEventListener("pagehide",this.handlePageHide)}isSupported(){return this.unavailableReason===null}getSnapshot(t){return{active:this.activeScopes.has(t),pending:this.pendingScopes.has(t),supported:this.isSupported(),unavailableReason:this.unavailableReason}}subscribe(t,n){const r=this.listeners.get(t)??new Set;return r.add(n),this.listeners.set(t,r),n(this.getSnapshot(t)),()=>{r.delete(n),r.size===0&&this.listeners.delete(t)}}async enable(t){this.activeScopes.add(t),this.pendingScopes.add(t),this.notify(t);try{await this.ensureWakeLock()}catch(n){throw this.activeScopes.delete(t),new Error(H1e(n),{cause:n})}finally{this.pendingScopes.delete(t),this.notify(t)}}async disable(t){const n=this.activeScopes.delete(t);this.pendingScopes.delete(t),this.notify(t),!(!n||this.activeScopes.size>0)&&await this.releaseSentinel()}async toggle(t){this.activeScopes.has(t)?await this.disable(t):await this.enable(t)}dispose(){var t,n;(t=this.documentRef)==null||t.removeEventListener("visibilitychange",this.handleVisibilityChange),(n=this.windowRef)==null||n.removeEventListener("pagehide",this.handlePageHide),this.activeScopes.clear(),this.pendingScopes.clear(),this.releaseSentinel().catch(()=>{});for(const r of this.listeners.keys())this.notify(r)}async ensureWakeLock(){var t;if(this.activeScopes.size!==0&&((t=this.documentRef)==null?void 0:t.visibilityState)!=="hidden"&&!(this.sentinel&&!this.sentinel.released))return this.requestInFlight?this.requestInFlight:(this.requestInFlight=this.requestWakeLock().then(async n=>{var r;if(this.activeScopes.size===0||((r=this.documentRef)==null?void 0:r.visibilityState)==="hidden"){n.released||await n.release();return}this.sentinel=n,n.addEventListener("release",()=>{var i;this.sentinel===n&&(this.sentinel=null),this.activeScopes.size>0&&((i=this.documentRef)==null?void 0:i.visibilityState)!=="hidden"&&this.ensureWakeLock().catch(()=>{})},{once:!0})}).finally(()=>{this.requestInFlight=null}),this.requestInFlight)}async releaseSentinel(){const t=this.sentinel;this.sentinel=null,!(!t||t.released)&&await t.release()}notify(t){var r;const n=this.getSnapshot(t);(r=this.listeners.get(t))==null||r.forEach(i=>i(n))}}const jl=new U1e;function _H(e){const[t,n]=b.useState(()=>jl.getSnapshot(e));b.useEffect(()=>jl.subscribe(e,n),[e]),b.useEffect(()=>()=>{jl.disable(e).catch(()=>{})},[e]);const r=b.useCallback(()=>jl.enable(e),[e]),i=b.useCallback(()=>jl.disable(e),[e]),s=b.useCallback(()=>jl.toggle(e),[e]);return{...t,enable:r,disable:i,toggle:s}}function W1e({axis:e,label:t,value:n,min:r,max:i,disabled:s,onCommit:o}){const[l,u]=b.useState(null),[d,f]=b.useState(!1),[h,y]=b.useState(!1);function g(){u(null),f(!1),y(!1)}function _(w){if(s||!d||l===null){g();return}const S=l.trim(),x=Number(S);if(!/^\d+$/.test(S)||!Number.isSafeInteger(x)||x<r||x>i){Ue.error(`请输入 ${r}–${i} 之间的整数`),w?y(!0):g();return}g(),x!==n&&o(x)}return m.jsx("input",{type:"text",inputMode:"numeric",enterKeyHint:"done",pattern:"[0-9]*","aria-label":`设置${t}`,"aria-invalid":h,"data-slot":`chat-menu-${e}-value`,"data-terminal-dimension-input":"","data-editing":l!==null?"true":"false",className:qe("h-[22px] w-9 rounded-[5px] border border-transparent bg-transparent px-0.5 text-center text-sm font-medium leading-none tabular-nums text-foreground outline-none hover:bg-muted/45 focus:border-ring focus:bg-background disabled:cursor-not-allowed disabled:opacity-50 [@media(pointer:coarse)]:focus:text-base",h&&"border-destructive focus:border-destructive"),disabled:s,value:l??(n==null?void 0:n.toString())??"",placeholder:"—",autoComplete:"off",spellCheck:!1,onFocus:w=>{u(w.currentTarget.value),f(!1),w.currentTarget.select()},onChange:w=>{u(w.currentTarget.value),f(!0),y(!1)},onBlur:()=>_(!1),onKeyDown:w=>{w.stopPropagation(),!w.nativeEvent.isComposing&&(w.key==="Enter"?(w.preventDefault(),_(!0)):w.key==="Escape"&&(w.preventDefault(),g()))}})}function q1e(){return new AudioContext}class V1e{constructor(t=q1e){je(this,"context",null);this.createContext=t}get(){return this.context??(this.context=this.createContext()),this.context}async prepare(){const t=this.get();if(t.state!=="running"&&t.state!=="closed"&&await t.resume(),t.state!=="running")throw new Error("浏览器未允许播放 Voice Pilot 提示音");return t}async reactivateAfterCapture(){const t=this.get();if(t.state==="closed")throw new Error("Voice Pilot 播放上下文已关闭");if(t.state==="running"&&await t.suspend(),t.state!=="running"&&await t.resume(),t.state!=="running")throw new Error("浏览器未能恢复 Voice Pilot 音频输出");return t}}const Sy=new V1e,YL=400,jd=[];let wH=1;function Y1e(){return typeof performance>"u"?0:Math.round(performance.now()*10)/10}function wp(e){const t={sequence:wH++,timestamp:new Date().toISOString(),monotonicMs:Y1e(),sessionId:e.sessionId,scope:e.scope,event:e.event,...e.attemptId?{attemptId:e.attemptId}:{},...e.requestId?{requestId:e.requestId}:{},...e.details?{details:{...e.details}}:{}};jd.push(t),jd.length>YL&&jd.splice(0,jd.length-YL)}function K1e(){return jd.map(e=>({...e,...e.details?{details:{...e.details}}:{}}))}function G1e(){jd.length=0,wH=1}typeof window<"u"&&(window.__devAnywhereVoicePilotDiagnostics={snapshot:K1e,clear:G1e});function xH(e){return`voice-pilot:${e}`}function X1e(e){const t=new Int16Array(e.length);for(let n=0;n<e.length;n+=1){const r=Math.max(-1,Math.min(1,e[n]??0));t[n]=r<0?Math.round(r*32768):Math.floor(r*32767)}return new Uint8Array(t.buffer)}const Z1e="modulepreload",Q1e=function(e){return"/"+e},KL={},SH=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){let o=function(d){return Promise.all(d.map(f=>Promise.resolve(f).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),u=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));i=o(n.map(d=>{if(d=Q1e(d),d in KL)return;KL[d]=!0;const f=d.endsWith(".css"),h=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${h}`))return;const y=document.createElement("link");if(y.rel=f?"stylesheet":Z1e,f||(y.as="script"),y.crossOrigin="",y.href=d,u&&y.setAttribute("nonce",u),document.head.appendChild(y),f)return new Promise((g,_)=>{y.addEventListener("load",g),y.addEventListener("error",()=>_(new Error(`Unable to preload CSS for ${d}`)))})}))}function s(o){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=o,window.dispatchEvent(l),!l.defaultPrevented)throw o}return i.then(o=>{for(const l of o||[])l.status==="rejected"&&s(l.reason);return t().catch(s)})},J1e="/assets/fvad-DYxbW2my.wasm",uf=16e3,eEe=20,Fl=uf*eEe/1e3,fS=Fl*Int16Array.BYTES_PER_ELEMENT;let GL=null;async function tEe(){return GL??(GL=SH(async()=>{const{default:e}=await import("./fvad-DvEzQ7Vo.js");return{default:e}},[]).then(({default:e})=>e({locateFile:t=>t.endsWith(".wasm")?J1e:t}))),GL}class xT{constructor(t,n,r){je(this,"destroyed",!1);this.module=t,this.handle=n,this.framePointer=r}static async create(t=3){const n=await tEe(),r=n._fvad_new();if(!r)throw new Error("无法初始化浏览器语音活动检测器");const i=n._malloc(fS);if(!i)throw n._fvad_free(r),new Error("无法分配浏览器语音活动检测缓冲区");if(n._fvad_set_sample_rate(r,uf)!==0)throw n._free(i),n._fvad_free(r),new Error("浏览器语音活动检测器不支持 16 kHz 音频");if(n._fvad_set_mode(r,t)!==0)throw n._free(i),n._fvad_free(r),new Error("无法配置浏览器语音活动检测器");return new xT(n,r,i)}process(t){if(this.destroyed)throw new Error("浏览器语音活动检测器已释放");if(t.byteLength!==fS)throw new Error(`语音活动检测帧必须为 ${fS} 字节`);this.module.HEAPU8.set(t,this.framePointer);const n=this.module._fvad_process(this.handle,this.framePointer,Fl);if(n<0)throw new Error("浏览器语音活动检测失败");return n===1}reset(){this.destroyed||this.module._fvad_reset(this.handle)}destroy(){this.destroyed||(this.destroyed=!0,this.module._free(this.framePointer),this.module._fvad_free(this.handle))}}class nEe{constructor(t={}){je(this,"startSpeechFrames");je(this,"endSilenceFrames");je(this,"active",!1);je(this,"speechFrames",0);je(this,"silenceFrames",0);if(this.startSpeechFrames=t.startSpeechFrames??10,this.endSilenceFrames=t.endSilenceFrames??30,this.startSpeechFrames<1||this.endSilenceFrames<1)throw new Error("Invalid voice activity gate configuration")}push(t){return this.active?t?(this.silenceFrames=0,"none"):(this.silenceFrames+=1,this.silenceFrames<this.endSilenceFrames?"none":(this.active=!1,this.silenceFrames=0,"speech-end")):(this.speechFrames=t?this.speechFrames+1:0,this.speechFrames>=this.startSpeechFrames?(this.active=!0,this.speechFrames=0,this.silenceFrames=0,"speech-start"):"none")}reset(){this.active=!1,this.speechFrames=0,this.silenceFrames=0}}class rEe{constructor(){je(this,"pending",new Float32Array(Fl));je(this,"pendingLength",0)}push(t,n){let r=0;if(this.pendingLength>0){const i=Fl-this.pendingLength,s=Math.min(i,t.length);this.pending.set(t.subarray(0,s),this.pendingLength),this.pendingLength+=s,r+=s,this.pendingLength===Fl&&(n(this.pending.slice()),this.pendingLength=0)}for(;r+Fl<=t.length;)n(t.slice(r,r+Fl)),r+=Fl;if(r<t.length){const i=t.subarray(r);this.pending.set(i,0),this.pendingLength=i.length}}reset(){this.pendingLength=0}}const iEe="/__dev_anywhere_debug/voice-fixture",sEe=uf*SF/1e3;function oEe(){return xT.create(3)}const aEe={createVad:oEe,getUserMedia:e=>navigator.mediaDevices.getUserMedia(e),createAudioContext:e=>new AudioContext(e),fetch:e=>fetch(e)};function lEe(e){if(e.length===0)return 0;let t=0;for(const n of e)t+=n*n;return Math.min(1,Math.sqrt(t/e.length)*10)}function cEe(e){for(const t of e.getTracks())t.stop()}function EH(e){const t=e.createAudioContext({sampleRate:uf});if(t.sampleRate!==uf)throw t.close().catch(()=>{}),new Error("浏览器无法提供 Voice Pilot 所需的 16 kHz 音频输入");return t}async function uEe(e){const t=EH(e);let n;try{n=await e.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0,sampleRate:uf}})}catch(i){throw await t.close().catch(()=>{}),i}const r=t.createMediaStreamSource(n);return{context:t,input:r,async start(){t.state==="suspended"&&await t.resume()},async stop(){r.disconnect(),cEe(n),t.state!=="closed"&&await t.close()}}}async function dEe(e,t){const n=EH(t);try{const r=await t.fetch(e);if(!r.ok)throw new Error(`测试录音读取失败 (${r.status})`);const i=await n.decodeAudioData(await r.arrayBuffer()),s=n.createBufferSource();s.buffer=i;let o=!1,l=!1;return{context:n,input:s,async start(){o||l||(o=!0,n.state==="suspended"&&await n.resume(),s.start())},async stop(){if(!l){if(l=!0,o)try{s.stop()}catch{}s.disconnect(),n.state!=="closed"&&await n.close()}}}}catch(r){throw await n.close().catch(()=>{}),r}}function CH(e=window.location.search,t=!1){return t&&new URLSearchParams(e).get("voice-fixture")==="default"?{kind:"fixture",url:iEe}:{kind:"microphone"}}async function fEe(e,t=aEe){const n=await t.createVad();let r;try{r=e.source.kind==="fixture"?await dEe(e.source.url,t):await uEe(t)}catch(f){throw n.destroy(),f}const i=new nEe,s=new rEe,o=r.context.createScriptProcessor(sEe,1,1);let l=!1,u=null,d=null;return o.onaudioprocess=f=>{l&&s.push(f.inputBuffer.getChannelData(0),h=>{const y=X1e(h),g=n.process(y);e.onFrame({pcm:y,speechProbability:g?1:0,activityLevel:lEe(h)});const _=i.push(g);_==="speech-start"&&e.onSpeechStart(),_==="speech-end"&&e.onSpeechEnd()})},r.input.connect(o),o.connect(r.context.destination),{source:e.source.kind,start(){return d?Promise.reject(new Error("语音采集已停止")):(u??(u=(async()=>{l=!0,await r.start()})()),u)},stop(){return d??(d=(async()=>{l=!1,o.onaudioprocess=null,o.disconnect(),i.reset(),s.reset(),n.reset(),n.destroy(),await r.stop()})()),d}}}function kH(e=pf().osName){return{mediaAccept:"image/*,video/*",fileAccept:e==="Android"?"application/*,text/*":void 0}}function hEe(e){const[t,n,...r]=Array.from(e);return t&&n===" "&&r.length>0?{indicator:t,label:r.join("")}:{label:e}}function pEe({title:e,isPtyTitle:t}){if(!t)return m.jsx(m.Fragment,{children:e});const{indicator:n,label:r}=hEe(e);return m.jsxs("span",{className:"inline-flex items-center justify-center max-w-full min-w-0 font-mono font-normal",children:[n&&m.jsx("span",{className:"inline-block w-[1.25ch] shrink-0 text-center","aria-hidden":"true",children:n}),m.jsx("span",{className:"truncate",children:n?` ${r}`:r})]})}function mEe(e){const t=e instanceof Error?e.name:"";return t==="NotAllowedError"||t==="SecurityError"?"没有麦克风权限,请在浏览器里允许访问麦克风。":t==="NotFoundError"||t==="DevicesNotFoundError"?"未检测到可用麦克风。":t==="NotReadableError"||t==="TrackStartError"?"麦克风正在被其他应用占用。":e instanceof Error?e.message:"无法访问麦克风。"}async function gEe(){var t;if(!((t=navigator.mediaDevices)!=null&&t.getUserMedia))throw new Error("当前浏览器不支持麦克风访问。");let e=null;try{e=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(n){throw new Error(mEe(n),{cause:n})}finally{e==null||e.getTracks().forEach(n=>n.stop())}}const Ml="min-h-9 gap-2.5",Fv="px-2 pb-1 pt-2 text-xs font-semibold text-muted-foreground",vEe=[{axis:"cols",label:"列数",unit:"列",Icon:GV,min:eb,max:iu},{axis:"rows",label:"行数",unit:"行",Icon:rK,min:tb,max:su}];function Bs({children:e,className:t}){return m.jsx("span",{"aria-hidden":"true","data-slot":"chat-menu-icon",className:qe("inline-flex size-5 shrink-0 items-center justify-center text-muted-foreground [&_svg]:size-4",t),children:e})}function yEe({label:e}){return m.jsxs(Bs,{className:"relative",children:[m.jsx(SC,{className:"size-4","aria-hidden":"true"}),m.jsx("span",{className:"absolute -right-1.5 -top-1 flex h-3 min-w-4 items-center justify-center rounded-[3px] border border-border bg-popover px-0.5 font-mono text-[7px] leading-none text-muted-foreground shadow-sm",children:e})]})}function bEe({sessionId:e,mode:t,onFind:n,onResizeTerminal:r}){const i=qr(ve=>ve.homePath),s=kH(),o=Cs(),l=Ut(ve=>ve.sessions.find(Je=>Je.sessionId===e)),u=Ut(ve=>ve.ptyTitles[e]),d=Ut(ve=>ve.ptyGeometryBySessionId[e]),f=Me(ve=>ve.ptyFontSize),h=Me(ve=>ve.chatContentFontSize),y=Me(ve=>ve.selectedProxyId),g=Me(ve=>ve.connected),_=Me(ve=>ve.proxyOnline),w=Me(ve=>ve.adjustPtyFontSize),S=Me(ve=>ve.adjustChatContentFontSize),x=Me(ve=>ve.setChatContentFontSize),k=Me(ve=>ve.resetPtyFontSize),R=Me(ve=>ve.resetChatContentFontSize),A=Me(ve=>ve.inputModePreference==="hardware"),M=Ut(ve=>ve.renameSession),T=WC(y,e),P=(l==null?void 0:l.provider)!=="codex",z=Ut(ve=>P&&T?!!ve.ptyAutoYesBySessionKey[T]:!1),Y=Ut(ve=>ve.setPtyAutoYes),G=yo("(pointer: coarse), (hover: none)")&&!A,I=t==="pty"||(l==null?void 0:l.mode)==="pty",N=d$(l??{}).menu,L=b.useRef(null),B=b.useRef(null),O=b.useRef(!1),[D,F]=b.useState(!1),V=(l==null?void 0:l.kind)==="terminal",j=_H(e),q=An(ve=>ve.bySessionId[e]??a_),K=An(ve=>ve.enable),$=An(ve=>ve.disable),te=!!(l!=null&&l.nameLocked&&(l!=null&&l.name)),J=QC(l,i),ne=te&&(l==null?void 0:l.name)||J||I&&u||(l==null?void 0:l.name)||e.slice(0,8),Q=!!(I&&!V&&u&&!te),ce=I?f:AC(h,G),re=!I&&G?Qz:Xz,le=I?k:R,[we,Ce]=b.useState(!1),[ye,Re]=b.useState(!1),Rt=q.enabled,Ke=j.active||Rt,et=j.pending||!j.supported||Rt;function $e(ve){if(I){w(ve);return}if(G){x(ce+ve);return}S(ve)}function Fe(){j.toggle().catch(ve=>{Ue.error(ve instanceof Error?ve.message:String(ve))})}async function xt(ve){var dt;if(I||V){Ue.info("Voice Pilot 目前适用于聊天会话。");return}if(ve!==!0){$(e);return}const Je=$t;if(!Je){Ue.error("请先连接开发机");return}try{if(!((dt=(await Je.requestVoiceConfig()).config)!=null&&dt.configured)){Ue.info("请先在设置里配置 Voice Pilot。");return}Ce(!0)}catch(Ot){Ue.error(Ot instanceof Error?Ot.message:String(Ot))}}async function _t(){var Ot;Re(!0);let ve=null,Je=!1;const dt=xH(e);try{wp({sessionId:e,scope:"runtime",event:"wake-lock-requested",details:{userActivationActive:((Ot=navigator.userActivation)==null?void 0:Ot.isActive)??!1,visibilityState:document.visibilityState,secureContext:window.isSecureContext}});const Lt=jl.enable(dt).then(()=>{wp({sessionId:e,scope:"runtime",event:"wake-lock-acquired"})},Ct=>{throw wp({sessionId:e,scope:"runtime",event:"wake-lock-failed",details:{error:Ct instanceof Error?Ct.message:String(Ct)}}),new Error("屏幕常亮请求被浏览器拒绝,Voice Pilot 未开启。",{cause:Ct})});ve=Pk.acquire("capture");const sn=Sy.prepare(),on=CH().kind==="microphone"?gEe():Promise.resolve();await Promise.all([Lt,sn,on]),K(e),Je=!0,Ce(!1)}catch(Lt){wp({sessionId:e,scope:"runtime",event:"startup-failed",details:{error:Lt instanceof Error?Lt.message:String(Lt)}}),Ue.error(Lt instanceof Error?Lt.message:String(Lt))}finally{ve==null||ve.release(),Je||await jl.disable(dt).catch(()=>{}),Re(!1)}}const st=b.useRef(null),Ae=b.useRef(null),[ut,mt]=b.useState(!1);async function ge(ve){var Lt;const Je=(Lt=ve.target.files)==null?void 0:Lt[0];if(ve.target.value="",!Je)return;const dt=$t;if(!dt){Ue.error("请先连接开发机");return}const Ot=await em({relay:dt,sessionId:e,file:Je});Ot&&Mo(e,`@${Ot} `)}async function Ye(ve,Je){const dt=$t;if(!dt)throw new Error("请先连接开发机");const Ot=await dt.renameSession(ve,Je);if(!Ot.success)throw new Error(Ot.error??"重命名失败");M(ve,Ot.name??Je),Ue.success("已重命名会话")}return m.jsxs("div",{className:"border-b border-border bg-card pt-[env(safe-area-inset-top)] shrink-0","data-slot":"chat-header",children:[m.jsx("div",{className:"dev-chat-shell-rail-inset","data-slot":"chat-header-rail-inset",children:m.jsxs("div",{className:"grid min-h-12 w-full grid-cols-[2.25rem_minmax(0,1fr)_2.25rem] items-center","data-slot":"chat-header-rail",children:[m.jsx("div",{className:"flex justify-start",children:m.jsx(vt,{variant:"ghost",size:"icon-sm",className:"md:hidden",onClick:()=>o("/sessions"),"aria-label":"返回会话列表","data-slot":"chat-back-button",children:m.jsx(ff,{"aria-hidden":"true"})})}),m.jsx("span",{className:"text-sm font-semibold truncate text-center px-2","data-slot":"chat-session-title",children:m.jsx(pEe,{title:ne,isPtyTitle:Q})}),m.jsxs(_f,{modal:!1,onOpenChange:ve=>{ve?O.current=!1:F(!1)},children:[m.jsx(wf,{asChild:!0,children:m.jsx(vt,{ref:L,variant:"ghost",size:"icon-sm",className:"justify-self-end","aria-label":"会话操作","data-slot":"chat-overflow-trigger",onPointerDownCapture:ve=>{if(ve.currentTarget.getAttribute("data-state")==="open")return;const Je=document.activeElement,dt=Je==null?void 0:Je.closest('[data-slot="pty-keepalive-entry"]');B.current=I&&Je instanceof HTMLTextAreaElement&&Je.matches('[data-slot="pty-host"] .xterm-helper-textarea')&&(dt==null?void 0:dt.getAttribute("data-session-id"))===e&&dt.getAttribute("data-active")==="true"?Je:null},onKeyDownCapture:ve=>{["Enter"," ","ArrowDown"].includes(ve.key)&&(B.current=null)},children:m.jsx(iY,{"aria-hidden":"true"})})}),m.jsxs(xf,{align:"end",className:"w-max min-w-44 max-w-[calc(100vw-1rem)] data-[state=open]:animate-none","data-slot":"chat-overflow-menu",onEscapeKeyDown:ve=>{if(ve.target instanceof HTMLElement&&ve.target.matches('[data-terminal-dimension-input][data-editing="true"]')){ve.preventDefault();return}O.current=!0},onInteractOutside:()=>{const ve=document.activeElement;ve instanceof HTMLInputElement&&ve.hasAttribute("data-terminal-dimension-input")&&ve.blur()},onCloseAutoFocus:ve=>{const Je=B.current,dt=O.current;B.current=null,O.current=!1;const Ot=Je==null?void 0:Je.closest('[data-slot="pty-keepalive-entry"]'),Lt=document.activeElement;ve.defaultPrevented||!dt||!I||!(Je!=null&&Je.isConnected)||(Ot==null?void 0:Ot.getAttribute("data-session-id"))!==e||Ot.getAttribute("data-active")!=="true"||Lt!==document.body&&Lt!==document.documentElement&&Lt!==L.current&&Lt!==Je&&!(Lt!=null&&Lt.closest('[data-slot="chat-overflow-menu"]'))||(ve.preventDefault(),Je.focus({preventScroll:!0}))},children:[m.jsx(vv,{className:Fv,children:"会话"}),m.jsxs(Zr,{className:Ml,"data-slot":"chat-menu-find",onSelect:n,children:[m.jsx(Bs,{children:m.jsx(ky,{"aria-hidden":"true"})}),"在会话中查找"]}),m.jsxs(Zr,{className:Ml,"data-slot":"chat-menu-rename",onSelect:()=>mt(!0),children:[m.jsx(Bs,{children:m.jsx(KY,{"aria-hidden":"true"})}),"重命名"]}),m.jsxs(v0,{checked:Ke,className:qe("min-h-9 justify-start gap-2.5 pl-2 pr-8 [&>span:first-child]:left-auto [&>span:first-child]:right-2",!j.supported&&!Ke&&"pr-2"),disabled:et,"data-slot":"chat-menu-screen-wake-lock-item",onCheckedChange:Fe,children:[m.jsx(Bs,{children:m.jsx(AY,{"aria-hidden":"true"})}),m.jsx("span",{className:"min-w-0 flex-1",children:j.supported?Rt?"屏幕常亮(Voice Pilot 控制)":"屏幕常亮":j.unavailableReason==="insecure-context"?"屏幕常亮(需要 HTTPS)":"屏幕常亮(浏览器不支持)"})]}),I&&!V&&P&&m.jsxs(v0,{checked:z,className:"min-h-9 justify-start gap-2.5 pl-2 pr-8 [&>span:first-child]:left-auto [&>span:first-child]:right-2",disabled:!T,"data-slot":"chat-menu-pty-auto-yes-item",onCheckedChange:ve=>{T&&Y(T,ve===!0)},children:[m.jsx(Bs,{children:m.jsx(PK,{"aria-hidden":"true"})}),m.jsx("span",{className:"min-w-0 flex-1",children:"Always yes"})]}),!I&&!V&&m.jsxs(v0,{checked:q.enabled,className:"min-h-9 justify-start gap-2.5 pl-2 pr-8 [&>span:first-child]:left-auto [&>span:first-child]:right-2","data-slot":"chat-menu-voice-pilot-item",onCheckedChange:xt,children:[m.jsx(Bs,{children:m.jsx(BY,{"aria-hidden":"true"})}),m.jsx("span",{className:"min-w-0 flex-1",children:"Voice Pilot"})]}),m.jsx(Gc,{}),(l==null?void 0:l.mode)==="pty"&&l.ptyOwner==="proxy-hosted"&&r&&m.jsxs(m.Fragment,{children:[m.jsx(vv,{className:Fv,children:"终端尺寸"}),m.jsxs(Zr,{className:Ml,"data-slot":"chat-menu-fit-terminal",disabled:!g||!_||l.state==="error",onSelect:()=>r("fit"),children:[m.jsx(Bs,{children:m.jsx(OY,{"aria-hidden":"true"})}),"按窗口调整终端尺寸"]}),vEe.map(({axis:ve,label:Je,unit:dt,Icon:Ot,min:Lt,max:sn})=>{const Gt=d==null?void 0:d[ve],on=!g||!_||l.state==="error"||Gt===void 0;return m.jsxs("div",{role:"group","aria-label":Je,className:"flex min-h-9 items-center gap-2.5 px-2 text-sm","data-slot":`chat-menu-${ve}-control`,children:[m.jsx(Bs,{children:m.jsx(Ot,{"aria-hidden":"true"})}),m.jsx("span",{children:Je}),m.jsxs("div",{className:"inline-flex shrink-0 items-center gap-2",children:[m.jsx(vt,{variant:"ghost",size:"icon-sm",className:"size-[22px] rounded-[5px] bg-muted/45 text-muted-foreground hover:bg-accent hover:text-accent-foreground",disabled:on||Gt!==void 0&&Gt<=Lt,"aria-label":`减少${dt}`,"data-slot":`chat-menu-decrease-${ve}`,onClick:Ct=>{Ct.stopPropagation(),r(`decrease-${ve}`)},children:m.jsx(uP,{"aria-hidden":"true"})}),m.jsx(W1e,{axis:ve,label:Je,value:Gt,min:Lt,max:sn,disabled:on,onCommit:Ct=>r({axis:ve,value:Ct})},`${e}-${ve}`),m.jsx(vt,{variant:"ghost",size:"icon-sm",className:"size-[22px] rounded-[5px] bg-muted/45 text-muted-foreground hover:bg-accent hover:text-accent-foreground",disabled:on||Gt!==void 0&&Gt>=sn,"aria-label":`增加${dt}`,"data-slot":`chat-menu-increase-${ve}`,onClick:Ct=>{Ct.stopPropagation(),r(`increase-${ve}`)},children:m.jsx(dP,{"aria-hidden":"true"})})]})]},ve)}),m.jsx(Gc,{})]}),I&&m.jsxs(m.Fragment,{children:[m.jsxs(Rde,{open:D,onOpenChange:F,children:[m.jsxs(Ade,{className:qe(Ml,"[&>svg:last-child]:ml-0"),"data-slot":"chat-menu-shortcuts-trigger",onClick:ve=>{D&&(ve.preventDefault(),F(!1))},children:[m.jsx(Bs,{children:m.jsx(SC,{"aria-hidden":"true"})}),"发送快捷键"]}),m.jsx(Tde,{children:m.jsx(Nde,{className:qe("min-w-44 max-w-[calc(100vw-1rem)] max-h-(--radix-dropdown-menu-content-available-height) overflow-y-auto","data-[side=left]:translate-x-[max(0px,calc(100%-var(--radix-dropdown-menu-content-available-width)))]","data-[side=right]:-translate-x-[max(0px,calc(100%-var(--radix-dropdown-menu-content-available-width)))]"),sideOffset:4,collisionPadding:8,"data-slot":"chat-menu-shortcuts",children:N.map(ve=>m.jsxs(Zr,{className:Ml,"data-slot":`chat-menu-send-${ve.id}`,disabled:!g||!_||(l==null?void 0:l.mode)!=="pty"||l.state==="error",onSelect:()=>Mo(e,ve.data),children:[m.jsx(yEe,{label:ve.display}),"发送 ",ve.key]},ve.id))})})]}),m.jsx(Gc,{})]}),I&&!V?m.jsxs(m.Fragment,{children:[m.jsx(vv,{className:Fv,children:"文件"}),m.jsxs(Zr,{className:Ml,"data-slot":"chat-menu-upload-image",onClick:()=>{var ve;return(ve=Ae.current)==null?void 0:ve.click()},children:[m.jsx(Bs,{children:m.jsx(cm,{"aria-hidden":"true"})}),"上传照片或视频"]}),m.jsxs(Zr,{className:Ml,"data-slot":"chat-menu-upload-file",onClick:()=>{var ve;return(ve=st.current)==null?void 0:ve.click()},children:[m.jsx(Bs,{children:m.jsx(Pz,{"aria-hidden":"true"})}),"上传文件"]}),m.jsx(Gc,{})]}):null,m.jsx(vv,{className:Fv,children:"字号"}),m.jsx("div",{className:"px-2 pb-1","data-slot":"chat-menu-font-control",children:m.jsxs("div",{className:"inline-grid min-h-9 grid-cols-[1.25rem_auto] items-center gap-x-2.5 py-1","data-slot":"chat-menu-font-row",children:[m.jsx(Bs,{children:m.jsx(xK,{"aria-hidden":"true"})}),m.jsxs("div",{className:"col-start-2 inline-flex w-fit shrink-0 items-center gap-2","data-slot":"chat-menu-font-stepper",children:[m.jsx(vt,{variant:"ghost",size:"icon-sm",className:"size-[22px] rounded-[5px] bg-muted/45 text-muted-foreground hover:bg-accent hover:text-accent-foreground",disabled:ce<=re,"aria-label":"字号变小","data-slot":"chat-menu-font-smaller",onClick:ve=>{ve.stopPropagation(),$e(-1)},children:m.jsx(uP,{"aria-hidden":"true"})}),m.jsxs("span",{className:"flex h-[22px] min-w-11 items-center justify-center px-1 text-sm font-medium leading-none tabular-nums text-foreground","data-slot":"chat-menu-font-size",children:[ce,"px"]}),m.jsx(vt,{variant:"ghost",size:"icon-sm",className:"size-[22px] rounded-[5px] bg-muted/45 text-muted-foreground hover:bg-accent hover:text-accent-foreground",disabled:ce>=Zz,"aria-label":"字号变大","data-slot":"chat-menu-font-larger",onClick:ve=>{ve.stopPropagation(),$e(1)},children:m.jsx(dP,{"aria-hidden":"true"})})]})]})}),m.jsxs(Zr,{className:Ml,"data-slot":"chat-menu-font-reset",onClick:le,children:[m.jsx(Bs,{children:m.jsx(JY,{"aria-hidden":"true"})}),m.jsx("span",{"data-slot":"chat-menu-font-reset-label",children:"恢复默认"})]})]})]})]})}),m.jsx(cp,{open:ut,sessionId:e,initialName:l==null?void 0:l.name,onOpenChange:mt,onRename:Ye}),m.jsx(es,{open:we&&!q.enabled,onOpenChange:ve=>{ye||Ce(ve)},children:m.jsxs(ts,{className:"sm:max-w-md","data-slot":"voice-pilot-wake-lock-dialog",focusSurfaceOnOpen:!0,children:[m.jsxs(ns,{children:[m.jsx($i,{children:"开启 Voice Pilot?"}),m.jsx(Es,{children:"开启后会持续聆听并保持屏幕常亮,停止后自动恢复。"})]}),m.jsxs(qs,{children:[m.jsx(vt,{type:"button",variant:"outline",disabled:ye,onClick:()=>Ce(!1),children:"取消"}),m.jsx(vt,{type:"button","data-slot":"voice-pilot-confirm-start",disabled:ye,onClick:()=>{_t()},children:ye?"正在开启...":"开启 Voice Pilot"})]})]})}),I?m.jsxs(m.Fragment,{children:[m.jsx("input",{ref:Ae,type:"file",accept:s.mediaAccept,className:"hidden","data-slot":"chat-menu-upload-image-input",onChange:ve=>{ge(ve)}}),m.jsx("input",{ref:st,type:"file",accept:s.fileAccept,className:"hidden","data-slot":"chat-menu-upload-file-input",onChange:ve=>{ge(ve)}})]}):null]})}function _d(e,t,n){let r=n.initialDeps??[],i,s=!0;function o(){var l,u,d;let f;n.key&&((l=n.debug)!=null&&l.call(n))&&(f=Date.now());const h=e();if(!(h.length!==r.length||h.some((_,w)=>r[w]!==_)))return i;r=h;let g;if(n.key&&((u=n.debug)!=null&&u.call(n))&&(g=Date.now()),i=t(...h),n.key&&((d=n.debug)!=null&&d.call(n))){const _=Math.round((Date.now()-f)*100)/100,w=Math.round((Date.now()-g)*100)/100,S=w/16,x=(k,R)=>{for(k=String(k);k.length<R;)k=" "+k;return k};console.info(`%c⏱ ${x(w,5)} /${x(_,5)} ms`,`
740
740
  font-size: .6rem;
741
741
  font-weight: bold;
742
742
  color: hsl(${Math.max(0,Math.min(120-120*S,120))}deg 100% 31%);`,n==null?void 0:n.key)}return n!=null&&n.onChange&&!(s&&n.skipInitialOnChange)&&n.onChange(i),s=!1,i}return o.updateDeps=l=>{r=l},o}function XL(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const _Ee=(e,t)=>Math.abs(e-t)<1.01,wEe=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},ZL=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},xEe=e=>e,SEe=e=>{const t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let i=t;i<=n;i++)r.push(i);return r},EEe=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const i=o=>{const{width:l,height:u}=o;t({width:Math.round(l),height:Math.round(u)})};if(i(ZL(n)),!r.ResizeObserver)return()=>{};const s=new r.ResizeObserver(o=>{const l=()=>{const u=o[0];if(u!=null&&u.borderBoxSize){const d=u.borderBoxSize[0];if(d){i({width:d.inlineSize,height:d.blockSize});return}}i(ZL(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()});return s.observe(n,{box:"border-box"}),()=>{s.unobserve(n)}},QL={passive:!0},JL=typeof window>"u"?!0:"onscrollend"in window,CEe=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;let i=0;const s=e.options.useScrollendEvent&&JL?()=>{}:wEe(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=f=>()=>{const{horizontal:h,isRtl:y}=e.options;i=h?n.scrollLeft*(y&&-1||1):n.scrollTop,s(),t(i,f)},l=o(!0),u=o(!1);n.addEventListener("scroll",l,QL);const d=e.options.useScrollendEvent&&JL;return d&&n.addEventListener("scrollend",u,QL),()=>{n.removeEventListener("scroll",l),d&&n.removeEventListener("scrollend",u)}},kEe=(e,t,n)=>{if(t!=null&&t.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},TEe=(e,{adjustments:t=0,behavior:n},r)=>{var i,s;const o=e+t;(s=(i=r.scrollElement)==null?void 0:i.scrollTo)==null||s.call(i,{[r.options.horizontal?"left":"top"]:o,behavior:n})};class REe{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var n,r,i;return((i=(r=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:r.now)==null?void 0:i.call(r))??Date.now()},this.observer=(()=>{let n=null;const r=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(i=>{i.forEach(s=>{const o=()=>{const l=s.target,u=this.indexFromElement(l);if(!l.isConnected){this.observer.unobserve(l);return}this.shouldMeasureDuringScroll(u)&&this.resizeItem(u,this.options.measureElement(l,s,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var i;(i=r())==null||i.disconnect(),n=null},observe:i=>{var s;return(s=r())==null?void 0:s.observe(i,{box:"border-box"})},unobserve:i=>{var s;return(s=r())==null?void 0:s.unobserve(i)}}})(),this.range=null,this.setOptions=n=>{Object.entries(n).forEach(([r,i])=>{typeof i>"u"&&delete n[r]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:xEe,rangeExtractor:SEe,onChange:()=>{},measureElement:kEe,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",...n}},this.notify=n=>{var r,i;(i=(r=this.options).onChange)==null||i.call(r,this,n)},this.maybeNotify=_d(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(i=>{this.observer.observe(i)}),this.unsubs.push(this.options.observeElementRect(this,i=>{this.scrollRect=i,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(i,s)=>{this.scrollAdjustments=0,this.scrollDirection=s?this.getScrollOffset()<i?"forward":"backward":null,this.scrollOffset=i,this.isScrolling=s,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(n,r)=>{const i=new Map,s=new Map;for(let o=r-1;o>=0;o--){const l=n[o];if(i.has(l.lane))continue;const u=s.get(l.lane);if(u==null||l.end>u.end?s.set(l.lane,l):l.end<u.end&&i.set(l.lane,!0),i.size===this.options.lanes)break}return s.size===this.options.lanes?Array.from(s.values()).sort((o,l)=>o.end===l.end?o.index-l.index:o.end-l.end)[0]:void 0},this.getMeasurementOptions=_d(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(n,r,i,s,o,l,u)=>(this.prevLanes!==void 0&&this.prevLanes!==l&&(this.lanesChangedFlag=!0),this.prevLanes=l,this.pendingMeasuredCacheIndexes=[],{count:n,paddingStart:r,scrollMargin:i,getItemKey:s,enabled:o,lanes:l,laneAssignmentMode:u}),{key:!1}),this.getMeasurements=_d(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:n,paddingStart:r,scrollMargin:i,getItemKey:s,enabled:o,lanes:l,laneAssignmentMode:u},d)=>{if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const g of this.laneAssignments.keys())g>=n&&this.laneAssignments.delete(g);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(g=>{this.itemSizeCache.set(g.key,g.size)}));const f=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1);const h=this.measurementsCache.slice(0,f),y=new Array(l).fill(void 0);for(let g=0;g<f;g++){const _=h[g];_&&(y[_.lane]=g)}for(let g=f;g<n;g++){const _=s(g),w=this.laneAssignments.get(g);let S,x;const k=u==="estimate"||d.has(_);if(w!==void 0&&this.options.lanes>1){S=w;const T=y[S],P=T!==void 0?h[T]:void 0;x=P?P.end+this.options.gap:r+i}else{const T=this.options.lanes===1?h[g-1]:this.getFurthestMeasurement(h,g);x=T?T.end+this.options.gap:r+i,S=T?T.lane:g%this.options.lanes,this.options.lanes>1&&k&&this.laneAssignments.set(g,S)}const R=d.get(_),A=typeof R=="number"?R:this.options.estimateSize(g),M=x+A;h[g]={index:g,start:x,size:A,end:M,key:_,lane:S},y[S]=g}return this.measurementsCache=h,h},{key:!1,debug:()=>this.options.debug}),this.calculateRange=_d(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,r,i,s)=>this.range=n.length>0&&r>0?AEe({measurements:n,outerSize:r,scrollOffset:i,lanes:s}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=_d(()=>{let n=null,r=null;const i=this.calculateRange();return i&&(n=i.startIndex,r=i.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,r]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,r]},(n,r,i,s,o)=>s===null||o===null?[]:n({startIndex:s,endIndex:o,overscan:r,count:i}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const r=this.options.indexAttribute,i=n.getAttribute(r);return i?parseInt(i,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=n=>{var r;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const i=this.scrollState.index??((r=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:r.index);if(i!==void 0&&this.range){const s=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),o=Math.max(0,i-s),l=Math.min(this.options.count-1,i+s);return n>=o&&n<=l}return!0},this.measureElement=n=>{if(!n){this.elementsCache.forEach((o,l)=>{o.isConnected||(this.observer.unobserve(o),this.elementsCache.delete(l))});return}const r=this.indexFromElement(n),i=this.options.getItemKey(r),s=this.elementsCache.get(i);s!==n&&(s&&this.observer.unobserve(s),this.observer.observe(n),this.elementsCache.set(i,n)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(r)&&this.resizeItem(r,this.options.measureElement(n,void 0,this))},this.resizeItem=(n,r)=>{var i;const s=this.measurementsCache[n];if(!s)return;const o=this.itemSizeCache.get(s.key)??s.size,l=r-o;l!==0&&(((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(s,l,this):s.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=l,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(s.index),this.itemSizeCache=new Map(this.itemSizeCache.set(s.key,r)),this.notify(!1))},this.getVirtualItems=_d(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,r)=>{const i=[];for(let s=0,o=n.length;s<o;s++){const l=n[s],u=r[l];i.push(u)}return i},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const r=this.getMeasurements();if(r.length!==0)return XL(r[TH(0,r.length-1,i=>XL(r[i]).start,n)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const n=this.scrollElement.document.documentElement;return this.options.horizontal?n.scrollWidth-this.scrollElement.innerWidth:n.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(n,r,i=0)=>{if(!this.scrollElement)return 0;const s=this.getSize(),o=this.getScrollOffset();r==="auto"&&(r=n>=o+s?"end":"start"),r==="center"?n+=(i-s)/2:r==="end"&&(n-=s);const l=this.getMaxScrollOffset();return Math.max(Math.min(l,n),0)},this.getOffsetForIndex=(n,r="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const i=this.getSize(),s=this.getScrollOffset(),o=this.measurementsCache[n];if(!o)return;if(r==="auto")if(o.end>=s+i-this.options.scrollPaddingEnd)r="end";else if(o.start<=s+this.options.scrollPaddingStart)r="start";else return[s,r];if(r==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),r];const l=r==="end"?o.end+this.options.scrollPaddingEnd:o.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(l,r,o.size),r]},this.scrollToOffset=(n,{align:r="start",behavior:i="auto"}={})=>{const s=this.getOffsetForAlignment(n,r),o=this.now();this.scrollState={index:null,align:r,behavior:i,startedAt:o,lastTargetOffset:s,stableFrames:0},this._scrollToOffset(s,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollToIndex=(n,{align:r="auto",behavior:i="auto"}={})=>{n=Math.max(0,Math.min(n,this.options.count-1));const s=this.getOffsetForIndex(n,r);if(!s)return;const[o,l]=s,u=this.now();this.scrollState={index:n,align:l,behavior:i,startedAt:u,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollBy=(n,{behavior:r="auto"}={})=>{const i=this.getScrollOffset()+n,s=this.now();this.scrollState={index:null,align:"start",behavior:r,startedAt:s,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var n;const r=this.getMeasurements();let i;if(r.length===0)i=this.options.paddingStart;else if(this.options.lanes===1)i=((n=r[r.length-1])==null?void 0:n.end)??0;else{const s=Array(this.options.lanes).fill(null);let o=r.length-1;for(;o>=0&&s.some(l=>l===null);){const l=r[o];s[l.lane]===null&&(s[l.lane]=l.end),o--}i=Math.max(...s.filter(l=>l!==null))}return Math.max(i-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(n,{adjustments:r,behavior:i})=>{this.options.scrollToFn(n,{behavior:i,adjustments:r},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(t)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const r=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,i=r?r[0]:this.scrollState.lastTargetOffset,s=1,o=i!==this.scrollState.lastTargetOffset;if(!o&&_Ee(i,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=s){this.scrollState=null;return}}else this.scrollState.stableFrames=0,o&&(this.scrollState.lastTargetOffset=i,this.scrollState.behavior="auto",this._scrollToOffset(i,{adjustments:void 0,behavior:"auto"}));this.scheduleScrollReconcile()}}const TH=(e,t,n,r)=>{for(;e<=t;){const i=(e+t)/2|0,s=n(i);if(s<r)e=i+1;else if(s>r)t=i-1;else return i}return e>0?e-1:0};function AEe({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){const i=e.length-1,s=u=>e[u].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=TH(0,i,s,n),l=o;if(r===1)for(;l<i&&e[l].end<n+t;)l++;else if(r>1){const u=Array(r).fill(0);for(;l<i&&u.some(f=>f<n+t);){const f=e[l];u[f.lane]=f.end,l++}const d=Array(r).fill(n+t);for(;o>=0&&d.some(f=>f>=n);){const f=e[o];d[f.lane]=f.start,o--}o=Math.max(0,o-o%r),l=Math.min(i,l+(r-1-l%r))}return{startIndex:o,endIndex:l}}const eD=typeof document<"u"?b.useLayoutEffect:b.useEffect;function NEe({useFlushSync:e=!0,...t}){const n=b.useReducer(()=>({}),{})[1],r={...t,onChange:(s,o)=>{var l;e&&o?xu.flushSync(n):n(),(l=t.onChange)==null||l.call(t,s,o)}},[i]=b.useState(()=>new REe(r));return i.setOptions(r),eD(()=>i._didMount(),[]),eD(()=>i._willUpdate()),i}function MEe(e){return NEe({observeElementRect:EEe,observeElementOffset:CEe,scrollToFn:TEe,...e})}function PEe(e){var n;const t=[];for(const r of e.matchAll(new RegExp("(?<!\\S)@(.+?)(?=\\s+@|\\s*$)","gu"))){const i=r[1]??"",s=r.index??-1;if(s<0||!i)continue;const o=pT(i)?"image":vT(i,{allowBare:!0})?"file":null;o&&t.push({kind:o,path:i,start:s,end:s+(((n=r[0])==null?void 0:n.length)??0)})}return t}function IEe(e){const t=PEe(e),n=[];let r=e.trimEnd().length;for(let i=t.length-1;i>=0;i-=1){const s=t[i];if(s){if(!/^\s*$/u.test(e.slice(s.end,r))||e[s.start]!=="@")break;n.unshift({kind:s.kind,path:s.path}),r=s.start}}return n.length===0?{bodyText:e,attachments:[]}:{bodyText:e.slice(0,r).trimEnd(),attachments:n}}function OEe(e){return e.kind==="diff"}const LEe=12e4;function tD(e){return e?e.replace(/\r\n?/gu,`
@@ -861,4 +861,4 @@ fn main() {
861
861
  ---
862
862
 
863
863
  _End of sample._
864
- `;function SLe(){return m.jsx("div",{className:"min-h-dvh bg-background text-foreground p-6",children:m.jsxs("div",{className:"mx-auto max-w-[720px] space-y-6",children:[m.jsxs("header",{children:[m.jsx("h1",{className:"text-lg font-semibold",children:"Markdown 渲染走查"}),m.jsx("p",{className:"text-sm text-muted-foreground",children:"下方模拟 assistant 气泡容器 (max-w 约束), 验证所有 markdown 元素在气泡内的实际渲染。"})]}),m.jsx("article",{className:"flex justify-start",children:m.jsx("div",{className:"max-w-[80%] rounded-md bg-card text-foreground px-4 py-2 text-sm",children:m.jsx(tC,{text:xLe})})})]})})}function E8(e){if([e.left,e.top,e.width,e.height,e.frameWidth,e.frameHeight].some(l=>!Number.isFinite(l))||e.width<=0||e.height<=0||e.frameWidth<=0||e.frameHeight<=0)return null;const n=Math.min(e.width/e.frameWidth,e.height/e.frameHeight),r=e.frameWidth*n,i=e.frameHeight*n,s=e.left+(e.width-r)/2,o=e.top+(e.height-i)/2;return{left:s,top:o,right:s+r,bottom:o+i,width:r,height:i}}function C8(e,t,n){return{x:Math.min(1,Math.max(0,(e-n.left)/n.width)),y:Math.min(1,Math.max(0,(t-n.top)/n.height))}}function ELe(e,t,n){if(!Number.isFinite(e)||!Number.isFinite(t))return null;const r=E8(n);return!r||e<r.left||e>r.right||t<r.top||t>r.bottom?null:C8(e,t,r)}function CLe(e,t,n){if(!Number.isFinite(e)||!Number.isFinite(t))return null;const r=E8(n);return r?C8(e,t,r):null}async function kLe(e){const t=e.slice();return createImageBitmap(new Blob([t.buffer],{type:"image/jpeg"}))}class TLe{constructor(t,n,r=kLe){je(this,"latest",null);je(this,"painting",!1);je(this,"disposed",!1);je(this,"generation",0);je(this,"lastSequence",-1);je(this,"sizeReportedGeneration",-1);this.canvas=t,this.onSize=n,this.decoder=r}enqueue(t,n){var r;this.disposed||t<=this.lastSequence||((r=this.latest)==null?void 0:r.generation)===this.generation&&t<=this.latest.sequence||(this.latest={generation:this.generation,sequence:t,jpeg:n.slice()},this.painting||this.paintLoop())}reset(t=!1){var n;this.disposed||(this.generation+=1,this.latest=null,this.lastSequence=-1,t&&((n=this.canvas.getContext("2d",{alpha:!1}))==null||n.clearRect(0,0,this.canvas.width,this.canvas.height)))}dispose(){this.disposed=!0,this.generation+=1,this.latest=null}async paintLoop(){var t;this.painting=!0;try{for(;!this.disposed&&this.latest;){const n=this.latest;this.latest=null;let r;try{r=await this.decoder(n.jpeg)}catch(i){!this.disposed&&n.generation===this.generation&&console.warn("Failed to decode device preview frame",i);continue}try{if(this.disposed||n.generation!==this.generation||n.sequence<=this.lastSequence)continue;const i=this.canvas.width!==r.width||this.canvas.height!==r.height;i&&(this.canvas.width=r.width,this.canvas.height=r.height),(i||this.sizeReportedGeneration!==n.generation)&&(this.sizeReportedGeneration=n.generation,this.onSize({width:r.width,height:r.height})),(t=this.canvas.getContext("2d",{alpha:!1}))==null||t.drawImage(r,0,0),this.lastSequence=n.sequence}finally{r.close()}}}finally{this.painting=!1,!this.disposed&&this.latest&&this.paintLoop()}}}const RLe=120,ALe=8*1024*1024,NLe=1e3/30,MLe=.15,PLe=100,ILe=.001;function OLe(e,t){if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.byteLength;n+=1)if(e[n]!==t[n])return!1;return!0}function Wc(e,t){if(e instanceof Error)return e;if(typeof e=="string"&&e.length>0)return new Error(e);if(e&&typeof e=="object"){const n=e,r=[n.name,n.message,n.error].filter(i=>typeof i=="string"&&i.length>0).join(": ");if(r.length>0)return new Error(r)}return new Error(t)}function LLe(e){const t=e.error;if(!t)return new Error("H.264 video playback failed");const n=t.message||`media error ${t.code}`;return new Error(`H.264 video playback failed: ${n}`)}class DLe{constructor(t,n={}){je(this,"muxer",null);je(this,"initialSources");je(this,"initialVideoState");je(this,"configuration",null);je(this,"configurationApplied",!1);je(this,"muxerReady",!1);je(this,"awaitingKeyframe",!0);je(this,"pendingFrames",[]);je(this,"fedFramesAwaitingPlayback",[]);je(this,"bufferedPacketCount",0);je(this,"bufferedBytes",0);je(this,"maxBufferedPackets");je(this,"maxBufferedBytes");je(this,"lastObservedMediaTime",null);je(this,"resyncRequired",!1);je(this,"playPending",!1);je(this,"playRequested",!1);je(this,"started",!1);je(this,"destroyed",!1);je(this,"generation",0);je(this,"playbackDelayTimer",null);je(this,"handlePlaying",()=>{this.destroyed||(this.observePlaybackProgress(),this.playRequested=!0,this.markStarted())});je(this,"handleTimeUpdate",()=>{this.observePlaybackProgress()});je(this,"handleVideoError",()=>{this.destroyed||this.reportError(LLe(this.video))});this.video=t,this.options=n,this.maxBufferedPackets=RB(n.maxBufferedPackets,RLe),this.maxBufferedBytes=RB(n.maxBufferedBytes,ALe),this.initialSources=new Set(t.querySelectorAll("source")),this.initialVideoState={autoplay:t.autoplay,disableRemotePlayback:t.disableRemotePlayback,muted:t.muted,playsInline:t.playsInline,src:t.getAttribute("src"),srcObject:t.srcObject},t.srcObject=null,t.muted=!0,t.autoplay=!0,t.playsInline=!0,t.disableRemotePlayback=!0,t.addEventListener("playing",this.handlePlaying),t.addEventListener("error",this.handleVideoError),t.addEventListener("timeupdate",this.handleTimeUpdate);const r={node:t,mode:"video",flushingTime:0,maxDelay:150,clearBuffer:!0,onReady:()=>this.handleMuxerReady(),onError:i=>this.handleMuxerError(i),onUnsupportedCodec:i=>{this.reportError(new Error(`Browser does not support the H.264 codec ${i}`))}};this.initializeMuxer(r)}feed(t){if(!(this.destroyed||t.data.byteLength===0)){if(this.observePlaybackProgress(),t.kind==="configuration"){this.feedConfiguration(t.data);return}this.feedFrame(t)}}destroy(){var n;if(this.destroyed)return;this.destroyed=!0,this.generation+=1,this.clearBufferedGeneration(),this.video.removeEventListener("playing",this.handlePlaying),this.video.removeEventListener("error",this.handleVideoError),this.video.removeEventListener("timeupdate",this.handleTimeUpdate),this.stopPlaybackDelayChecks();const t=this.generatedObjectUrls();try{(n=this.muxer)==null||n.destroy()}catch{}this.muxer=null;try{this.video.pause()}catch{}this.removeGeneratedSources(),this.video.removeAttribute("src"),this.initialVideoState.src!==null&&this.video.setAttribute("src",this.initialVideoState.src),this.video.srcObject=this.initialVideoState.srcObject,this.video.autoplay=this.initialVideoState.autoplay,this.video.disableRemotePlayback=this.initialVideoState.disableRemotePlayback,this.video.muted=this.initialVideoState.muted,this.video.playsInline=this.initialVideoState.playsInline;for(const r of t)this.revokeObjectUrl(r);try{this.video.load()}catch{}}async initializeMuxer(t){try{const{default:n}=await SH(async()=>{const{default:r}=await import("./jmuxer.min-CRmhZDB4.js").then(i=>i.j);return{default:r}},__vite__mapDeps([0,1]));if(this.destroyed)return;this.muxer=new n(t)}catch(n){if(this.destroyed)return;this.reportError(Wc(n,"Failed to initialize H.264 video playback")),this.destroy()}}feedConfiguration(t){if(this.configuration&&OLe(this.configuration,t))return;const n=this.configuration!==null&&this.configurationApplied;if(this.clearBufferedGeneration(),this.wouldOverflow(t.byteLength)){this.requireResync();return}if(this.configuration=t.slice(),this.addBufferedPacket(t.byteLength),this.awaitingKeyframe=!0,n){this.resetMuxer();return}this.applyConfigurationIfReady()}feedFrame(t){if(!this.configuration)return;if(this.awaitingKeyframe){if(!t.keyframe)return;this.awaitingKeyframe=!1,this.resyncRequired=!1}const n={data:t.data.slice(),durationMs:Number.isFinite(t.durationMs)&&t.durationMs>0?t.durationMs:NLe,keyframe:t.keyframe};if(n.keyframe&&this.clearPendingFrames(),this.wouldOverflow(n.data.byteLength)){this.requireResync();return}if(this.addBufferedPacket(n.data.byteLength),!this.muxerReady||!this.configurationApplied){this.pendingFrames.push(n);return}this.applyFrame(n)||this.removeBufferedPacket(n.data.byteLength)}resetMuxer(){var r;const t=this.generatedSources(),n=this.generatedObjectUrls();this.generation+=1,this.muxerReady=!1,this.configurationApplied=!1,this.awaitingKeyframe=!0,this.playPending=!1,this.playRequested=!1,this.stopPlaybackDelayChecks();try{(r=this.muxer)==null||r.reset()}catch(i){this.reportError(Wc(i,"Failed to reset H.264 video playback"))}for(const i of t)i.remove();for(const i of n)this.revokeObjectUrl(i)}handleMuxerReady(){this.destroyed||(this.muxerReady=!0,this.startPlaybackDelayChecks(),this.applyConfigurationIfReady(),this.flushPendingFrames())}startPlaybackDelayChecks(){this.playbackDelayTimer===null&&(this.playbackDelayTimer=setInterval(()=>{this.catchUpToLiveEdge()},PLe))}stopPlaybackDelayChecks(){this.playbackDelayTimer!==null&&(clearInterval(this.playbackDelayTimer),this.playbackDelayTimer=null)}catchUpToLiveEdge(){if(this.destroyed||this.video.seeking)return;const t=this.video.buffered;if(t.length!==0)try{const n=t.end(t.length-1),r=this.video.currentTime;if(!Number.isFinite(n)||!Number.isFinite(r)||n-r<=MLe)return;this.video.currentTime=Math.max(0,n-ILe),this.observePlaybackProgress()}catch{}}applyConfigurationIfReady(){if(!(this.destroyed||!this.muxerReady||this.configurationApplied||!this.configuration||!this.muxer))try{this.muxer.feed({video:this.configuration,duration:0,isLastVideoFrameComplete:!0}),this.configurationApplied=!0,this.flushPendingFrames()}catch(t){this.reportError(Wc(t,"Failed to apply H.264 decoder configuration"))}}applyFrame(t){if(this.destroyed||!this.muxer)return!1;try{return this.muxer.feed({video:t.data,duration:t.durationMs,isLastVideoFrameComplete:!0}),this.fedFramesAwaitingPlayback.push({byteLength:t.data.byteLength,remainingDurationMs:t.durationMs}),this.attemptPlayback(),!0}catch(n){return this.reportError(Wc(n,"Failed to feed an H.264 video frame")),!1}}flushPendingFrames(){if(this.destroyed||!this.muxerReady||!this.configurationApplied||!this.muxer)return;this.observePlaybackProgress();const t=this.pendingFrames;this.pendingFrames=[];for(const n of t){if(this.destroyed)return;this.applyFrame(n)||this.removeBufferedPacket(n.data.byteLength)}}attemptPlayback(){if(this.destroyed||this.playPending||this.playRequested)return;this.playPending=!0,this.playRequested=!0;const t=this.generation;let n;try{n=this.video.play()}catch(r){this.playPending=!1,this.playRequested=!1,this.reportError(Wc(r,"Browser blocked H.264 video playback"));return}n.then(()=>{this.destroyed||t!==this.generation||(this.playPending=!1,this.markStarted())},r=>{this.destroyed||t!==this.generation||(this.playPending=!1,this.playRequested=!1,this.reportError(Wc(r,"Browser blocked H.264 video playback")))})}handleMuxerError(t){this.destroyed||(t.name==="InvalidStateError"&&(this.generation+=1,this.muxerReady=!1,this.configurationApplied=!1,this.awaitingKeyframe=!0,this.clearBufferedGeneration(),this.playPending=!1,this.playRequested=!1,this.stopPlaybackDelayChecks()),this.reportError(Wc(t,"H.264 video buffer failed")))}markStarted(){var t,n;this.started||(this.started=!0,(n=(t=this.options).onStart)==null||n.call(t))}reportError(t){var n,r;this.destroyed||(r=(n=this.options).onError)==null||r.call(n,t)}observePlaybackProgress(){const t=this.video.currentTime;if(!Number.isFinite(t)||t<0)return;if(this.lastObservedMediaTime===null||t<this.lastObservedMediaTime){this.lastObservedMediaTime=t;return}let n=(t-this.lastObservedMediaTime)*1e3;if(this.lastObservedMediaTime=t,!(n<=0))for(;n>0;){const r=this.fedFramesAwaitingPlayback[0];if(!r)return;if(n+Number.EPSILON<r.remainingDurationMs){r.remainingDurationMs-=n;return}n-=r.remainingDurationMs,this.fedFramesAwaitingPlayback.shift(),this.removeBufferedPacket(r.byteLength)}}wouldOverflow(t){return this.bufferedPacketCount+1>this.maxBufferedPackets||this.bufferedBytes+t>this.maxBufferedBytes}addBufferedPacket(t){this.bufferedPacketCount+=1,this.bufferedBytes+=t}removeBufferedPacket(t){this.bufferedPacketCount=Math.max(0,this.bufferedPacketCount-1),this.bufferedBytes=Math.max(0,this.bufferedBytes-t)}clearPendingFrames(){for(const t of this.pendingFrames)this.removeBufferedPacket(t.data.byteLength);this.pendingFrames=[]}clearBufferedGeneration(){this.pendingFrames=[],this.fedFramesAwaitingPlayback=[],this.configuration=null,this.configurationApplied=!1,this.bufferedPacketCount=0,this.bufferedBytes=0,this.lastObservedMediaTime=null}requireResync(){var n,r;const t=!this.resyncRequired;this.resyncRequired=!0,this.clearBufferedGeneration(),this.awaitingKeyframe=!0,this.resetMuxer(),t&&!this.destroyed&&((r=(n=this.options).onResyncRequired)==null||r.call(n,new Error("H.264 playback buffer overflowed; reconnecting for a fresh keyframe")))}generatedSources(){return Array.from(this.video.querySelectorAll("source")).filter(t=>!this.initialSources.has(t))}removeGeneratedSources(){for(const t of this.generatedSources())t.remove()}generatedObjectUrls(){const t=new Set,n=this.video.getAttribute("src");n!==this.initialVideoState.src&&(n!=null&&n.startsWith("blob:"))&&t.add(n);for(const r of this.generatedSources()){const i=r.getAttribute("src");i!=null&&i.startsWith("blob:")&&t.add(i)}return[...t]}revokeObjectUrl(t){if(typeof URL.revokeObjectURL=="function")try{URL.revokeObjectURL(t)}catch{}}}function RB(e,t){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0?e:t}class BLe{constructor(){je(this,"buffer",new Uint8Array(0))}push(t){if(t.byteLength===0)return[];const n=new Uint8Array(this.buffer.byteLength+t.byteLength);n.set(this.buffer),n.set(t,this.buffer.byteLength),this.buffer=n;const r=[];let i=0;for(;this.buffer.byteLength-i>=Ah;){const s=new DataView(this.buffer.buffer,this.buffer.byteOffset+i,Ah),o=s.getUint32(0,!0),l=s.getUint32(4,!0);if(o===0||o>Oy)throw this.buffer=new Uint8Array(0),new RangeError(`Invalid device preview frame length: ${o}`);const u=Ah+o;if(this.buffer.byteLength-i<u)break;r.push({sequence:l,jpeg:this.buffer.slice(i+Ah,i+u)}),i+=u}if(i>0&&(this.buffer=this.buffer.slice(i)),this.buffer.byteLength>Ah+Oy)throw this.buffer=new Uint8Array(0),new RangeError("Device preview stream buffer exceeded its limit");return r}finish(){if(this.buffer.byteLength!==0)throw this.buffer=new Uint8Array(0),new Error("Device preview stream ended with a truncated frame")}}class zLe{constructor(){je(this,"buffer",new Uint8Array(0))}push(t){if(t.byteLength===0)return[];const n=new Uint8Array(this.buffer.byteLength+t.byteLength);n.set(this.buffer),n.set(t,this.buffer.byteLength),this.buffer=n;const r=[];let i=0;for(;this.buffer.byteLength-i>=rp;){const s=this.buffer.subarray(i),o=Bne(s);if(!o)throw this.buffer=new Uint8Array(0),new RangeError("Invalid H.264 device preview packet header");const l=rp+o.annexBLength;if(this.buffer.byteLength-i<l)break;r.push({sequence:o.packetSequence,kind:o.configuration?"configuration":"frame",keyframe:o.keyframe,durationMs:o.durationMs,data:this.buffer.slice(i+rp,i+l)}),i+=l}if(i>0&&(this.buffer=this.buffer.slice(i)),this.buffer.byteLength>rp+Oy)throw this.buffer=new Uint8Array(0),new RangeError("H.264 device preview stream buffer exceeded its limit");return r}finish(){if(this.buffer.byteLength!==0)throw this.buffer=new Uint8Array(0),new Error("H.264 device preview stream ended with a truncated packet")}}function jLe(e){let t;try{t=new URL(e,globalThis.location.href)}catch{throw new Error("无效的模拟器画面地址")}if(t.origin!==globalThis.location.origin||t.username!==""||t.password!==""||!/^\/api\/device-preview-streams\/[A-Za-z0-9_-]{1,256}$/u.test(t.pathname)||t.search!==""||t.hash!=="")throw new Error("拒绝连接不受信任的模拟器画面地址")}function FLe(e){const t=Number(e.headers.get("X-Device-Width")),n=Number(e.headers.get("X-Device-Height"));return!Number.isSafeInteger(t)||t<=0||!Number.isSafeInteger(n)||n<=0?null:{width:t,height:n}}async function k8(e,t,n){jLe(e);const r=Sb(),i=await n(e,{method:"GET",cache:"no-store",credentials:"same-origin",...r?{headers:{Authorization:`Bearer ${r}`}}:{},signal:t});if(!i.ok||!i.body)throw new Error(`无法打开模拟器画面(${i.status})`);return i}async function $Le(e,t){const n=t.fetch??globalThis.fetch,r=await k8(e,t.signal,n);if(r.headers.get("X-Device-Preview-Format")!=="jpeg")throw new Error("开发机返回了错误的模拟器画面格式");const i=new BLe,s=r.body.getReader();try{for(;;){const{done:o,value:l}=await s.read();if(o)break;const d=i.push(l).at(-1);d&&await t.onFrame(d)}i.finish()}finally{s.releaseLock()}}async function HLe(e,t){var l;const n=t.fetch??globalThis.fetch,r=await k8(e,t.signal,n);if(r.headers.get("X-Device-Preview-Format")!=="h264_annex_b")throw new Error("开发机没有返回 H.264 模拟器画面");const i=FLe(r);i&&((l=t.onSize)==null||l.call(t,i));const s=new zLe,o=r.body.getReader();try{for(;;){const{done:u,value:d}=await o.read();if(u)break;for(const f of s.push(d))await t.onPacket(f)}s.finish()}finally{o.releaseLock()}}const ULe=16,WLe=16;class qLe{constructor(t){je(this,"send");je(this,"onFailure");je(this,"now");je(this,"moveFlushMs");je(this,"maxInFlightMoves");je(this,"active",null);je(this,"inFlightMoves",0);je(this,"disposed",!1);je(this,"failed",!1);this.send=t.send,this.onFailure=t.onFailure,this.now=t.now??(()=>performance.now()),this.moveFlushMs=t.moveFlushMs??ULe,this.maxInFlightMoves=t.maxInFlightMoves??WLe}begin(t,n){if(this.disposed||this.failed||this.active)return!1;const r={pointerId:t,lastPoint:n,lastMoveAt:Number.NEGATIVE_INFINITY,pendingMove:null,moveFlushTimer:null};return this.active=r,this.dispatch(this.input("down",n)),!0}move(t,n){const r=this.matchingActive(t);if(!r)return!1;r.lastPoint=n,r.pendingMove=n;const i=this.now(),s=this.moveFlushMs-(i-r.lastMoveAt);return s>0?(r.moveFlushTimer===null&&(r.moveFlushTimer=setTimeout(()=>{r.moveFlushTimer=null,!(this.active!==r||this.disposed||this.failed)&&(r.lastMoveAt=this.now(),this.flushLatestMove())},s)),!0):(this.clearMoveTimer(r),r.lastMoveAt=i,this.flushLatestMove(),!0)}end(t,n){const r=this.matchingActive(t);return r?(r.lastPoint=n,this.finish(r),this.dispatch(this.input("up",n)),!0):!1}cancel(t){const n=this.active;if(!n||t!==void 0&&n.pointerId!==t)return!1;const r=n.lastPoint;return this.finish(n),this.dispatch(this.input("up",r)),!0}dispose(){if(this.disposed)return;const t=this.active;if(t&&this.finish(t),this.disposed=!0,!(!t||this.failed))try{Promise.resolve(this.send(this.input("up",t.lastPoint))).catch(()=>{})}catch{}}matchingActive(t){var n;return this.disposed||this.failed||((n=this.active)==null?void 0:n.pointerId)!==t?null:this.active}finish(t){this.active===t&&(this.active=null),this.clearMoveTimer(t),t.pendingMove=null}clearMoveTimer(t){t.moveFlushTimer!==null&&clearTimeout(t.moveFlushTimer),t.moveFlushTimer=null}flushLatestMove(){const t=this.active;if(!t||this.disposed||this.failed||!t.pendingMove||t.moveFlushTimer!==null||this.inFlightMoves>=this.maxInFlightMoves)return;const n=t.pendingMove;t.pendingMove=null,this.inFlightMoves+=1,this.dispatch(this.input("move",n),()=>{this.inFlightMoves=Math.max(0,this.inFlightMoves-1),this.flushLatestMove()})}dispatch(t,n){let r;try{r=Promise.resolve(this.send(t))}catch(i){this.fail(i),n==null||n();return}r.then(()=>n==null?void 0:n(),i=>{this.fail(i),n==null||n()})}fail(t){if(this.disposed||this.failed)return;this.failed=!0;const n=this.active;n&&this.finish(n),this.onFailure(t)}input(t,n){return{kind:"touch",phase:t,x:n.x,y:n.y}}}const VLe=15e3,YLe=1e4,KLe={ios:40,android:28},GLe={ios:{width:390,height:844},android:{width:412,height:915}};function XLe(){const{id:e=""}=dz(),t=Cs(),n=fr($e=>c5($e).find(Fe=>Fe.previewId===e)),r=fr($e=>$e.listLoaded),i=fr($e=>{var Fe;return((Fe=$e.authoritative)==null?void 0:Fe.scope)??null}),s=Zo($e=>cie($e,i,"device",e,"reconnect")),o=b.useRef(null),l=b.useRef(null),u=b.useRef(null),d=b.useRef(null),f=b.useRef(null),h=b.useRef(()=>{}),y=b.useRef(null),g=b.useRef(null),[_,w]=b.useState(0),[S,x]=b.useState("waiting"),[k,R]=b.useState(null),[A,M]=b.useState(null),[T,P]=b.useState(null),[z,Y]=b.useState(""),[U,G]=b.useState(!1),[I,N]=b.useState(!1),[L,B]=b.useState(!1),O=n==null?void 0:n.previewId,D=n==null?void 0:n.state,F=n==null?void 0:n.platform,V=b.useCallback(()=>{const $e=f.current;f.current=null,$e==null||$e.dispose()},[]);b.useEffect(()=>{if(F!=="ios"){d.current=null,P(null);return}const $e=o.current;if(!$e)return;const Fe=new TLe($e,P);return Fe.reset(!0),P(null),d.current=Fe,()=>{Fe.dispose(),d.current=null}},[O,F]),b.useEffect(()=>{if(V(),h.current=()=>{},y.current=null,g.current=null,M(null),N(!1),B(!1),!O||D!=="ready"){D==="disconnected"?(x("error"),R("模拟器已断开")):(x("waiting"),R(null));return}const $e=$t,Fe=i;if(!$e||!Fe||!Pt.isActive($e,Fe)){x("error"),R("开发机连接已断开");return}let xt=!1,_t=null,st=null,Ae=null,ut=null,mt=null,ge=0,Ye=!1;const ve=()=>{mt=null,Ae==null||Ae.abort(),Ae=null,ut==null||ut.destroy(),ut=null,_t&&clearTimeout(_t),_t=null,st&&clearTimeout(st),st=null},Je=Ct=>{x("streaming"),st&&clearTimeout(st),st=setTimeout(()=>{st=null,!(xt||Ct.signal.aborted||mt!==Ct.leaseId||!Pt.isActive($e,Fe))&&(ge=0)},YLe)},dt=()=>{if(xt||document.visibilityState==="hidden"||!Pt.isActive($e,Fe))return;const Ct=Math.min(5e3,500*2**ge);ge+=1,_t=setTimeout(()=>void Ot(),Ct)},Ot=async()=>{var gn;if(V(),ve(),xt||document.visibilityState==="hidden"||!Pt.isActive($e,Fe))return;Ye=!1,(gn=d.current)==null||gn.reset(),P(null),x("connecting"),R(null),M(null);const Ct=new AbortController;Ae=Ct;try{const zt=await Pt.requestDevicePreviewStream(Fe,O,F==="android"?{format:"h264_annex_b"}:{format:"jpeg",maxFps:15},{signal:Ct.signal});if(xt||Ct.signal.aborted||!Pt.isActive($e,Fe)||!zt)return;if(!zt.success)throw new Error(zt.error);const nn=zt;if(mt=nn.leaseId,M(nn),F==="android"){const Fn=l.current;if(!Fn)throw new Error("无法初始化 Android 模拟器播放器");let Xn;const Nn=new Promise((ue,be)=>{Xn=be}),W=setTimeout(()=>{Xn(new Error("Android 模拟器画面启动超时"))},VLe),ie=ue=>{Xn(ue instanceof Error?ue:new Error(String(ue)))},oe=new DLe(Fn,{onStart:()=>{clearTimeout(W),!(xt||nn.signal.aborted||!Pt.isActive($e,Fe))&&Je(nn)},onError:ie,onResyncRequired:ie});ut=oe;try{await Promise.race([HLe(nn.url,{signal:nn.signal,onSize:ue=>{!xt&&!nn.signal.aborted&&Pt.isActive($e,Fe)&&P(ue)},onPacket:ue=>{!xt&&!nn.signal.aborted&&Pt.isActive($e,Fe)&&oe.feed(ue)}}),Nn])}finally{clearTimeout(W)}if(!xt&&!nn.signal.aborted&&Pt.isActive($e,Fe))throw new Error("模拟器画面已断开");return}let En=!1;if(await $Le(nn.url,{signal:nn.signal,onFrame:Fn=>{if(xt||nn.signal.aborted||!Pt.isActive($e,Fe))return;const Xn=d.current;Xn&&(Xn.enqueue(Fn.sequence,Fn.jpeg),En||(En=!0,Je(nn)))}}),!xt&&!nn.signal.aborted&&Pt.isActive($e,Fe))throw new Error("模拟器画面已断开")}catch(zt){if(xt||Ct.signal.aborted||!Pt.isActive($e,Fe))return;Lt(zt,!1)}},Lt=(Ct,gn)=>{if(xt||Ye||!Pt.isActive($e,Fe))return;Ye=!0;const zt=Ct instanceof Error?Ct.message:"模拟器画面已断开";V(),ve(),y.current=null,g.current=null,M(null),N(!1),B(!1),x("error"),R(zt),gn&&Ue.error(zt),dt()},sn=(Ct,gn,zt=!0)=>{Ct===mt&&Lt(gn,zt)};h.current=sn;const Gt=$e.onMessage(Ct=>{if(Ct.type!=="device_preview_control_revoked_push"||!Jt(Ct.scope,Fe)||Ct.leaseId!==mt||!Pt.isActive($e,Fe))return;if(g.current=null,B(!1),Ct.reason==="taken_over"){y.current=null,N(!1),V(),M(zt=>(zt==null?void 0:zt.leaseId)===Ct.leaseId?{...zt,controlMode:"view_only"}:zt),Ue.info("控制权已由其他页面接管");return}const gn=new Error(Ct.reason==="proxy_offline"?"开发机连接已断开":Ct.reason==="lease_expired"?"模拟器画面连接已过期":"模拟器画面已断开");sn(Ct.leaseId,gn,!1)}),on=()=>{if(document.visibilityState==="hidden"){V(),ve(),y.current=null,g.current=null,M(null),N(!1),B(!1),x("waiting");return}ge=0,Ot()};return document.addEventListener("visibilitychange",on),Ot(),()=>{xt=!0,h.current===sn&&(h.current=()=>{}),Gt(),document.removeEventListener("visibilitychange",on),V(),ve()}},[V,O,F,i,D,_]),b.useEffect(()=>{var $e;($e=f.current)==null||$e.cancel()},[T==null?void 0:T.height,T==null?void 0:T.width]);const j=(n==null?void 0:n.state)==="ready"&&(A==null?void 0:A.previewId)===n.previewId&&i&&Jt(A.scope,i)?A:null,q=(n==null?void 0:n.interactive)===!0&&S==="streaming"&&(j==null?void 0:j.controlMode)==="controller";b.useEffect(()=>{V();const $e=$t,Fe=j;if(!$e||!Fe||!q)return;const xt=new qLe({send:async _t=>{const st=await Pt.sendDevicePreviewInput(Fe,_t);if(!st)throw new Error("模拟器控制连接已失效");if(!st.success)throw new Error(st.error)},onFailure:_t=>{f.current===xt&&h.current(Fe.leaseId,_t)}});return f.current=xt,()=>{f.current===xt&&(f.current=null),xt.dispose()}},[q,j,V]);const K=T??GLe[(n==null?void 0:n.platform)==="android"?"android":"ios"],$=KLe[(n==null?void 0:n.platform)==="android"?"android":"ios"],te=K.width/K.height,J=K.width>K.height?"landscape":"portrait",ne=J==="landscape"?`, ${K.width}px`:"",Q={aspectRatio:`${K.width} / ${K.height}`,width:`max(1px, min(calc(100cqw - ${$}px), calc(${(te*100).toFixed(6)}cqh - ${(te*$).toFixed(6)}px)${ne}))`};b.useEffect(()=>{q||G(!1)},[q]);const ce=b.useCallback(async($e,Fe=!0)=>{const xt=$t,_t=j;if(!xt||!_t||!q)return!1;try{const st=await Pt.sendDevicePreviewInput(_t,$e);return!st||!Pt.isActive(xt,_t.scope)?!1:st.success?!0:(Fe&&Ue.error(st.error),!1)}catch(st){return _t.signal.aborted||!Pt.isActive(xt,_t.scope)||Fe&&Ue.error(st instanceof Error?st.message:"模拟器操作失败"),!1}},[q,j]);function re($e,Fe){const xt=u.current;if(!xt||!T)return null;const _t=xt.getBoundingClientRect(),st={left:_t.left,top:_t.top,width:_t.width,height:_t.height,frameWidth:T.width,frameHeight:T.height};return Fe==="start"?ELe($e.clientX,$e.clientY,st):CLe($e.clientX,$e.clientY,st)}function le($e){var _t,st;if(!q||$e.button!==0)return;const Fe=re($e,"start");if(!Fe)return;const xt=f.current;xt!=null&&xt.begin($e.pointerId,Fe)&&($e.preventDefault(),(st=(_t=$e.currentTarget).setPointerCapture)==null||st.call(_t,$e.pointerId))}function we($e){var xt;const Fe=re($e,"captured");Fe&&(xt=f.current)!=null&&xt.move($e.pointerId,Fe)&&$e.preventDefault()}function Ce($e){var xt;const Fe=re($e,"captured");Fe&&((xt=f.current)!=null&&xt.end($e.pointerId,Fe))&&$e.preventDefault()}function ye($e){var Fe;(Fe=f.current)==null||Fe.cancel($e.pointerId)}async function Re(){const $e=$t,Fe=j;if(!$e||!Fe||L||S!=="streaming")return;const xt=Symbol("device-preview-control-claim");g.current=xt,B(!0);try{const _t=await Pt.claimDevicePreviewControl(Fe);if(g.current!==xt||!_t||!Pt.isActive($e,Fe.scope))return;if(!_t.success){Ue.error(_t.error);return}M(st=>(st==null?void 0:st.leaseId)===Fe.leaseId?{...st,controlMode:"controller"}:st)}catch(_t){if(g.current!==xt||Fe.signal.aborted||!Pt.isActive($e,Fe.scope))return;Ue.error(_t instanceof Error?_t.message:"暂时无法取得控制权")}finally{g.current===xt&&(g.current=null,B(!1))}}async function Rt($e){$e.preventDefault();const Fe=z;if(!Fe||I)return;const xt=Symbol("device-preview-text-input");y.current=xt,N(!0);const _t=await ce({kind:"text",text:Fe});y.current===xt&&(_t&&(Y(""),G(!1)),y.current=null,N(!1))}function Ke(){var $e;($e=f.current)==null||$e.cancel(),ce({kind:"orientation",orientation:T&&T.width>T.height?"portrait":"landscape_right"})}async function et(){if((n==null?void 0:n.state)!=="disconnected"){w(xt=>xt+1);return}const $e=$t,Fe=Pt.getActiveScope();if(!$e||!Fe){Ue.error("请先连接开发机");return}try{const xt=await Pt.reconnectDevicePreview(Fe,n.previewId);xt.success||Ue.error(xt.error)}catch(xt){if(!Pt.isActive($e,Fe))return;Ue.error(xt instanceof Error?xt.message:"无法重新连接模拟器预览")}}return n?m.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background","data-slot":"device-preview-page","data-preview-id":n.previewId,"data-stream-status":S,"data-control-mode":n.interactive?(j==null?void 0:j.controlMode)??"none":"unavailable",children:[m.jsxs("header",{className:"flex min-h-14 shrink-0 items-center gap-2 border-b px-3 md:px-4",children:[m.jsx(vt,{variant:"ghost",size:"icon",className:"md:hidden","aria-label":"返回",onClick:()=>t("/sessions"),children:m.jsx(ff,{"aria-hidden":"true"})}),m.jsx(CC,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsx("p",{className:"truncate text-sm font-medium",children:n.name}),m.jsxs("p",{className:"truncate text-xs text-muted-foreground",children:[n.model," · ",n.platform==="ios"?"iOS":"Android"," ",n.osVersion]})]}),n.interactive&&S==="streaming"&&(j==null?void 0:j.controlMode)==="view_only"?m.jsx(vt,{size:"sm",variant:"outline",disabled:L,onClick:()=>void Re(),"data-slot":"device-preview-claim-control",children:"接管控制"}):m.jsx("span",{className:"text-xs text-muted-foreground",children:q?"可操控":S==="streaming"?"仅查看":"连接中"})]}),m.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-muted/30",children:m.jsxs("div",{className:qe("grid h-full min-h-0 min-w-0 gap-3 p-3 md:gap-4 md:p-6",J==="portrait"?"grid-rows-[minmax(0,1fr)_auto] md:grid-cols-[minmax(0,1fr)_auto] md:grid-rows-1":"grid-rows-[minmax(0,1fr)_auto]"),"data-slot":"device-preview-stage","data-orientation":J,children:[m.jsxs("div",{className:"relative flex min-h-0 min-w-0 items-center justify-center overflow-hidden [container-type:size]","data-slot":"device-preview-viewport",children:[m.jsxs("div",{className:qe("relative isolate shrink-0 transition-[width,aspect-ratio] duration-300 ease-out motion-reduce:transition-none [container-type:size]",n.platform==="ios"?"[--device-screen-radius:clamp(22px,14cqmin,56px)] [--ios-rail:clamp(10px,4cqmin,16px)]":"[--device-screen-radius:clamp(14px,6.5cqw,38px)]"),style:Q,"data-slot":"device-preview-device-shell","data-platform":n.platform,"data-orientation":J,children:[m.jsx(ZLe,{platform:n.platform,orientation:J}),m.jsx("div",{ref:u,className:qe("relative z-10 flex h-full w-full min-h-0 min-w-0 items-center justify-center overflow-hidden rounded-[var(--device-screen-radius)] bg-black ring-1 ring-black",q&&"cursor-pointer"),"data-slot":"device-preview-surface","data-control-enabled":q?"true":"false",children:n.platform==="android"?m.jsx("video",{ref:l,className:"pointer-events-none h-full w-full object-contain","data-slot":"device-preview-video",muted:!0,autoPlay:!0,playsInline:!0,disableRemotePlayback:!0,onLoadedMetadata:$e=>{const Fe=$e.currentTarget;Fe.videoWidth>0&&Fe.videoHeight>0&&P({width:Fe.videoWidth,height:Fe.videoHeight})},onResize:$e=>{const Fe=$e.currentTarget;Fe.videoWidth>0&&Fe.videoHeight>0&&P({width:Fe.videoWidth,height:Fe.videoHeight})}}):m.jsx("canvas",{ref:o,className:"pointer-events-none h-full w-full object-contain","data-slot":"device-preview-canvas"})}),m.jsx("div",{className:qe("absolute inset-0 z-20 select-none rounded-[var(--device-screen-radius)]",q?"touch-none cursor-pointer":"pointer-events-none"),onPointerDown:le,onPointerMove:we,onPointerUp:Ce,onPointerCancel:ye,onLostPointerCapture:ye,onContextMenu:$e=>{q&&$e.preventDefault()},"data-slot":"device-preview-input-surface","data-control-enabled":q?"true":"false","aria-hidden":"true"})]}),S!=="streaming"?m.jsx("div",{className:"absolute inset-0 z-30 flex items-center justify-center bg-background/55 p-6 backdrop-blur-[1px]","data-slot":"device-preview-stream-overlay","data-stream-status":S,children:m.jsx("div",{className:"grid max-w-sm justify-items-center gap-3 text-center",children:S==="error"?m.jsxs(m.Fragment,{children:[m.jsx("p",{className:"text-sm text-muted-foreground",children:k}),m.jsxs(vt,{variant:"outline",size:"sm",disabled:s,onClick:()=>void et(),"data-slot":"device-preview-retry",children:[s?m.jsx(li,{className:"size-4 animate-spin","aria-hidden":!0}):null,s?"正在重新连接":"重新连接"]})]}):m.jsxs(m.Fragment,{children:[m.jsx(li,{className:"size-5 animate-spin text-muted-foreground","aria-hidden":!0}),m.jsx("p",{className:"text-sm text-muted-foreground",children:"正在连接画面..."})]})})}):null]}),m.jsx("div",{className:"relative z-20 flex min-w-0 items-center justify-center pb-[max(0px,env(safe-area-inset-bottom))] md:pb-0","data-slot":"device-preview-control-dock","data-orientation":J,role:"group","aria-label":"模拟器控制",children:m.jsxs("div",{className:qe("flex max-w-full items-center gap-1 rounded-full border border-border/70 bg-card/85 p-1.5 shadow-xl ring-1 ring-black/5 backdrop-blur-xl",J==="portrait"&&"md:flex-col"),children:[m.jsx(jS,{control:"home",label:"主屏幕",disabled:!q,icon:m.jsx(xY,{"aria-hidden":"true"}),tooltipSide:J==="portrait"?"left":"top",onClick:()=>void ce({kind:"button",button:"home"})}),n.platform==="android"?m.jsx(jS,{control:"back",label:"返回",disabled:!q,icon:m.jsx(EK,{"aria-hidden":"true"}),tooltipSide:J==="portrait"?"left":"top",onClick:()=>void ce({kind:"button",button:"back"})}):null,m.jsx(jS,{control:"orientation",label:"旋转",disabled:!q||!T,icon:m.jsx(tK,{"aria-hidden":"true"}),tooltipSide:J==="portrait"?"left":"top",onClick:Ke}),m.jsx("span",{className:qe("mx-0.5 h-6 w-px shrink-0 bg-border/80",J==="portrait"&&"md:mx-0 md:h-px md:w-6"),"aria-hidden":"true"}),m.jsxs(Ub,{open:U,onOpenChange:$e=>{(!$e||q)&&G($e)},children:[m.jsxs(Sf,{children:[m.jsx(Ef,{asChild:!0,children:m.jsx(Wb,{asChild:!0,children:m.jsx(vt,{type:"button",variant:"ghost",size:"icon",className:qe("size-11 rounded-full text-muted-foreground hover:text-foreground",U&&"bg-accent text-foreground"),disabled:!q,"aria-label":"粘贴文字","aria-expanded":U,"aria-controls":"device-preview-text-form","data-slot":"device-preview-text-toggle",children:m.jsx(WS,{"aria-hidden":"true"})})})}),m.jsx(Cf,{side:J==="portrait"?"left":"top",sideOffset:10,hideArrow:!0,children:"粘贴文字"})]}),m.jsx(qb,{side:J==="portrait"?"left":"top",align:"center",sideOffset:12,className:"w-[min(20rem,calc(100vw-1.5rem))] rounded-2xl bg-card/95 p-2 shadow-2xl backdrop-blur-xl",children:m.jsxs("form",{id:"device-preview-text-form",className:"flex items-end gap-2","data-slot":"device-preview-text-form",onSubmit:$e=>void Rt($e),children:[m.jsx("textarea",{value:z,onChange:$e=>Y($e.target.value),disabled:!q||I,maxLength:4096,rows:3,placeholder:"粘贴文字","aria-label":"粘贴文字","data-slot":"device-preview-text-input",className:"min-h-20 min-w-0 flex-1 resize-none rounded-xl border bg-background px-3 py-2 text-base outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 md:text-sm"}),m.jsx(vt,{type:"submit",size:"icon",className:"size-10 rounded-xl",disabled:!q||!z||I,"aria-label":"粘贴","data-slot":"device-preview-send-text",children:I?m.jsx(li,{className:"animate-spin","aria-hidden":"true"}):m.jsx(WS,{"aria-hidden":"true"})})]})})]})]})})]})})]}):m.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center",children:r?m.jsxs("div",{className:"grid gap-3",children:[m.jsx("p",{className:"text-sm text-muted-foreground",children:"无法找到该预览"}),m.jsx(vt,{variant:"outline",onClick:()=>t("/sessions"),children:"返回"})]}):m.jsx(li,{className:"size-5 animate-spin text-muted-foreground","aria-label":"加载中"})})}function jS({control:e,label:t,icon:n,disabled:r,tooltipSide:i,onClick:s}){return m.jsxs(Sf,{children:[m.jsx(Ef,{asChild:!0,children:m.jsx(vt,{type:"button",variant:"ghost",size:"icon",className:"size-11 rounded-full text-muted-foreground hover:text-foreground","aria-label":t,disabled:r,onClick:s,"data-slot":"device-preview-control","data-control":e,children:n})}),m.jsx(Cf,{side:i,sideOffset:10,hideArrow:!0,className:"border border-border/80 bg-card/95 px-2.5 py-1 text-muted-foreground shadow-sm backdrop-blur",children:t})]})}function ZLe({platform:e,orientation:t}){const n=t==="portrait";return e==="ios"?m.jsxs("div",{"aria-hidden":"true","data-slot":"device-preview-device-chrome","data-platform":"ios","data-orientation":t,className:qe("pointer-events-none absolute -inset-[var(--ios-rail)] z-0 select-none rounded-[calc(var(--device-screen-radius)+var(--ios-rail))] border border-black/85 bg-[#202024] ring-1 ring-black/30","shadow-[inset_1px_1px_0_rgba(255,255,255,0.16),inset_-1px_-1px_0_rgba(0,0,0,0.72)]"),children:[m.jsx("span",{className:"absolute inset-[2px] rounded-[calc(var(--device-screen-radius)+var(--ios-rail)-2px)] ring-1 ring-inset ring-white/[0.05]"}),n?m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"absolute -left-[4px] top-[16%] h-[clamp(12px,4%,22px)] w-[4px] rounded-l-[3px] border border-r-0 border-black/70 bg-[#343439] shadow-[inset_1px_0_0_rgba(255,255,255,0.14)]"}),m.jsx("span",{className:"absolute -left-[4px] top-[23%] h-[clamp(24px,7%,42px)] w-[4px] rounded-l-[3px] border border-r-0 border-black/70 bg-[#343439] shadow-[inset_1px_0_0_rgba(255,255,255,0.14)]"}),m.jsx("span",{className:"absolute -left-[4px] top-[32%] h-[clamp(24px,7%,42px)] w-[4px] rounded-l-[3px] border border-r-0 border-black/70 bg-[#343439] shadow-[inset_1px_0_0_rgba(255,255,255,0.14)]"}),m.jsx("span",{className:"absolute -right-[4px] top-[28%] h-[clamp(36px,12%,64px)] w-[4px] rounded-r-[3px] border border-l-0 border-black/70 bg-[#343439] shadow-[inset_-1px_0_0_rgba(255,255,255,0.14)]"})]}):m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"absolute -top-[4px] left-[16%] h-[4px] w-[clamp(12px,4%,22px)] rounded-t-[3px] border border-b-0 border-black/70 bg-[#343439] shadow-[inset_0_1px_0_rgba(255,255,255,0.14)]"}),m.jsx("span",{className:"absolute -top-[4px] left-[23%] h-[4px] w-[clamp(24px,7%,42px)] rounded-t-[3px] border border-b-0 border-black/70 bg-[#343439] shadow-[inset_0_1px_0_rgba(255,255,255,0.14)]"}),m.jsx("span",{className:"absolute -top-[4px] left-[32%] h-[4px] w-[clamp(24px,7%,42px)] rounded-t-[3px] border border-b-0 border-black/70 bg-[#343439] shadow-[inset_0_1px_0_rgba(255,255,255,0.14)]"}),m.jsx("span",{className:"absolute -bottom-[4px] left-[28%] h-[4px] w-[clamp(36px,12%,64px)] rounded-b-[3px] border border-t-0 border-black/70 bg-[#343439] shadow-[inset_0_-1px_0_rgba(255,255,255,0.14)]"})]})]}):m.jsxs("div",{"aria-hidden":"true","data-slot":"device-preview-device-chrome","data-platform":"android","data-orientation":t,className:qe("pointer-events-none absolute -inset-[9px] z-0 select-none rounded-[calc(var(--device-screen-radius)+9px)] border border-black/70 bg-[linear-gradient(145deg,#68717a_0%,#22272d_22%,#08090b_58%,#454c55_100%)] ring-1 ring-white/15"),children:[m.jsx("span",{className:qe("absolute rounded-full bg-white/25 shadow-sm",n?"left-1/2 top-[3px] h-px w-[14%] -translate-x-1/2":"left-[3px] top-1/2 h-[14%] w-px -translate-y-1/2")}),n?m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"absolute -right-[4px] top-[20%] h-[14%] min-h-7 w-[3px] rounded-r-sm bg-slate-500 shadow-sm"}),m.jsx("span",{className:"absolute -right-[4px] top-[38%] h-[9%] min-h-4 w-[3px] rounded-r-sm bg-slate-400 shadow-sm"})]}):m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"absolute -top-[4px] left-[20%] h-[3px] w-[14%] min-w-7 rounded-t-sm bg-slate-500 shadow-sm"}),m.jsx("span",{className:"absolute -top-[4px] left-[38%] h-[3px] w-[9%] min-w-4 rounded-t-sm bg-slate-400 shadow-sm"})]})]})}const Kd=eV([{path:"/",element:m.jsx(D1e,{}),children:[{index:!0,element:m.jsx(B1e,{})},{path:"sessions",element:m.jsx(z1e,{})},{path:"chat/:id",element:m.jsx(uLe,{})},{path:"preview/device/:id",element:m.jsx(XLe,{})}]},{path:"/pty-test",element:m.jsx(mLe,{})},{path:"/tokens",element:m.jsx(wLe,{})},{path:"/markdown-test",element:m.jsx(SLe,{})}]);function QLe({browserName:e}){const[t,n]=b.useState("idle"),r=async()=>{const i=await Fp(window.location.href,{allowUserGestureFallback:!0});n(i==="failed"?"failed":"copied")};return m.jsxs("div",{className:"flex min-h-[100dvh] flex-col overflow-hidden bg-background text-foreground","data-slot":"unsupported-ipad-browser",children:[m.jsx("header",{className:"mx-auto flex w-full max-w-5xl items-center px-6 py-5 sm:px-10",children:m.jsx(Gz,{className:"text-sm",slot:"unsupported-browser-brand"})}),m.jsx("main",{className:"mx-auto flex w-full max-w-5xl flex-1 items-center px-6 pb-20 sm:px-10 sm:pb-24",children:m.jsxs("section",{className:"max-w-xl","aria-labelledby":"unsupported-browser-title",children:[m.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[m.jsx(ZV,{className:"size-4 text-primary","aria-hidden":"true"}),m.jsx("span",{children:"iPad 浏览器支持"})]}),m.jsx("h1",{id:"unsupported-browser-title",className:"mt-4 text-3xl font-semibold tracking-normal sm:text-4xl",children:"请使用 Safari 打开"}),m.jsxs("p",{className:"mt-4 max-w-lg text-base leading-7 text-muted-foreground",children:["DEV Anywhere 暂不支持 iPad 上的 ",e,"。当前版本仅支持 Safari,以保证终端输入和实体键盘行为稳定。"]}),m.jsxs("div",{className:"mt-7 flex flex-wrap items-center gap-3",children:[m.jsxs(vt,{className:"h-11 px-4",onClick:r,children:[t==="copied"?m.jsx(ua,{className:"size-4","aria-hidden":"true"}):m.jsx(Sz,{className:"size-4","aria-hidden":"true"}),t==="copied"?"链接已复制":"复制当前链接"]}),m.jsx("span",{className:"text-sm text-muted-foreground","aria-live":"polite",children:t==="copied"?"请切换到 Safari 后粘贴打开":t==="failed"?"复制失败,请从地址栏复制":"复制后在 Safari 中打开"})]})]})})]})}function JLe({children:e}){const t=L1e();return t.supported?e:m.jsx(QLe,{browserName:t.browserName})}function eDe(){return m.jsx(JLe,{children:m.jsx(tDe,{})})}function tDe(){return Fse(),m.jsx(Hde,{delayDuration:200,children:m.jsx(E7,{router:Kd})})}function nDe(e=window.history){e.scrollRestoration="manual"}nDe();jG();dpe();FW.createRoot(document.getElementById("root")).render(m.jsx(b.StrictMode,{children:m.jsx(eDe,{})}));export{SH as _,rm as a,iDe as g};
864
+ `;function SLe(){return m.jsx("div",{className:"min-h-dvh bg-background text-foreground p-6",children:m.jsxs("div",{className:"mx-auto max-w-[720px] space-y-6",children:[m.jsxs("header",{children:[m.jsx("h1",{className:"text-lg font-semibold",children:"Markdown 渲染走查"}),m.jsx("p",{className:"text-sm text-muted-foreground",children:"下方模拟 assistant 气泡容器 (max-w 约束), 验证所有 markdown 元素在气泡内的实际渲染。"})]}),m.jsx("article",{className:"flex justify-start",children:m.jsx("div",{className:"max-w-[80%] rounded-md bg-card text-foreground px-4 py-2 text-sm",children:m.jsx(tC,{text:xLe})})})]})})}function E8(e){if([e.left,e.top,e.width,e.height,e.frameWidth,e.frameHeight].some(l=>!Number.isFinite(l))||e.width<=0||e.height<=0||e.frameWidth<=0||e.frameHeight<=0)return null;const n=Math.min(e.width/e.frameWidth,e.height/e.frameHeight),r=e.frameWidth*n,i=e.frameHeight*n,s=e.left+(e.width-r)/2,o=e.top+(e.height-i)/2;return{left:s,top:o,right:s+r,bottom:o+i,width:r,height:i}}function C8(e,t,n){return{x:Math.min(1,Math.max(0,(e-n.left)/n.width)),y:Math.min(1,Math.max(0,(t-n.top)/n.height))}}function ELe(e,t,n){if(!Number.isFinite(e)||!Number.isFinite(t))return null;const r=E8(n);return!r||e<r.left||e>r.right||t<r.top||t>r.bottom?null:C8(e,t,r)}function CLe(e,t,n){if(!Number.isFinite(e)||!Number.isFinite(t))return null;const r=E8(n);return r?C8(e,t,r):null}async function kLe(e){const t=e.slice();return createImageBitmap(new Blob([t.buffer],{type:"image/jpeg"}))}class TLe{constructor(t,n,r=kLe){je(this,"latest",null);je(this,"painting",!1);je(this,"disposed",!1);je(this,"generation",0);je(this,"lastSequence",-1);je(this,"sizeReportedGeneration",-1);this.canvas=t,this.onSize=n,this.decoder=r}enqueue(t,n){var r;this.disposed||t<=this.lastSequence||((r=this.latest)==null?void 0:r.generation)===this.generation&&t<=this.latest.sequence||(this.latest={generation:this.generation,sequence:t,jpeg:n.slice()},this.painting||this.paintLoop())}reset(t=!1){var n;this.disposed||(this.generation+=1,this.latest=null,this.lastSequence=-1,t&&((n=this.canvas.getContext("2d",{alpha:!1}))==null||n.clearRect(0,0,this.canvas.width,this.canvas.height)))}dispose(){this.disposed=!0,this.generation+=1,this.latest=null}async paintLoop(){var t;this.painting=!0;try{for(;!this.disposed&&this.latest;){const n=this.latest;this.latest=null;let r;try{r=await this.decoder(n.jpeg)}catch(i){!this.disposed&&n.generation===this.generation&&console.warn("Failed to decode device preview frame",i);continue}try{if(this.disposed||n.generation!==this.generation||n.sequence<=this.lastSequence)continue;const i=this.canvas.width!==r.width||this.canvas.height!==r.height;i&&(this.canvas.width=r.width,this.canvas.height=r.height),(i||this.sizeReportedGeneration!==n.generation)&&(this.sizeReportedGeneration=n.generation,this.onSize({width:r.width,height:r.height})),(t=this.canvas.getContext("2d",{alpha:!1}))==null||t.drawImage(r,0,0),this.lastSequence=n.sequence}finally{r.close()}}}finally{this.painting=!1,!this.disposed&&this.latest&&this.paintLoop()}}}const RLe=120,ALe=8*1024*1024,NLe=1e3/30,MLe=.15,PLe=100,ILe=.001;function OLe(e,t){if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.byteLength;n+=1)if(e[n]!==t[n])return!1;return!0}function Wc(e,t){if(e instanceof Error)return e;if(typeof e=="string"&&e.length>0)return new Error(e);if(e&&typeof e=="object"){const n=e,r=[n.name,n.message,n.error].filter(i=>typeof i=="string"&&i.length>0).join(": ");if(r.length>0)return new Error(r)}return new Error(t)}function LLe(e){const t=e.error;if(!t)return new Error("H.264 video playback failed");const n=t.message||`media error ${t.code}`;return new Error(`H.264 video playback failed: ${n}`)}class DLe{constructor(t,n={}){je(this,"muxer",null);je(this,"initialSources");je(this,"initialVideoState");je(this,"configuration",null);je(this,"configurationApplied",!1);je(this,"muxerReady",!1);je(this,"awaitingKeyframe",!0);je(this,"pendingFrames",[]);je(this,"fedFramesAwaitingPlayback",[]);je(this,"bufferedPacketCount",0);je(this,"bufferedBytes",0);je(this,"maxBufferedPackets");je(this,"maxBufferedBytes");je(this,"lastObservedMediaTime",null);je(this,"resyncRequired",!1);je(this,"playPending",!1);je(this,"playRequested",!1);je(this,"started",!1);je(this,"destroyed",!1);je(this,"generation",0);je(this,"playbackDelayTimer",null);je(this,"handlePlaying",()=>{this.destroyed||(this.observePlaybackProgress(),this.playRequested=!0,this.markStarted())});je(this,"handleTimeUpdate",()=>{this.observePlaybackProgress()});je(this,"handleVideoError",()=>{this.destroyed||this.reportError(LLe(this.video))});this.video=t,this.options=n,this.maxBufferedPackets=RB(n.maxBufferedPackets,RLe),this.maxBufferedBytes=RB(n.maxBufferedBytes,ALe),this.initialSources=new Set(t.querySelectorAll("source")),this.initialVideoState={autoplay:t.autoplay,disableRemotePlayback:t.disableRemotePlayback,muted:t.muted,playsInline:t.playsInline,src:t.getAttribute("src"),srcObject:t.srcObject},t.srcObject=null,t.muted=!0,t.autoplay=!0,t.playsInline=!0,t.disableRemotePlayback=!0,t.addEventListener("playing",this.handlePlaying),t.addEventListener("error",this.handleVideoError),t.addEventListener("timeupdate",this.handleTimeUpdate);const r={node:t,mode:"video",flushingTime:0,maxDelay:150,clearBuffer:!0,onReady:()=>this.handleMuxerReady(),onError:i=>this.handleMuxerError(i),onUnsupportedCodec:i=>{this.reportError(new Error(`Browser does not support the H.264 codec ${i}`))}};this.initializeMuxer(r)}feed(t){if(!(this.destroyed||t.data.byteLength===0)){if(this.observePlaybackProgress(),t.kind==="configuration"){this.feedConfiguration(t.data);return}this.feedFrame(t)}}destroy(){var n;if(this.destroyed)return;this.destroyed=!0,this.generation+=1,this.clearBufferedGeneration(),this.video.removeEventListener("playing",this.handlePlaying),this.video.removeEventListener("error",this.handleVideoError),this.video.removeEventListener("timeupdate",this.handleTimeUpdate),this.stopPlaybackDelayChecks();const t=this.generatedObjectUrls();try{(n=this.muxer)==null||n.destroy()}catch{}this.muxer=null;try{this.video.pause()}catch{}this.removeGeneratedSources(),this.video.removeAttribute("src"),this.initialVideoState.src!==null&&this.video.setAttribute("src",this.initialVideoState.src),this.video.srcObject=this.initialVideoState.srcObject,this.video.autoplay=this.initialVideoState.autoplay,this.video.disableRemotePlayback=this.initialVideoState.disableRemotePlayback,this.video.muted=this.initialVideoState.muted,this.video.playsInline=this.initialVideoState.playsInline;for(const r of t)this.revokeObjectUrl(r);try{this.video.load()}catch{}}async initializeMuxer(t){try{const{default:n}=await SH(async()=>{const{default:r}=await import("./jmuxer.min-ZEZpvKJO.js").then(i=>i.j);return{default:r}},__vite__mapDeps([0,1]));if(this.destroyed)return;this.muxer=new n(t)}catch(n){if(this.destroyed)return;this.reportError(Wc(n,"Failed to initialize H.264 video playback")),this.destroy()}}feedConfiguration(t){if(this.configuration&&OLe(this.configuration,t))return;const n=this.configuration!==null&&this.configurationApplied;if(this.clearBufferedGeneration(),this.wouldOverflow(t.byteLength)){this.requireResync();return}if(this.configuration=t.slice(),this.addBufferedPacket(t.byteLength),this.awaitingKeyframe=!0,n){this.resetMuxer();return}this.applyConfigurationIfReady()}feedFrame(t){if(!this.configuration)return;if(this.awaitingKeyframe){if(!t.keyframe)return;this.awaitingKeyframe=!1,this.resyncRequired=!1}const n={data:t.data.slice(),durationMs:Number.isFinite(t.durationMs)&&t.durationMs>0?t.durationMs:NLe,keyframe:t.keyframe};if(n.keyframe&&this.clearPendingFrames(),this.wouldOverflow(n.data.byteLength)){this.requireResync();return}if(this.addBufferedPacket(n.data.byteLength),!this.muxerReady||!this.configurationApplied){this.pendingFrames.push(n);return}this.applyFrame(n)||this.removeBufferedPacket(n.data.byteLength)}resetMuxer(){var r;const t=this.generatedSources(),n=this.generatedObjectUrls();this.generation+=1,this.muxerReady=!1,this.configurationApplied=!1,this.awaitingKeyframe=!0,this.playPending=!1,this.playRequested=!1,this.stopPlaybackDelayChecks();try{(r=this.muxer)==null||r.reset()}catch(i){this.reportError(Wc(i,"Failed to reset H.264 video playback"))}for(const i of t)i.remove();for(const i of n)this.revokeObjectUrl(i)}handleMuxerReady(){this.destroyed||(this.muxerReady=!0,this.startPlaybackDelayChecks(),this.applyConfigurationIfReady(),this.flushPendingFrames())}startPlaybackDelayChecks(){this.playbackDelayTimer===null&&(this.playbackDelayTimer=setInterval(()=>{this.catchUpToLiveEdge()},PLe))}stopPlaybackDelayChecks(){this.playbackDelayTimer!==null&&(clearInterval(this.playbackDelayTimer),this.playbackDelayTimer=null)}catchUpToLiveEdge(){if(this.destroyed||this.video.seeking)return;const t=this.video.buffered;if(t.length!==0)try{const n=t.end(t.length-1),r=this.video.currentTime;if(!Number.isFinite(n)||!Number.isFinite(r)||n-r<=MLe)return;this.video.currentTime=Math.max(0,n-ILe),this.observePlaybackProgress()}catch{}}applyConfigurationIfReady(){if(!(this.destroyed||!this.muxerReady||this.configurationApplied||!this.configuration||!this.muxer))try{this.muxer.feed({video:this.configuration,duration:0,isLastVideoFrameComplete:!0}),this.configurationApplied=!0,this.flushPendingFrames()}catch(t){this.reportError(Wc(t,"Failed to apply H.264 decoder configuration"))}}applyFrame(t){if(this.destroyed||!this.muxer)return!1;try{return this.muxer.feed({video:t.data,duration:t.durationMs,isLastVideoFrameComplete:!0}),this.fedFramesAwaitingPlayback.push({byteLength:t.data.byteLength,remainingDurationMs:t.durationMs}),this.attemptPlayback(),!0}catch(n){return this.reportError(Wc(n,"Failed to feed an H.264 video frame")),!1}}flushPendingFrames(){if(this.destroyed||!this.muxerReady||!this.configurationApplied||!this.muxer)return;this.observePlaybackProgress();const t=this.pendingFrames;this.pendingFrames=[];for(const n of t){if(this.destroyed)return;this.applyFrame(n)||this.removeBufferedPacket(n.data.byteLength)}}attemptPlayback(){if(this.destroyed||this.playPending||this.playRequested)return;this.playPending=!0,this.playRequested=!0;const t=this.generation;let n;try{n=this.video.play()}catch(r){this.playPending=!1,this.playRequested=!1,this.reportError(Wc(r,"Browser blocked H.264 video playback"));return}n.then(()=>{this.destroyed||t!==this.generation||(this.playPending=!1,this.markStarted())},r=>{this.destroyed||t!==this.generation||(this.playPending=!1,this.playRequested=!1,this.reportError(Wc(r,"Browser blocked H.264 video playback")))})}handleMuxerError(t){this.destroyed||(t.name==="InvalidStateError"&&(this.generation+=1,this.muxerReady=!1,this.configurationApplied=!1,this.awaitingKeyframe=!0,this.clearBufferedGeneration(),this.playPending=!1,this.playRequested=!1,this.stopPlaybackDelayChecks()),this.reportError(Wc(t,"H.264 video buffer failed")))}markStarted(){var t,n;this.started||(this.started=!0,(n=(t=this.options).onStart)==null||n.call(t))}reportError(t){var n,r;this.destroyed||(r=(n=this.options).onError)==null||r.call(n,t)}observePlaybackProgress(){const t=this.video.currentTime;if(!Number.isFinite(t)||t<0)return;if(this.lastObservedMediaTime===null||t<this.lastObservedMediaTime){this.lastObservedMediaTime=t;return}let n=(t-this.lastObservedMediaTime)*1e3;if(this.lastObservedMediaTime=t,!(n<=0))for(;n>0;){const r=this.fedFramesAwaitingPlayback[0];if(!r)return;if(n+Number.EPSILON<r.remainingDurationMs){r.remainingDurationMs-=n;return}n-=r.remainingDurationMs,this.fedFramesAwaitingPlayback.shift(),this.removeBufferedPacket(r.byteLength)}}wouldOverflow(t){return this.bufferedPacketCount+1>this.maxBufferedPackets||this.bufferedBytes+t>this.maxBufferedBytes}addBufferedPacket(t){this.bufferedPacketCount+=1,this.bufferedBytes+=t}removeBufferedPacket(t){this.bufferedPacketCount=Math.max(0,this.bufferedPacketCount-1),this.bufferedBytes=Math.max(0,this.bufferedBytes-t)}clearPendingFrames(){for(const t of this.pendingFrames)this.removeBufferedPacket(t.data.byteLength);this.pendingFrames=[]}clearBufferedGeneration(){this.pendingFrames=[],this.fedFramesAwaitingPlayback=[],this.configuration=null,this.configurationApplied=!1,this.bufferedPacketCount=0,this.bufferedBytes=0,this.lastObservedMediaTime=null}requireResync(){var n,r;const t=!this.resyncRequired;this.resyncRequired=!0,this.clearBufferedGeneration(),this.awaitingKeyframe=!0,this.resetMuxer(),t&&!this.destroyed&&((r=(n=this.options).onResyncRequired)==null||r.call(n,new Error("H.264 playback buffer overflowed; reconnecting for a fresh keyframe")))}generatedSources(){return Array.from(this.video.querySelectorAll("source")).filter(t=>!this.initialSources.has(t))}removeGeneratedSources(){for(const t of this.generatedSources())t.remove()}generatedObjectUrls(){const t=new Set,n=this.video.getAttribute("src");n!==this.initialVideoState.src&&(n!=null&&n.startsWith("blob:"))&&t.add(n);for(const r of this.generatedSources()){const i=r.getAttribute("src");i!=null&&i.startsWith("blob:")&&t.add(i)}return[...t]}revokeObjectUrl(t){if(typeof URL.revokeObjectURL=="function")try{URL.revokeObjectURL(t)}catch{}}}function RB(e,t){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0?e:t}class BLe{constructor(){je(this,"buffer",new Uint8Array(0))}push(t){if(t.byteLength===0)return[];const n=new Uint8Array(this.buffer.byteLength+t.byteLength);n.set(this.buffer),n.set(t,this.buffer.byteLength),this.buffer=n;const r=[];let i=0;for(;this.buffer.byteLength-i>=Ah;){const s=new DataView(this.buffer.buffer,this.buffer.byteOffset+i,Ah),o=s.getUint32(0,!0),l=s.getUint32(4,!0);if(o===0||o>Oy)throw this.buffer=new Uint8Array(0),new RangeError(`Invalid device preview frame length: ${o}`);const u=Ah+o;if(this.buffer.byteLength-i<u)break;r.push({sequence:l,jpeg:this.buffer.slice(i+Ah,i+u)}),i+=u}if(i>0&&(this.buffer=this.buffer.slice(i)),this.buffer.byteLength>Ah+Oy)throw this.buffer=new Uint8Array(0),new RangeError("Device preview stream buffer exceeded its limit");return r}finish(){if(this.buffer.byteLength!==0)throw this.buffer=new Uint8Array(0),new Error("Device preview stream ended with a truncated frame")}}class zLe{constructor(){je(this,"buffer",new Uint8Array(0))}push(t){if(t.byteLength===0)return[];const n=new Uint8Array(this.buffer.byteLength+t.byteLength);n.set(this.buffer),n.set(t,this.buffer.byteLength),this.buffer=n;const r=[];let i=0;for(;this.buffer.byteLength-i>=rp;){const s=this.buffer.subarray(i),o=Bne(s);if(!o)throw this.buffer=new Uint8Array(0),new RangeError("Invalid H.264 device preview packet header");const l=rp+o.annexBLength;if(this.buffer.byteLength-i<l)break;r.push({sequence:o.packetSequence,kind:o.configuration?"configuration":"frame",keyframe:o.keyframe,durationMs:o.durationMs,data:this.buffer.slice(i+rp,i+l)}),i+=l}if(i>0&&(this.buffer=this.buffer.slice(i)),this.buffer.byteLength>rp+Oy)throw this.buffer=new Uint8Array(0),new RangeError("H.264 device preview stream buffer exceeded its limit");return r}finish(){if(this.buffer.byteLength!==0)throw this.buffer=new Uint8Array(0),new Error("H.264 device preview stream ended with a truncated packet")}}function jLe(e){let t;try{t=new URL(e,globalThis.location.href)}catch{throw new Error("无效的模拟器画面地址")}if(t.origin!==globalThis.location.origin||t.username!==""||t.password!==""||!/^\/api\/device-preview-streams\/[A-Za-z0-9_-]{1,256}$/u.test(t.pathname)||t.search!==""||t.hash!=="")throw new Error("拒绝连接不受信任的模拟器画面地址")}function FLe(e){const t=Number(e.headers.get("X-Device-Width")),n=Number(e.headers.get("X-Device-Height"));return!Number.isSafeInteger(t)||t<=0||!Number.isSafeInteger(n)||n<=0?null:{width:t,height:n}}async function k8(e,t,n){jLe(e);const r=Sb(),i=await n(e,{method:"GET",cache:"no-store",credentials:"same-origin",...r?{headers:{Authorization:`Bearer ${r}`}}:{},signal:t});if(!i.ok||!i.body)throw new Error(`无法打开模拟器画面(${i.status})`);return i}async function $Le(e,t){const n=t.fetch??globalThis.fetch,r=await k8(e,t.signal,n);if(r.headers.get("X-Device-Preview-Format")!=="jpeg")throw new Error("开发机返回了错误的模拟器画面格式");const i=new BLe,s=r.body.getReader();try{for(;;){const{done:o,value:l}=await s.read();if(o)break;const d=i.push(l).at(-1);d&&await t.onFrame(d)}i.finish()}finally{s.releaseLock()}}async function HLe(e,t){var l;const n=t.fetch??globalThis.fetch,r=await k8(e,t.signal,n);if(r.headers.get("X-Device-Preview-Format")!=="h264_annex_b")throw new Error("开发机没有返回 H.264 模拟器画面");const i=FLe(r);i&&((l=t.onSize)==null||l.call(t,i));const s=new zLe,o=r.body.getReader();try{for(;;){const{done:u,value:d}=await o.read();if(u)break;for(const f of s.push(d))await t.onPacket(f)}s.finish()}finally{o.releaseLock()}}const ULe=16,WLe=16;class qLe{constructor(t){je(this,"send");je(this,"onFailure");je(this,"now");je(this,"moveFlushMs");je(this,"maxInFlightMoves");je(this,"active",null);je(this,"inFlightMoves",0);je(this,"disposed",!1);je(this,"failed",!1);this.send=t.send,this.onFailure=t.onFailure,this.now=t.now??(()=>performance.now()),this.moveFlushMs=t.moveFlushMs??ULe,this.maxInFlightMoves=t.maxInFlightMoves??WLe}begin(t,n){if(this.disposed||this.failed||this.active)return!1;const r={pointerId:t,lastPoint:n,lastMoveAt:Number.NEGATIVE_INFINITY,pendingMove:null,moveFlushTimer:null};return this.active=r,this.dispatch(this.input("down",n)),!0}move(t,n){const r=this.matchingActive(t);if(!r)return!1;r.lastPoint=n,r.pendingMove=n;const i=this.now(),s=this.moveFlushMs-(i-r.lastMoveAt);return s>0?(r.moveFlushTimer===null&&(r.moveFlushTimer=setTimeout(()=>{r.moveFlushTimer=null,!(this.active!==r||this.disposed||this.failed)&&(r.lastMoveAt=this.now(),this.flushLatestMove())},s)),!0):(this.clearMoveTimer(r),r.lastMoveAt=i,this.flushLatestMove(),!0)}end(t,n){const r=this.matchingActive(t);return r?(r.lastPoint=n,this.finish(r),this.dispatch(this.input("up",n)),!0):!1}cancel(t){const n=this.active;if(!n||t!==void 0&&n.pointerId!==t)return!1;const r=n.lastPoint;return this.finish(n),this.dispatch(this.input("up",r)),!0}dispose(){if(this.disposed)return;const t=this.active;if(t&&this.finish(t),this.disposed=!0,!(!t||this.failed))try{Promise.resolve(this.send(this.input("up",t.lastPoint))).catch(()=>{})}catch{}}matchingActive(t){var n;return this.disposed||this.failed||((n=this.active)==null?void 0:n.pointerId)!==t?null:this.active}finish(t){this.active===t&&(this.active=null),this.clearMoveTimer(t),t.pendingMove=null}clearMoveTimer(t){t.moveFlushTimer!==null&&clearTimeout(t.moveFlushTimer),t.moveFlushTimer=null}flushLatestMove(){const t=this.active;if(!t||this.disposed||this.failed||!t.pendingMove||t.moveFlushTimer!==null||this.inFlightMoves>=this.maxInFlightMoves)return;const n=t.pendingMove;t.pendingMove=null,this.inFlightMoves+=1,this.dispatch(this.input("move",n),()=>{this.inFlightMoves=Math.max(0,this.inFlightMoves-1),this.flushLatestMove()})}dispatch(t,n){let r;try{r=Promise.resolve(this.send(t))}catch(i){this.fail(i),n==null||n();return}r.then(()=>n==null?void 0:n(),i=>{this.fail(i),n==null||n()})}fail(t){if(this.disposed||this.failed)return;this.failed=!0;const n=this.active;n&&this.finish(n),this.onFailure(t)}input(t,n){return{kind:"touch",phase:t,x:n.x,y:n.y}}}const VLe=15e3,YLe=1e4,KLe={ios:40,android:28},GLe={ios:{width:390,height:844},android:{width:412,height:915}};function XLe(){const{id:e=""}=dz(),t=Cs(),n=fr($e=>c5($e).find(Fe=>Fe.previewId===e)),r=fr($e=>$e.listLoaded),i=fr($e=>{var Fe;return((Fe=$e.authoritative)==null?void 0:Fe.scope)??null}),s=Zo($e=>cie($e,i,"device",e,"reconnect")),o=b.useRef(null),l=b.useRef(null),u=b.useRef(null),d=b.useRef(null),f=b.useRef(null),h=b.useRef(()=>{}),y=b.useRef(null),g=b.useRef(null),[_,w]=b.useState(0),[S,x]=b.useState("waiting"),[k,R]=b.useState(null),[A,M]=b.useState(null),[T,P]=b.useState(null),[z,Y]=b.useState(""),[U,G]=b.useState(!1),[I,N]=b.useState(!1),[L,B]=b.useState(!1),O=n==null?void 0:n.previewId,D=n==null?void 0:n.state,F=n==null?void 0:n.platform,V=b.useCallback(()=>{const $e=f.current;f.current=null,$e==null||$e.dispose()},[]);b.useEffect(()=>{if(F!=="ios"){d.current=null,P(null);return}const $e=o.current;if(!$e)return;const Fe=new TLe($e,P);return Fe.reset(!0),P(null),d.current=Fe,()=>{Fe.dispose(),d.current=null}},[O,F]),b.useEffect(()=>{if(V(),h.current=()=>{},y.current=null,g.current=null,M(null),N(!1),B(!1),!O||D!=="ready"){D==="disconnected"?(x("error"),R("模拟器已断开")):(x("waiting"),R(null));return}const $e=$t,Fe=i;if(!$e||!Fe||!Pt.isActive($e,Fe)){x("error"),R("开发机连接已断开");return}let xt=!1,_t=null,st=null,Ae=null,ut=null,mt=null,ge=0,Ye=!1;const ve=()=>{mt=null,Ae==null||Ae.abort(),Ae=null,ut==null||ut.destroy(),ut=null,_t&&clearTimeout(_t),_t=null,st&&clearTimeout(st),st=null},Je=Ct=>{x("streaming"),st&&clearTimeout(st),st=setTimeout(()=>{st=null,!(xt||Ct.signal.aborted||mt!==Ct.leaseId||!Pt.isActive($e,Fe))&&(ge=0)},YLe)},dt=()=>{if(xt||document.visibilityState==="hidden"||!Pt.isActive($e,Fe))return;const Ct=Math.min(5e3,500*2**ge);ge+=1,_t=setTimeout(()=>void Ot(),Ct)},Ot=async()=>{var gn;if(V(),ve(),xt||document.visibilityState==="hidden"||!Pt.isActive($e,Fe))return;Ye=!1,(gn=d.current)==null||gn.reset(),P(null),x("connecting"),R(null),M(null);const Ct=new AbortController;Ae=Ct;try{const zt=await Pt.requestDevicePreviewStream(Fe,O,F==="android"?{format:"h264_annex_b"}:{format:"jpeg",maxFps:15},{signal:Ct.signal});if(xt||Ct.signal.aborted||!Pt.isActive($e,Fe)||!zt)return;if(!zt.success)throw new Error(zt.error);const nn=zt;if(mt=nn.leaseId,M(nn),F==="android"){const Fn=l.current;if(!Fn)throw new Error("无法初始化 Android 模拟器播放器");let Xn;const Nn=new Promise((ue,be)=>{Xn=be}),W=setTimeout(()=>{Xn(new Error("Android 模拟器画面启动超时"))},VLe),ie=ue=>{Xn(ue instanceof Error?ue:new Error(String(ue)))},oe=new DLe(Fn,{onStart:()=>{clearTimeout(W),!(xt||nn.signal.aborted||!Pt.isActive($e,Fe))&&Je(nn)},onError:ie,onResyncRequired:ie});ut=oe;try{await Promise.race([HLe(nn.url,{signal:nn.signal,onSize:ue=>{!xt&&!nn.signal.aborted&&Pt.isActive($e,Fe)&&P(ue)},onPacket:ue=>{!xt&&!nn.signal.aborted&&Pt.isActive($e,Fe)&&oe.feed(ue)}}),Nn])}finally{clearTimeout(W)}if(!xt&&!nn.signal.aborted&&Pt.isActive($e,Fe))throw new Error("模拟器画面已断开");return}let En=!1;if(await $Le(nn.url,{signal:nn.signal,onFrame:Fn=>{if(xt||nn.signal.aborted||!Pt.isActive($e,Fe))return;const Xn=d.current;Xn&&(Xn.enqueue(Fn.sequence,Fn.jpeg),En||(En=!0,Je(nn)))}}),!xt&&!nn.signal.aborted&&Pt.isActive($e,Fe))throw new Error("模拟器画面已断开")}catch(zt){if(xt||Ct.signal.aborted||!Pt.isActive($e,Fe))return;Lt(zt,!1)}},Lt=(Ct,gn)=>{if(xt||Ye||!Pt.isActive($e,Fe))return;Ye=!0;const zt=Ct instanceof Error?Ct.message:"模拟器画面已断开";V(),ve(),y.current=null,g.current=null,M(null),N(!1),B(!1),x("error"),R(zt),gn&&Ue.error(zt),dt()},sn=(Ct,gn,zt=!0)=>{Ct===mt&&Lt(gn,zt)};h.current=sn;const Gt=$e.onMessage(Ct=>{if(Ct.type!=="device_preview_control_revoked_push"||!Jt(Ct.scope,Fe)||Ct.leaseId!==mt||!Pt.isActive($e,Fe))return;if(g.current=null,B(!1),Ct.reason==="taken_over"){y.current=null,N(!1),V(),M(zt=>(zt==null?void 0:zt.leaseId)===Ct.leaseId?{...zt,controlMode:"view_only"}:zt),Ue.info("控制权已由其他页面接管");return}const gn=new Error(Ct.reason==="proxy_offline"?"开发机连接已断开":Ct.reason==="lease_expired"?"模拟器画面连接已过期":"模拟器画面已断开");sn(Ct.leaseId,gn,!1)}),on=()=>{if(document.visibilityState==="hidden"){V(),ve(),y.current=null,g.current=null,M(null),N(!1),B(!1),x("waiting");return}ge=0,Ot()};return document.addEventListener("visibilitychange",on),Ot(),()=>{xt=!0,h.current===sn&&(h.current=()=>{}),Gt(),document.removeEventListener("visibilitychange",on),V(),ve()}},[V,O,F,i,D,_]),b.useEffect(()=>{var $e;($e=f.current)==null||$e.cancel()},[T==null?void 0:T.height,T==null?void 0:T.width]);const j=(n==null?void 0:n.state)==="ready"&&(A==null?void 0:A.previewId)===n.previewId&&i&&Jt(A.scope,i)?A:null,q=(n==null?void 0:n.interactive)===!0&&S==="streaming"&&(j==null?void 0:j.controlMode)==="controller";b.useEffect(()=>{V();const $e=$t,Fe=j;if(!$e||!Fe||!q)return;const xt=new qLe({send:async _t=>{const st=await Pt.sendDevicePreviewInput(Fe,_t);if(!st)throw new Error("模拟器控制连接已失效");if(!st.success)throw new Error(st.error)},onFailure:_t=>{f.current===xt&&h.current(Fe.leaseId,_t)}});return f.current=xt,()=>{f.current===xt&&(f.current=null),xt.dispose()}},[q,j,V]);const K=T??GLe[(n==null?void 0:n.platform)==="android"?"android":"ios"],$=KLe[(n==null?void 0:n.platform)==="android"?"android":"ios"],te=K.width/K.height,J=K.width>K.height?"landscape":"portrait",ne=J==="landscape"?`, ${K.width}px`:"",Q={aspectRatio:`${K.width} / ${K.height}`,width:`max(1px, min(calc(100cqw - ${$}px), calc(${(te*100).toFixed(6)}cqh - ${(te*$).toFixed(6)}px)${ne}))`};b.useEffect(()=>{q||G(!1)},[q]);const ce=b.useCallback(async($e,Fe=!0)=>{const xt=$t,_t=j;if(!xt||!_t||!q)return!1;try{const st=await Pt.sendDevicePreviewInput(_t,$e);return!st||!Pt.isActive(xt,_t.scope)?!1:st.success?!0:(Fe&&Ue.error(st.error),!1)}catch(st){return _t.signal.aborted||!Pt.isActive(xt,_t.scope)||Fe&&Ue.error(st instanceof Error?st.message:"模拟器操作失败"),!1}},[q,j]);function re($e,Fe){const xt=u.current;if(!xt||!T)return null;const _t=xt.getBoundingClientRect(),st={left:_t.left,top:_t.top,width:_t.width,height:_t.height,frameWidth:T.width,frameHeight:T.height};return Fe==="start"?ELe($e.clientX,$e.clientY,st):CLe($e.clientX,$e.clientY,st)}function le($e){var _t,st;if(!q||$e.button!==0)return;const Fe=re($e,"start");if(!Fe)return;const xt=f.current;xt!=null&&xt.begin($e.pointerId,Fe)&&($e.preventDefault(),(st=(_t=$e.currentTarget).setPointerCapture)==null||st.call(_t,$e.pointerId))}function we($e){var xt;const Fe=re($e,"captured");Fe&&(xt=f.current)!=null&&xt.move($e.pointerId,Fe)&&$e.preventDefault()}function Ce($e){var xt;const Fe=re($e,"captured");Fe&&((xt=f.current)!=null&&xt.end($e.pointerId,Fe))&&$e.preventDefault()}function ye($e){var Fe;(Fe=f.current)==null||Fe.cancel($e.pointerId)}async function Re(){const $e=$t,Fe=j;if(!$e||!Fe||L||S!=="streaming")return;const xt=Symbol("device-preview-control-claim");g.current=xt,B(!0);try{const _t=await Pt.claimDevicePreviewControl(Fe);if(g.current!==xt||!_t||!Pt.isActive($e,Fe.scope))return;if(!_t.success){Ue.error(_t.error);return}M(st=>(st==null?void 0:st.leaseId)===Fe.leaseId?{...st,controlMode:"controller"}:st)}catch(_t){if(g.current!==xt||Fe.signal.aborted||!Pt.isActive($e,Fe.scope))return;Ue.error(_t instanceof Error?_t.message:"暂时无法取得控制权")}finally{g.current===xt&&(g.current=null,B(!1))}}async function Rt($e){$e.preventDefault();const Fe=z;if(!Fe||I)return;const xt=Symbol("device-preview-text-input");y.current=xt,N(!0);const _t=await ce({kind:"text",text:Fe});y.current===xt&&(_t&&(Y(""),G(!1)),y.current=null,N(!1))}function Ke(){var $e;($e=f.current)==null||$e.cancel(),ce({kind:"orientation",orientation:T&&T.width>T.height?"portrait":"landscape_right"})}async function et(){if((n==null?void 0:n.state)!=="disconnected"){w(xt=>xt+1);return}const $e=$t,Fe=Pt.getActiveScope();if(!$e||!Fe){Ue.error("请先连接开发机");return}try{const xt=await Pt.reconnectDevicePreview(Fe,n.previewId);xt.success||Ue.error(xt.error)}catch(xt){if(!Pt.isActive($e,Fe))return;Ue.error(xt instanceof Error?xt.message:"无法重新连接模拟器预览")}}return n?m.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background","data-slot":"device-preview-page","data-preview-id":n.previewId,"data-stream-status":S,"data-control-mode":n.interactive?(j==null?void 0:j.controlMode)??"none":"unavailable",children:[m.jsxs("header",{className:"flex min-h-14 shrink-0 items-center gap-2 border-b px-3 md:px-4",children:[m.jsx(vt,{variant:"ghost",size:"icon",className:"md:hidden","aria-label":"返回",onClick:()=>t("/sessions"),children:m.jsx(ff,{"aria-hidden":"true"})}),m.jsx(CC,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),m.jsxs("div",{className:"min-w-0 flex-1",children:[m.jsx("p",{className:"truncate text-sm font-medium",children:n.name}),m.jsxs("p",{className:"truncate text-xs text-muted-foreground",children:[n.model," · ",n.platform==="ios"?"iOS":"Android"," ",n.osVersion]})]}),n.interactive&&S==="streaming"&&(j==null?void 0:j.controlMode)==="view_only"?m.jsx(vt,{size:"sm",variant:"outline",disabled:L,onClick:()=>void Re(),"data-slot":"device-preview-claim-control",children:"接管控制"}):m.jsx("span",{className:"text-xs text-muted-foreground",children:q?"可操控":S==="streaming"?"仅查看":"连接中"})]}),m.jsx("div",{className:"min-h-0 flex-1 overflow-hidden bg-muted/30",children:m.jsxs("div",{className:qe("grid h-full min-h-0 min-w-0 gap-3 p-3 md:gap-4 md:p-6",J==="portrait"?"grid-rows-[minmax(0,1fr)_auto] md:grid-cols-[minmax(0,1fr)_auto] md:grid-rows-1":"grid-rows-[minmax(0,1fr)_auto]"),"data-slot":"device-preview-stage","data-orientation":J,children:[m.jsxs("div",{className:"relative flex min-h-0 min-w-0 items-center justify-center overflow-hidden [container-type:size]","data-slot":"device-preview-viewport",children:[m.jsxs("div",{className:qe("relative isolate shrink-0 transition-[width,aspect-ratio] duration-300 ease-out motion-reduce:transition-none [container-type:size]",n.platform==="ios"?"[--device-screen-radius:clamp(22px,14cqmin,56px)] [--ios-rail:clamp(10px,4cqmin,16px)]":"[--device-screen-radius:clamp(14px,6.5cqw,38px)]"),style:Q,"data-slot":"device-preview-device-shell","data-platform":n.platform,"data-orientation":J,children:[m.jsx(ZLe,{platform:n.platform,orientation:J}),m.jsx("div",{ref:u,className:qe("relative z-10 flex h-full w-full min-h-0 min-w-0 items-center justify-center overflow-hidden rounded-[var(--device-screen-radius)] bg-black ring-1 ring-black",q&&"cursor-pointer"),"data-slot":"device-preview-surface","data-control-enabled":q?"true":"false",children:n.platform==="android"?m.jsx("video",{ref:l,className:"pointer-events-none h-full w-full object-contain","data-slot":"device-preview-video",muted:!0,autoPlay:!0,playsInline:!0,disableRemotePlayback:!0,onLoadedMetadata:$e=>{const Fe=$e.currentTarget;Fe.videoWidth>0&&Fe.videoHeight>0&&P({width:Fe.videoWidth,height:Fe.videoHeight})},onResize:$e=>{const Fe=$e.currentTarget;Fe.videoWidth>0&&Fe.videoHeight>0&&P({width:Fe.videoWidth,height:Fe.videoHeight})}}):m.jsx("canvas",{ref:o,className:"pointer-events-none h-full w-full object-contain","data-slot":"device-preview-canvas"})}),m.jsx("div",{className:qe("absolute inset-0 z-20 select-none rounded-[var(--device-screen-radius)]",q?"touch-none cursor-pointer":"pointer-events-none"),onPointerDown:le,onPointerMove:we,onPointerUp:Ce,onPointerCancel:ye,onLostPointerCapture:ye,onContextMenu:$e=>{q&&$e.preventDefault()},"data-slot":"device-preview-input-surface","data-control-enabled":q?"true":"false","aria-hidden":"true"})]}),S!=="streaming"?m.jsx("div",{className:"absolute inset-0 z-30 flex items-center justify-center bg-background/55 p-6 backdrop-blur-[1px]","data-slot":"device-preview-stream-overlay","data-stream-status":S,children:m.jsx("div",{className:"grid max-w-sm justify-items-center gap-3 text-center",children:S==="error"?m.jsxs(m.Fragment,{children:[m.jsx("p",{className:"text-sm text-muted-foreground",children:k}),m.jsxs(vt,{variant:"outline",size:"sm",disabled:s,onClick:()=>void et(),"data-slot":"device-preview-retry",children:[s?m.jsx(li,{className:"size-4 animate-spin","aria-hidden":!0}):null,s?"正在重新连接":"重新连接"]})]}):m.jsxs(m.Fragment,{children:[m.jsx(li,{className:"size-5 animate-spin text-muted-foreground","aria-hidden":!0}),m.jsx("p",{className:"text-sm text-muted-foreground",children:"正在连接画面..."})]})})}):null]}),m.jsx("div",{className:"relative z-20 flex min-w-0 items-center justify-center pb-[max(0px,env(safe-area-inset-bottom))] md:pb-0","data-slot":"device-preview-control-dock","data-orientation":J,role:"group","aria-label":"模拟器控制",children:m.jsxs("div",{className:qe("flex max-w-full items-center gap-1 rounded-full border border-border/70 bg-card/85 p-1.5 shadow-xl ring-1 ring-black/5 backdrop-blur-xl",J==="portrait"&&"md:flex-col"),children:[m.jsx(jS,{control:"home",label:"主屏幕",disabled:!q,icon:m.jsx(xY,{"aria-hidden":"true"}),tooltipSide:J==="portrait"?"left":"top",onClick:()=>void ce({kind:"button",button:"home"})}),n.platform==="android"?m.jsx(jS,{control:"back",label:"返回",disabled:!q,icon:m.jsx(EK,{"aria-hidden":"true"}),tooltipSide:J==="portrait"?"left":"top",onClick:()=>void ce({kind:"button",button:"back"})}):null,m.jsx(jS,{control:"orientation",label:"旋转",disabled:!q||!T,icon:m.jsx(tK,{"aria-hidden":"true"}),tooltipSide:J==="portrait"?"left":"top",onClick:Ke}),m.jsx("span",{className:qe("mx-0.5 h-6 w-px shrink-0 bg-border/80",J==="portrait"&&"md:mx-0 md:h-px md:w-6"),"aria-hidden":"true"}),m.jsxs(Ub,{open:U,onOpenChange:$e=>{(!$e||q)&&G($e)},children:[m.jsxs(Sf,{children:[m.jsx(Ef,{asChild:!0,children:m.jsx(Wb,{asChild:!0,children:m.jsx(vt,{type:"button",variant:"ghost",size:"icon",className:qe("size-11 rounded-full text-muted-foreground hover:text-foreground",U&&"bg-accent text-foreground"),disabled:!q,"aria-label":"粘贴文字","aria-expanded":U,"aria-controls":"device-preview-text-form","data-slot":"device-preview-text-toggle",children:m.jsx(WS,{"aria-hidden":"true"})})})}),m.jsx(Cf,{side:J==="portrait"?"left":"top",sideOffset:10,hideArrow:!0,children:"粘贴文字"})]}),m.jsx(qb,{side:J==="portrait"?"left":"top",align:"center",sideOffset:12,className:"w-[min(20rem,calc(100vw-1.5rem))] rounded-2xl bg-card/95 p-2 shadow-2xl backdrop-blur-xl",children:m.jsxs("form",{id:"device-preview-text-form",className:"flex items-end gap-2","data-slot":"device-preview-text-form",onSubmit:$e=>void Rt($e),children:[m.jsx("textarea",{value:z,onChange:$e=>Y($e.target.value),disabled:!q||I,maxLength:4096,rows:3,placeholder:"粘贴文字","aria-label":"粘贴文字","data-slot":"device-preview-text-input",className:"min-h-20 min-w-0 flex-1 resize-none rounded-xl border bg-background px-3 py-2 text-base outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 md:text-sm"}),m.jsx(vt,{type:"submit",size:"icon",className:"size-10 rounded-xl",disabled:!q||!z||I,"aria-label":"粘贴","data-slot":"device-preview-send-text",children:I?m.jsx(li,{className:"animate-spin","aria-hidden":"true"}):m.jsx(WS,{"aria-hidden":"true"})})]})})]})]})})]})})]}):m.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center",children:r?m.jsxs("div",{className:"grid gap-3",children:[m.jsx("p",{className:"text-sm text-muted-foreground",children:"无法找到该预览"}),m.jsx(vt,{variant:"outline",onClick:()=>t("/sessions"),children:"返回"})]}):m.jsx(li,{className:"size-5 animate-spin text-muted-foreground","aria-label":"加载中"})})}function jS({control:e,label:t,icon:n,disabled:r,tooltipSide:i,onClick:s}){return m.jsxs(Sf,{children:[m.jsx(Ef,{asChild:!0,children:m.jsx(vt,{type:"button",variant:"ghost",size:"icon",className:"size-11 rounded-full text-muted-foreground hover:text-foreground","aria-label":t,disabled:r,onClick:s,"data-slot":"device-preview-control","data-control":e,children:n})}),m.jsx(Cf,{side:i,sideOffset:10,hideArrow:!0,className:"border border-border/80 bg-card/95 px-2.5 py-1 text-muted-foreground shadow-sm backdrop-blur",children:t})]})}function ZLe({platform:e,orientation:t}){const n=t==="portrait";return e==="ios"?m.jsxs("div",{"aria-hidden":"true","data-slot":"device-preview-device-chrome","data-platform":"ios","data-orientation":t,className:qe("pointer-events-none absolute -inset-[var(--ios-rail)] z-0 select-none rounded-[calc(var(--device-screen-radius)+var(--ios-rail))] border border-black/85 bg-[#202024] ring-1 ring-black/30","shadow-[inset_1px_1px_0_rgba(255,255,255,0.16),inset_-1px_-1px_0_rgba(0,0,0,0.72)]"),children:[m.jsx("span",{className:"absolute inset-[2px] rounded-[calc(var(--device-screen-radius)+var(--ios-rail)-2px)] ring-1 ring-inset ring-white/[0.05]"}),n?m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"absolute -left-[4px] top-[16%] h-[clamp(12px,4%,22px)] w-[4px] rounded-l-[3px] border border-r-0 border-black/70 bg-[#343439] shadow-[inset_1px_0_0_rgba(255,255,255,0.14)]"}),m.jsx("span",{className:"absolute -left-[4px] top-[23%] h-[clamp(24px,7%,42px)] w-[4px] rounded-l-[3px] border border-r-0 border-black/70 bg-[#343439] shadow-[inset_1px_0_0_rgba(255,255,255,0.14)]"}),m.jsx("span",{className:"absolute -left-[4px] top-[32%] h-[clamp(24px,7%,42px)] w-[4px] rounded-l-[3px] border border-r-0 border-black/70 bg-[#343439] shadow-[inset_1px_0_0_rgba(255,255,255,0.14)]"}),m.jsx("span",{className:"absolute -right-[4px] top-[28%] h-[clamp(36px,12%,64px)] w-[4px] rounded-r-[3px] border border-l-0 border-black/70 bg-[#343439] shadow-[inset_-1px_0_0_rgba(255,255,255,0.14)]"})]}):m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"absolute -top-[4px] left-[16%] h-[4px] w-[clamp(12px,4%,22px)] rounded-t-[3px] border border-b-0 border-black/70 bg-[#343439] shadow-[inset_0_1px_0_rgba(255,255,255,0.14)]"}),m.jsx("span",{className:"absolute -top-[4px] left-[23%] h-[4px] w-[clamp(24px,7%,42px)] rounded-t-[3px] border border-b-0 border-black/70 bg-[#343439] shadow-[inset_0_1px_0_rgba(255,255,255,0.14)]"}),m.jsx("span",{className:"absolute -top-[4px] left-[32%] h-[4px] w-[clamp(24px,7%,42px)] rounded-t-[3px] border border-b-0 border-black/70 bg-[#343439] shadow-[inset_0_1px_0_rgba(255,255,255,0.14)]"}),m.jsx("span",{className:"absolute -bottom-[4px] left-[28%] h-[4px] w-[clamp(36px,12%,64px)] rounded-b-[3px] border border-t-0 border-black/70 bg-[#343439] shadow-[inset_0_-1px_0_rgba(255,255,255,0.14)]"})]})]}):m.jsxs("div",{"aria-hidden":"true","data-slot":"device-preview-device-chrome","data-platform":"android","data-orientation":t,className:qe("pointer-events-none absolute -inset-[9px] z-0 select-none rounded-[calc(var(--device-screen-radius)+9px)] border border-black/70 bg-[linear-gradient(145deg,#68717a_0%,#22272d_22%,#08090b_58%,#454c55_100%)] ring-1 ring-white/15"),children:[m.jsx("span",{className:qe("absolute rounded-full bg-white/25 shadow-sm",n?"left-1/2 top-[3px] h-px w-[14%] -translate-x-1/2":"left-[3px] top-1/2 h-[14%] w-px -translate-y-1/2")}),n?m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"absolute -right-[4px] top-[20%] h-[14%] min-h-7 w-[3px] rounded-r-sm bg-slate-500 shadow-sm"}),m.jsx("span",{className:"absolute -right-[4px] top-[38%] h-[9%] min-h-4 w-[3px] rounded-r-sm bg-slate-400 shadow-sm"})]}):m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"absolute -top-[4px] left-[20%] h-[3px] w-[14%] min-w-7 rounded-t-sm bg-slate-500 shadow-sm"}),m.jsx("span",{className:"absolute -top-[4px] left-[38%] h-[3px] w-[9%] min-w-4 rounded-t-sm bg-slate-400 shadow-sm"})]})]})}const Kd=eV([{path:"/",element:m.jsx(D1e,{}),children:[{index:!0,element:m.jsx(B1e,{})},{path:"sessions",element:m.jsx(z1e,{})},{path:"chat/:id",element:m.jsx(uLe,{})},{path:"preview/device/:id",element:m.jsx(XLe,{})}]},{path:"/pty-test",element:m.jsx(mLe,{})},{path:"/tokens",element:m.jsx(wLe,{})},{path:"/markdown-test",element:m.jsx(SLe,{})}]);function QLe({browserName:e}){const[t,n]=b.useState("idle"),r=async()=>{const i=await Fp(window.location.href,{allowUserGestureFallback:!0});n(i==="failed"?"failed":"copied")};return m.jsxs("div",{className:"flex min-h-[100dvh] flex-col overflow-hidden bg-background text-foreground","data-slot":"unsupported-ipad-browser",children:[m.jsx("header",{className:"mx-auto flex w-full max-w-5xl items-center px-6 py-5 sm:px-10",children:m.jsx(Gz,{className:"text-sm",slot:"unsupported-browser-brand"})}),m.jsx("main",{className:"mx-auto flex w-full max-w-5xl flex-1 items-center px-6 pb-20 sm:px-10 sm:pb-24",children:m.jsxs("section",{className:"max-w-xl","aria-labelledby":"unsupported-browser-title",children:[m.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[m.jsx(ZV,{className:"size-4 text-primary","aria-hidden":"true"}),m.jsx("span",{children:"iPad 浏览器支持"})]}),m.jsx("h1",{id:"unsupported-browser-title",className:"mt-4 text-3xl font-semibold tracking-normal sm:text-4xl",children:"请使用 Safari 打开"}),m.jsxs("p",{className:"mt-4 max-w-lg text-base leading-7 text-muted-foreground",children:["DEV Anywhere 暂不支持 iPad 上的 ",e,"。当前版本仅支持 Safari,以保证终端输入和实体键盘行为稳定。"]}),m.jsxs("div",{className:"mt-7 flex flex-wrap items-center gap-3",children:[m.jsxs(vt,{className:"h-11 px-4",onClick:r,children:[t==="copied"?m.jsx(ua,{className:"size-4","aria-hidden":"true"}):m.jsx(Sz,{className:"size-4","aria-hidden":"true"}),t==="copied"?"链接已复制":"复制当前链接"]}),m.jsx("span",{className:"text-sm text-muted-foreground","aria-live":"polite",children:t==="copied"?"请切换到 Safari 后粘贴打开":t==="failed"?"复制失败,请从地址栏复制":"复制后在 Safari 中打开"})]})]})})]})}function JLe({children:e}){const t=L1e();return t.supported?e:m.jsx(QLe,{browserName:t.browserName})}function eDe(){return m.jsx(JLe,{children:m.jsx(tDe,{})})}function tDe(){return Fse(),m.jsx(Hde,{delayDuration:200,children:m.jsx(E7,{router:Kd})})}function nDe(e=window.history){e.scrollRestoration="manual"}nDe();jG();dpe();FW.createRoot(document.getElementById("root")).render(m.jsx(b.StrictMode,{children:m.jsx(eDe,{})}));export{SH as _,rm as a,iDe as g};