@dev-anywhere/relay 0.5.27 → 0.5.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -507,7 +507,7 @@ ${t}`:e:t}function j_(e,t,n){const r=Hg(t),i=Hg(n);return!r&&!i?null:{kind:"diff
507
507
 
508
508
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
509
509
 
510
- 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},ree="DialogDescriptionWarning",iee=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${OI(ree).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},s1=yI,see=_I,o1=SI,a1=xI,l1=EI,DI=kI,PI=RI,Dv=NI;function oee(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 aee(e){const[t,n]=b.useState(void 0);return Ci(()=>{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 lee=["top","right","bottom","left"],al=Math.min,ls=Math.max,Wg=Math.round,Bm=Math.floor,So=e=>({x:e,y:e}),cee={left:"right",right:"left",bottom:"top",top:"bottom"};function A0(e,t,n){return ls(e,al(t,n))}function ra(e,t){return typeof e=="function"?e(t):e}function ia(e){return e.split("-")[0]}function ad(e){return e.split("-")[1]}function c1(e){return e==="x"?"y":"x"}function u1(e){return e==="y"?"height":"width"}function _o(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function d1(e){return c1(_o(e))}function uee(e,t,n){n===void 0&&(n=!1);const r=ad(e),i=d1(e),s=u1(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(o=qg(o)),[o,qg(o)]}function dee(e){const t=qg(e);return[N0(e),t,N0(t)]}function N0(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const wN=["left","right"],SN=["right","left"],hee=["top","bottom"],fee=["bottom","top"];function pee(e,t,n){switch(e){case"top":case"bottom":return n?t?SN:wN:t?wN:SN;case"left":case"right":return t?hee:fee;default:return[]}}function mee(e,t,n,r){const i=ad(e);let s=pee(ia(e),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),t&&(s=s.concat(s.map(N0)))),s}function qg(e){const t=ia(e);return cee[t]+e.slice(t.length)}function gee(e){return{top:0,right:0,bottom:0,left:0,...e}}function LI(e){return typeof e!="number"?gee(e):{top:e,right:e,bottom:e,left:e}}function Vg(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 xN(e,t,n){let{reference:r,floating:i}=e;const s=_o(t),o=d1(t),l=u1(o),u=ia(t),d=s==="y",h=r.x+r.width/2-i.width/2,p=r.y+r.height/2-i.height/2,y=r[l]/2-i[l]/2;let v;switch(u){case"top":v={x:h,y:r.y-i.height};break;case"bottom":v={x:h,y:r.y+r.height};break;case"right":v={x:r.x+r.width,y:p};break;case"left":v={x:r.x-i.width,y:p};break;default:v={x:r.x,y:r.y}}switch(ad(t)){case"start":v[o]-=y*(n&&d?-1:1);break;case"end":v[o]+=y*(n&&d?-1:1);break}return v}async function vee(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:h="viewport",elementContext:p="floating",altBoundary:y=!1,padding:v=0}=ra(t,e),_=LI(v),x=l[y?p==="floating"?"reference":"floating":p],E=Vg(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(x)))==null||n?x:x.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:d,rootBoundary:h,strategy:u})),k=p==="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},I=Vg(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:k,offsetParent:R,strategy:u}):k);return{top:(E.top-I.top+_.top)/A.y,bottom:(I.bottom-E.bottom+_.bottom)/A.y,left:(E.left-I.left+_.left)/A.x,right:(I.right-E.right+_.right)/A.x}}const yee=50,bee=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,l=o.detectOverflow?o:{...o,detectOverflow:vee},u=await(o.isRTL==null?void 0:o.isRTL(t));let d=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:h,y:p}=xN(d,r,u),y=r,v=0;const _={};for(let w=0;w<s.length;w++){const x=s[w];if(!x)continue;const{name:E,fn:k}=x,{x:R,y:A,data:I,reset:T}=await k({x:h,y:p,initialPlacement:r,placement:y,strategy:i,middlewareData:_,rects:d,platform:l,elements:{reference:e,floating:t}});h=R??h,p=A??p,_[E]={..._[E],...I},T&&v<yee&&(v++,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:h,y:p}=xN(d,y,u)),w=-1)}return{x:h,y:p,placement:y,strategy:i,middlewareData:_}},_ee=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:h=0}=ra(e,t)||{};if(d==null)return{};const p=LI(h),y={x:n,y:r},v=d1(i),_=u1(v),w=await o.getDimensions(d),x=v==="y",E=x?"top":"left",k=x?"bottom":"right",R=x?"clientHeight":"clientWidth",A=s.reference[_]+s.reference[v]-y[v]-s.floating[_],I=y[v]-s.reference[v],T=await(o.getOffsetParent==null?void 0:o.getOffsetParent(d));let H=T?T[R]:0;(!H||!await(o.isElement==null?void 0:o.isElement(T)))&&(H=l.floating[R]||s.floating[_]);const D=A/2-I/2,W=H/2-w[_]/2-1,U=al(p[E],W),F=al(p[k],W),O=U,M=H-w[_]-F,B=H/2-w[_]/2+D,L=A0(O,B,M),N=!u.arrow&&ad(i)!=null&&B!==L&&s.reference[_]/2-(B<O?U:F)-w[_]/2<0,V=N?B<O?B-O:B-M:0;return{[v]:y[v]+V,data:{[v]:L,centerOffset:B-L-V,...N&&{alignmentOffset:V}},reset:N}}}),wee=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:h=!0,crossAxis:p=!0,fallbackPlacements:y,fallbackStrategy:v="bestFit",fallbackAxisSideDirection:_="none",flipAlignment:w=!0,...x}=ra(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const E=ia(i),k=_o(l),R=ia(l)===l,A=await(u.isRTL==null?void 0:u.isRTL(d.floating)),I=y||(R||!w?[qg(l)]:dee(l)),T=_!=="none";!y&&T&&I.push(...mee(l,w,_,A));const H=[l,...I],D=await u.detectOverflow(t,x),W=[];let U=((r=s.flip)==null?void 0:r.overflows)||[];if(h&&W.push(D[E]),p){const B=uee(i,o,A);W.push(D[B[0]],D[B[1]])}if(U=[...U,{placement:i,overflows:W}],!W.every(B=>B<=0)){var F,O;const B=(((F=s.flip)==null?void 0:F.index)||0)+1,L=H[B];if(L&&(!(p==="alignment"?k!==_o(L):!1)||U.every(Y=>_o(Y.placement)===k?Y.overflows[0]>0:!0)))return{data:{index:B,overflows:U},reset:{placement:L}};let N=(O=U.filter(V=>V.overflows[0]<=0).sort((V,Y)=>V.overflows[1]-Y.overflows[1])[0])==null?void 0:O.placement;if(!N)switch(v){case"bestFit":{var M;const V=(M=U.filter(Y=>{if(T){const $=_o(Y.placement);return $===k||$==="y"}return!0}).map(Y=>[Y.placement,Y.overflows.filter($=>$>0).reduce(($,P)=>$+P,0)]).sort((Y,$)=>Y[1]-$[1])[0])==null?void 0:M[0];V&&(N=V);break}case"initialPlacement":N=l;break}if(i!==N)return{reset:{placement:N}}}return{}}}};function EN(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function CN(e){return lee.some(t=>e[t]>=0)}const See=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...s}=ra(e,t);switch(i){case"referenceHidden":{const o=await r.detectOverflow(t,{...s,elementContext:"reference"}),l=EN(o,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:CN(l)}}}case"escaped":{const o=await r.detectOverflow(t,{...s,altBoundary:!0}),l=EN(o,n.floating);return{data:{escapedOffsets:l,escaped:CN(l)}}}default:return{}}}}},II=new Set(["left","top"]);async function xee(e,t){const{placement:n,platform:r,elements:i}=e,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=ia(n),l=ad(n),u=_o(n)==="y",d=II.has(o)?-1:1,h=s&&u?-1:1,p=ra(t,e);let{mainAxis:y,crossAxis:v,alignmentAxis:_}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return l&&typeof _=="number"&&(v=l==="end"?_*-1:_),u?{x:v*h,y:y*d}:{x:y*d,y:v*h}}const Eee=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 xee(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}}}}},Cee=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:E=>{let{x:k,y:R}=E;return{x:k,y:R}}},...d}=ra(e,t),h={x:n,y:r},p=await s.detectOverflow(t,d),y=_o(ia(i)),v=c1(y);let _=h[v],w=h[y];if(o){const E=v==="y"?"top":"left",k=v==="y"?"bottom":"right",R=_+p[E],A=_-p[k];_=A0(R,_,A)}if(l){const E=y==="y"?"top":"left",k=y==="y"?"bottom":"right",R=w+p[E],A=w-p[k];w=A0(R,w,A)}const x=u.fn({...t,[v]:_,[y]:w});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[v]:o,[y]:l}}}}}},kee=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}=ra(e,t),h={x:n,y:r},p=_o(i),y=c1(p);let v=h[y],_=h[p];const w=ra(l,t),x=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]+x.mainAxis,I=s.reference[y]+s.reference[R]-x.mainAxis;v<A?v=A:v>I&&(v=I)}if(d){var E,k;const R=y==="y"?"width":"height",A=II.has(ia(i)),I=s.reference[p]-s.floating[R]+(A&&((E=o.offset)==null?void 0:E[p])||0)+(A?0:x.crossAxis),T=s.reference[p]+s.reference[R]+(A?0:((k=o.offset)==null?void 0:k[p])||0)-(A?x.crossAxis:0);_<I?_=I:_>T&&(_=T)}return{[y]:v,[p]:_}}}},Tee=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}=ra(e,t),h=await o.detectOverflow(t,d),p=ia(i),y=ad(i),v=_o(i)==="y",{width:_,height:w}=s.floating;let x,E;p==="top"||p==="bottom"?(x=p,E=y===(await(o.isRTL==null?void 0:o.isRTL(l.floating))?"start":"end")?"left":"right"):(E=p,x=y==="end"?"top":"bottom");const k=w-h.top-h.bottom,R=_-h.left-h.right,A=al(w-h[x],k),I=al(_-h[E],R),T=!t.middlewareData.shift;let H=A,D=I;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(D=R),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(H=k),T&&!y){const U=ls(h.left,0),F=ls(h.right,0),O=ls(h.top,0),M=ls(h.bottom,0);v?D=_-2*(U!==0||F!==0?U+F:ls(h.left,h.right)):H=w-2*(O!==0||M!==0?O+M:ls(h.top,h.bottom))}await u({...t,availableWidth:D,availableHeight:H});const W=await o.getDimensions(l.floating);return _!==W.width||w!==W.height?{reset:{rects:!0}}:{}}}};function Pv(){return typeof window<"u"}function ld(e){return zI(e)?(e.nodeName||"").toLowerCase():"#document"}function cs(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ro(e){var t;return(t=(zI(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function zI(e){return Pv()?e instanceof Node||e instanceof cs(e).Node:!1}function Gs(e){return Pv()?e instanceof Element||e instanceof cs(e).Element:!1}function oa(e){return Pv()?e instanceof HTMLElement||e instanceof cs(e).HTMLElement:!1}function kN(e){return!Pv()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof cs(e).ShadowRoot}function Bf(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=Xs(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function Ree(e){return/^(table|td|th)$/.test(ld(e))}function Lv(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Aee=/transform|translate|scale|rotate|perspective|filter/,Nee=/paint|layout|strict|content/,Hl=e=>!!e&&e!=="none";let Y_;function h1(e){const t=Gs(e)?Xs(e):e;return Hl(t.transform)||Hl(t.translate)||Hl(t.scale)||Hl(t.rotate)||Hl(t.perspective)||!f1()&&(Hl(t.backdropFilter)||Hl(t.filter))||Aee.test(t.willChange||"")||Nee.test(t.contain||"")}function Mee(e){let t=ll(e);for(;oa(t)&&!Vu(t);){if(h1(t))return t;if(Lv(t))return null;t=ll(t)}return null}function f1(){return Y_==null&&(Y_=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Y_}function Vu(e){return/^(html|body|#document)$/.test(ld(e))}function Xs(e){return cs(e).getComputedStyle(e)}function Iv(e){return Gs(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ll(e){if(ld(e)==="html")return e;const t=e.assignedSlot||e.parentNode||kN(e)&&e.host||Ro(e);return kN(t)?t.host:t}function BI(e){const t=ll(e);return Vu(t)?e.ownerDocument?e.ownerDocument.body:e.body:oa(t)&&Bf(t)?t:BI(t)}function mf(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=BI(e),s=i===((r=e.ownerDocument)==null?void 0:r.body),o=cs(i);if(s){const l=M0(o);return t.concat(o,o.visualViewport||[],Bf(i)?i:[],l&&n?mf(l):[])}else return t.concat(i,mf(i,[],n))}function M0(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function jI(e){const t=Xs(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=oa(e),s=i?e.offsetWidth:n,o=i?e.offsetHeight:r,l=Wg(n)!==s||Wg(r)!==o;return l&&(n=s,r=o),{width:n,height:r,$:l}}function p1(e){return Gs(e)?e:e.contextElement}function ju(e){const t=p1(e);if(!oa(t))return So(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:s}=jI(t);let o=(s?Wg(n.width):n.width)/r,l=(s?Wg(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const Oee=So(0);function FI(e){const t=cs(e);return!f1()||!t.visualViewport?Oee:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Dee(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==cs(e)?!1:t}function ac(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),s=p1(e);let o=So(1);t&&(r?Gs(r)&&(o=ju(r)):o=ju(e));const l=Dee(s,n,r)?FI(s):So(0);let u=(i.left+l.x)/o.x,d=(i.top+l.y)/o.y,h=i.width/o.x,p=i.height/o.y;if(s){const y=cs(s),v=r&&Gs(r)?cs(r):r;let _=y,w=M0(_);for(;w&&r&&v!==_;){const x=ju(w),E=w.getBoundingClientRect(),k=Xs(w),R=E.left+(w.clientLeft+parseFloat(k.paddingLeft))*x.x,A=E.top+(w.clientTop+parseFloat(k.paddingTop))*x.y;u*=x.x,d*=x.y,h*=x.x,p*=x.y,u+=R,d+=A,_=cs(w),w=M0(_)}}return Vg({width:h,height:p,x:u,y:d})}function zv(e,t){const n=Iv(e).scrollLeft;return t?t.left+n:ac(Ro(e)).left+n}function $I(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-zv(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function Pee(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const s=i==="fixed",o=Ro(r),l=t?Lv(t.floating):!1;if(r===o||l&&s)return n;let u={scrollLeft:0,scrollTop:0},d=So(1);const h=So(0),p=oa(r);if((p||!p&&!s)&&((ld(r)!=="body"||Bf(o))&&(u=Iv(r)),p)){const v=ac(r);d=ju(r),h.x=v.x+r.clientLeft,h.y=v.y+r.clientTop}const y=o&&!p&&!s?$I(o,u):So(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-u.scrollLeft*d.x+h.x+y.x,y:n.y*d.y-u.scrollTop*d.y+h.y+y.y}}function Lee(e){return Array.from(e.getClientRects())}function Iee(e){const t=Ro(e),n=Iv(e),r=e.ownerDocument.body,i=ls(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=ls(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+zv(e);const l=-n.scrollTop;return Xs(r).direction==="rtl"&&(o+=ls(t.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:l}}const TN=25;function zee(e,t){const n=cs(e),r=Ro(e),i=n.visualViewport;let s=r.clientWidth,o=r.clientHeight,l=0,u=0;if(i){s=i.width,o=i.height;const h=f1();(!h||h&&t==="fixed")&&(l=i.offsetLeft,u=i.offsetTop)}const d=zv(r);if(d<=0){const h=r.ownerDocument,p=h.body,y=getComputedStyle(p),v=h.compatMode==="CSS1Compat"&&parseFloat(y.marginLeft)+parseFloat(y.marginRight)||0,_=Math.abs(r.clientWidth-p.clientWidth-v);_<=TN&&(s-=_)}else d<=TN&&(s+=d);return{width:s,height:o,x:l,y:u}}function Bee(e,t){const n=ac(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=oa(e)?ju(e):So(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 RN(e,t,n){let r;if(t==="viewport")r=zee(e,n);else if(t==="document")r=Iee(Ro(e));else if(Gs(t))r=Bee(t,n);else{const i=FI(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Vg(r)}function HI(e,t){const n=ll(e);return n===t||!Gs(n)||Vu(n)?!1:Xs(n).position==="fixed"||HI(n,t)}function jee(e,t){const n=t.get(e);if(n)return n;let r=mf(e,[],!1).filter(l=>Gs(l)&&ld(l)!=="body"),i=null;const s=Xs(e).position==="fixed";let o=s?ll(e):e;for(;Gs(o)&&!Vu(o);){const l=Xs(o),u=h1(o);!u&&l.position==="fixed"&&(i=null),(s?!u&&!i:!u&&l.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||Bf(o)&&!u&&HI(e,o))?r=r.filter(h=>h!==o):i=l,o=ll(o)}return t.set(e,r),r}function Fee(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[...n==="clippingAncestors"?Lv(t)?[]:jee(t,this._c):[].concat(n),r],l=RN(t,o[0],i);let u=l.top,d=l.right,h=l.bottom,p=l.left;for(let y=1;y<o.length;y++){const v=RN(t,o[y],i);u=ls(v.top,u),d=al(v.right,d),h=al(v.bottom,h),p=ls(v.left,p)}return{width:d-p,height:h-u,x:p,y:u}}function $ee(e){const{width:t,height:n}=jI(e);return{width:t,height:n}}function Hee(e,t,n){const r=oa(t),i=Ro(t),s=n==="fixed",o=ac(e,!0,s,t);let l={scrollLeft:0,scrollTop:0};const u=So(0);function d(){u.x=zv(i)}if(r||!r&&!s)if((ld(t)!=="body"||Bf(i))&&(l=Iv(t)),r){const v=ac(t,!0,s,t);u.x=v.x+t.clientLeft,u.y=v.y+t.clientTop}else i&&d();s&&!r&&i&&d();const h=i&&!r&&!s?$I(i,l):So(0),p=o.left+l.scrollLeft-u.x-h.x,y=o.top+l.scrollTop-u.y-h.y;return{x:p,y,width:o.width,height:o.height}}function K_(e){return Xs(e).position==="static"}function AN(e,t){if(!oa(e)||Xs(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ro(e)===n&&(n=n.ownerDocument.body),n}function UI(e,t){const n=cs(e);if(Lv(e))return n;if(!oa(e)){let i=ll(e);for(;i&&!Vu(i);){if(Gs(i)&&!K_(i))return i;i=ll(i)}return n}let r=AN(e,t);for(;r&&Ree(r)&&K_(r);)r=AN(r,t);return r&&Vu(r)&&K_(r)&&!h1(r)?n:r||Mee(e)||n}const Uee=async function(e){const t=this.getOffsetParent||UI,n=this.getDimensions,r=await n(e.floating);return{reference:Hee(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Wee(e){return Xs(e).direction==="rtl"}const qee={convertOffsetParentRelativeRectToViewportRelativeRect:Pee,getDocumentElement:Ro,getClippingRect:Fee,getOffsetParent:UI,getElementRects:Uee,getClientRects:Lee,getDimensions:$ee,getScale:ju,isElement:Gs,isRTL:Wee};function WI(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Vee(e,t){let n=null,r;const i=Ro(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:h,top:p,width:y,height:v}=d;if(l||t(),!y||!v)return;const _=Bm(p),w=Bm(i.clientWidth-(h+y)),x=Bm(i.clientHeight-(p+v)),E=Bm(h),R={rootMargin:-_+"px "+-w+"px "+-x+"px "+-E+"px",threshold:ls(0,al(1,u))||1};let A=!0;function I(T){const H=T[0].intersectionRatio;if(H!==u){if(!A)return o();H?o(!1,H):r=setTimeout(()=>{o(!1,1e-7)},1e3)}H===1&&!WI(d,e.getBoundingClientRect())&&o(),A=!1}try{n=new IntersectionObserver(I,{...R,root:i.ownerDocument})}catch{n=new IntersectionObserver(I,R)}n.observe(e)}return o(!0),s}function Yee(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=p1(e),h=i||s?[...d?mf(d):[],...t?mf(t):[]]:[];h.forEach(E=>{i&&E.addEventListener("scroll",n,{passive:!0}),s&&E.addEventListener("resize",n)});const p=d&&l?Vee(d,n):null;let y=-1,v=null;o&&(v=new ResizeObserver(E=>{let[k]=E;k&&k.target===d&&v&&t&&(v.unobserve(t),cancelAnimationFrame(y),y=requestAnimationFrame(()=>{var R;(R=v)==null||R.observe(t)})),n()}),d&&!u&&v.observe(d),t&&v.observe(t));let _,w=u?ac(e):null;u&&x();function x(){const E=ac(e);w&&!WI(w,E)&&n(),w=E,_=requestAnimationFrame(x)}return n(),()=>{var E;h.forEach(k=>{i&&k.removeEventListener("scroll",n),s&&k.removeEventListener("resize",n)}),p==null||p(),(E=v)==null||E.disconnect(),v=null,u&&cancelAnimationFrame(_)}}const Kee=Eee,Gee=Cee,Xee=wee,Zee=Tee,Qee=See,NN=_ee,Jee=kee,ete=(e,t,n)=>{const r=new Map,i={platform:qee,...n},s={...i.platform,_c:r};return bee(e,t,{...i,platform:s})};var tte=typeof document<"u",nte=function(){},bg=tte?b.useLayoutEffect:nte;function Yg(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(!Yg(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)&&!Yg(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function qI(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function MN(e,t){const n=qI(e);return Math.round(t*n)/n}function G_(e){const t=b.useRef(e);return bg(()=>{t.current=e}),t}function rte(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,[h,p]=b.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[y,v]=b.useState(r);Yg(y,r)||v(r);const[_,w]=b.useState(null),[x,E]=b.useState(null),k=b.useCallback(Y=>{Y!==T.current&&(T.current=Y,w(Y))},[]),R=b.useCallback(Y=>{Y!==H.current&&(H.current=Y,E(Y))},[]),A=s||_,I=o||x,T=b.useRef(null),H=b.useRef(null),D=b.useRef(h),W=u!=null,U=G_(u),F=G_(i),O=G_(d),M=b.useCallback(()=>{if(!T.current||!H.current)return;const Y={placement:t,strategy:n,middleware:y};F.current&&(Y.platform=F.current),ete(T.current,H.current,Y).then($=>{const P={...$,isPositioned:O.current!==!1};B.current&&!Yg(D.current,P)&&(D.current=P,id.flushSync(()=>{p(P)}))})},[y,t,n,F,O]);bg(()=>{d===!1&&D.current.isPositioned&&(D.current.isPositioned=!1,p(Y=>({...Y,isPositioned:!1})))},[d]);const B=b.useRef(!1);bg(()=>(B.current=!0,()=>{B.current=!1}),[]),bg(()=>{if(A&&(T.current=A),I&&(H.current=I),A&&I){if(U.current)return U.current(A,I,M);M()}},[A,I,M,U,W]);const L=b.useMemo(()=>({reference:T,floating:H,setReference:k,setFloating:R}),[k,R]),N=b.useMemo(()=>({reference:A,floating:I}),[A,I]),V=b.useMemo(()=>{const Y={position:n,left:0,top:0};if(!N.floating)return Y;const $=MN(N.floating,h.x),P=MN(N.floating,h.y);return l?{...Y,transform:"translate("+$+"px, "+P+"px)",...qI(N.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:$,top:P}},[n,l,N.floating,h.x,h.y]);return b.useMemo(()=>({...h,update:M,refs:L,elements:N,floatingStyles:V}),[h,M,L,N,V])}const ite=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?NN({element:r.current,padding:i}).fn(n):{}:r?NN({element:r,padding:i}).fn(n):{}}}},ste=(e,t)=>{const n=Kee(e);return{name:n.name,fn:n.fn,options:[e,t]}},ote=(e,t)=>{const n=Gee(e);return{name:n.name,fn:n.fn,options:[e,t]}},ate=(e,t)=>({fn:Jee(e).fn,options:[e,t]}),lte=(e,t)=>{const n=Xee(e);return{name:n.name,fn:n.fn,options:[e,t]}},cte=(e,t)=>{const n=Zee(e);return{name:n.name,fn:n.fn,options:[e,t]}},ute=(e,t)=>{const n=Qee(e);return{name:n.name,fn:n.fn,options:[e,t]}},dte=(e,t)=>{const n=ite(e);return{name:n.name,fn:n.fn,options:[e,t]}};var hte="Arrow",VI=b.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...s}=e;return g.jsx(Jt.svg,{...s,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:g.jsx("polygon",{points:"0,0 30,0 15,10"})})});VI.displayName=hte;var fte=VI,m1="Popper",[YI,yl]=sa(m1),[pte,KI]=YI(m1),GI=e=>{const{__scopePopper:t,children:n}=e,[r,i]=b.useState(null);return g.jsx(pte,{scope:t,anchor:r,onAnchorChange:i,children:n})};GI.displayName=m1;var XI="PopperAnchor",ZI=b.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...i}=e,s=KI(XI,n),o=b.useRef(null),l=zn(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:g.jsx(Jt.div,{...i,ref:l})});ZI.displayName=XI;var g1="PopperContent",[mte,gte]=YI(g1),QI=b.forwardRef((e,t)=>{var Q,me,ve,Ce,Me,Ve;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:s="center",alignOffset:o=0,arrowPadding:l=0,avoidCollisions:u=!0,collisionBoundary:d=[],collisionPadding:h=0,sticky:p="partial",hideWhenDetached:y=!1,updatePositionStrategy:v="optimized",onPlaced:_,...w}=e,x=KI(g1,n),[E,k]=b.useState(null),R=zn(t,Qe=>k(Qe)),[A,I]=b.useState(null),T=aee(A),H=(T==null?void 0:T.width)??0,D=(T==null?void 0:T.height)??0,W=r+(s!=="center"?"-"+s:""),U=typeof h=="number"?h:{top:0,right:0,bottom:0,left:0,...h},F=Array.isArray(d)?d:[d],O=F.length>0,M={padding:U,boundary:F.filter(yte),altBoundary:O},{refs:B,floatingStyles:L,placement:N,isPositioned:V,middlewareData:Y}=rte({strategy:"fixed",placement:W,whileElementsMounted:(...Qe)=>Yee(...Qe,{animationFrame:v==="always"}),elements:{reference:x.anchor},middleware:[ste({mainAxis:i+D,alignmentAxis:o}),u&&ote({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?ate():void 0,...M}),u&&lte({...M}),cte({...M,apply:({elements:Qe,rects:ct,availableWidth:Ot,availableHeight:he})=>{const{width:Ke,height:Rt}=ct.reference,ye=Qe.floating.style;ye.setProperty("--radix-popper-available-width",`${Ot}px`),ye.setProperty("--radix-popper-available-height",`${he}px`),ye.setProperty("--radix-popper-anchor-width",`${Ke}px`),ye.setProperty("--radix-popper-anchor-height",`${Rt}px`)}}),A&&dte({element:A,padding:l}),bte({arrowWidth:H,arrowHeight:D}),y&&ute({strategy:"referenceHidden",...M})]}),[$,P]=tz(N),q=Co(_);Ci(()=>{V&&(q==null||q())},[V,q]);const K=(Q=Y.arrow)==null?void 0:Q.x,z=(me=Y.arrow)==null?void 0:me.y,X=((ve=Y.arrow)==null?void 0:ve.centerOffset)!==0,[ee,te]=b.useState();return Ci(()=>{E&&te(window.getComputedStyle(E).zIndex)},[E]),g.jsx("div",{ref:B.setFloating,"data-radix-popper-content-wrapper":"",style:{...L,transform:V?L.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ee,"--radix-popper-transform-origin":[(Ce=Y.transformOrigin)==null?void 0:Ce.x,(Me=Y.transformOrigin)==null?void 0:Me.y].join(" "),...((Ve=Y.hide)==null?void 0:Ve.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:g.jsx(mte,{scope:n,placedSide:$,onArrowChange:I,arrowX:K,arrowY:z,shouldHideArrow:X,children:g.jsx(Jt.div,{"data-side":$,"data-align":P,...w,ref:R,style:{...w.style,animation:V?void 0:"none"}})})})});QI.displayName=g1;var JI="PopperArrow",vte={top:"bottom",right:"left",bottom:"top",left:"right"},ez=b.forwardRef(function(t,n){const{__scopePopper:r,...i}=t,s=gte(JI,r),o=vte[s.placedSide];return g.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:g.jsx(fte,{...i,ref:n,style:{...i.style,display:"block"}})})});ez.displayName=JI;function yte(e){return e!==null}var bte=e=>({name:"transformOrigin",options:e,fn(t){var x,E,k;const{placement:n,rects:r,middlewareData:i}=t,o=((x=i.arrow)==null?void 0:x.centerOffset)!==0,l=o?0:e.arrowWidth,u=o?0:e.arrowHeight,[d,h]=tz(n),p={start:"0%",center:"50%",end:"100%"}[h],y=(((E=i.arrow)==null?void 0:E.x)??0)+l/2,v=(((k=i.arrow)==null?void 0:k.y)??0)+u/2;let _="",w="";return d==="bottom"?(_=o?p:`${y}px`,w=`${-u}px`):d==="top"?(_=o?p:`${y}px`,w=`${r.floating.height+u}px`):d==="right"?(_=`${-u}px`,w=o?p:`${v}px`):d==="left"&&(_=`${r.floating.width+u}px`,w=o?p:`${v}px`),{data:{x:_,y:w}}}});function tz(e){const[t,n="center"]=e.split("-");return[t,n]}var Bv=GI,jf=ZI,jv=QI,Fv=ez,X_="rovingFocusGroup.onEntryFocus",_te={bubbles:!1,cancelable:!0},Ff="RovingFocusGroup",[O0,nz,wte]=e1(Ff),[Ste,rz]=sa(Ff,[wte]),[xte,Ete]=Ste(Ff),iz=b.forwardRef((e,t)=>g.jsx(O0.Provider,{scope:e.__scopeRovingFocusGroup,children:g.jsx(O0.Slot,{scope:e.__scopeRovingFocusGroup,children:g.jsx(Cte,{...e,ref:t})})}));iz.displayName=Ff;var Cte=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:s,currentTabStopId:o,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:u,onEntryFocus:d,preventScrollOnEntryFocus:h=!1,...p}=e,y=b.useRef(null),v=zn(t,y),_=t1(s),[w,x]=sc({prop:o,defaultProp:l??null,onChange:u,caller:Ff}),[E,k]=b.useState(!1),R=Co(d),A=nz(n),I=b.useRef(!1),[T,H]=b.useState(0);return b.useEffect(()=>{const D=y.current;if(D)return D.addEventListener(X_,R),()=>D.removeEventListener(X_,R)},[R]),g.jsx(xte,{scope:n,orientation:r,dir:_,loop:i,currentTabStopId:w,onItemFocus:b.useCallback(D=>x(D),[x]),onItemShiftTab:b.useCallback(()=>k(!0),[]),onFocusableItemAdd:b.useCallback(()=>H(D=>D+1),[]),onFocusableItemRemove:b.useCallback(()=>H(D=>D-1),[]),children:g.jsx(Jt.div,{tabIndex:E||T===0?-1:0,"data-orientation":r,...p,ref:v,style:{outline:"none",...e.style},onMouseDown:bt(e.onMouseDown,()=>{I.current=!0}),onFocus:bt(e.onFocus,D=>{const W=!I.current;if(D.target===D.currentTarget&&W&&!E){const U=new CustomEvent(X_,_te);if(D.currentTarget.dispatchEvent(U),!U.defaultPrevented){const F=A().filter(N=>N.focusable),O=F.find(N=>N.active),M=F.find(N=>N.id===w),L=[O,M,...F].filter(Boolean).map(N=>N.ref.current);az(L,h)}}I.current=!1}),onBlur:bt(e.onBlur,()=>k(!1))})})}),sz="RovingFocusGroupItem",oz=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:s,children:o,...l}=e,u=vi(),d=s||u,h=Ete(sz,n),p=h.currentTabStopId===d,y=nz(n),{onFocusableItemAdd:v,onFocusableItemRemove:_,currentTabStopId:w}=h;return b.useEffect(()=>{if(r)return v(),()=>_()},[r,v,_]),g.jsx(O0.ItemSlot,{scope:n,id:d,focusable:r,active:i,children:g.jsx(Jt.span,{tabIndex:p?0:-1,"data-orientation":h.orientation,...l,ref:t,onMouseDown:bt(e.onMouseDown,x=>{r?h.onItemFocus(d):x.preventDefault()}),onFocus:bt(e.onFocus,()=>h.onItemFocus(d)),onKeyDown:bt(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){h.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const E=Rte(x,h.orientation,h.dir);if(E!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let R=y().filter(A=>A.focusable).map(A=>A.ref.current);if(E==="last")R.reverse();else if(E==="prev"||E==="next"){E==="prev"&&R.reverse();const A=R.indexOf(x.currentTarget);R=h.loop?Ate(R,A+1):R.slice(A+1)}setTimeout(()=>az(R))}}),children:typeof o=="function"?o({isCurrentTabStop:p,hasTabStop:w!=null}):o})})});oz.displayName=sz;var kte={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Tte(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Rte(e,t,n){const r=Tte(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return kte[r]}function az(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Ate(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Nte=iz,Mte=oz,D0=["Enter"," "],Ote=["ArrowDown","PageUp","Home"],lz=["ArrowUp","PageDown","End"],Dte=[...Ote,...lz],Pte={ltr:[...D0,"ArrowRight"],rtl:[...D0,"ArrowLeft"]},Lte={ltr:["ArrowLeft"],rtl:["ArrowRight"]},$f="Menu",[gf,Ite,zte]=e1($f),[_c,cz]=sa($f,[zte,yl,rz]),$v=yl(),uz=rz(),[Bte,wc]=_c($f),[jte,Hf]=_c($f),dz=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,l=$v(t),[u,d]=b.useState(null),h=b.useRef(!1),p=Co(s),y=t1(i);return b.useEffect(()=>{const v=()=>{h.current=!0,document.addEventListener("pointerdown",_,{capture:!0,once:!0}),document.addEventListener("pointermove",_,{capture:!0,once:!0})},_=()=>h.current=!1;return document.addEventListener("keydown",v,{capture:!0}),()=>{document.removeEventListener("keydown",v,{capture:!0}),document.removeEventListener("pointerdown",_,{capture:!0}),document.removeEventListener("pointermove",_,{capture:!0})}},[]),g.jsx(Bv,{...l,children:g.jsx(Bte,{scope:t,open:n,onOpenChange:p,content:u,onContentChange:d,children:g.jsx(jte,{scope:t,onClose:b.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:h,dir:y,modal:o,children:r})})})};dz.displayName=$f;var Fte="MenuAnchor",v1=b.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=$v(n);return g.jsx(jf,{...i,...r,ref:t})});v1.displayName=Fte;var y1="MenuPortal",[$te,hz]=_c(y1,{forceMount:void 0}),fz=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=wc(y1,t);return g.jsx($te,{scope:t,forceMount:n,children:g.jsx(Ls,{present:n||s.open,children:g.jsx(od,{asChild:!0,container:i,children:r})})})};fz.displayName=y1;var Ns="MenuContent",[Hte,b1]=_c(Ns),pz=b.forwardRef((e,t)=>{const n=hz(Ns,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=wc(Ns,e.__scopeMenu),o=Hf(Ns,e.__scopeMenu);return g.jsx(gf.Provider,{scope:e.__scopeMenu,children:g.jsx(Ls,{present:r||s.open,children:g.jsx(gf.Slot,{scope:e.__scopeMenu,children:o.modal?g.jsx(Ute,{...i,ref:t}):g.jsx(Wte,{...i,ref:t})})})})}),Ute=b.forwardRef((e,t)=>{const n=wc(Ns,e.__scopeMenu),r=b.useRef(null),i=zn(t,r);return b.useEffect(()=>{const s=r.current;if(s)return Mv(s)},[]),g.jsx(_1,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:bt(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Wte=b.forwardRef((e,t)=>{const n=wc(Ns,e.__scopeMenu);return g.jsx(_1,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),qte=ol("MenuContent.ScrollLock"),_1=b.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEntryFocus:u,onEscapeKeyDown:d,onPointerDownOutside:h,onFocusOutside:p,onInteractOutside:y,onDismiss:v,disableOutsideScroll:_,...w}=e,x=wc(Ns,n),E=Hf(Ns,n),k=$v(n),R=uz(n),A=Ite(n),[I,T]=b.useState(null),H=b.useRef(null),D=zn(t,H,x.onContentChange),W=b.useRef(0),U=b.useRef(""),F=b.useRef(0),O=b.useRef(null),M=b.useRef("right"),B=b.useRef(0),L=_?zf:b.Fragment,N=_?{as:qte,allowPinchZoom:!0}:void 0,V=$=>{var Q,me;const P=U.current+$,q=A().filter(ve=>!ve.disabled),K=document.activeElement,z=(Q=q.find(ve=>ve.ref.current===K))==null?void 0:Q.textValue,X=q.map(ve=>ve.textValue),ee=rne(X,P,z),te=(me=q.find(ve=>ve.textValue===ee))==null?void 0:me.ref.current;(function ve(Ce){U.current=Ce,window.clearTimeout(W.current),Ce!==""&&(W.current=window.setTimeout(()=>ve(""),1e3))})(P),te&&setTimeout(()=>te.focus())};b.useEffect(()=>()=>window.clearTimeout(W.current),[]),Av();const Y=b.useCallback($=>{var q,K;return M.current===((q=O.current)==null?void 0:q.side)&&sne($,(K=O.current)==null?void 0:K.area)},[]);return g.jsx(Hte,{scope:n,searchRef:U,onItemEnter:b.useCallback($=>{Y($)&&$.preventDefault()},[Y]),onItemLeave:b.useCallback($=>{var P;Y($)||((P=H.current)==null||P.focus(),T(null))},[Y]),onTriggerLeave:b.useCallback($=>{Y($)&&$.preventDefault()},[Y]),pointerGraceTimerRef:F,onPointerGraceIntentChange:b.useCallback($=>{O.current=$},[]),children:g.jsx(L,{...N,children:g.jsx(If,{asChild:!0,trapped:i,onMountAutoFocus:bt(s,$=>{var P;$.preventDefault(),(P=H.current)==null||P.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:g.jsx(sd,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:d,onPointerDownOutside:h,onFocusOutside:p,onInteractOutside:y,onDismiss:v,children:g.jsx(Nte,{asChild:!0,...R,dir:E.dir,orientation:"vertical",loop:r,currentTabStopId:I,onCurrentTabStopIdChange:T,onEntryFocus:bt(u,$=>{E.isUsingKeyboardRef.current||$.preventDefault()}),preventScrollOnEntryFocus:!0,children:g.jsx(jv,{role:"menu","aria-orientation":"vertical","data-state":Nz(x.open),"data-radix-menu-content":"",dir:E.dir,...k,...w,ref:D,style:{outline:"none",...w.style},onKeyDown:bt(w.onKeyDown,$=>{const q=$.target.closest("[data-radix-menu-content]")===$.currentTarget,K=$.ctrlKey||$.altKey||$.metaKey,z=$.key.length===1;q&&($.key==="Tab"&&$.preventDefault(),!K&&z&&V($.key));const X=H.current;if($.target!==X||!Dte.includes($.key))return;$.preventDefault();const te=A().filter(Q=>!Q.disabled).map(Q=>Q.ref.current);lz.includes($.key)&&te.reverse(),tne(te)}),onBlur:bt(e.onBlur,$=>{$.currentTarget.contains($.target)||(window.clearTimeout(W.current),U.current="")}),onPointerMove:bt(e.onPointerMove,vf($=>{const P=$.target,q=B.current!==$.clientX;if($.currentTarget.contains(P)&&q){const K=$.clientX>B.current?"right":"left";M.current=K,B.current=$.clientX}}))})})})})})})});pz.displayName=Ns;var Vte="MenuGroup",w1=b.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return g.jsx(Jt.div,{role:"group",...r,ref:t})});w1.displayName=Vte;var Yte="MenuLabel",mz=b.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return g.jsx(Jt.div,{...r,ref:t})});mz.displayName=Yte;var Kg="MenuItem",ON="menu.itemSelect",Hv=b.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=b.useRef(null),o=Hf(Kg,e.__scopeMenu),l=b1(Kg,e.__scopeMenu),u=zn(t,s),d=b.useRef(!1),h=()=>{const p=s.current;if(!n&&p){const y=new CustomEvent(ON,{bubbles:!0,cancelable:!0});p.addEventListener(ON,v=>r==null?void 0:r(v),{once:!0}),nI(p,y),y.defaultPrevented?d.current=!1:o.onClose()}};return g.jsx(gz,{...i,ref:u,disabled:n,onClick:bt(e.onClick,h),onPointerDown:p=>{var y;(y=e.onPointerDown)==null||y.call(e,p),d.current=!0},onPointerUp:bt(e.onPointerUp,p=>{var y;d.current||(y=p.currentTarget)==null||y.click()}),onKeyDown:bt(e.onKeyDown,p=>{const y=l.searchRef.current!=="";n||y&&p.key===" "||D0.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});Hv.displayName=Kg;var gz=b.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=b1(Kg,n),l=uz(n),u=b.useRef(null),d=zn(t,u),[h,p]=b.useState(!1),[y,v]=b.useState("");return b.useEffect(()=>{const _=u.current;_&&v((_.textContent??"").trim())},[s.children]),g.jsx(gf.ItemSlot,{scope:n,disabled:r,textValue:i??y,children:g.jsx(Mte,{asChild:!0,...l,focusable:!r,children:g.jsx(Jt.div,{role:"menuitem","data-highlighted":h?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:d,onPointerMove:bt(e.onPointerMove,vf(_=>{r?o.onItemLeave(_):(o.onItemEnter(_),_.defaultPrevented||_.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:bt(e.onPointerLeave,vf(_=>o.onItemLeave(_))),onFocus:bt(e.onFocus,()=>p(!0)),onBlur:bt(e.onBlur,()=>p(!1))})})})}),Kte="MenuCheckboxItem",vz=b.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return g.jsx(Sz,{scope:e.__scopeMenu,checked:n,children:g.jsx(Hv,{role:"menuitemcheckbox","aria-checked":Gg(n)?"mixed":n,...i,ref:t,"data-state":x1(n),onSelect:bt(i.onSelect,()=>r==null?void 0:r(Gg(n)?!0:!n),{checkForDefaultPrevented:!1})})})});vz.displayName=Kte;var yz="MenuRadioGroup",[Gte,Xte]=_c(yz,{value:void 0,onValueChange:()=>{}}),bz=b.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=Co(r);return g.jsx(Gte,{scope:e.__scopeMenu,value:n,onValueChange:s,children:g.jsx(w1,{...i,ref:t})})});bz.displayName=yz;var _z="MenuRadioItem",wz=b.forwardRef((e,t)=>{const{value:n,...r}=e,i=Xte(_z,e.__scopeMenu),s=n===i.value;return g.jsx(Sz,{scope:e.__scopeMenu,checked:s,children:g.jsx(Hv,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":x1(s),onSelect:bt(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});wz.displayName=_z;var S1="MenuItemIndicator",[Sz,Zte]=_c(S1,{checked:!1}),xz=b.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=Zte(S1,n);return g.jsx(Ls,{present:r||Gg(s.checked)||s.checked===!0,children:g.jsx(Jt.span,{...i,ref:t,"data-state":x1(s.checked)})})});xz.displayName=S1;var Qte="MenuSeparator",Ez=b.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return g.jsx(Jt.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Ez.displayName=Qte;var Jte="MenuArrow",Cz=b.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=$v(n);return g.jsx(Fv,{...i,...r,ref:t})});Cz.displayName=Jte;var ene="MenuSub",[mRe,kz]=_c(ene),Ih="MenuSubTrigger",Tz=b.forwardRef((e,t)=>{const n=wc(Ih,e.__scopeMenu),r=Hf(Ih,e.__scopeMenu),i=kz(Ih,e.__scopeMenu),s=b1(Ih,e.__scopeMenu),o=b.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:u}=s,d={__scopeMenu:e.__scopeMenu},h=b.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return b.useEffect(()=>h,[h]),b.useEffect(()=>{const p=l.current;return()=>{window.clearTimeout(p),u(null)}},[l,u]),g.jsx(v1,{asChild:!0,...d,children:g.jsx(gz,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":Nz(n.open),...e,ref:na(t,i.onTriggerChange),onClick:p=>{var y;(y=e.onClick)==null||y.call(e,p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:bt(e.onPointerMove,vf(p=>{s.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(s.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),h()},100))})),onPointerLeave:bt(e.onPointerLeave,vf(p=>{var v,_;h();const y=(v=n.content)==null?void 0:v.getBoundingClientRect();if(y){const w=(_=n.content)==null?void 0:_.dataset.side,x=w==="right",E=x?-5:5,k=y[x?"left":"right"],R=y[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:p.clientX+E,y:p.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(p),p.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:bt(e.onKeyDown,p=>{var v;const y=s.searchRef.current!=="";e.disabled||y&&p.key===" "||Pte[r.dir].includes(p.key)&&(n.onOpenChange(!0),(v=n.content)==null||v.focus(),p.preventDefault())})})})});Tz.displayName=Ih;var Rz="MenuSubContent",Az=b.forwardRef((e,t)=>{const n=hz(Ns,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=wc(Ns,e.__scopeMenu),o=Hf(Ns,e.__scopeMenu),l=kz(Rz,e.__scopeMenu),u=b.useRef(null),d=zn(t,u);return g.jsx(gf.Provider,{scope:e.__scopeMenu,children:g.jsx(Ls,{present:r||s.open,children:g.jsx(gf.Slot,{scope:e.__scopeMenu,children:g.jsx(_1,{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:h=>{var p;o.isUsingKeyboardRef.current&&((p=u.current)==null||p.focus()),h.preventDefault()},onCloseAutoFocus:h=>h.preventDefault(),onFocusOutside:bt(e.onFocusOutside,h=>{h.target!==l.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:bt(e.onEscapeKeyDown,h=>{o.onClose(),h.preventDefault()}),onKeyDown:bt(e.onKeyDown,h=>{var v;const p=h.currentTarget.contains(h.target),y=Lte[o.dir].includes(h.key);p&&y&&(s.onOpenChange(!1),(v=l.trigger)==null||v.focus(),h.preventDefault())})})})})})});Az.displayName=Rz;function Nz(e){return e?"open":"closed"}function Gg(e){return e==="indeterminate"}function x1(e){return Gg(e)?"indeterminate":e?"checked":"unchecked"}function tne(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function nne(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function rne(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=nne(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 ine(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,h=l.y,p=u.x,y=u.y;h>r!=y>r&&n<(p-d)*(r-h)/(y-h)+d&&(i=!i)}return i}function sne(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return ine(n,t)}function vf(e){return t=>t.pointerType==="mouse"?e(t):void 0}var one=dz,ane=v1,lne=fz,cne=pz,une=w1,dne=mz,hne=Hv,fne=vz,pne=bz,mne=wz,gne=xz,vne=Ez,yne=Cz,bne=Tz,_ne=Az,Uv="DropdownMenu",[wne]=sa(Uv,[cz]),Li=cz(),[Sne,Mz]=wne(Uv),Oz=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:l=!0}=e,u=Li(t),d=b.useRef(null),[h,p]=sc({prop:i,defaultProp:s??!1,onChange:o,caller:Uv});return g.jsx(Sne,{scope:t,triggerId:vi(),triggerRef:d,contentId:vi(),open:h,onOpenChange:p,onOpenToggle:b.useCallback(()=>p(y=>!y),[p]),modal:l,children:g.jsx(one,{...u,open:h,onOpenChange:p,dir:r,modal:l,children:n})})};Oz.displayName=Uv;var Dz="DropdownMenuTrigger",Pz=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,s=Mz(Dz,n),o=Li(n);return g.jsx(ane,{asChild:!0,...o,children:g.jsx(Jt.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:na(t,s.triggerRef),onPointerDown:bt(e.onPointerDown,l=>{!r&&l.button===0&&l.ctrlKey===!1&&(s.onOpenToggle(),s.open||l.preventDefault())}),onKeyDown:bt(e.onKeyDown,l=>{r||(["Enter"," "].includes(l.key)&&s.onOpenToggle(),l.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(l.key)&&l.preventDefault())})})})});Pz.displayName=Dz;var xne="DropdownMenuPortal",Lz=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Li(t);return g.jsx(lne,{...r,...n})};Lz.displayName=xne;var Iz="DropdownMenuContent",zz=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mz(Iz,n),s=Li(n),o=b.useRef(!1);return g.jsx(cne,{id:i.contentId,"aria-labelledby":i.triggerId,...s,...r,ref:t,onCloseAutoFocus:bt(e.onCloseAutoFocus,l=>{var u;o.current||(u=i.triggerRef.current)==null||u.focus(),o.current=!1,l.preventDefault()}),onInteractOutside:bt(e.onInteractOutside,l=>{const u=l.detail.originalEvent,d=u.button===0&&u.ctrlKey===!0,h=u.button===2||d;(!i.modal||h)&&(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)"}})});zz.displayName=Iz;var Ene="DropdownMenuGroup",Cne=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Li(n);return g.jsx(une,{...i,...r,ref:t})});Cne.displayName=Ene;var kne="DropdownMenuLabel",Bz=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Li(n);return g.jsx(dne,{...i,...r,ref:t})});Bz.displayName=kne;var Tne="DropdownMenuItem",jz=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Li(n);return g.jsx(hne,{...i,...r,ref:t})});jz.displayName=Tne;var Rne="DropdownMenuCheckboxItem",Fz=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Li(n);return g.jsx(fne,{...i,...r,ref:t})});Fz.displayName=Rne;var Ane="DropdownMenuRadioGroup",Nne=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Li(n);return g.jsx(pne,{...i,...r,ref:t})});Nne.displayName=Ane;var Mne="DropdownMenuRadioItem",One=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Li(n);return g.jsx(mne,{...i,...r,ref:t})});One.displayName=Mne;var Dne="DropdownMenuItemIndicator",$z=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Li(n);return g.jsx(gne,{...i,...r,ref:t})});$z.displayName=Dne;var Pne="DropdownMenuSeparator",Hz=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Li(n);return g.jsx(vne,{...i,...r,ref:t})});Hz.displayName=Pne;var Lne="DropdownMenuArrow",Ine=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Li(n);return g.jsx(yne,{...i,...r,ref:t})});Ine.displayName=Lne;var zne="DropdownMenuSubTrigger",Bne=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Li(n);return g.jsx(bne,{...i,...r,ref:t})});Bne.displayName=zne;var jne="DropdownMenuSubContent",Fne=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Li(n);return g.jsx(_ne,{...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)"}})});Fne.displayName=jne;var $ne=Oz,Hne=Pz,Une=Lz,Wne=zz,qne=Bz,Vne=jz,Yne=Fz,Kne=$z,Gne=Hz;function DN(e,[t,n]){return Math.min(n,Math.max(t,e))}var Wv="Popover",[Uz]=sa(Wv,[yl]),Uf=yl(),[Xne,bl]=Uz(Wv),Wz=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:o=!1}=e,l=Uf(t),u=b.useRef(null),[d,h]=b.useState(!1),[p,y]=sc({prop:r,defaultProp:i??!1,onChange:s,caller:Wv});return g.jsx(Bv,{...l,children:g.jsx(Xne,{scope:t,contentId:vi(),triggerRef:u,open:p,onOpenChange:y,onOpenToggle:b.useCallback(()=>y(v=>!v),[y]),hasCustomAnchor:d,onCustomAnchorAdd:b.useCallback(()=>h(!0),[]),onCustomAnchorRemove:b.useCallback(()=>h(!1),[]),modal:o,children:n})})};Wz.displayName=Wv;var qz="PopoverAnchor",Zne=b.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=bl(qz,n),s=Uf(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:l}=i;return b.useEffect(()=>(o(),()=>l()),[o,l]),g.jsx(jf,{...s,...r,ref:t})});Zne.displayName=qz;var Vz="PopoverTrigger",Yz=b.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=bl(Vz,n),s=Uf(n),o=zn(t,i.triggerRef),l=g.jsx(Jt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Qz(i.open),...r,ref:o,onClick:bt(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?l:g.jsx(jf,{asChild:!0,...s,children:l})});Yz.displayName=Vz;var E1="PopoverPortal",[Qne,Jne]=Uz(E1,{forceMount:void 0}),Kz=e=>{const{__scopePopover:t,forceMount:n,children:r,container:i}=e,s=bl(E1,t);return g.jsx(Qne,{scope:t,forceMount:n,children:g.jsx(Ls,{present:n||s.open,children:g.jsx(od,{asChild:!0,container:i,children:r})})})};Kz.displayName=E1;var Yu="PopoverContent",Gz=b.forwardRef((e,t)=>{const n=Jne(Yu,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,s=bl(Yu,e.__scopePopover);return g.jsx(Ls,{present:r||s.open,children:s.modal?g.jsx(tre,{...i,ref:t}):g.jsx(nre,{...i,ref:t})})});Gz.displayName=Yu;var ere=ol("PopoverContent.RemoveScroll"),tre=b.forwardRef((e,t)=>{const n=bl(Yu,e.__scopePopover),r=b.useRef(null),i=zn(t,r),s=b.useRef(!1);return b.useEffect(()=>{const o=r.current;if(o)return Mv(o)},[]),g.jsx(zf,{as:ere,allowPinchZoom:!0,children:g.jsx(Xz,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:bt(e.onCloseAutoFocus,o=>{var l;o.preventDefault(),s.current||(l=n.triggerRef.current)==null||l.focus()}),onPointerDownOutside:bt(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:bt(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),nre=b.forwardRef((e,t)=>{const n=bl(Yu,e.__scopePopover),r=b.useRef(!1),i=b.useRef(!1);return g.jsx(Xz,{...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()}})}),Xz=b.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:o,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:h,...p}=e,y=bl(Yu,n),v=Uf(n);return Av(),g.jsx(If,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:g.jsx(sd,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:h,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onDismiss:()=>y.onOpenChange(!1),children:g.jsx(jv,{"data-state":Qz(y.open),role:"dialog",id:y.contentId,...v,...p,ref:t,style:{...p.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)"}})})})}),Zz="PopoverClose",rre=b.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=bl(Zz,n);return g.jsx(Jt.button,{type:"button",...r,ref:t,onClick:bt(e.onClick,()=>i.onOpenChange(!1))})});rre.displayName=Zz;var ire="PopoverArrow",sre=b.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Uf(n);return g.jsx(Fv,{...i,...r,ref:t})});sre.displayName=ire;function Qz(e){return e?"open":"closed"}var ore=Wz,are=Yz,lre=Kz,cre=Gz,ure=[" ","Enter","ArrowUp","ArrowDown"],dre=[" ","Enter"],lc="Select",[qv,Vv,hre]=e1(lc),[cd]=sa(lc,[hre,yl]),Yv=yl(),[fre,_l]=cd(lc),[pre,mre]=cd(lc),Jz=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:s,value:o,defaultValue:l,onValueChange:u,dir:d,name:h,autoComplete:p,disabled:y,required:v,form:_}=e,w=Yv(t),[x,E]=b.useState(null),[k,R]=b.useState(null),[A,I]=b.useState(!1),T=t1(d),[H,D]=sc({prop:r,defaultProp:i??!1,onChange:s,caller:lc}),[W,U]=sc({prop:o,defaultProp:l,onChange:u,caller:lc}),F=b.useRef(null),O=x?_||!!x.closest("form"):!0,[M,B]=b.useState(new Set),L=Array.from(M).map(N=>N.props.value).join(";");return g.jsx(Bv,{...w,children:g.jsxs(fre,{required:v,scope:t,trigger:x,onTriggerChange:E,valueNode:k,onValueNodeChange:R,valueNodeHasChildren:A,onValueNodeHasChildrenChange:I,contentId:vi(),value:W,onValueChange:U,open:H,onOpenChange:D,dir:T,triggerPointerDownPosRef:F,disabled:y,children:[g.jsx(qv.Provider,{scope:t,children:g.jsx(pre,{scope:e.__scopeSelect,onNativeOptionAdd:b.useCallback(N=>{B(V=>new Set(V).add(N))},[]),onNativeOptionRemove:b.useCallback(N=>{B(V=>{const Y=new Set(V);return Y.delete(N),Y})},[]),children:n})}),O?g.jsxs(wB,{"aria-hidden":!0,required:v,tabIndex:-1,name:h,autoComplete:p,value:W,onChange:N=>U(N.target.value),disabled:y,form:_,children:[W===void 0?g.jsx("option",{value:""}):null,Array.from(M)]},L):null]})})};Jz.displayName=lc;var eB="SelectTrigger",tB=b.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...i}=e,s=Yv(n),o=_l(eB,n),l=o.disabled||r,u=zn(t,o.onTriggerChange),d=Vv(n),h=b.useRef("touch"),[p,y,v]=xB(w=>{const x=d().filter(R=>!R.disabled),E=x.find(R=>R.value===o.value),k=EB(x,w,E);k!==void 0&&o.onValueChange(k.value)}),_=w=>{l||(o.onOpenChange(!0),v()),w&&(o.triggerPointerDownPosRef.current={x:Math.round(w.pageX),y:Math.round(w.pageY)})};return g.jsx(jf,{asChild:!0,...s,children:g.jsx(Jt.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":SB(o.value)?"":void 0,...i,ref:u,onClick:bt(i.onClick,w=>{w.currentTarget.focus(),h.current!=="mouse"&&_(w)}),onPointerDown:bt(i.onPointerDown,w=>{h.current=w.pointerType;const x=w.target;x.hasPointerCapture(w.pointerId)&&x.releasePointerCapture(w.pointerId),w.button===0&&w.ctrlKey===!1&&w.pointerType==="mouse"&&(_(w),w.preventDefault())}),onKeyDown:bt(i.onKeyDown,w=>{const x=p.current!=="";!(w.ctrlKey||w.altKey||w.metaKey)&&w.key.length===1&&y(w.key),!(x&&w.key===" ")&&ure.includes(w.key)&&(_(),w.preventDefault())})})})});tB.displayName=eB;var nB="SelectValue",rB=b.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:i,children:s,placeholder:o="",...l}=e,u=_l(nB,n),{onValueNodeHasChildrenChange:d}=u,h=s!==void 0,p=zn(t,u.onValueNodeChange);return Ci(()=>{d(h)},[d,h]),g.jsx(Jt.span,{...l,ref:p,style:{pointerEvents:"none"},children:SB(u.value)?g.jsx(g.Fragment,{children:o}):s})});rB.displayName=nB;var gre="SelectIcon",iB=b.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...i}=e;return g.jsx(Jt.span,{"aria-hidden":!0,...i,ref:t,children:r||"▼"})});iB.displayName=gre;var vre="SelectPortal",sB=e=>g.jsx(od,{asChild:!0,...e});sB.displayName=vre;var cc="SelectContent",oB=b.forwardRef((e,t)=>{const n=_l(cc,e.__scopeSelect),[r,i]=b.useState();if(Ci(()=>{i(new DocumentFragment)},[]),!n.open){const s=r;return s?id.createPortal(g.jsx(aB,{scope:e.__scopeSelect,children:g.jsx(qv.Slot,{scope:e.__scopeSelect,children:g.jsx("div",{children:e.children})})}),s):null}return g.jsx(lB,{...e,ref:t})});oB.displayName=cc;var Us=10,[aB,wl]=cd(cc),yre="SelectContentImpl",bre=ol("SelectContent.RemoveScroll"),lB=b.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:s,onPointerDownOutside:o,side:l,sideOffset:u,align:d,alignOffset:h,arrowPadding:p,collisionBoundary:y,collisionPadding:v,sticky:_,hideWhenDetached:w,avoidCollisions:x,...E}=e,k=_l(cc,n),[R,A]=b.useState(null),[I,T]=b.useState(null),H=zn(t,Q=>A(Q)),[D,W]=b.useState(null),[U,F]=b.useState(null),O=Vv(n),[M,B]=b.useState(!1),L=b.useRef(!1);b.useEffect(()=>{if(R)return Mv(R)},[R]),Av();const N=b.useCallback(Q=>{const[me,...ve]=O().map(Ve=>Ve.ref.current),[Ce]=ve.slice(-1),Me=document.activeElement;for(const Ve of Q)if(Ve===Me||(Ve==null||Ve.scrollIntoView({block:"nearest"}),Ve===me&&I&&(I.scrollTop=0),Ve===Ce&&I&&(I.scrollTop=I.scrollHeight),Ve==null||Ve.focus(),document.activeElement!==Me))return},[O,I]),V=b.useCallback(()=>N([D,R]),[N,D,R]);b.useEffect(()=>{M&&V()},[M,V]);const{onOpenChange:Y,triggerPointerDownPosRef:$}=k;b.useEffect(()=>{if(R){let Q={x:0,y:0};const me=Ce=>{var Me,Ve;Q={x:Math.abs(Math.round(Ce.pageX)-(((Me=$.current)==null?void 0:Me.x)??0)),y:Math.abs(Math.round(Ce.pageY)-(((Ve=$.current)==null?void 0:Ve.y)??0))}},ve=Ce=>{Q.x<=10&&Q.y<=10?Ce.preventDefault():R.contains(Ce.target)||Y(!1),document.removeEventListener("pointermove",me),$.current=null};return $.current!==null&&(document.addEventListener("pointermove",me),document.addEventListener("pointerup",ve,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",me),document.removeEventListener("pointerup",ve,{capture:!0})}}},[R,Y,$]),b.useEffect(()=>{const Q=()=>Y(!1);return window.addEventListener("blur",Q),window.addEventListener("resize",Q),()=>{window.removeEventListener("blur",Q),window.removeEventListener("resize",Q)}},[Y]);const[P,q]=xB(Q=>{const me=O().filter(Me=>!Me.disabled),ve=me.find(Me=>Me.ref.current===document.activeElement),Ce=EB(me,Q,ve);Ce&&setTimeout(()=>Ce.ref.current.focus())}),K=b.useCallback((Q,me,ve)=>{const Ce=!L.current&&!ve;(k.value!==void 0&&k.value===me||Ce)&&(W(Q),Ce&&(L.current=!0))},[k.value]),z=b.useCallback(()=>R==null?void 0:R.focus(),[R]),X=b.useCallback((Q,me,ve)=>{const Ce=!L.current&&!ve;(k.value!==void 0&&k.value===me||Ce)&&F(Q)},[k.value]),ee=r==="popper"?P0:cB,te=ee===P0?{side:l,sideOffset:u,align:d,alignOffset:h,arrowPadding:p,collisionBoundary:y,collisionPadding:v,sticky:_,hideWhenDetached:w,avoidCollisions:x}:{};return g.jsx(aB,{scope:n,content:R,viewport:I,onViewportChange:T,itemRefCallback:K,selectedItem:D,onItemLeave:z,itemTextRefCallback:X,focusSelectedItem:V,selectedItemText:U,position:r,isPositioned:M,searchRef:P,children:g.jsx(zf,{as:bre,allowPinchZoom:!0,children:g.jsx(If,{asChild:!0,trapped:k.open,onMountAutoFocus:Q=>{Q.preventDefault()},onUnmountAutoFocus:bt(i,Q=>{var me;(me=k.trigger)==null||me.focus({preventScroll:!0}),Q.preventDefault()}),children:g.jsx(sd,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:Q=>Q.preventDefault(),onDismiss:()=>k.onOpenChange(!1),children:g.jsx(ee,{role:"listbox",id:k.contentId,"data-state":k.open?"open":"closed",dir:k.dir,onContextMenu:Q=>Q.preventDefault(),...E,...te,onPlaced:()=>B(!0),ref:H,style:{display:"flex",flexDirection:"column",outline:"none",...E.style},onKeyDown:bt(E.onKeyDown,Q=>{const me=Q.ctrlKey||Q.altKey||Q.metaKey;if(Q.key==="Tab"&&Q.preventDefault(),!me&&Q.key.length===1&&q(Q.key),["ArrowUp","ArrowDown","Home","End"].includes(Q.key)){let Ce=O().filter(Me=>!Me.disabled).map(Me=>Me.ref.current);if(["ArrowUp","End"].includes(Q.key)&&(Ce=Ce.slice().reverse()),["ArrowUp","ArrowDown"].includes(Q.key)){const Me=Q.target,Ve=Ce.indexOf(Me);Ce=Ce.slice(Ve+1)}setTimeout(()=>N(Ce)),Q.preventDefault()}})})})})})})});lB.displayName=yre;var _re="SelectItemAlignedPosition",cB=b.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...i}=e,s=_l(cc,n),o=wl(cc,n),[l,u]=b.useState(null),[d,h]=b.useState(null),p=zn(t,H=>h(H)),y=Vv(n),v=b.useRef(!1),_=b.useRef(!0),{viewport:w,selectedItem:x,selectedItemText:E,focusSelectedItem:k}=o,R=b.useCallback(()=>{if(s.trigger&&s.valueNode&&l&&d&&w&&x&&E){const H=s.trigger.getBoundingClientRect(),D=d.getBoundingClientRect(),W=s.valueNode.getBoundingClientRect(),U=E.getBoundingClientRect();if(s.dir!=="rtl"){const Me=U.left-D.left,Ve=W.left-Me,Qe=H.left-Ve,ct=H.width+Qe,Ot=Math.max(ct,D.width),he=window.innerWidth-Us,Ke=DN(Ve,[Us,Math.max(Us,he-Ot)]);l.style.minWidth=ct+"px",l.style.left=Ke+"px"}else{const Me=D.right-U.right,Ve=window.innerWidth-W.right-Me,Qe=window.innerWidth-H.right-Ve,ct=H.width+Qe,Ot=Math.max(ct,D.width),he=window.innerWidth-Us,Ke=DN(Ve,[Us,Math.max(Us,he-Ot)]);l.style.minWidth=ct+"px",l.style.right=Ke+"px"}const F=y(),O=window.innerHeight-Us*2,M=w.scrollHeight,B=window.getComputedStyle(d),L=parseInt(B.borderTopWidth,10),N=parseInt(B.paddingTop,10),V=parseInt(B.borderBottomWidth,10),Y=parseInt(B.paddingBottom,10),$=L+N+M+Y+V,P=Math.min(x.offsetHeight*5,$),q=window.getComputedStyle(w),K=parseInt(q.paddingTop,10),z=parseInt(q.paddingBottom,10),X=H.top+H.height/2-Us,ee=O-X,te=x.offsetHeight/2,Q=x.offsetTop+te,me=L+N+Q,ve=$-me;if(me<=X){const Me=F.length>0&&x===F[F.length-1].ref.current;l.style.bottom="0px";const Ve=d.clientHeight-w.offsetTop-w.offsetHeight,Qe=Math.max(ee,te+(Me?z:0)+Ve+V),ct=me+Qe;l.style.height=ct+"px"}else{const Me=F.length>0&&x===F[0].ref.current;l.style.top="0px";const Qe=Math.max(X,L+w.offsetTop+(Me?K:0)+te)+ve;l.style.height=Qe+"px",w.scrollTop=me-X+w.offsetTop}l.style.margin=`${Us}px 0`,l.style.minHeight=P+"px",l.style.maxHeight=O+"px",r==null||r(),requestAnimationFrame(()=>v.current=!0)}},[y,s.trigger,s.valueNode,l,d,w,x,E,s.dir,r]);Ci(()=>R(),[R]);const[A,I]=b.useState();Ci(()=>{d&&I(window.getComputedStyle(d).zIndex)},[d]);const T=b.useCallback(H=>{H&&_.current===!0&&(R(),k==null||k(),_.current=!1)},[R,k]);return g.jsx(Sre,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:v,onScrollButtonChange:T,children:g.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:A},children:g.jsx(Jt.div,{...i,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})});cB.displayName=_re;var wre="SelectPopperPosition",P0=b.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:i=Us,...s}=e,o=Yv(n);return g.jsx(jv,{...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)"}})});P0.displayName=wre;var[Sre,C1]=cd(cc,{}),L0="SelectViewport",uB=b.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...i}=e,s=wl(L0,n),o=C1(L0,n),l=zn(t,s.onViewportChange),u=b.useRef(0);return g.jsxs(g.Fragment,{children:[g.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}),g.jsx(qv.Slot,{scope:n,children:g.jsx(Jt.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:bt(i.onScroll,d=>{const h=d.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:y}=o;if(y!=null&&y.current&&p){const v=Math.abs(u.current-h.scrollTop);if(v>0){const _=window.innerHeight-Us*2,w=parseFloat(p.style.minHeight),x=parseFloat(p.style.height),E=Math.max(w,x);if(E<_){const k=E+v,R=Math.min(_,k),A=k-R;p.style.height=R+"px",p.style.bottom==="0px"&&(h.scrollTop=A>0?A:0,p.style.justifyContent="flex-end")}}}u.current=h.scrollTop})})})]})});uB.displayName=L0;var dB="SelectGroup",[xre,Ere]=cd(dB),Cre=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=vi();return g.jsx(xre,{scope:n,id:i,children:g.jsx(Jt.div,{role:"group","aria-labelledby":i,...r,ref:t})})});Cre.displayName=dB;var hB="SelectLabel",kre=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=Ere(hB,n);return g.jsx(Jt.div,{id:i.id,...r,ref:t})});kre.displayName=hB;var Xg="SelectItem",[Tre,fB]=cd(Xg),pB=b.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:i=!1,textValue:s,...o}=e,l=_l(Xg,n),u=wl(Xg,n),d=l.value===r,[h,p]=b.useState(s??""),[y,v]=b.useState(!1),_=zn(t,k=>{var R;return(R=u.itemRefCallback)==null?void 0:R.call(u,k,r,i)}),w=vi(),x=b.useRef("touch"),E=()=>{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 g.jsx(Tre,{scope:n,value:r,disabled:i,textId:w,isSelected:d,onItemTextChange:b.useCallback(k=>{p(R=>R||((k==null?void 0:k.textContent)??"").trim())},[]),children:g.jsx(qv.ItemSlot,{scope:n,value:r,disabled:i,textValue:h,children:g.jsx(Jt.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:bt(o.onFocus,()=>v(!0)),onBlur:bt(o.onBlur,()=>v(!1)),onClick:bt(o.onClick,()=>{x.current!=="mouse"&&E()}),onPointerUp:bt(o.onPointerUp,()=>{x.current==="mouse"&&E()}),onPointerDown:bt(o.onPointerDown,k=>{x.current=k.pointerType}),onPointerMove:bt(o.onPointerMove,k=>{var R;x.current=k.pointerType,i?(R=u.onItemLeave)==null||R.call(u):x.current==="mouse"&&k.currentTarget.focus({preventScroll:!0})}),onPointerLeave:bt(o.onPointerLeave,k=>{var R;k.currentTarget===document.activeElement&&((R=u.onItemLeave)==null||R.call(u))}),onKeyDown:bt(o.onKeyDown,k=>{var A;((A=u.searchRef)==null?void 0:A.current)!==""&&k.key===" "||(dre.includes(k.key)&&E(),k.key===" "&&k.preventDefault())})})})})});pB.displayName=Xg;var zh="SelectItemText",mB=b.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:i,...s}=e,o=_l(zh,n),l=wl(zh,n),u=fB(zh,n),d=mre(zh,n),[h,p]=b.useState(null),y=zn(t,E=>p(E),u.onItemTextChange,E=>{var k;return(k=l.itemTextRefCallback)==null?void 0:k.call(l,E,u.value,u.disabled)}),v=h==null?void 0:h.textContent,_=b.useMemo(()=>g.jsx("option",{value:u.value,disabled:u.disabled,children:v},u.value),[u.disabled,u.value,v]),{onNativeOptionAdd:w,onNativeOptionRemove:x}=d;return Ci(()=>(w(_),()=>x(_)),[w,x,_]),g.jsxs(g.Fragment,{children:[g.jsx(Jt.span,{id:u.textId,...s,ref:y}),u.isSelected&&o.valueNode&&!o.valueNodeHasChildren?id.createPortal(s.children,o.valueNode):null]})});mB.displayName=zh;var gB="SelectItemIndicator",vB=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return fB(gB,n).isSelected?g.jsx(Jt.span,{"aria-hidden":!0,...r,ref:t}):null});vB.displayName=gB;var I0="SelectScrollUpButton",yB=b.forwardRef((e,t)=>{const n=wl(I0,e.__scopeSelect),r=C1(I0,e.__scopeSelect),[i,s]=b.useState(!1),o=zn(t,r.onScrollButtonChange);return Ci(()=>{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?g.jsx(_B,{...e,ref:o,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=n;l&&u&&(l.scrollTop=l.scrollTop-u.offsetHeight)}}):null});yB.displayName=I0;var z0="SelectScrollDownButton",bB=b.forwardRef((e,t)=>{const n=wl(z0,e.__scopeSelect),r=C1(z0,e.__scopeSelect),[i,s]=b.useState(!1),o=zn(t,r.onScrollButtonChange);return Ci(()=>{if(n.viewport&&n.isPositioned){let l=function(){const d=u.scrollHeight-u.clientHeight,h=Math.ceil(u.scrollTop)<d;s(h)};const u=n.viewport;return l(),u.addEventListener("scroll",l),()=>u.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),i?g.jsx(_B,{...e,ref:o,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=n;l&&u&&(l.scrollTop=l.scrollTop+u.offsetHeight)}}):null});bB.displayName=z0;var _B=b.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...i}=e,s=wl("SelectScrollButton",n),o=b.useRef(null),l=Vv(n),u=b.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return b.useEffect(()=>()=>u(),[u]),Ci(()=>{var h;const d=l().find(p=>p.ref.current===document.activeElement);(h=d==null?void 0:d.ref.current)==null||h.scrollIntoView({block:"nearest"})},[l]),g.jsx(Jt.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:bt(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:bt(i.onPointerMove,()=>{var d;(d=s.onItemLeave)==null||d.call(s),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:bt(i.onPointerLeave,()=>{u()})})}),Rre="SelectSeparator",Are=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return g.jsx(Jt.div,{"aria-hidden":!0,...r,ref:t})});Are.displayName=Rre;var B0="SelectArrow",Nre=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=Yv(n),s=_l(B0,n),o=wl(B0,n);return s.open&&o.position==="popper"?g.jsx(Fv,{...i,...r,ref:t}):null});Nre.displayName=B0;var Mre="SelectBubbleInput",wB=b.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const i=b.useRef(null),s=zn(r,i),o=oee(t);return b.useEffect(()=>{const l=i.current;if(!l)return;const u=window.HTMLSelectElement.prototype,h=Object.getOwnPropertyDescriptor(u,"value").set;if(o!==t&&h){const p=new Event("change",{bubbles:!0});h.call(l,t),l.dispatchEvent(p)}},[o,t]),g.jsx(Jt.select,{...n,style:{...rI,...n.style},ref:s,defaultValue:t})});wB.displayName=Mre;function SB(e){return e===""||e===void 0}function xB(e){const t=Co(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 EB(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=Ore(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 Ore(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Dre=Jz,Pre=tB,Lre=rB,Ire=iB,zre=sB,Bre=oB,jre=uB,Fre=pB,$re=mB,Hre=vB,Ure=yB,Wre=bB,[Kv]=sa("Tooltip",[yl]),Gv=yl(),CB="TooltipProvider",qre=700,j0="tooltip.open",[Vre,k1]=Kv(CB),kB=e=>{const{__scopeTooltip:t,delayDuration:n=qre,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)},[]),g.jsx(Vre,{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})};kB.displayName=CB;var yf="Tooltip",[Yre,Wf]=Kv(yf),TB=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:l}=e,u=k1(yf,e.__scopeTooltip),d=Gv(t),[h,p]=b.useState(null),y=vi(),v=b.useRef(0),_=o??u.disableHoverableContent,w=l??u.delayDuration,x=b.useRef(!1),[E,k]=sc({prop:r,defaultProp:i??!1,onChange:H=>{H?(u.onOpen(),document.dispatchEvent(new CustomEvent(j0))):u.onClose(),s==null||s(H)},caller:yf}),R=b.useMemo(()=>E?x.current?"delayed-open":"instant-open":"closed",[E]),A=b.useCallback(()=>{window.clearTimeout(v.current),v.current=0,x.current=!1,k(!0)},[k]),I=b.useCallback(()=>{window.clearTimeout(v.current),v.current=0,k(!1)},[k]),T=b.useCallback(()=>{window.clearTimeout(v.current),v.current=window.setTimeout(()=>{x.current=!0,k(!0),v.current=0},w)},[w,k]);return b.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=0)},[]),g.jsx(Bv,{...d,children:g.jsx(Yre,{scope:t,contentId:y,open:E,stateAttribute:R,trigger:h,onTriggerChange:p,onTriggerEnter:b.useCallback(()=>{u.isOpenDelayedRef.current?T():A()},[u.isOpenDelayedRef,T,A]),onTriggerLeave:b.useCallback(()=>{_?I():(window.clearTimeout(v.current),v.current=0)},[I,_]),onOpen:A,onClose:I,disableHoverableContent:_,children:n})})};TB.displayName=yf;var F0="TooltipTrigger",RB=b.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Wf(F0,n),s=k1(F0,n),o=Gv(n),l=b.useRef(null),u=zn(t,l,i.onTriggerChange),d=b.useRef(!1),h=b.useRef(!1),p=b.useCallback(()=>d.current=!1,[]);return b.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),g.jsx(jf,{asChild:!0,...o,children:g.jsx(Jt.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:u,onPointerMove:bt(e.onPointerMove,y=>{y.pointerType!=="touch"&&!h.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),h.current=!0)}),onPointerLeave:bt(e.onPointerLeave,()=>{i.onTriggerLeave(),h.current=!1}),onPointerDown:bt(e.onPointerDown,()=>{i.open&&i.onClose(),d.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:bt(e.onFocus,()=>{d.current||i.onOpen()}),onBlur:bt(e.onBlur,i.onClose),onClick:bt(e.onClick,i.onClose)})})});RB.displayName=F0;var T1="TooltipPortal",[Kre,Gre]=Kv(T1,{forceMount:void 0}),AB=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,s=Wf(T1,t);return g.jsx(Kre,{scope:t,forceMount:n,children:g.jsx(Ls,{present:n||s.open,children:g.jsx(od,{asChild:!0,container:i,children:r})})})};AB.displayName=T1;var Ku="TooltipContent",NB=b.forwardRef((e,t)=>{const n=Gre(Ku,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,o=Wf(Ku,e.__scopeTooltip);return g.jsx(Ls,{present:r||o.open,children:o.disableHoverableContent?g.jsx(MB,{side:i,...s,ref:t}):g.jsx(Xre,{side:i,...s,ref:t})})}),Xre=b.forwardRef((e,t)=>{const n=Wf(Ku,e.__scopeTooltip),r=k1(Ku,e.__scopeTooltip),i=b.useRef(null),s=zn(t,i),[o,l]=b.useState(null),{trigger:u,onClose:d}=n,h=i.current,{onPointerInTransitChange:p}=r,y=b.useCallback(()=>{l(null),p(!1)},[p]),v=b.useCallback((_,w)=>{const x=_.currentTarget,E={x:_.clientX,y:_.clientY},k=eie(E,x.getBoundingClientRect()),R=tie(E,k),A=nie(w.getBoundingClientRect()),I=iie([...R,...A]);l(I),p(!0)},[p]);return b.useEffect(()=>()=>y(),[y]),b.useEffect(()=>{if(u&&h){const _=x=>v(x,h),w=x=>v(x,u);return u.addEventListener("pointerleave",_),h.addEventListener("pointerleave",w),()=>{u.removeEventListener("pointerleave",_),h.removeEventListener("pointerleave",w)}}},[u,h,v,y]),b.useEffect(()=>{if(o){const _=w=>{const x=w.target,E={x:w.clientX,y:w.clientY},k=(u==null?void 0:u.contains(x))||(h==null?void 0:h.contains(x)),R=!rie(E,o);k?y():R&&(y(),d())};return document.addEventListener("pointermove",_),()=>document.removeEventListener("pointermove",_)}},[u,h,o,d,y]),g.jsx(MB,{...e,ref:s})}),[Zre,Qre]=Kv(yf,{isInside:!1}),Jre=OQ("TooltipContent"),MB=b.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...l}=e,u=Wf(Ku,n),d=Gv(n),{onClose:h}=u;return b.useEffect(()=>(document.addEventListener(j0,h),()=>document.removeEventListener(j0,h)),[h]),b.useEffect(()=>{if(u.trigger){const p=y=>{const v=y.target;v!=null&&v.contains(u.trigger)&&h()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[u.trigger,h]),g.jsx(sd,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:p=>p.preventDefault(),onDismiss:h,children:g.jsxs(jv,{"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:[g.jsx(Jre,{children:r}),g.jsx(Zre,{scope:n,isInside:!0,children:g.jsx(sI,{id:u.contentId,role:"tooltip",children:i||r})})]})})});NB.displayName=Ku;var OB="TooltipArrow",DB=b.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Gv(n);return Qre(OB,n).isInside?null:g.jsx(Fv,{...i,...r,ref:t})});DB.displayName=OB;function eie(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 tie(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 nie(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 rie(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,h=l.y,p=u.x,y=u.y;h>r!=y>r&&n<(p-d)*(r-h)/(y-h)+d&&(i=!i)}return i}function iie(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),sie(t)}function sie(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 oie=kB,aie=TB,lie=RB,cie=AB,uie=NB,die=DB;function R1({...e}){return g.jsx(ore,{"data-slot":"popover",...e})}function A1({...e}){return g.jsx(are,{"data-slot":"popover-trigger",...e})}function N1({className:e,align:t="center",sideOffset:n=4,...r}){return g.jsx(lre,{children:g.jsx(cre,{"data-slot":"popover-content",align:t,sideOffset:n,className:Ye("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),...r})})}const hie={"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 tc({variant:e,action:t}){const{heading:n,body:r}=hie[e];return e==="no-messages"?g.jsx("div",{className:"flex h-full w-full items-center justify-center animate-in fade-in-0 duration-200 motion-reduce:animate-none",children:g.jsx("p",{className:"text-sm text-muted-foreground",children:n})}):g.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:[g.jsx("h2",{className:"text-2xl font-semibold",children:n}),r&&g.jsx("p",{className:"max-w-md text-sm text-muted-foreground",children:r}),t&&g.jsx("div",{children:t})]})}const fie={online:"bg-[var(--color-status-success)]",offline:"bg-[var(--muted-foreground)]",connecting:"bg-[var(--color-status-working)] animate-pulse"},pie={online:"开发机在线",offline:"开发机离线",connecting:"正在连接开发机"};function PN({status:e,className:t}){return g.jsx("span",{className:Ye("inline-block w-2 h-2 rounded-full shrink-0",fie[e],t),role:"status","aria-label":pie[e]})}function PB({layout:e,variant:t="default"}){const n=Ne(_=>_.proxies),r=Ne(_=>_.proxyListLoaded),i=Ne(_=>_.relayClientAuthIssue),s=Ne(_=>_.selectedProxyId),o=Ne(_=>_.proxySwitchTarget),l=Pi(),u=Qs(),[d,h]=b.useState(!1);async function p(_,w){if(o)return;const x=Pt;if(!x){nt.error("请先连接开发机");return}const E=w??_,k=s!==null&&s!==_;Ne.getState().setProxySwitchTarget({proxyId:_,name:E});try{const R=await x.selectProxy(_);if(!R.success){nt.error(`无法连接 ${E}:${R.error??"未知错误"}`);return}k&&($t.getState().prepareForProxySwitch(E),ii.getState().prepareForProxySwitch()),hr("local",dn.proxyId,_),Ne.getState().setProxy(_,w??null),Ne.getState().setProxyOnline(!0),Ne.getState().transitionToPhase("session_browsing"),x.sendControl({type:"session_list"}),x.requestProxyInfo().then(A=>{if(Ne.getState().selectedProxyId!==_)return;const I=ii.getState();I.setHomePath(A.homePath),I.setAgentCli(A.agentCli)}).catch(A=>{console.error("[proxy-switcher] post-bind proxy info fetch failed",A)}),x.requestAgentStatuses().then(A=>{if(Ne.getState().selectedProxyId!==_)return;const I=$t.getState();for(const T of A)I.setAgentStatus(T.sessionId,T.payload)}).catch(A=>{console.error("[proxy-switcher] post-bind data fetch failed",A)}),x.requestSessionHistory().then(A=>{Ne.getState().selectedProxyId===_&&$t.getState().setHistorySessions(A)}).catch(A=>{console.error("[proxy-switcher] post-bind data fetch failed",A)}),h(!1),(e==="page"||l.pathname.startsWith("/chat/"))&&u("/sessions")}catch(R){const A=R instanceof Error?R.message:"未知错误";nt.error(`无法连接 ${E}:${A}`)}finally{Ne.getState().setProxySwitchTarget(null)}}if(e==="page")return i==="missing_client_token"?g.jsx(tc,{variant:"client-token-missing"}):i==="invalid_client_token"?g.jsx(tc,{variant:"client-token-invalid"}):r?n.length===0?g.jsx(tc,{variant:"no-proxy"}):g.jsxs("div",{className:"flex flex-col gap-3 p-4 h-full overflow-auto",children:[g.jsx("h3",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"可连接开发机"}),g.jsx("ul",{role:"list",className:"flex flex-col gap-2",children:n.map(_=>{const w=(o==null?void 0:o.proxyId)===_.proxyId,x=o!==null;return g.jsx("li",{children:g.jsxs("button",{type:"button","data-slot":"proxy-item","data-proxy-id":_.proxyId,"data-online":_.online,"data-selecting":w||void 0,disabled:!_.online||x,"aria-busy":w||void 0,onClick:()=>p(_.proxyId,_.name),className:Ye("w-full flex items-center gap-3 px-3 h-11 min-h-[44px] rounded-md border bg-card transition-colors text-left disabled:cursor-not-allowed disabled:hover:bg-card",w?"border-primary/40 bg-accent text-accent-foreground":"border-border hover:bg-accent",x&&!w?"opacity-50":"",_.online?"":"opacity-50"),"aria-pressed":s===_.proxyId,title:_.online?void 0:"这台开发机离线,暂时无法连接",children:[g.jsx(PN,{status:_.online?"online":"offline"}),g.jsx("span",{className:"text-sm font-normal flex-1 truncate min-w-0",children:_.name??_.proxyId}),w?g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:"正在连接"}),g.jsx(Jl,{className:"h-4 w-4 animate-spin text-primary shrink-0","aria-hidden":!0})]}):s===_.proxyId?g.jsx(ta,{className:"h-4 w-4 text-primary shrink-0","aria-label":"已选"}):null,!_.online&&!w&&g.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:"离线"})]})},_.proxyId)})})]}):g.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:[g.jsx(Jl,{className:"h-5 w-5 animate-spin","aria-hidden":!0}),g.jsx("p",{className:"text-sm",children:"连接中..."})]});const y=n.find(_=>_.proxyId===s),v=(y==null?void 0:y.name)??(y==null?void 0:y.proxyId)??"未选择开发机";return g.jsxs(R1,{open:d,onOpenChange:h,children:[g.jsx(A1,{asChild:!0,children:g.jsxs("button",{type:"button","data-slot":"proxy-switcher-trigger",className:Ye("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 h-10 w-full items-center gap-2 rounded-md border border-border bg-background px-4 hover:bg-accent"),"aria-label":`当前连接:${v}`,children:[t==="default"&&g.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":!0}),g.jsx("span",{className:Ye("truncate",t==="sidebarChrome"?"min-w-0 text-base font-semibold leading-none":"flex-1 text-center text-sm font-normal"),children:v}),g.jsx(pl,{className:"h-4 w-4 text-muted-foreground shrink-0 transition-transform group-data-[state=open]:rotate-180","aria-hidden":!0})]})}),g.jsx(N1,{align:"start",className:"w-[260px] p-1",children:n.length===0?g.jsx("div",{className:"text-xs text-muted-foreground p-2",children:"暂无可连接开发机"}):g.jsx("ul",{role:"list",className:"flex flex-col",children:n.map(_=>{const w=(o==null?void 0:o.proxyId)===_.proxyId,x=o!==null;return g.jsx("li",{children:g.jsxs("button",{type:"button","data-slot":"proxy-item","data-proxy-id":_.proxyId,"data-online":_.online,"data-selecting":w||void 0,disabled:!_.online||x,"aria-busy":w||void 0,onClick:()=>p(_.proxyId,_.name),className:Ye("w-full flex items-center gap-2 px-2 h-9 rounded-md transition-colors text-left disabled:cursor-not-allowed disabled:hover:bg-transparent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",w?"bg-accent text-accent-foreground":"hover:bg-accent",x&&!w?"opacity-50":"",_.online?"":"opacity-50"),"aria-pressed":s===_.proxyId,title:_.online?void 0:"这台开发机离线",children:[g.jsx(PN,{status:_.online?"online":"offline"}),g.jsx("span",{className:"text-sm font-normal flex-1 truncate min-w-0",children:_.name??_.proxyId}),w?g.jsx(Jl,{className:"h-4 w-4 animate-spin text-primary shrink-0","aria-label":"正在连接"}):s===_.proxyId?g.jsx(ta,{className:"h-4 w-4 text-primary shrink-0","aria-label":"已选"}):null,!_.online&&s!==_.proxyId&&!w&&g.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:"离线"})]})},_.proxyId)})})})]})}const LN=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,IN=jP,mie=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return IN(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 h=n==null?void 0:n[d],p=s==null?void 0:s[d];if(h===null)return null;const y=LN(h)||LN(p);return i[d][y]}),l=n&&Object.entries(n).reduce((d,h)=>{let[p,y]=h;return y===void 0||(d[p]=y),d},{}),u=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((d,h)=>{let{class:p,className:y,...v}=h;return Object.entries(v).every(_=>{let[w,x]=_;return Array.isArray(x)?x.includes({...s,...l}[w]):{...s,...l}[w]===x})?[...d,p,y]:d},[]);return IN(e,o,u,n==null?void 0:n.class,n==null?void 0:n.className)},gie=mie("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 _t({className:e,variant:t="default",size:n="default",asChild:r=!1,...i}){const s=r?NQ:"button";return g.jsx(s,{"data-slot":"button","data-variant":t,"data-size":n,className:Ye(gie({variant:t,size:n,className:e})),...i})}function vie({delayDuration:e=0,...t}){return g.jsx(oie,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function qf({...e}){return g.jsx(aie,{"data-slot":"tooltip",...e})}function Vf({...e}){return g.jsx(lie,{"data-slot":"tooltip-trigger",...e})}function Yf({className:e,sideOffset:t=0,children:n,hideArrow:r=!1,...i}){return g.jsx(cie,{children:g.jsxs(uie,{"data-slot":"tooltip-content",sideOffset:t,className:Ye("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&&g.jsx(die,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})}function Xv({...e}){return g.jsx(s1,{"data-slot":"sheet",...e})}function yie({...e}){return g.jsx(see,{"data-slot":"sheet-trigger",...e})}function bie({...e}){return g.jsx(o1,{"data-slot":"sheet-portal",...e})}function _ie({className:e,...t}){return g.jsx(a1,{"data-slot":"sheet-overlay",className:Ye("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 Zv({className:e,overlayClassName:t,children:n,side:r="right",showCloseButton:i=!0,focusSurfaceOnOpen:s=!1,onOpenAutoFocus:o,...l}){return g.jsxs(bie,{children:[g.jsx(_ie,{className:t}),g.jsxs(l1,{"data-slot":"sheet-content",className:Ye("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:u=>{o==null||o(u),!(!s||u.defaultPrevented)&&(u.preventDefault(),u.currentTarget.focus({preventScroll:!0}))},...l,children:[n,i&&g.jsxs(Dv,{"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:[g.jsx(vc,{className:"size-4"}),g.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function M1({className:e,...t}){return g.jsx("div",{"data-slot":"sheet-header",className:Ye("flex flex-col gap-1.5 p-4",e),...t})}function Qv({className:e,...t}){return g.jsx(DI,{"data-slot":"sheet-title",className:Ye("font-semibold text-foreground",e),...t})}function wie({className:e,...t}){return g.jsx(PI,{"data-slot":"sheet-description",className:Ye("text-sm text-muted-foreground",e),...t})}function O1({...e}){return g.jsx($ne,{"data-slot":"dropdown-menu",...e})}function D1({...e}){return g.jsx(Hne,{"data-slot":"dropdown-menu-trigger",...e})}function P1({className:e,sideOffset:t=4,...n}){return g.jsx(Une,{children:g.jsx(Wne,{"data-slot":"dropdown-menu-content",sideOffset:t,className:Ye("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),...n})})}function yo({className:e,inset:t,variant:n="default",...r}){return g.jsx(Vne,{"data-slot":"dropdown-menu-item","data-inset":t,"data-variant":n,className:Ye("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 Z_({className:e,children:t,checked:n,...r}){return g.jsxs(Yne,{"data-slot":"dropdown-menu-checkbox-item",className:Ye("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:[g.jsx("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:g.jsx(Kne,{children:g.jsx(ta,{className:"size-4"})})}),t]})}function jm({className:e,inset:t,...n}){return g.jsx(qne,{"data-slot":"dropdown-menu-label","data-inset":t,className:Ye("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",e),...n})}function Q_({className:e,...t}){return g.jsx(Gne,{"data-slot":"dropdown-menu-separator",className:Ye("-mx-1 my-1 h-px bg-border",e),...t})}const Sie={claude:"Claude Code",codex:"Codex"},zN=["claude","codex"];function Jv(e){return Sie[e]}function LB(e,t){return zN.indexOf(e)-zN.indexOf(t)}function $0(e){return e.provider??"claude"}const H0=60*1e3,U0=60*H0,xie=24*U0;function IB(e,t=Date.now()){const n=t-e;if(n<H0)return"刚刚";if(n<U0)return`${Math.floor(n/H0)} 分钟前`;if(n<xie)return`${Math.floor(n/U0)} 小时前`;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 BN={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 W0(e){return e.kind!=="terminal"?BN[e.state]:e.state==="terminated"?BN.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 Eie({session:e}){const t=W0(e);return g.jsx("span",{className:Ye("inline-block size-2 rounded-full shrink-0",t.dot),"aria-label":`会话状态:${t.label}`,role:"status"})}function Cie({mode:e}){if(e!=="pty"&&e!=="json")return null;const t=e==="json"?"聊天视图":"终端视图",n=e==="json"?Mx:Dx;return g.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:g.jsx(n,{className:"size-3.5","aria-hidden":"true"})})}function kie({session:e,selected:t,now:n,onClick:r,onRename:i,onTerminate:s}){const o=e.lastActive,l=e.cwd??e.name??e.sessionId,u=Tv(e.name),d=Xx(e),h=e.nameLocked&&e.name?e.name:d||(u==="New Session"?e.sessionId.slice(0,8):u),p=!!e.mode||!!e.provider||o!==void 0,y=o!==void 0?IB(o,n):null,v=e.mode==="pty"&&e.ptyOwner==="local-terminal",_=e.kind==="terminal"?"终止终端":v?"断开远程连接":"终止会话";return g.jsxs("li",{className:Ye("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&&g.jsx("span",{className:"dev-sidebar-active-indicator absolute left-0 top-0 bottom-0 w-[2px]","aria-hidden":"true"}),g.jsxs("button",{type:"button",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:[g.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[g.jsx(Eie,{session:e}),g.jsx("span",{className:"text-sm font-normal truncate flex-1",title:l,children:h})]}),p&&g.jsxs("span",{className:"flex items-center gap-1.5 text-xs leading-5 h-5",children:[e.mode&&g.jsx(Cie,{mode:e.mode}),e.mode&&g.jsx("span",{className:"text-muted-foreground/60 shrink-0","aria-hidden":"true",children:"·"}),e.provider&&e.kind!=="terminal"&&g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"font-mono text-muted-foreground shrink-0",children:Jv(e.provider)}),g.jsx("span",{className:"text-muted-foreground/60 shrink-0","aria-hidden":"true",children:"·"})]}),g.jsx("span",{className:Ye("shrink-0",W0(e).text),children:W0(e).label}),y&&g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"text-muted-foreground/60 shrink-0","aria-hidden":"true",children:"·"}),g.jsx("span",{className:"text-muted-foreground shrink-0 tabular-nums",children:y})]})]})]}),(i||s)&&g.jsxs(O1,{children:[g.jsx(D1,{asChild:!0,children:g.jsx(_t,{variant:"ghost",size:"icon-xs",className:"size-11 md:size-6","aria-label":"会话操作","data-slot":"session-row-menu-trigger",onClick:w=>w.stopPropagation(),children:g.jsx(y8,{"aria-hidden":"true"})})}),g.jsxs(P1,{align:"end","data-slot":"session-row-menu",children:[i&&g.jsx(yo,{"data-slot":"session-row-rename-item",onSelect:w=>{w.stopPropagation(),i()},children:"重命名"}),s&&g.jsx(yo,{variant:"destructive","data-slot":"session-row-terminate-item",onSelect:w=>{w.stopPropagation(),s()},children:_})]})]})]})}function Sc({...e}){return g.jsx(s1,{"data-slot":"dialog",...e})}function Tie({...e}){return g.jsx(o1,{"data-slot":"dialog-portal",...e})}function Rie({...e}){return g.jsx(Dv,{"data-slot":"dialog-close",...e})}function Aie({className:e,...t}){return g.jsx(a1,{"data-slot":"dialog-overlay",className:Ye("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 xc({className:e,children:t,showCloseButton:n=!0,focusSurfaceOnOpen:r=!1,onOpenAutoFocus:i,...s}){return g.jsxs(Tie,{"data-slot":"dialog-portal",children:[g.jsx(Aie,{}),g.jsxs(l1,{"data-slot":"dialog-content",className:Ye("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:o=>{i==null||i(o),!(!r||o.defaultPrevented)&&(o.preventDefault(),o.currentTarget.focus({preventScroll:!0}))},...s,children:[t,n&&g.jsxs(Dv,{"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:[g.jsx(vc,{}),g.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Ec({className:e,...t}){return g.jsx("div",{"data-slot":"dialog-header",className:Ye("flex flex-col gap-2 text-center sm:text-left",e),...t})}function Gu({className:e,showCloseButton:t=!1,children:n,...r}){return g.jsxs("div",{"data-slot":"dialog-footer",className:Ye("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end max-sm:[&_button]:min-h-11",e),...r,children:[n,t&&g.jsx(Dv,{asChild:!0,children:g.jsx(_t,{variant:"outline",children:"Close"})})]})}function cl({className:e,...t}){return g.jsx(DI,{"data-slot":"dialog-title",className:Ye("text-lg leading-none font-semibold",e),...t})}function uc({className:e,...t}){return g.jsx(PI,{"data-slot":"dialog-description",className:Ye("text-sm text-muted-foreground",e),...t})}function ul(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 Nie({session:e,now:t,disabled:n,loading:r,onClick:i,modeTag:s}){const o=g.jsx(Mie,{title:e.title,modeTag:s}),l=g.jsx("span",{className:"text-xs text-muted-foreground tabular-nums",children:IB(e.updatedAt,t)}),u=g.jsxs("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[o,l]});return g.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:g.jsxs("button",{type:"button",onClick:i,disabled:n,"data-slot":"history-row-primary",className:Ye("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,g.jsx(W9,{className:Ye("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 Mie({title:e,modeTag:t}){return g.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[g.jsx("span",{className:"text-sm font-normal truncate min-w-0",title:e,children:e}),t&&g.jsx(Oie,{mode:t})]})}function Oie({mode:e}){const t=e==="json"?"聊天视图":"终端视图",n=e==="json"?Mx:Dx;return g.jsx("span",{"data-slot":"history-mode-tag","data-mode":e,role:"img","aria-label":t,title:t,className:Ye("inline-flex size-5 shrink-0 items-center justify-center rounded border","border-border bg-muted/50 text-muted-foreground"),children:g.jsx(n,{className:"size-3","aria-hidden":"true"})})}function zB({providerLabel:e}){return g.jsx("div",{className:"grid min-w-0 gap-4","data-slot":"bypass-permission-warning",role:"alert",children:g.jsxs("div",{className:"flex min-w-0 items-start gap-3 text-sm",children:[g.jsx(_7,{className:"mt-0.5 size-5 shrink-0 text-destructive","aria-hidden":"true"}),g.jsxs("div",{className:"grid min-w-0 gap-2",children:[g.jsxs("p",{className:"font-medium text-foreground",children:[e," 将不再请求工具审批。"]}),g.jsx("p",{className:"text-muted-foreground",children:"Agent 可以直接执行命令、修改或删除文件,并可能绕过部分沙箱保护。"})]})]})})}function Die({now:e}){const t=$t(F=>F.historySessions),[n,r]=b.useState(null),[i,s]=b.useState(null),[o,l]=b.useState("json"),[u,d]=b.useState("default"),[h,p]=b.useState(!1),[y,v]=b.useState(!1),[_,w]=b.useState(new Set),[x,E]=b.useState(new Set),k=Qs(),R=b.useMemo(()=>{const F=new Map;for(const O of t){const M=$0(O);let B=F.get(M);B||(B=new Map,F.set(M,B));const L=BB(O.projectDir),N=B.get(L);N?N.sessions.push(O):B.set(L,{dir:L,sessions:[O]})}return Array.from(F.entries()).sort(([O],[M])=>LB(O,M)).map(([O,M])=>({provider:O,sessions:Array.from(M.values()).flatMap(B=>B.sessions),projects:Array.from(M.values()).map(B=>({dir:B.dir,shortDir:Tv(B.dir),sessions:B.sessions}))}))},[t]);function A(F){s(F),l(Pie(F)),d("default")}async function I(F,O,M){if(n)return;const B=Pt;if(!B){nt.error("请先连接开发机");return}r(F.id);const L=$0(F);try{const N=await B.createSession({cwd:F.projectDir,mode:O,provider:L,resumeSessionId:F.id,...M?{permissionMode:M}:{}});if(N.error||!N.sessionId){nt.error(`恢复失败:${N.error??"未知错误"}`);return}const V={sessionId:N.sessionId,state:"idle",mode:N.mode??O,provider:N.provider??"claude"};$t.getState().addSession(V),k(`/chat/${N.sessionId}?mode=${N.mode??O}`),s(null)}catch(N){nt.error(`恢复失败:${N instanceof Error?N.message:String(N)}`)}finally{r(null)}}function T(){const F=Pt;!F||h||(p(!0),F.requestSessionHistory().then(O=>$t.getState().setHistorySessions(O)).catch(O=>{nt.error(O instanceof Error?O.message:String(O))}).finally(()=>{p(!1)}))}function H(F,O){const M=jN(F,O);E(B=>{const L=new Set(B);return L.has(M)?L.delete(M):L.add(M),L})}function D(F){w(O=>{const M=new Set(O);return M.has(F)?M.delete(F):M.add(F),M})}const W=t.length>0,U=i?jB():[];return g.jsxs("div",{"data-slot":"history-list",className:"flex flex-col",children:[g.jsxs("div",{className:"flex min-h-[36px] w-full items-center gap-1.5 px-4 py-1.5",children:[g.jsxs("button",{type:"button",onClick:()=>W&&v(F=>!F),disabled:!W,"aria-expanded":W?y:void 0,"data-slot":"history-section-header","data-expanded":y,className:Ye("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:[g.jsxs("h3",{className:"min-w-0 text-sm font-semibold text-foreground",children:["全部会话",W?g.jsxs("span",{className:"ml-1 text-muted-foreground/70 font-normal",children:["· ",t.length]}):null]}),W?g.jsx(Zh,{className:Ye("size-3.5 shrink-0 text-muted-foreground/80 transition-transform",y&&"rotate-90"),"aria-hidden":"true"}):null]}),g.jsx(_t,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"刷新全部会话","aria-busy":h,title:"刷新",onClick:T,disabled:h,"data-slot":"history-refresh",children:g.jsx(Ox,{className:Ye("size-3.5",h&&"animate-spin"),"aria-hidden":"true"})})]}),!W&&g.jsx("div",{className:"px-4 py-3 text-sm text-muted-foreground/70","data-slot":"history-empty",children:"暂无会话记录"}),W&&y&&g.jsx("ul",{role:"list",className:"flex flex-col",children:R.map(F=>{const O=_.has(F.provider);return g.jsxs("li",{children:[g.jsxs("button",{type:"button",onClick:()=>D(F.provider),"aria-expanded":!O,"data-slot":"history-provider-header","data-expanded":!O,className:Ye("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:[g.jsx("span",{className:"font-mono",children:Jv(F.provider)}),g.jsx("span",{className:"h-px flex-1 bg-border/70","aria-hidden":"true"}),g.jsx("span",{className:"tabular-nums",children:F.sessions.length}),g.jsx(Zh,{className:Ye("size-3.5 shrink-0 text-muted-foreground/80 transition-transform",!O&&"rotate-90"),"aria-hidden":"true"})]}),!O&&g.jsx("ul",{role:"list",className:"flex flex-col",children:F.projects.map(M=>{const B=jN(F.provider,M.dir),L=x.has(B);return g.jsxs("li",{children:[g.jsxs("button",{type:"button",onClick:()=>H(F.provider,M.dir),"aria-expanded":L,"data-slot":"history-group-header","data-expanded":L,className:Ye("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:[g.jsx("span",{className:"text-sm font-mono truncate flex-1 min-w-0",title:M.dir,children:M.shortDir}),g.jsx("span",{className:"text-xs text-muted-foreground/80 tabular-nums shrink-0",children:M.sessions.length}),g.jsx(Zh,{className:Ye("size-3.5 shrink-0 text-muted-foreground/80 transition-transform",L&&"rotate-90"),"aria-hidden":"true"})]}),L&&g.jsx("ul",{role:"list",className:"flex flex-col",children:M.sessions.map(N=>g.jsx(Nie,{session:N,now:e,disabled:n!==null,loading:n===N.id,onClick:()=>A(N),modeTag:N.preferredMode},N.id))})]},B)})})]},F.provider)})}),g.jsx(Lie,{session:i,open:i!==null,modes:U,mode:o,permissionMode:u,submitting:n!==null,onOpenChange:F=>{F||s(null)},onModeChange:l,onPermissionModeChange:d,onConfirm:()=>{i&&I(i,o,u)}})]})}function jN(e,t){return`${e}:${BB(t)}`}function BB(e){const t=e.trim();return!t||t==="/"?t||"/":t.replace(/\/+$/,"")||"/"}function jB(){return["json","pty"]}function Pie(e){const t=jB();return e.preferredMode&&t.includes(e.preferredMode)?e.preferredMode:t[0]??"json"}function Lie({session:e,open:t,modes:n,mode:r,permissionMode:i,submitting:s,onOpenChange:o,onModeChange:l,onPermissionModeChange:u,onConfirm:d}){const[h,p]=b.useState(!1),y=i==="bypassPermissions",v=ul("(min-width: 768px)");b.useEffect(()=>{t||p(!1)},[t]);const _=h?g.jsx(zB,{providerLabel:e?Jv($0(e)):"Agent"}):g.jsxs("div",{className:"grid min-w-0 gap-4",children:[g.jsxs("div",{className:"grid min-w-0 gap-2",children:[g.jsx("span",{className:"text-sm font-medium",children:"模式"}),g.jsxs("div",{role:"radiogroup","aria-label":"恢复模式",className:"grid min-w-0 grid-cols-2 gap-2",children:[n.includes("json")&&g.jsx(FN,{checked:r==="json",label:"聊天",icon:g.jsx(Mx,{className:"size-4","aria-hidden":"true"}),disabled:s,onClick:()=>l("json")}),n.includes("pty")&&g.jsx(FN,{checked:r==="pty",label:"终端",icon:g.jsx(Dx,{className:"size-4","aria-hidden":"true"}),disabled:s,onClick:()=>l("pty")})]})]}),g.jsxs("div",{className:"grid min-w-0 gap-2",children:[g.jsx("span",{className:"text-sm font-medium",children:"权限模式"}),g.jsxs("div",{role:"radiogroup","aria-label":"权限模式",className:"grid min-w-0 gap-2",children:[g.jsx(J_,{checked:i==="default",label:"严格审批",description:"所有需要权限的操作都要确认。",disabled:s,onClick:()=>u("default")}),g.jsx(J_,{checked:i==="auto",label:"自动判定",description:"交给 Agent CLI 的原生策略判断。",disabled:s,onClick:()=>u("auto")}),g.jsx(J_,{checked:i==="bypassPermissions",label:"跳过全部审批",description:"危险模式,会跳过工具审批和部分沙箱保护。",destructive:!0,disabled:s,onClick:()=>u("bypassPermissions")})]})]})]}),w=g.jsxs(g.Fragment,{children:[g.jsx(_t,{type:"button",variant:"ghost",disabled:s,onClick:()=>{h?p(!1):o(!1)},children:h?"返回":"取消"}),g.jsx(_t,{type:"button",variant:h?"destructive":"default",disabled:s,onClick:()=>{if(y&&!h){p(!0);return}d()},"data-slot":h?"bypass-permission-confirm":void 0,children:s?"恢复中...":h?"确认":"恢复"})]});return v?g.jsx(Sc,{open:t,onOpenChange:o,children:g.jsxs(xc,{focusSurfaceOnOpen:!0,className:"min-w-0 sm:max-w-md","data-slot":"history-restore-dialog",children:[g.jsxs(Ec,{className:"min-w-0",children:[g.jsx(cl,{children:h?"跳过全部审批?":"恢复会话"}),g.jsx(uc,{className:"min-w-0 truncate pr-10 sm:pr-0",title:e==null?void 0:e.title,children:(e==null?void 0:e.title)??""})]}),_,g.jsx(Gu,{children:w})]})}):g.jsx(Xv,{open:t,onOpenChange:o,children:g.jsxs(Zv,{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:[g.jsxs(M1,{className:"min-w-0 shrink-0 px-4 pb-2 pt-4 text-left",children:[g.jsx(Qv,{children:h?"跳过全部审批?":"恢复会话"}),g.jsx(wie,{className:"min-w-0 truncate pr-10",title:e==null?void 0:e.title,children:(e==null?void 0:e.title)??""})]}),g.jsx("div",{className:"min-h-0 overflow-y-auto px-4 pb-3","data-slot":"history-restore-body",children:_}),g.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:g.jsx("div",{className:"flex flex-col-reverse gap-2 [&_button]:min-h-11 [&_button]:w-full",children:w})})]})})}function FN({checked:e,label:t,icon:n,disabled:r,onClick:i}){return g.jsxs("button",{type:"button",role:"radio","aria-label":t,"aria-checked":e,disabled:r,onClick:i,className:Ye("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,g.jsx("span",{className:"min-w-0 text-center",children:t}),g.jsx(ta,{className:Ye("size-3.5 justify-self-end transition-opacity",e?"opacity-100":"opacity-0"),"aria-hidden":"true"})]})}function J_({checked:e,label:t,description:n,destructive:r,disabled:i,onClick:s}){return g.jsxs("button",{type:"button",role:"radio","aria-label":t,"aria-checked":e,disabled:i,onClick:s,className:Ye("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:[g.jsx("span",{className:Ye("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&&g.jsx("span",{className:Ye("size-2 rounded-full",r?"bg-destructive":"bg-primary")})}),g.jsxs("span",{className:"grid min-w-0 gap-1",children:[g.jsx("span",{className:Ye("text-sm font-medium",r?"text-destructive":"text-foreground"),children:t}),g.jsx("span",{className:"min-w-0 break-words text-xs leading-5 text-muted-foreground",children:n})]}),e&&g.jsx(ta,{className:Ye("mt-0.5 size-4 shrink-0",r?"text-destructive":"text-primary"),"aria-hidden":"true"})]})}function Iie({...e}){return g.jsx(Dre,{"data-slot":"select",...e})}function zie({...e}){return g.jsx(Lre,{"data-slot":"select-value",...e})}function Bie({className:e,size:t="default",children:n,...r}){return g.jsxs(Pre,{"data-slot":"select-trigger","data-size":t,className:Ye("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,g.jsx(Ire,{asChild:!0,children:g.jsx(pl,{className:"size-4 opacity-50"})})]})}function jie({className:e,children:t,position:n="item-aligned",align:r="center",...i}){return g.jsx(zre,{children:g.jsxs(Bre,{"data-slot":"select-content",className:Ye("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,...i,children:[g.jsx($ie,{}),g.jsx(jre,{className:Ye("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),g.jsx(Hie,{})]})})}function Fie({className:e,children:t,...n}){return g.jsxs(Fre,{"data-slot":"select-item",className:Ye("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:[g.jsx("span",{"data-slot":"select-item-indicator",className:"absolute right-2 flex size-3.5 items-center justify-center",children:g.jsx(Hre,{children:g.jsx(ta,{className:"size-4"})})}),g.jsx($re,{children:t})]})}function $ie({className:e,...t}){return g.jsx(Ure,{"data-slot":"select-scroll-up-button",className:Ye("flex cursor-default items-center justify-center py-1",e),...t,children:g.jsx(Nx,{className:"size-4"})})}function Hie({className:e,...t}){return g.jsx(Wre,{"data-slot":"select-scroll-down-button",className:Ye("flex cursor-default items-center justify-center py-1",e),...t,children:g.jsx(pl,{className:"size-4"})})}function L1(e){return!e||e.endsWith("/")?e:`${e}/`}function Uie(e){const t=e.split("@").pop()??"",n=t.lastIndexOf("/");return n>=0?t.slice(n+1).toLowerCase():t.toLowerCase()}function Wie(e){const t=e.split("@").pop()??"",n=t.lastIndexOf("/");return n>=0?t.slice(0,n+1):""}function qie(e,t,n){var o;if(t==="insert")return{currentPath:Wie(e)||"./",query:Uie(e)};if(!e)return{currentPath:"./",query:""};const r=e.replace(/\/+$/,"")||"/";if(e.endsWith("/")||r===(n==null?void 0:n.baseCwd)||((o=n==null?void 0:n.knownDirs)==null?void 0:o.has(r)))return{currentPath:L1(r),query:""};const s=e.lastIndexOf("/");return{currentPath:s>=0?e.slice(0,s+1):"./",query:s>=0?e.slice(s+1).toLowerCase():e.toLowerCase()}}function Vie(e,t){if(t.startsWith("/"))return t.replace(/\/+$/,"")||"/";if(!e)return"";const n=t.replace(/^\.\//,"").replace(/\/+$/,"");return n?`${e}/${n}`:e}function Yie(e,t){return`${L1(e)}${t.name}${t.isDir?"/":""}`}function $N(e,t){const n=e.trim().replace(/\/+$/,"")||"/",r=t.trim().replace(/^\/+|\/+$/g,"");return!n.startsWith("/")||!r||t.trim().startsWith("/")||r.split("/").some(i=>i===""||i==="."||i==="..")?null:n==="/"?`/${r}`:`${n}/${r}`}const FB=b.forwardRef(function({filter:t,onSelect:n,onCreateDirectory:r,mode:i="insert",placement:s="floating",dirsOnly:o=!1,title:l},u){const d=ii($=>$.tree),h=ii($=>$.cwd),p=ii($=>$.homePath),y=i==="insert"?h:p||h,v=b.useMemo(()=>new Set(d.keys()),[d]),_=b.useMemo(()=>qie(t,i,{baseCwd:y,knownDirs:v}),[t,i,y,v]),w=_.currentPath,x=b.useMemo(()=>Vie(y,w),[y,w]),E=_.query,k=b.useRef(new Set),[R,A]=b.useState(!1),[I,T]=b.useState(""),[H,D]=b.useState(!1);b.useEffect(()=>{if(!x||d.has(x)||k.current.has(x))return;const $=Pt;if(!$)return;let P=!1;return k.current.add(x),$.requestDirectoryList(x).then(q=>{P||ii.getState().setDirEntries(q.path,q.entries)}).catch(()=>{P||ii.getState().setDirEntries(x,[])}).finally(()=>{k.current.delete(x)}),()=>{P=!0}},[x,d]);const W=!d.has(x),U=b.useMemo(()=>{let $=d.get(x)??[];return o&&($=$.filter(P=>P.isDir)),E&&($=$.filter(P=>P.name.toLowerCase().includes(E))),$},[d,x,E,o]),[F,O]=b.useState(0);b.useEffect(()=>O(0),[w,E]),b.useEffect(()=>{A(!1),T("")},[x]),b.useEffect(()=>{F>=U.length&&U.length>0&&O(U.length-1)},[U.length,F]);const M=b.useRef(null),B=b.useRef(!1);b.useEffect(()=>{var P;if(!B.current)return;B.current=!1;const $=(P=M.current)==null?void 0:P.querySelector(`[data-entry-index="${F}"]`);$==null||$.scrollIntoView({block:"nearest"})},[F]);const L=b.useCallback($=>{const P=Yie(w,$);return i==="insert"?P.replace(/^\.\//,""):P},[w,i]);async function N(){const $=$N(x,I);if(!(!$||!r)){D(!0);try{const P=await r($);if(!P)return;T(""),A(!1),n(L1(P))}finally{D(!1)}}}b.useImperativeHandle(u,()=>({handleKey($){return U.length===0?!1:$.key==="ArrowDown"?(B.current=!0,O(P=>Math.min(U.length-1,P+1)),!0):$.key==="ArrowUp"?(B.current=!0,O(P=>Math.max(0,P-1)),!0):$.key==="Enter"&&!$.nativeEvent.isComposing?(n(L(U[F])),!0):!1}}),[U,F,L,n]);const V=s==="inline"?"relative w-full bg-popover border border-border rounded-md overflow-hidden":i==="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",Y=s==="inline"?"h-44 overflow-y-auto overscroll-contain":i==="select"?"max-h-44 overflow-y-auto overscroll-contain":"max-h-60 overflow-y-auto overscroll-contain";return g.jsxs("div",{className:V,"data-slot":"file-path-picker","data-mode":i,"data-placement":s,children:[i==="select"&&l?g.jsxs("div",{className:"border-b border-border/70 px-3 py-2",children:[g.jsxs("div",{className:"flex items-center justify-between gap-3",children:[g.jsx("span",{className:"text-xs text-muted-foreground",children:l}),r?g.jsx("button",{type:"button",className:"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 disabled:cursor-not-allowed disabled:opacity-50",disabled:!x||H,onClick:()=>A($=>!$),children:"新建目录"}):null]}),R?g.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[g.jsx("input",{type:"text",value:I,onChange:$=>T($.target.value),onKeyDown:$=>{$.key==="Enter"&&!$.nativeEvent.isComposing&&($.preventDefault(),N()),$.key==="Escape"&&(A(!1),T(""))},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}),g.jsx("button",{type:"button",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:!$N(x,I)||H,onClick:()=>void N(),children:H?"创建中...":"创建目录"})]}):null]}):null,g.jsx("div",{className:Y,children:U.length===0?g.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:W?"加载中...":"没有匹配的路径"}):g.jsx("ul",{ref:M,role:"list",className:"flex flex-col",children:U.map(($,P)=>g.jsx("li",{children:g.jsx("button",{type:"button",onClick:()=>n(L($)),onMouseEnter:()=>O(P),className:Ye("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",P===F&&"bg-[color-mix(in_srgb,var(--primary)_15%,transparent)]",$.isDir&&"font-semibold"),"data-slot":"file-entry","data-entry-type":$.isDir?"dir":"file","data-entry-index":P,children:g.jsxs("span",{className:"font-mono text-[13px]",children:[$.name,$.isDir?"/":""]})})},$.name))})})]})}),HN="工作目录不存在或不可访问:",Kie=[{value:"default",label:"严格审批"},{value:"auto",label:"自动判定"},{value:"acceptEdits",label:"自动接受编辑"},{value:"plan",label:"只读规划"},{value:"bypassPermissions",label:"跳过全部审批"}],$B=[{value:"default",label:"严格审批"},{value:"auto",label:"自动判定"},{value:"bypassPermissions",label:"跳过全部审批"}],ea={claude:"Claude Code",codex:"Codex"};function Gie(e,t){return t!==Zr.PATH_NOT_FOUND||!e.startsWith(HN)?null:e.slice(HN.length).trim()||null}function Zg(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 Xie(e,t){return t.title?t.disabled?`${ea[e]}:${t.title}`:`${ea[e]} 路径:${t.title}`:`${ea[e]}:${t.label}`}function Zie(e,t){return e!=="codex"||$B.some(n=>n.value===t)?t:"default"}async function Qie({relay:e,agentCli:t,form:n,timeoutMs:r=Kx}){var d,h;const i=n.cwd.trim();if(!i)return{type:"validation_error",message:"请输入工作目录"};if(!e)return{type:"relay_missing",message:"请先连接开发机"};if(Zg(n.provider,t).disabled){const p=(d=t==null?void 0:t[n.provider])==null?void 0:d.error;return{type:"provider_unavailable",message:p?`${ea[n.provider]} 不可用:${p}`:`${ea[n.provider]} 暂不可用`}}const o=n.mode,l=n.provider,u=n.name.trim();try{const p=await e.createSession({kind:"agent",cwd:i,name:u||void 0,mode:o,provider:l,permissionMode:n.permissionMode},r);if(p.error||!p.sessionId){const w=Gie(p.error??"",p.errorCode);return w?{type:"missing_cwd",path:w,message:"找不到这个工作目录"}:{type:"create_error",message:`创建失败:${p.error??"未知错误"}`}}const y=p.mode??o,v=((h=p.name)==null?void 0:h.trim())||void 0;return{type:"success",session:{sessionId:p.sessionId,...p.kind!==void 0?{kind:p.kind}:{},name:v,...p.nameLocked!==void 0?{nameLocked:p.nameLocked}:{},state:"idle",mode:y,provider:p.provider??l,...p.ptyOwner!==void 0?{ptyOwner:p.ptyOwner}:{}},route:`/chat/${p.sessionId}?mode=${y}`}}catch(p){return{type:"exception",message:p instanceof Error?p.message:String(p)}}}async function Jie({relay:e,timeoutMs:t=Kx}){var n;if(!e)return{type:"relay_missing",message:"请先连接开发机"};try{const r=await e.createSession({kind:"terminal",mode:"pty"},t);return r.error||!r.sessionId?{type:"create_error",message:`创建终端失败:${r.error??"未知错误"}`}:{type:"success",session:{sessionId:r.sessionId,kind:"terminal",name:((n=r.name)==null?void 0:n.trim())||void 0,...r.nameLocked!==void 0?{nameLocked:r.nameLocked}:{},state:"idle",mode:"pty",provider:r.provider??"claude",...r.ptyOwner!==void 0?{ptyOwner:r.ptyOwner}:{}},route:`/chat/${r.sessionId}?mode=pty`}}catch(r){return{type:"exception",message:r instanceof Error?r.message:String(r)}}}function ese({agentCli:e,provider:t,isDesktop:n,editingCliProvider:r,cliPathInput:i,savingCliPath:s,onProviderChange:o,onOpenCliPathEditor:l,onCliPathInputChange:u,onCancelCliPathEditor:d,onSaveCliPath:h}){const p=Zg("claude",e),y=Zg("codex",e),v=e==null?void 0:e[t];return g.jsxs("section",{"aria-label":"Agent CLI",className:"flex min-w-0 flex-col gap-2",children:[g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsx("span",{className:"text-sm",children:"Agent CLI"}),g.jsx("span",{className:"text-xs text-muted-foreground",children:"选择要启动的 CLI"})]}),g.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-2 sm:grid-cols-2",children:[g.jsx(UN,{provider:"claude",selected:t==="claude",status:p,agentCliLoaded:!!e,onClick:()=>o("claude")}),g.jsx(UN,{provider:"codex",selected:t==="codex",status:y,agentCliLoaded:!!e,onClick:()=>o("codex")})]}),g.jsx("div",{className:"relative min-w-0 rounded-md border border-border bg-muted/20 px-3 py-2.5 md:p-3","data-slot":"agent-cli-path-card",children:r===t?g.jsx(tse,{provider:r,agentCli:e,cliPathInput:i,savingCliPath:s,onCliPathInputChange:u,onCancel:d,onSave:h}):g.jsx(nse,{provider:t,selectedCli:v,isDesktop:n,onOpenCliPathEditor:l})})]})}function UN({provider:e,selected:t,status:n,agentCliLoaded:r,onClick:i}){return g.jsxs(qf,{children:[g.jsx(Vf,{asChild:!0,children:g.jsxs("button",{type:"button","aria-pressed":t,"aria-label":ea[e],onClick:i,className:Ye("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",t?"border-primary/70 bg-primary/10":"border-border bg-muted/20"),children:[g.jsx("span",{className:"text-sm font-medium",children:ea[e]}),g.jsx("span",{className:Ye("text-xs text-muted-foreground",n.disabled&&r&&"text-destructive"),children:n.label})]})}),g.jsx(Yf,{side:"top",className:"max-w-[min(520px,calc(100vw-2rem))]",children:g.jsx("span",{className:"break-all font-mono text-xs",children:Xie(e,n)})})]})}function tse({provider:e,agentCli:t,cliPathInput:n,savingCliPath:r,onCliPathInputChange:i,onCancel:s,onSave:o}){return g.jsxs(g.Fragment,{children:[g.jsx("p",{className:"mb-1 text-xs text-muted-foreground",children:"CLI 路径"}),g.jsxs("div",{className:"flex min-w-0 flex-col gap-2 sm:flex-row sm:items-center",children:[g.jsxs("label",{className:"min-w-0 flex-1",children:[g.jsx("span",{className:"sr-only",children:"CLI 路径"}),g.jsx("input",{type:"text",list:`agent-cli-path-${e}`,value:n,onChange:l=>i(l.target.value),onKeyDown:l=>{l.key==="Enter"&&(l.preventDefault(),o()),l.key==="Escape"&&(l.preventDefault(),s())},placeholder:e==="claude"?"/path/to/claude":"/path/to/codex",className:"min-h-11 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 md:h-10 md:min-h-0 md:text-sm"}),g.jsx("datalist",{id:`agent-cli-path-${e}`,children:((t==null?void 0:t[e].suggestions)??[]).map(l=>g.jsx("option",{value:l},l))})]}),g.jsxs("div",{className:"flex shrink-0 justify-end gap-2",children:[g.jsx(_t,{type:"button",variant:"ghost",className:"min-h-11 shrink-0 rounded px-2.5 text-xs font-medium text-muted-foreground hover:text-foreground md:h-8 md:min-h-0",onClick:s,disabled:r,children:"取消"}),g.jsx(_t,{type:"button",className:"min-h-11 shrink-0 rounded px-2.5 text-xs font-medium md:h-8 md:min-h-0",onClick:o,disabled:r||!n.trim(),children:r?"保存中...":"保存路径"})]})]})]})}function nse({provider:e,selectedCli:t,isDesktop:n,onOpenCliPathEditor:r}){return n?g.jsxs(g.Fragment,{children:[g.jsx("p",{className:"mb-1 text-xs text-muted-foreground",children:"CLI 路径"}),g.jsxs("div",{className:"flex min-w-0 flex-col gap-2 md:flex-row md:items-center",children:[g.jsx("p",{className:Ye("flex h-10 min-w-0 flex-1 items-center truncate font-mono text-sm",t!=null&&t.available?"text-foreground":"text-destructive"),title:(t==null?void 0:t.command)??(t==null?void 0:t.error),children:(t==null?void 0:t.command)??(t==null?void 0:t.error)??"等待检测结果"}),g.jsx(_t,{type:"button",variant:"outline",className:"h-8 min-h-0 shrink-0 self-end rounded px-2.5 text-xs font-medium text-muted-foreground hover:text-foreground sm:self-auto",onClick:()=>r(e),children:"指定路径"})]})]}):g.jsxs(g.Fragment,{children:[g.jsx("p",{className:"pr-11 text-xs text-muted-foreground",children:"CLI 路径"}),g.jsx(_t,{type:"button",variant:"ghost",size:"icon",className:"absolute right-1 top-1/2 size-11 -translate-y-1/2 rounded-full text-muted-foreground hover:bg-accent/70 hover:text-foreground","aria-label":"指定路径",onClick:()=>r(e),children:g.jsx(G8,{className:"size-4","aria-hidden":"true"})}),g.jsx("p",{className:Ye("mt-1 min-w-0 break-all pr-11 font-mono text-sm leading-5",t!=null&&t.available?"text-foreground":"text-destructive"),title:(t==null?void 0:t.command)??(t==null?void 0:t.error),children:(t==null?void 0:t.command)??(t==null?void 0:t.error)??"等待检测结果"})]})}function Bh({open:e,onOpenChange:t}){const[n,r]=b.useState(""),[i,s]=b.useState(""),[o,l]=b.useState("claude"),[u,d]=b.useState("pty"),[h,p]=b.useState("default"),[y,v]=b.useState(!1),[_,w]=b.useState(!1),[x,E]=b.useState(null),[k,R]=b.useState(!1),[A,I]=b.useState(null),[T,H]=b.useState(""),[D,W]=b.useState(!1),U=b.useRef(null),F=b.useRef(e);F.current=e;const O=Qs(),M=ii(Ce=>Ce.homePath),B=ii(Ce=>Ce.agentCli),L=ul("(min-width: 768px)");b.useEffect(()=>{e&&!i&&M&&s(M)},[e,M,i]),b.useEffect(()=>{if(!e||M&&B)return;const Ce=Pt==null?void 0:Pt.requestProxyInfo();Ce&&Ce.then(Me=>{const Ve=ii.getState();Ve.setHomePath(Me.homePath),Ve.setAgentCli(Me.agentCli)}).catch(Me=>{console.error("[create-session-dialog] requestProxyInfo failed",Me)})},[e,M,B]),b.useEffect(()=>{if(!k)return;function Ce(Me){var Qe;const Ve=Me.target;Ve instanceof Node&&((Qe=U.current)!=null&&Qe.contains(Ve))||window.setTimeout(()=>R(!1),0)}return document.addEventListener("pointerdown",Ce,!0),()=>document.removeEventListener("pointerdown",Ce,!0)},[k]);function N(){r(""),s(""),R(!1),l("claude"),d("pty"),p("default"),v(!1),E(null),I(null),H(""),W(!1)}function V(){if(h==="bypassPermissions"){v(!0);return}z()}async function Y(){await z(),F.current&&v(!1)}const $=o==="codex"?$B:Kie,P=Zg(o,B),q=_||D||P.disabled;function K(Ce){const Me=Zie(Ce,h);Me!==h&&p(Me)}async function z(Ce){E(null),w(!0);try{const Me=await Qie({relay:Pt,agentCli:B,form:{cwd:Ce??i,name:n,provider:o,permissionMode:h,mode:u}});if(Me.type==="success"){if($t.getState().addSession(Me.session),!F.current)return;t(!1),N(),O(Me.route);return}if(Me.type==="missing_cwd"&&E(Me.path),nt.error(Me.message),Me.type==="validation_error"||Me.type==="relay_missing")return}finally{w(!1)}}async function X(Ce){const Me=Pt;if(!Me)return nt.error("请先连接开发机"),null;try{const Ve=await Me.createDirectory(Ce);return Ve.success?(s(Ve.path),E(null),nt.success("目录已创建"),Ve.path):(nt.error(`目录创建失败:${Ve.error??"未知错误"}`),null)}catch(Ve){return nt.error(Ve instanceof Error?Ve.message:String(Ve)),null}}function ee(Ce){var Ve;const Me=B==null?void 0:B[Ce];I(Ce),H((Me==null?void 0:Me.command)??((Ve=Me==null?void 0:Me.suggestions)==null?void 0:Ve[0])??"")}async function te(){if(!A)return;const Ce=T.trim();if(!Ce){nt.error("请输入 Agent CLI 路径");return}const Me=Pt;if(!Me){nt.error("请先连接开发机");return}W(!0);try{const Ve=await Me.updateAgentCliPath(A,Ce);if(Ve.error||!Ve.agentCli){nt.error(`路径保存失败:${Ve.error??"未知错误"}`);return}ii.getState().setAgentCli(Ve.agentCli),nt.success(`${ea[A]} 路径已保存`),I(null),H("")}catch(Ve){nt.error(Ve instanceof Error?Ve.message:String(Ve))}finally{W(!1)}}function Q(Ce){d(Ce),K(o)}function me(Ce){var Ve;const Me=Ce.relatedTarget;Me instanceof Node&&((Ve=U.current)!=null&&Ve.contains(Me))||window.setTimeout(()=>R(!1),0)}const ve=y?g.jsxs("div",{className:"grid min-w-0 gap-5","data-slot":"bypass-permission-confirmation",children:[g.jsx(zB,{providerLabel:ea[o]}),g.jsxs(Gu,{children:[g.jsx(_t,{type:"button",variant:"ghost",className:"min-h-11 md:min-h-0",onClick:()=>v(!1),disabled:_,children:"返回"}),g.jsx(_t,{type:"button",variant:"destructive",className:"min-h-11 md:min-h-0",onClick:()=>void Y(),disabled:_,"data-slot":"bypass-permission-confirm",children:_?"创建中...":"确认"})]})]}):g.jsxs("form",{className:"flex min-w-0 flex-col gap-4","data-slot":"create-session-form",autoComplete:"off",onSubmit:Ce=>{Ce.preventDefault(),V()},children:[g.jsxs("label",{className:"flex min-w-0 flex-col gap-1",children:[g.jsx("span",{className:"text-sm",children:"名称(可选)"}),g.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:"自动生成"})]}),g.jsxs("div",{ref:U,className:"relative flex min-w-0 flex-col gap-2",onBlur:me,children:[g.jsx("span",{id:"create-session-cwd-label",className:"text-sm",children:"工作目录"}),g.jsx("input",{id:"create-session-cwd",type:"text","aria-labelledby":"create-session-cwd-label",name:"dev-anywhere-session-cwd",autoComplete:"off",autoCorrect:"off",spellCheck:!1,value:i,onFocus:()=>R(!0),onChange:Ce=>{s(Ce.target.value),E(null)},placeholder:"输入绝对路径",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 md:h-9 md:min-h-0 md:text-sm"}),k?g.jsx(FB,{mode:"select",dirsOnly:!0,filter:i,title:"选择下一级目录",onCreateDirectory:X,onSelect:Ce=>{s(Ce),E(null),R(!0)}}):null]}),x?g.jsxs("section",{role:"status","aria-live":"polite",className:"rounded-md border border-primary/50 bg-primary/10 p-3",children:[g.jsx("p",{className:"text-sm font-medium",children:"工作目录不存在"}),g.jsx("p",{className:"mt-1 break-all font-mono text-xs text-muted-foreground",children:x})]}):null,g.jsxs("section",{"aria-label":"交互方式",className:"flex min-w-0 flex-col gap-2",children:[g.jsx("span",{className:"text-sm",children:"交互方式"}),g.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-2 sm:grid-cols-2",children:[g.jsxs("button",{type:"button","aria-pressed":u==="pty",onClick:()=>Q("pty"),className:Ye("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:[g.jsx("span",{className:"text-sm font-medium",children:"终端模式"}),g.jsx("span",{className:"text-xs text-muted-foreground",children:"像本地终端一样操作"})]}),g.jsxs("button",{type:"button","aria-pressed":u==="json",onClick:()=>Q("json"),className:Ye("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:[g.jsx("span",{className:"text-sm font-medium",children:"聊天模式"}),g.jsx("span",{className:"text-xs text-muted-foreground",children:"气泡式对话,支持 Voice Pilot"})]})]})]}),g.jsx(ese,{agentCli:B,provider:o,isDesktop:L,editingCliProvider:A,cliPathInput:T,savingCliPath:D,onProviderChange:Ce=>{l(Ce),K(Ce)},onOpenCliPathEditor:ee,onCliPathInputChange:H,onCancelCliPathEditor:()=>{I(null),H("")},onSaveCliPath:()=>void te()}),g.jsxs("label",{className:"flex min-w-0 flex-col gap-2",children:[g.jsx("span",{className:"text-sm",children:"权限模式"}),g.jsxs(Iie,{value:h,onValueChange:Ce=>p(Ce),children:[g.jsx(Bie,{className:"w-full",children:g.jsx(zie,{})}),g.jsx(jie,{children:$.map(Ce=>g.jsx(Fie,{value:Ce.value,children:Ce.label},Ce.value))})]})]}),g.jsxs(Gu,{children:[g.jsx(_t,{type:"button",variant:"ghost",className:"min-h-11 md:min-h-0",onClick:()=>t(!1),disabled:_,children:"取消"}),g.jsx(_t,{type:"submit",className:"min-h-11 md:min-h-0",disabled:q,children:_?"创建中...":"创建"})]})]});return L?g.jsx(Sc,{open:e,onOpenChange:t,children:g.jsxs(xc,{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:[g.jsx(Ec,{children:g.jsx(cl,{children:y?"跳过全部审批?":"新建会话"})}),ve]})}):g.jsx(Xv,{open:e,onOpenChange:t,children:g.jsxs(Zv,{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:[g.jsx(M1,{className:"px-0 pb-1 pt-0 text-left",children:g.jsx(Qv,{children:y?"跳过全部审批?":"新建会话"})}),ve]})})}function jh({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),[h,p]=b.useState(!1);b.useEffect(()=>{e&&(l(s),d(null),p(!1))},[s,e]);async function y(v){v.preventDefault();const _=o.trim();if(!_){d("会话标题不能为空");return}if(t){p(!0);try{await i(t,_),r(!1)}catch(w){d(w instanceof Error?w.message:String(w))}finally{p(!1)}}}return g.jsx(Sc,{open:e,onOpenChange:r,children:g.jsx(xc,{className:"sm:max-w-md","data-slot":"session-rename-dialog",children:g.jsxs("form",{className:"grid gap-4",onSubmit:v=>void y(v),children:[g.jsxs(Ec,{children:[g.jsx(cl,{children:"重命名会话"}),g.jsx(uc,{children:"自定义名称会显示在会话列表和顶部标题中。"})]}),g.jsxs("div",{className:"grid gap-2",children:[g.jsx("label",{htmlFor:"session-rename-title",className:"text-sm font-medium",children:"会话标题"}),g.jsx("input",{id:"session-rename-title",value:o,autoFocus:!0,maxLength:100,"aria-invalid":!!u,"aria-describedby":u?"session-rename-error":void 0,className:Ye("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:h,onChange:v=>{l(v.target.value),u&&d(null)}}),u?g.jsx("p",{id:"session-rename-error",className:"text-sm text-destructive",children:u}):null]}),g.jsxs(Gu,{children:[g.jsx(_t,{type:"button",variant:"outline",onClick:()=>r(!1),children:"取消"}),g.jsx(_t,{type:"submit",disabled:h,children:"保存"})]})]})})})}function rse(e){return(e==null?void 0:e.mode)==="pty"&&e.ptyOwner==="local-terminal"}function ise(e){return(e==null?void 0:e.kind)==="terminal"}function sse(e){return rse(e)?{title:"断开远程连接?",description:"这只会断开当前页面和本地终端的连接,本地终端里的 Claude Code/Codex 会继续运行。重新接入前,页面不能继续查看或输入这个会话。",confirmLabel:"断开远程连接",destructive:!1}:ise(e)?{title:"终止终端?",description:"这会停止当前终端进程,并清理这个终端会话的运行状态。终止后不能继续输入,也无法恢复正在执行的命令。",confirmLabel:"终止终端",destructive:!0}:{title:"终止会话?",description:"这会停止当前 Agent 进程,并清理这个会话的运行状态。终止后不能继续输入,也无法恢复正在执行的任务。",confirmLabel:"终止会话",destructive:!0}}function Fm({open:e,session:t,onOpenChange:n,onConfirm:r}){const i=sse(t);function s(){t&&(r(t),n(!1))}return g.jsx(Sc,{open:e,onOpenChange:n,children:g.jsxs(xc,{"data-slot":"session-termination-dialog",children:[g.jsxs(Ec,{children:[g.jsx(cl,{children:i.title}),g.jsx(uc,{children:i.description})]}),g.jsxs(Gu,{children:[g.jsx(_t,{type:"button",variant:"ghost",onClick:()=>n(!1),children:"取消"}),g.jsx(_t,{type:"button",variant:i.destructive?"destructive":"default",onClick:s,"data-slot":"session-termination-confirm",children:i.confirmLabel})]})]})})}function HB(e){var t,n,r,i,s,o,l,u,d,h,p,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"||((h=e.agentStatus)==null?void 0:h.phase)==="tool_use"||((p=e.agentStatus)==null?void 0:p.phase)==="outputting"||((y=e.ptyState)==null?void 0:y.state)==="working"?"working":"idle"}function ose(e){if(e.session.state==="error")return"error";const t=HB(e);return t==="disconnected"?e.session.state:t}function UB({layout:e}){const t=$t(X=>X.sessions),n=$t(X=>X.sessionListLoaded),r=$t(X=>X.agentStatusBySessionId),i=$t(X=>X.ptyStateBySessionId),s=$t(X=>X.renameSession),o=Qt(X=>X.bySessionId),l=_U("/chat/:id"),u=(l==null?void 0:l.params.id)??null,d=Ne(X=>!!X.selectedProxyId),h=Ne(X=>X.proxyListLoaded),p=Ne(X=>X.proxySwitchTarget),y=$t(X=>X.loadingProxyName),v=p!==null||!h||d&&!n,_=(p==null?void 0:p.name)??y,w=_?`正在连接 ${_}...`:"连接中...",x=Qs(),[E,k]=b.useState(!1),[R,A]=b.useState(!1),[I,T]=b.useState(null),[H,D]=b.useState(null),{creatingTerminal:W,createTerminal:U}=WB(),[F,O]=b.useState(new Set),[M,B]=b.useState(()=>Date.now());b.useEffect(()=>{const X=setInterval(()=>B(Date.now()),6e4);return()=>clearInterval(X)},[]);function L(X,ee){x(`/chat/${X}?mode=${ee??"json"}`,{replace:!1})}function N(X){const ee=X.sessionId,te=Pt;if(!te){nt.error("请先连接开发机");return}te.sendControl({type:"session_terminate",sessionId:ee}),$t.getState().removeSession(ee),Qt.getState().clearSession(ee),ee===u&&x("/sessions"),(X==null?void 0:X.mode)==="pty"&&X.ptyOwner==="local-terminal"?nt.info("已断开页面连接,本地终端仍在运行"):nt.info("正在终止会话",{duration:1500})}async function V(X,ee){const te=Pt;if(!te)throw new Error("请先连接开发机");const Q=await te.renameSession(X,ee);if(!Q.success)throw new Error(Q.error??"重命名失败");s(X,Q.name??ee),nt.success("已重命名会话")}function Y(X){O(ee=>{const te=new Set(ee);return te.has(X)?te.delete(X):te.add(X),te})}function $(X){var Q;const ee=X.mode==="json"&&(((Q=o[X.sessionId])==null?void 0:Q.pendingApprovals.some(me=>me.status==="pending"))??!1),te=ose({session:X,agentStatus:r[X.sessionId],ptyState:i[X.sessionId],hasPendingApproval:ee});return te===X.state?X:{...X,state:te}}const P=t.length>0;if(e==="sidebar"&&(v||!d))return g.jsxs(g.Fragment,{children:[g.jsx("div",{className:"px-4 py-3 text-sm text-muted-foreground/70","data-slot":v?"session-list-loading":void 0,role:v?"status":void 0,"aria-live":v?"polite":void 0,children:v?w:"请先连接开发机"}),g.jsx(Bh,{open:E,onOpenChange:k}),g.jsx(Fm,{open:H!==null,session:H,onOpenChange:X=>{X||D(null)},onConfirm:N}),g.jsx(jh,{open:I!==null,sessionId:(I==null?void 0:I.sessionId)??null,initialName:I==null?void 0:I.name,onOpenChange:X=>{X||T(null)},onRename:V})]});if(e==="page"&&v)return g.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:[g.jsx(Jl,{className:"h-5 w-5 animate-spin","aria-hidden":!0}),g.jsx("p",{className:"max-w-[min(24rem,calc(100%-2rem))] truncate text-sm",children:w})]});if(e==="page"&&!d)return g.jsxs("div",{className:"flex flex-col h-full",children:[g.jsx("div",{className:"flex-1",children:g.jsx(tc,{variant:"no-proxy"})}),g.jsx(Bh,{open:E,onOpenChange:k}),g.jsx(Fm,{open:H!==null,session:H,onOpenChange:X=>{X||D(null)},onConfirm:N}),g.jsx(jh,{open:I!==null,sessionId:(I==null?void 0:I.sessionId)??null,initialName:I==null?void 0:I.name,onOpenChange:X=>{X||T(null)},onRename:V})]});const q=g.jsxs("h3",{className:"px-4 pt-3 pb-2 text-sm font-semibold text-foreground","data-slot":"active-section-header",children:["活跃会话",P?g.jsxs("span",{className:"ml-1 text-muted-foreground/70 font-normal",children:["· ",t.length]}):null]}),K=P?g.jsx("ul",{role:"list",className:"flex flex-col w-full min-w-0",children:ase(t).map(X=>g.jsxs("li",{children:[g.jsxs("button",{type:"button",onClick:()=>Y(X.provider),"aria-expanded":!F.has(X.provider),className:Ye("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:[g.jsx("span",{className:"font-mono",children:lse(X.provider)}),g.jsx("span",{className:"h-px flex-1 bg-border/70","aria-hidden":"true"}),g.jsx("span",{className:"tabular-nums",children:X.sessions.length}),g.jsx(Zh,{className:Ye("size-3.5 shrink-0 text-muted-foreground/80 transition-transform",!F.has(X.provider)&&"rotate-90"),"aria-hidden":"true"})]}),F.has(X.provider)?null:g.jsx("ul",{role:"list",className:"flex flex-col",children:X.sessions.map(ee=>g.jsx(kie,{session:$(ee),selected:ee.sessionId===u,now:M,onClick:()=>L(ee.sessionId,ee.mode),onRename:()=>T(ee),onTerminate:()=>D(ee)},ee.sessionId))})]},X.provider))}):g.jsx("div",{className:"px-4 py-3 text-sm text-muted-foreground/70","data-slot":"active-empty",children:"暂无活跃会话"}),z=g.jsx(Die,{now:M});return e==="page"?g.jsxs("div",{className:"flex flex-col h-full",children:[g.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto overscroll-contain",children:[q,K,z]}),g.jsx("div",{className:"px-4 pt-4 pb-[calc(env(safe-area-inset-bottom)+1rem)] border-t border-border",children:g.jsxs(_t,{className:"min-h-11 w-full md:min-h-0","data-slot":"create-session-mobile-trigger",onClick:()=>A(!0),children:[g.jsx(RP,{"aria-hidden":"true"}),"新建"]})}),g.jsx(use,{open:R,creatingTerminal:W,onOpenChange:A,onCreateAgent:()=>{A(!1),k(!0)},onCreateTerminal:()=>void U(()=>A(!1))}),g.jsx(Bh,{open:E,onOpenChange:k}),g.jsx(Fm,{open:H!==null,session:H,onOpenChange:X=>{X||D(null)},onConfirm:N}),g.jsx(jh,{open:I!==null,sessionId:(I==null?void 0:I.sessionId)??null,initialName:I==null?void 0:I.name,onOpenChange:X=>{X||T(null)},onRename:V})]}):g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"dev-sidebar-scroll h-full overflow-y-auto overscroll-contain",children:[q,K,z]}),g.jsx(Bh,{open:E,onOpenChange:k}),g.jsx(Fm,{open:H!==null,session:H,onOpenChange:X=>{X||D(null)},onConfirm:N}),g.jsx(jh,{open:I!==null,sessionId:(I==null?void 0:I.sessionId)??null,initialName:I==null?void 0:I.name,onOpenChange:X=>{X||T(null)},onRename:V})]})}function ase(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])=>cse(n,r)).map(([n,r])=>({provider:n,sessions:r}))}function lse(e){return e==="terminal"?"终端":Jv(e)}function cse(e,t){return e===t?0:e==="terminal"?-1:t==="terminal"?1:LB(e,t)}function WB(){const e=Qs(),[t,n]=b.useState(!1);async function r(i){if(!t){n(!0);try{const s=await Jie({relay:Pt});if(s.type!=="success"){nt.error(s.message);return}$t.getState().addSession(s.session),i==null||i(),e(s.route)}finally{n(!1)}}}return{creatingTerminal:t,createTerminal:r}}function WN({compact:e=!1}){const[t,n]=b.useState(!1),[r,i]=b.useState(!1),s=b.useRef(!1),o=Ne(E=>!!E.selectedProxyId),l=Ne(E=>E.proxySwitchTarget!==null),u=o&&!l,{creatingTerminal:d,createTerminal:h}=WB();function p(){i(!0),window.setTimeout(()=>i(!1),2e3)}function y(){if(!u){p();return}s.current=!0,n(!0)}function v(){if(!u){p();return}s.current=!0,h()}function _(E){E.preventDefault(),p()}const w=g.jsxs(_t,{variant:"outline","data-slot":"create-session-trigger",className:Ye(e?"h-11 w-11 justify-center border-border px-0":"h-[46px] w-full justify-center gap-2 border-border px-3",!u&&"opacity-50 hover:bg-background"),"aria-label":"新建会话","aria-disabled":!u,onClick:u?void 0:_,children:[g.jsx(RP,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),!e&&g.jsx("span",{className:"truncate",children:"新建"})]}),x=u?g.jsxs(O1,{children:[g.jsx(D1,{asChild:!0,children:w}),g.jsxs(P1,{align:e?"end":"start",className:"w-52","data-slot":"create-session-type-menu",onCloseAutoFocus:E=>{s.current&&(s.current=!1,E.preventDefault())},children:[g.jsxs(yo,{className:"min-h-9 gap-2.5","data-slot":"create-agent-session-item",onSelect:y,children:[g.jsx(TP,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),"Agent 会话"]}),g.jsxs(yo,{className:"min-h-9 gap-2.5","data-slot":"create-terminal-session-item",disabled:d,onSelect:v,children:[g.jsx(cf,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),d?"正在创建终端会话...":"终端会话"]})]})]}):w;return g.jsxs(g.Fragment,{children:[u?x:g.jsxs(qf,{open:u?void 0:r,onOpenChange:u?void 0:i,children:[g.jsx(Vf,{asChild:!0,children:x}),g.jsx(Yf,{side:"top",children:l?"正在切换开发机":"请先连接开发机"})]}),g.jsx(Bh,{open:t,onOpenChange:n})]})}function use({open:e,creatingTerminal:t,onOpenChange:n,onCreateAgent:r,onCreateTerminal:i}){const s=b.useRef(!1);function o(l){s.current=!0,l()}return g.jsx(Xv,{open:e,onOpenChange:n,children:g.jsxs(Zv,{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:l=>{s.current&&(s.current=!1,l.preventDefault())},children:[g.jsx(M1,{className:"px-1 pb-1 pt-0 text-left",children:g.jsx(Qv,{children:"新建"})}),g.jsxs("div",{className:"grid gap-2 pb-1","data-slot":"create-session-type-options",children:[g.jsxs(_t,{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:()=>o(r),children:[g.jsx(TP,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),"Agent 会话"]}),g.jsxs(_t,{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:()=>o(i),children:[g.jsx(cf,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),t?"正在创建终端会话...":"终端会话"]})]})]})})}const dse="0.5.27",hse={version:dse},fse={playback:"playback",capture:"play-and-record"};function pse(){return typeof navigator>"u"?null:navigator.audioSession??null}function mse(){return{setMode:()=>{},release:()=>{}}}class gse{constructor(t=pse){yt(this,"leases",new Map);yt(this,"session",null);yt(this,"baselineType",null);yt(this,"nextLeaseId",1);yt(this,"nextOrder",1);this.getAudioSession=t}acquire(t){const n=this.getAudioSession();if(!n)return mse();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(fse[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 I1=new gse,q0=64,qN=-60,qB=32;function VN(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-qN)/-qN));return e<0?-r:r}function YN(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,h=-1;for(let p=l;p<u;p+=1){const y=i.getInt16(p*2,!0)/32768;d=Math.min(d,y),h=Math.max(h,y)}s.push({min:d,max:h})}return s}function vse(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 yse(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 VB{constructor(t,n=24e3,r={}){yt(this,"nextStartTime",0);yt(this,"activityEndToken",0);yt(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=vse(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*qB/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,h=Math.max(0,(d-this.context.currentTime)*1e3),p=t.slice(l*Int16Array.BYTES_PER_ELEMENT,u*Int16Array.BYTES_PER_ELEMENT),y=yse(n.subarray(l,u));this.scheduleTimer(()=>{var v,_,w,x;(_=(v=this.options).onActivityLevel)==null||_.call(v,y),(x=(w=this.options).onPlaybackChunk)==null||x.call(w,p)},h)}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 ew={provider:"aliyun-bailian",configured:!1,region:"cn",asrModel:"qwen3-asr-flash-realtime",ttsModel:"cosyvoice-v3-flash",ttsVoice:"longanyang",turnIdleSeconds:3},KN="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",bse=800,GN=300,_se=1600;function V0(e,t){return e.filter(n=>!n.model||n.model===t)}function XN({label:e,children:t,help:n}){return g.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:[g.jsx("span",{className:"block text-[13px] font-medium leading-none text-muted-foreground",children:e}),g.jsx("div",{className:"mt-2 min-w-0",children:t}),n?g.jsx("span",{className:"mt-2 block text-xs leading-relaxed text-muted-foreground",children:n}):null]})}function $m({label:e,value:t,options:n,onChange:r,placeholder:i="请选择",help:s}){const[o,l]=b.useState(!1),u=b.useId(),d=n.find(v=>v.value===t),h=(d==null?void 0:d.label)??(t||i),p=n.filter(v=>!v.disabled),y=!!YB(h).detail;return g.jsxs("div",{className:"min-w-0 rounded-lg border border-border/75 bg-card/55 p-3.5 sm:p-3",onBlur:v=>{v.currentTarget.contains(v.relatedTarget)||l(!1)},children:[g.jsx("div",{id:u,className:"text-[13px] font-medium leading-none text-muted-foreground",children:e}),g.jsxs("button",{type:"button","aria-labelledby":u,"aria-haspopup":"listbox","aria-expanded":o,disabled:p.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(v=>!v),"data-slot":"voice-settings-choice-trigger",children:[g.jsx(ZN,{label:h,muted:!d&&!t}),g.jsx(pl,{className:`size-4 shrink-0 text-muted-foreground transition-transform ${o?"rotate-180":""}`,"aria-hidden":"true"})]}),o?g.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(v=>{const _=v.value===t;return g.jsxs("button",{type:"button",role:"option","aria-label":v.label,"aria-selected":_,disabled:v.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:()=>{v.disabled||(r(v.value),l(!1))},children:[g.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center text-primary",children:_?g.jsx(ta,{className:"size-4","aria-hidden":"true"}):null}),g.jsx(ZN,{label:v.label})]},v.value)})}):null,s?g.jsx("div",{className:"mt-2 text-xs leading-relaxed text-muted-foreground",children:s}):null]})}function ZN({label:e,muted:t=!1}){const n=YB(e);return g.jsxs("span",{className:"min-w-0 flex-1",children:[g.jsx("span",{className:`block truncate text-base leading-6 md:text-sm ${t?"text-muted-foreground":"text-foreground"}`,children:n.title}),n.detail?g.jsx("span",{className:"mt-0.5 block truncate text-xs leading-4 text-muted-foreground",children:n.detail}):null]})}function wse({scrollRef:e}={}){const[t,n]=b.useState(ew),[r,i]=b.useState(String(ew.turnIdleSeconds)),[s,o]=b.useState(()=>Rm()),[l,u]=b.useState(""),[d,h]=b.useState(!1),[p,y]=b.useState(!1),[v,_]=b.useState({kind:"idle"}),w=b.useRef(null),x=b.useRef(null),E=b.useRef(null),k=b.useRef(null),R=b.useRef(null);b.useEffect(()=>{const te=Pt;if(!te){_({kind:"error",message:"请先连接 Relay 服务器"});return}let Q=!1;return _({kind:"loading"}),te.requestVoiceConfig().then(me=>{if(!Q){if(me.error||!me.config){_({kind:"error",message:me.error??"读取语音设置失败"});return}n(me.config),i(String(me.config.turnIdleSeconds)),u(""),h(!1),y(!0),_({kind:"idle"})}}).catch(me=>{Q||_({kind:"error",message:me instanceof Error?me.message:"读取语音设置失败"})}),()=>{Q=!0}},[]),b.useEffect(()=>{const te=Pt;if(!te||!p)return;let Q=!1;return te.requestVoiceCapabilities({region:t.region}).then(me=>{if(!Q){if(me.error||!me.capabilities){o(Rm());return}o(me.capabilities)}}).catch(()=>{Q||o(Rm())}),()=>{Q=!0}},[t.region,p]),b.useEffect(()=>()=>{K(),z()},[]);const A=b.useMemo(()=>v.kind==="loading"?"读取中...":v.kind==="saving"?"保存中...":v.kind==="testing"?"正在测试语音合成":v.kind==="playingTest"?"正在播放测试音频":v.kind==="testPassed"?"测试通过":v.kind==="saved"?"已保存":v.kind==="error"?v.message:null,[v]),I=v.kind==="saving"||v.kind==="loading"||v.kind==="testing"||v.kind==="playingTest",T=b.useMemo(()=>V0(s.ttsVoices,t.ttsModel),[s.ttsVoices,t.ttsModel]),D=T.some(te=>te.value===t.ttsVoice)?t.ttsVoice:"",W=T.length===0?"当前模型暂无可用音色":D?null:"请选择可用音色",U=b.useMemo(()=>Cse(r),[r]),F=U?null:"请输入正整数秒数",O=W??F,M=I||!!O,B=b.useMemo(()=>[{value:"cn",label:"中国大陆"},{value:"intl",label:"国际"}],[]),L=b.useMemo(()=>eM(s.asrModels,t.asrModel),[s.asrModels,t.asrModel]),N=b.useMemo(()=>kse(s.ttsModels,s.ttsVoices,t.ttsModel),[s.ttsModels,s.ttsVoices,t.ttsModel]),V=b.useMemo(()=>eM(T,D),[T,D]);function Y(){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:U??ew.turnIdleSeconds}}async function $(){if(I)return;if(O){_({kind:"error",message:O});return}const te=Pt;if(!te){_({kind:"error",message:"请先连接 Relay 服务器"});return}const Q=Y();z(),_({kind:"saving"});const me=performance.now();try{const ve=await te.updateVoiceConfig(Q),Ce=performance.now()-me;if(Ce<GN&&await Ese(GN-Ce),!ve.success||ve.error||!ve.config){_({kind:"error",message:ve.error??"保存语音设置失败"});return}n(ve.config),i(String(ve.config.turnIdleSeconds)),u(""),h(!1),_({kind:"saved"}),R.current=setTimeout(()=>{R.current=null,_(Me=>Me.kind==="saved"?{kind:"idle"}:Me)},_se),te.requestVoiceCapabilities({region:ve.config.region}).then(Me=>{Me.capabilities&&o(Me.capabilities)}).catch(()=>{o(Rm())})}catch(ve){_({kind:"error",message:ve instanceof Error?ve.message:"保存语音设置失败"})}}async function P(){if(I)return;if(O){_({kind:"error",message:O});return}const te=Pt;if(!te){_({kind:"error",message:"请先连接 Relay 服务器"});return}let Q;try{Q=q()}catch(me){_({kind:"error",message:JN(me)});return}_({kind:"testing"});try{const[me]=await Promise.all([te.testVoiceConfig(Y()),Q.ready]);if(!me.success||me.error){K(),_({kind:"error",message:me.error??"语音配置测试失败"});return}const ve=await X(me,Q.context);_({kind:"playingTest",transcript:me.transcript}),k.current=setTimeout(()=>{k.current=null,K(),_({kind:"testPassed",transcript:me.transcript})},ve)}catch(me){K(),_({kind:"error",message:JN(me)})}}function q(){K();const te=I1.acquire("playback");x.current=te;try{const Q=xse();return w.current=Q,{context:Q,ready:QN(Q)}}catch(Q){throw te.release(),x.current=null,Q}}function K(){var te,Q,me;k.current&&(clearTimeout(k.current),k.current=null),(te=E.current)==null||te.stop(),E.current=null,(Q=w.current)==null||Q.close(),w.current=null,(me=x.current)==null||me.release(),x.current=null}function z(){R.current&&(clearTimeout(R.current),R.current=null)}async function X(te,Q){if(!te.audioBase64)throw new Error("语音测试未返回可播放音频");if(te.audioEncoding&&te.audioEncoding!=="pcm_s16le")throw new Error("测试音频格式暂不支持");const me=te.audioSampleRate??24e3,ve=Sse(te.audioBase64);if(ve.byteLength===0||ve.byteLength%2!==0)throw new Error("测试音频数据无效");await QN(Q);const Ce=new VB(Q,me);E.current=Ce,Ce.enqueue(ve);const Me=Math.ceil(ve.byteLength/2/me*1e3);return Math.max(bse,Me)}function ee(te){var Q;return((Q=V0(s.ttsVoices,te)[0])==null?void 0:Q.value)??""}return g.jsxs("form",{className:"flex min-h-0 min-w-0 flex-1 flex-col","data-slot":"voice-settings-panel",autoComplete:"off",onSubmit:te=>{te.preventDefault(),$()},children:[g.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:g.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:g.jsxs("div",{className:"space-y-3","data-slot":"voice-settings-fields",children:[g.jsx("div",{className:"grid gap-2 rounded-lg border border-border/75 bg-card/55 p-3.5 sm:p-3",children:g.jsxs("div",{className:"flex items-center justify-between gap-3",children:[g.jsxs("div",{className:"min-w-0",children:[g.jsx("div",{className:"text-[13px] font-medium leading-none text-muted-foreground",children:"服务商"}),g.jsx("div",{className:"mt-2 truncate text-base font-medium text-foreground md:text-sm",children:"阿里云百炼"})]}),g.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"})]})}),g.jsx(XN,{label:"阿里云百炼 API Key",help:d?"保存后会清空已保存的 key":null,children:g.jsxs("div",{className:"flex min-w-0 gap-2",children:[g.jsxs("div",{className:"relative min-w-0 flex-1",children:[g.jsx(MP,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground","aria-hidden":"true"}),g.jsx("input",{"aria-label":"阿里云百炼 API Key",type:"password",name:"dev-anywhere-bailian-api-key",autoComplete:"off",value:l,onChange:te=>{u(te.target.value),h(!1)},placeholder:d?"保存后清空":t.configured?"••••••••••••••••":"输入 API Key",className:`${KN} w-full pl-9`})]}),t.configured&&g.jsxs(_t,{type:"button",variant:"outline",className:"min-h-11 shrink-0 px-3 md:h-9 md:min-h-0",onClick:()=>{u(""),h(!0)},children:[g.jsx(y7,{className:"size-4","aria-hidden":"true"}),"清空"]})]})}),g.jsx($m,{label:"地域",value:t.region,options:B,onChange:te=>n(Q=>({...Q,region:te==="intl"?"intl":"cn"}))}),g.jsx($m,{label:"语音识别模型",value:t.asrModel,options:L,onChange:te=>n(Q=>({...Q,asrModel:te}))}),g.jsx($m,{label:"语音合成模型",value:t.ttsModel,options:N,onChange:te=>n(Q=>({...Q,ttsModel:te,ttsVoice:ee(te)}))}),g.jsx($m,{label:"语音音色",value:D,options:V,placeholder:T.length===0?"暂无可用音色":"请选择音色",onChange:te=>n(Q=>({...Q,ttsVoice:te})),help:W}),g.jsx(XN,{label:"结束停顿时间(秒)",help:F,children:g.jsx("input",{"aria-label":"结束停顿时间(秒)",type:"number",min:1,step:1,inputMode:"numeric",value:r,onChange:te=>i(te.target.value),className:`${KN} w-full`})})]})})}),g.jsxs("div",{className:"bg-background/95 px-4 pb-3.5 pt-0 backdrop-blur sm:px-5","data-slot":"voice-settings-footer",children:[g.jsx("div",{className:"mr-4 border-t border-border/70","data-slot":"voice-settings-footer-divider"}),g.jsxs("div",{className:"mt-3.5 flex items-center justify-end gap-2",children:[A?g.jsx("div",{role:v.kind==="error"?"alert":"status","aria-live":"polite",className:v.kind==="error"?"min-w-0 flex-1 text-sm text-destructive":"min-w-0 flex-1 text-sm text-muted-foreground",children:A}):null,g.jsxs(_t,{type:"button",variant:"outline",disabled:M,onClick:()=>void P(),children:[g.jsx(PP,{className:"size-4","aria-hidden":"true"}),"测试"]}),g.jsxs(_t,{type:"submit",disabled:M,children:[g.jsx(s7,{className:"size-4","aria-hidden":"true"}),v.kind==="saving"?"保存中...":"保存"]})]})]})]})}function Sse(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 xse(){const e=window,t=e.AudioContext??e.webkitAudioContext;if(!t)throw new Error("当前浏览器不支持音频播放");return new t}async function QN(e){if(e.state!=="running")try{await e.resume()}catch{throw new Error("浏览器阻止了测试音频播放,请再次点击测试")}if(e.state!=="running")throw new Error("浏览器阻止了测试音频播放,请再次点击测试")}function JN(e){return e instanceof Error?e.message:"语音配置测试失败"}function Ese(e){return new Promise(t=>setTimeout(t,e))}function Cse(e){const t=e.trim();if(!/^[1-9]\d*$/.test(t))return null;const n=Number(t);return Number.isSafeInteger(n)?n:null}function eM(e,t){const n=e.map(r=>({value:r.value,label:KB(r)}));return!t||n.some(r=>r.value===t)?n:[{value:t,label:t},...n]}function kse(e,t,n){const r=e.map(i=>{const s=V0(t,i.value).length===0;return{value:i.value,label:`${KB(i)}${s?" · 暂无音色":""}`,disabled:s}});return!n||r.some(i=>i.value===n)?r:[{value:n,label:`${n} · 暂无音色`,disabled:!0},...r]}function YB(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 KB(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 Tse=[{value:"auto",label:"跟随系统"},{value:"light",label:"浅色"},{value:"dark",label:"深色"}],Rse=[{value:"auto",label:"自动"},{value:"touch",label:"触控优先"},{value:"hardware",label:"实体键盘优先"}],z1="dev-render-scroll min-h-0 space-y-3 overflow-y-auto overscroll-contain pr-4 sm:pr-1";function GB(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 Ase(e){const t=e||window.location.origin;return new URL("/health",t).toString()}function Nse(e){return e==="version"?"版本":e==="relay-token"?"Relay Token":e==="clients"?"客户端管理":"设置 Voice Pilot"}function Mse(e){return e==="version"?"Web 与 Relay 服务器版本。":e==="relay-token"?"连接受保护的 Relay 服务器,保存后立即重连。":e==="clients"?"管理当前连接的 Web 客户端。":"连接语音服务后,即可以语音交互的形式驱动会话。"}function Y0({open:e,onOpenChange:t}){const n=Ne(W=>W.relayUrl),r=Ne(W=>W.latencyMonitorEnabled),i=Ne(W=>W.setLatencyMonitorEnabled),s=Ne(W=>W.sessionIdleNotificationsEnabled),o=Ne(W=>W.setSessionIdleNotificationsEnabled),l=Ne(W=>W.inputModePreference),u=Ne(W=>W.setInputModePreference),d=Ne(W=>W.themePreference),h=Ne(W=>W.setThemePreference),p=Ne(W=>W.ptyScrollTraceEnabled),y=Ne(W=>W.setPtyScrollTraceEnabled),[v,_]=b.useState("menu"),[w,x]=b.useState({kind:"idle"}),E=b.useRef(null),k=b.useRef(null),R=EQ(),A=b.useMemo(()=>kv().osName==="iPad",[]),I=b.useCallback(async W=>{if(!W){o(!1);return}const U=await JZ();if(U==="granted"){o(!0);return}if(U==="denied"){nt.error("浏览器未授予通知权限,请在浏览器设置中允许通知");return}if(U==="default"){nt.info("未授予通知权限,会话通知保持关闭");return}nt.error("当前浏览器不支持系统通知")},[o]),T=b.useCallback(async W=>{x({kind:"loading"});try{const U=await fetch(Ase(n),{cache:"no-store",signal:W});if(!U.ok)throw new Error(`HTTP ${U.status}`);const F=await U.json();if(F.status!=="ok")throw new Error("状态异常");x({kind:"ready",version:F.version??"未知",uptime:F.uptime??0})}catch(U){if(U instanceof DOMException&&U.name==="AbortError")return;x({kind:"error",message:U instanceof Error?"当前 Relay 服务器无法读取版本":"读取失败"})}},[n]);b.useEffect(()=>{if(!e){_("menu");return}},[e]),b.useEffect(()=>{if(!e||v!=="version")return;const W=new AbortController;return T(W.signal),()=>W.abort()},[T,e,v]),b.useEffect(()=>{if(!e||v!=="voice")return;const W=window.requestAnimationFrame(()=>{var U;(U=E.current)==null||U.focus({preventScroll:!0}),k.current&&(k.current.scrollTop=0)});return()=>window.cancelAnimationFrame(W)},[e,v]);const H=w.kind==="ready"?w.version:w.kind==="loading"?"读取中...":w.kind==="error"?"读取失败":"未读取",D=w.kind==="ready"?`运行 ${GB(w.uptime)}`:w.kind==="error"?w.message:"从当前 Relay 服务器 /health 读取";return g.jsx(Sc,{open:e,onOpenChange:t,children:g.jsxs(xc,{className:Ye("grid max-h-[calc(100dvh-1rem)] grid-rows-[auto_minmax(0,1fr)] overflow-hidden p-4 sm:max-w-[440px] sm:p-6",v==="voice"&&"max-h-[min(760px,calc(100dvh-1rem))] !gap-0 !p-0 sm:max-w-[480px]",v==="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":v,focusSurfaceOnOpen:!0,ref:E,showCloseButton:v==="menu",children:[g.jsx(Ec,{className:Ye(v==="menu"&&"pr-12 text-left",v!=="menu"&&"text-left",v==="voice"&&"gap-0 px-4 pb-0 pt-3.5 text-left sm:px-5 sm:pt-4"),children:v!=="menu"?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"flex items-start gap-2",children:[g.jsx(_t,{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:g.jsx(_v,{className:"size-4","aria-hidden":"true"})}),g.jsxs("div",{className:"min-w-0 space-y-1.5 pt-0.5 text-left",children:[g.jsx(cl,{children:Nse(v)}),g.jsx(uc,{className:"max-w-[28rem] leading-5",children:Mse(v)})]})]}),v==="voice"?g.jsx("div",{className:"mr-4 mt-3.5 border-t border-border/70","data-slot":"voice-settings-header-divider"}):null]}):g.jsxs(g.Fragment,{children:[g.jsx(cl,{children:"设置"}),g.jsx(uc,{children:"连接、外观、通知和高级诊断选项。"})]})}),v==="version"?g.jsx(Ose,{relayVersion:H,relayDetail:D,relayMuted:w.kind==="error"}):v==="relay-token"?g.jsx(Pse,{saved:R}):v==="clients"?g.jsx(jse,{}):v==="voice"?g.jsx(wse,{scrollRef:k}):g.jsx(Dse,{relayTokenSaved:R,themePreference:d,onThemePreferenceChange:h,inputModePreference:l,onInputModePreferenceChange:u,showInputModeSetting:A,sessionIdleNotificationsEnabled:s,onSessionIdleNotificationsEnabledChange:I,ptyScrollTraceEnabled:p,onPtyScrollTraceEnabledChange:y,latencyMonitorEnabled:r,onLatencyMonitorEnabledChange:i,onOpenVoice:()=>_("voice"),onOpenRelayToken:()=>_("relay-token"),onOpenClients:()=>_("clients"),onOpenVersion:()=>_("version")})]})})}function Ose({relayVersion:e,relayDetail:t,relayMuted:n}){return g.jsxs("div",{className:z1,"data-slot":"settings-dialog-body",children:[g.jsx(nM,{icon:g.jsx(DP,{className:"size-4","aria-hidden":"true"}),label:"Web",value:hse.version,detail:"当前浏览器加载的版本"}),g.jsx(nM,{icon:g.jsx(LP,{className:"size-4","aria-hidden":"true"}),label:"Relay 服务器",value:e,detail:t,muted:n})]})}function Dse({relayTokenSaved:e,themePreference:t,onThemePreferenceChange:n,inputModePreference:r,onInputModePreferenceChange:i,showInputModeSetting:s,sessionIdleNotificationsEnabled:o,onSessionIdleNotificationsEnabledChange:l,ptyScrollTraceEnabled:u,onPtyScrollTraceEnabledChange:d,latencyMonitorEnabled:h,onLatencyMonitorEnabledChange:p,onOpenVoice:y,onOpenRelayToken:v,onOpenClients:_,onOpenVersion:w}){return g.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:[g.jsxs(du,{title:"服务",children:[g.jsx(Hm,{icon:g.jsx(K9,{className:"size-4","aria-hidden":"true"}),label:"Voice Pilot",detail:"用语音输入、听取回复和处理审批",onClick:y}),g.jsx(Hm,{icon:g.jsx(MP,{className:"size-4","aria-hidden":"true"}),label:"Relay Token",detail:`${e?"已保存":"未设置"} · 受保护的 Relay 服务器`,onClick:v}),g.jsx(Hm,{icon:g.jsx(C7,{className:"size-4","aria-hidden":"true"}),label:"客户端管理",detail:"已连接的浏览器页面和设备",onClick:_})]}),g.jsx(du,{title:"外观",children:g.jsx(tM,{icon:g.jsx(m7,{className:"size-4","aria-hidden":"true"}),label:"主题",value:t,options:Tse,onValueChange:n})}),g.jsx(du,{title:"通知",children:g.jsx(nw,{icon:g.jsx(X9,{className:"size-4","aria-hidden":"true"}),label:"会话空闲通知",detail:"会话从工作中转为空闲时发送浏览器通知",checked:o,onCheckedChange:l})}),s?g.jsx(du,{title:"交互",children:g.jsx(tM,{icon:g.jsx(OP,{className:"size-4","aria-hidden":"true"}),label:"输入方式",detail:"默认自动识别软键盘和实体键盘;必要时可强制一种方式",value:r,options:Rse,onValueChange:i})}):null,g.jsxs(du,{title:"高级诊断",children:[g.jsx(nw,{icon:g.jsx(cf,{className:"size-4","aria-hidden":"true"}),label:"PTY 滚动追踪",detail:"记录终端滚动和视口同步现场,方便复制诊断报告",checked:u,onCheckedChange:d}),g.jsx(nw,{icon:g.jsx(CP,{className:"size-4","aria-hidden":"true"}),label:"延迟监控",detail:"显示可拖动的连接延迟浮窗",checked:h,onCheckedChange:p})]}),g.jsx(du,{title:"关于",children:g.jsx(Hm,{icon:g.jsx(LP,{className:"size-4","aria-hidden":"true"}),label:"版本",onClick:w})})]})}function du({title:e,children:t}){return g.jsxs("section",{className:"space-y-2","data-slot":"settings-section",children:[g.jsx("h3",{className:"px-1 text-xs font-medium text-muted-foreground",children:e}),g.jsx("div",{className:"overflow-hidden rounded-lg border border-border bg-card/55 divide-y divide-border/70",children:t})]})}function tM({icon:e,label:t,detail:n,value:r,options:i,onValueChange:s}){const o=b.useId(),l=b.useId();return g.jsxs("div",{className:"flex w-full items-start gap-3 px-3 py-3 text-left","data-slot":"settings-choice-item",children:[g.jsx("div",{className:"flex size-8 shrink-0 items-center justify-center rounded-md bg-background/55 text-muted-foreground",children:e}),g.jsxs("div",{className:"min-w-0 flex-1",children:[g.jsx("div",{id:o,className:"text-sm font-medium text-foreground",children:t}),n?g.jsx("div",{id:l,className:"mt-1 text-xs text-muted-foreground",children:n}):null,g.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 g.jsx("button",{type:"button",role:"radio","aria-checked":d,className:Ye("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 Pse({saved:e}){const t=b.useId(),n=b.useId(),[r,i]=b.useState(""),[s,o]=b.useState(null),l=()=>{eI().catch(h=>{o(h instanceof Error?h.message:"Relay 重连失败。")})},u=()=>{const h=r.trim();if(!h){o("请输入 token。");return}if(!QL(h)){const p="Relay Token 保存失败,请检查浏览器存储权限。";o(p),nt.error(p);return}o(null),nt.success("Relay Token 已保存,正在重新连接"),l()},d=()=>{JL(),l()};return g.jsxs("form",{className:z1,"data-slot":"settings-dialog-body",onSubmit:h=>{h.preventDefault(),u()},children:[g.jsxs("div",{className:"rounded-md border border-border bg-card/70 p-3","data-slot":"relay-token-card",children:[g.jsx("label",{htmlFor:t,className:"text-sm font-medium text-foreground",children:"Token"}),g.jsx("input",{id:t,type:"password",value:r,onChange:h=>{i(h.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?g.jsx("p",{id:n,className:"mt-2 text-xs text-destructive",children:s}):null]}),g.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[e?g.jsx(_t,{type:"button",variant:"outline",onClick:d,children:"清空"}):null,g.jsx(_t,{type:"submit",disabled:!r.trim(),children:"保存"})]})]})}function Lse(e){return e.length<=16?e:`${e.slice(0,8)}...${e.slice(-4)}`}function Ise(e,t){var r;return((r=t.get(e))==null?void 0:r.trim())||Lse(e)}function zse(e){return NX(e)}function Bse(e){const t=Math.max(0,Math.floor((Date.now()-e)/1e3));return GB(t)}function tw({label:e,value:t,title:n}){return g.jsxs("div",{className:"grid grid-cols-[3.75rem_minmax(0,1fr)] items-baseline gap-2 text-xs leading-5",children:[g.jsx("span",{className:"shrink-0 text-muted-foreground/80",children:e}),g.jsx("span",{className:"min-w-0 truncate text-muted-foreground",title:n??t,children:t})]})}function jse(){const e=Ne(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]),h=b.useCallback(async()=>{const y=Pt;if(!y){n([]),o("Relay 未连接。"),i(!1);return}i(!0),o(null);try{n(await y.requestRelayClients())}catch(v){o(v instanceof Error?v.message:"读取客户端列表失败。")}finally{i(!1)}},[]);b.useEffect(()=>{h()},[h]);const p=b.useCallback(async y=>{const v=Pt;if(!v){o("Relay 未连接。");return}u(y),o(null);try{const _=await v.kickRelayClient(y);if(!_.success){o(_.error??"断开客户端失败。");return}n(w=>w.filter(x=>x.clientId!==y))}catch(_){o(_ instanceof Error?_.message:"断开客户端失败。")}finally{u(null)}},[]);return g.jsxs("div",{className:z1,"data-slot":"settings-dialog-body",children:[g.jsxs("div",{className:"flex min-h-9 items-center gap-2","data-slot":"relay-clients-toolbar",children:[g.jsx("div",{className:"text-sm font-medium text-foreground",children:r?"正在读取客户端":`${t.length} 个在线客户端`}),g.jsx(_t,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"刷新客户端列表",title:"刷新",onClick:()=>void h(),disabled:r,"data-slot":"relay-clients-refresh",children:g.jsx(Ox,{className:Ye("size-3.5",r&&"animate-spin"),"aria-hidden":"true"})})]}),s?g.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?g.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 v=y.current===!0,_=l===y.clientId;return g.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:g.jsxs("div",{className:"grid gap-3 sm:grid-cols-[minmax(0,1fr)_7.5rem] sm:items-start",children:[g.jsxs("div",{className:"min-w-0 space-y-1.5",children:[g.jsx("div",{className:"min-w-0",children:g.jsx("div",{className:"truncate text-sm font-medium leading-5 text-foreground",children:zse(y)})}),g.jsxs("div",{className:"space-y-1",children:[g.jsx(tw,{label:"已连接",value:Bse(y.connectedAt)}),y.proxyId?g.jsx(tw,{label:"连接到",value:Ise(y.proxyId,d),title:y.proxyId}):null,y.remoteAddress?g.jsx(tw,{label:"来源 IP",value:y.remoteAddress}):null]})]}),v?g.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:"当前设备"}):g.jsxs(_t,{type:"button",variant:"outline",size:"sm",className:"h-9 w-full justify-center",disabled:_,onClick:()=>void p(y.clientId),"data-slot":"relay-client-action",children:[g.jsx(L8,{className:"size-3.5","aria-hidden":"true"}),_?"断开中...":"断开"]})]})},y.clientId)})]})}function nw({icon:e,label:t,detail:n,checked:r,onCheckedChange:i}){const s=b.useId(),o=b.useId();return g.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:[g.jsx("div",{className:Ye("flex size-8 shrink-0 items-center justify-center rounded-md bg-background/55 transition-colors",r?"text-primary":"text-muted-foreground"),children:e}),g.jsxs("div",{className:"min-w-0 flex-1",children:[g.jsx("div",{id:s,className:"text-sm font-medium text-foreground",children:t}),g.jsx("div",{id:o,className:"mt-1 text-xs text-muted-foreground",children:n})]}),g.jsx("span",{className:Ye("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:g.jsx("span",{className:Ye("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 Hm({icon:e,label:t,detail:n,onClick:r}){const i=b.useId(),s=b.useId();return g.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:[g.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}),g.jsxs("div",{className:"min-w-0 flex-1",children:[g.jsx("div",{id:i,className:"text-sm font-medium text-foreground",children:t}),n?g.jsx("div",{id:s,className:"mt-1 text-xs text-muted-foreground",children:n}):null]}),g.jsx(Zh,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"})]})}function nM({icon:e,label:t,value:n,detail:r,muted:i=!1}){return g.jsxs("div",{className:"flex gap-3 rounded-md border border-border bg-card/70 p-3",children:[g.jsx("div",{className:Ye("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}),g.jsxs("div",{className:"min-w-0 flex-1",children:[g.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[g.jsx("div",{className:"text-sm text-muted-foreground",children:t}),g.jsx("div",{className:"min-w-0 truncate font-mono text-sm text-foreground",children:n})]}),g.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:r})]})]})}const Fse="xterm-helper-textarea";function $se(e=document.activeElement){return!(e instanceof HTMLElement)||!e.classList.contains(Fse)?!1:(e.blur(),!0)}function rM(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&&Hse(r,n))return!0;if(r===t)break;r=r.parentElement}return!1}function Hse(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 Use({releasePtyFocus:e=!0,containVerticalScroll:t=!0}={}){const n=b.useRef(null),r=b.useCallback(()=>{e&&$se()},[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 h=(n.current??u.clientY)-u.clientY;n.current=u.clientY,rM(l.target,l.currentTarget,h)||l.preventDefault()},[t]),o=b.useCallback(l=>{r(),t&&(rM(l.target,l.currentTarget,l.deltaY)||l.preventDefault())},[t,r]);return{onPointerDownCapture:r,onTouchStartCapture:i,onTouchMoveCapture:s,onWheelCapture:o}}function Wse({className:e}){const t=Ne(o=>o.sidebarCollapsed),n=Ne(o=>o.toggleSidebarCollapsed),[r,i]=b.useState(!1),s=Use();return t?g.jsxs(g.Fragment,{children:[g.jsxs("nav",{className:Ye("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:[g.jsx(sM,{collapsed:!0,onClick:n}),g.jsx("div",{className:"mt-3 h-px w-5 bg-border/70","aria-hidden":"true"}),g.jsxs("div",{className:"mt-auto flex flex-col gap-2",children:[g.jsx(iM,{compact:!0,tooltipSide:"right",onClick:()=>i(!0)}),g.jsx(WN,{compact:!0})]})]}),g.jsx(Y0,{open:r,onOpenChange:i})]}):g.jsxs(g.Fragment,{children:[g.jsxs("nav",{className:Ye("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:[g.jsx("div",{className:"dev-sidebar-fade p-2.5","data-slot":"sidebar-proxy-switcher",children:g.jsxs("div",{className:"dev-sidebar-chrome rounded-lg border p-3",children:[g.jsxs("div",{className:"flex items-center justify-between gap-3",children:[g.jsx(eL,{className:"text-[13px]",slot:"sidebar-brand"}),g.jsx(sM,{collapsed:!1,onClick:n})]}),g.jsx("div",{className:"mt-2.5",children:g.jsx(PB,{layout:"dropdown",variant:"sidebarChrome"})})]})}),g.jsx("div",{className:"dev-sidebar-fade flex min-h-0 flex-1 flex-col overflow-hidden","data-slot":"sidebar-session-list",children:g.jsx("div",{className:"flex-1 min-h-0",children:g.jsx(UB,{layout:"sidebar"})})}),g.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:[g.jsx("div",{className:"min-w-0 flex-1",children:g.jsx(WN,{})}),g.jsx("div",{className:"min-w-0 flex-1",children:g.jsx(iM,{onClick:()=>i(!0)})})]})]}),g.jsx(Y0,{open:r,onOpenChange:i})]})}function iM({compact:e=!1,tooltipSide:t="top",onClick:n}){return g.jsxs(qf,{delayDuration:500,children:[g.jsx(Vf,{asChild:!0,children:g.jsxs("button",{type:"button","aria-label":"设置","data-slot":"sidebar-settings-trigger",onClick:n,className:Ye("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:[g.jsx(IP,{className:"size-4","aria-hidden":"true"}),!e&&g.jsx("span",{className:"truncate text-sm font-medium",children:"设置"})]})}),g.jsx(Yf,{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 sM({collapsed:e,onClick:t}){const n=e?"展开侧边栏":"收起侧边栏",r=e?q8:U8;return g.jsxs(qf,{delayDuration:500,children:[g.jsx(Vf,{asChild:!0,children:g.jsx("button",{type:"button","aria-label":n,"data-slot":e?"sidebar-expand-trigger":"sidebar-collapse-trigger",onClick:t,className:Ye("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:g.jsx(r,{className:Ye("size-3.5 transition-transform",e&&"group-hover:translate-x-0.5",!e&&"group-hover:-translate-x-0.5"),"aria-hidden":"true"})})}),g.jsx(Yf,{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 qse=1500,Vse=300,oM=70,aM=35;function XB({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 h=setInterval(()=>s(p=>!p),530);return()=>clearInterval(h)},[]),b.useEffect(()=>{let h;const p=()=>e[u.current%e.length],y=()=>{const v=o.current;if(v==="typing"){const _=p();l.current<_.length?(l.current+=1,r(_.slice(0,l.current)),h=setTimeout(y,oM)):(o.current="paused",h=setTimeout(y,qse))}else v==="paused"?(o.current="deleting",h=setTimeout(y,aM)):v==="deleting"?l.current>0?(l.current-=1,r(p().slice(0,l.current)),h=setTimeout(y,aM)):(u.current+=1,o.current="waiting",h=setTimeout(y,Vse)):(o.current="typing",h=setTimeout(y,oM))};return h=setTimeout(y,500),()=>clearTimeout(h)},[e]);const d=n.startsWith("DEV")?3:n.length<=3&&"DEV".startsWith(n)?n.length:0;return g.jsxs("div",{className:`font-mono leading-tight select-none ${t??""}`,"data-slot":"brand-typewriter",children:[g.jsx("span",{className:"text-green-500",children:"> "}),g.jsx("span",{className:"text-primary","data-slot":"brand-typewriter-dev",children:n.slice(0,d)}),g.jsx("span",{className:"text-foreground/90",children:n.slice(d)}),g.jsx("span",{className:`text-primary ${i?"opacity-100":"opacity-0"}`,children:"_"})]})}const ZB=["DEV Anywhere","/unlimited @anytime"];function Yse({subtitle:e,action:t}){return g.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:g.jsxs("div",{className:"dev-mobile-brand-content min-w-0 space-y-3 pr-12",children:[g.jsx(XB,{texts:ZB,className:"dev-mobile-brand-typewriter max-w-full overflow-hidden text-ellipsis whitespace-nowrap font-bold tracking-normal"}),g.jsx("p",{className:"dev-mobile-brand-subtitle max-w-[34rem] text-sm leading-5 text-muted-foreground",children:e}),t?g.jsx("div",{className:"dev-mobile-brand-action flex max-w-full min-w-0 pt-1",children:t}):null]})})}const Kse=3e3,Gse=1e4,Um=12,Xse=4,lM={webRelay:"浏览器 ↔ Relay 服务器",relayProxy:"Relay 服务器 ↔ 开发机",webProxy:"浏览器 ↔ 开发机"},Zse={webRelay:{state:"idle"},relayProxy:{state:"idle"},webProxy:{state:"idle"}};function rw(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 hu(e){return{state:"unavailable",error:e,updatedAt:Date.now()}}function Fh(e){return e===void 0||!Number.isFinite(e)?"--":`${Math.max(0,Math.round(e))}ms`}function cM(e){switch(e){case"bad":return 4;case"unavailable":return 3;case"warn":return 2;case"measuring":return 1;default:return 0}}function QB(e){return e==="bad"||e==="unavailable"?"bad":e==="warn"?"warn":e==="ok"?"ok":"neutral"}function Qse(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 Jse(e){return e.state==="measuring"?"检测中":e.state==="unavailable"?e.error??"不可用":e.rttMs!==void 0?Fh(e.rttMs):"等待检测"}function eoe(){const e=Ei("local",dn.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 uM(e){hr("local",dn.latencyMonitorPosition,JSON.stringify(e))}function toe(){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 iw(e,t){const n=toe(),r=Um,i=Um,s=Math.max(r,n.width-t.width-Um),o=Math.max(i,n.height-t.height-Um);return{x:Math.min(s,Math.max(r,Math.round(e.x))),y:Math.min(o,Math.max(i,Math.round(e.y)))}}function noe(){const e=Ne(T=>T.latencyMonitorEnabled),t=Ne(T=>T.connected),n=Ne(T=>T.proxyOnline),r=Ne(T=>T.selectedProxyId),[i,s]=b.useState(Zse),[o,l]=b.useState(()=>eoe()),u=b.useRef(!1),d=b.useRef(null),h=b.useRef(null),p=b.useRef(!1),y=b.useMemo(()=>(Object.values(i).sort((T,H)=>cM(H.state)-cM(T.state))[0]??{state:"idle"}).state,[i]),v=QB(y);async function _(){if(u.current)return;const T=Pt;if(!T||!t){const U=hu("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"}:hu("未连接开发机"),webProxy:n?{...U.webProxy,state:"measuring"}:hu("未连接开发机")}));const[H,D,W]=await Promise.allSettled([T.measureWebRelayLatency(),n?T.measureRelayProxyLatency():Promise.resolve({success:!1}),n?T.measureWebProxyLatency():Promise.resolve({success:!1})]);s({webRelay:H.status==="fulfilled"?rw(H.value):hu(H.reason instanceof Error?H.reason.message:"测速失败"),relayProxy:D.status==="fulfilled"?rw(D.value):hu(D.reason instanceof Error?D.reason.message:"测速失败"),webProxy:W.status==="fulfilled"?rw(W.value):hu(W.reason instanceof Error?W.reason.message:"测速失败")}),u.current=!1}if(b.useEffect(()=>{if(!e)return;let T=!1,H=null;const D=async()=>{await _(),!T&&(H=setTimeout(D,document.hidden?Gse:Kse))};return D(),()=>{T=!0,u.current=!1,H&&clearTimeout(H)}},[e,t,n,r]),b.useEffect(()=>{if(!e||!o)return;const T=d.current;if(!T)return;const H=T.getBoundingClientRect(),D=iw(o,{width:H.width,height:H.height});D.x===o.x&&D.y===o.y||(l(D),uM(D))},[e,o]),!e)return null;const w=i.webProxy.rttMs!==void 0?i.webProxy:i.relayProxy,x=o!==null?{left:`${o.x}px`,top:`${o.y}px`}:void 0;function E(T){var D,W;if(T.button!==0)return;const H=T.currentTarget.getBoundingClientRect();h.current={pointerId:T.pointerId,startX:T.clientX,startY:T.clientY,originX:H.left,originY:H.top,width:H.width,height:H.height,dragging:!1},(W=(D=T.currentTarget).setPointerCapture)==null||W.call(D,T.pointerId)}function k(T){const H=h.current;if(!H||H.pointerId!==T.pointerId)return;const D=T.clientX-H.startX,W=T.clientY-H.startY;if(!H.dragging&&Math.hypot(D,W)<Xse)return;H.dragging=!0,T.preventDefault();const U=iw({x:H.originX+D,y:H.originY+W},{width:H.width,height:H.height});l(U)}function R(T){var F,O;const H=h.current;if(!H||H.pointerId!==T.pointerId||(h.current=null,(O=(F=T.currentTarget).releasePointerCapture)==null||O.call(F,T.pointerId),!H.dragging))return;T.preventDefault(),p.current=!0,window.setTimeout(()=>{p.current=!1},200);const D=T.clientX-H.startX,W=T.clientY-H.startY,U=iw({x:H.originX+D,y:H.originY+W},{width:H.width,height:H.height});l(U),uM(U)}function A(T){var D,W;const H=h.current;!H||H.pointerId!==T.pointerId||(h.current=null,(W=(D=T.currentTarget).releasePointerCapture)==null||W.call(D,T.pointerId))}function I(T){p.current&&(p.current=!1,T.preventDefault(),T.stopPropagation())}return g.jsxs(R1,{children:[g.jsx(A1,{asChild:!0,children:g.jsxs("button",{ref:d,type:"button",className:Ye("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",Qse(v)),style:x,"data-slot":"latency-monitor-trigger","aria-label":`延迟监控,Relay 服务器 ${Fh(i.webRelay.rttMs)},开发机 ${Fh(w.rttMs)}`,onPointerDown:E,onPointerMove:k,onPointerUp:R,onPointerCancel:A,onClickCapture:I,children:[g.jsx(CP,{className:"size-3.5","aria-hidden":"true"}),g.jsx("span",{className:"font-medium text-foreground",children:"延迟"}),g.jsxs("span",{className:"hidden text-muted-foreground sm:inline",children:["Relay ",Fh(i.webRelay.rttMs)]}),g.jsxs("span",{className:"text-muted-foreground",children:["开发机 ",Fh(w.rttMs)]}),g.jsx(pl,{className:"size-3 text-muted-foreground","aria-hidden":"true"})]})}),g.jsxs(N1,{align:"end",className:"w-[320px] p-3","data-slot":"latency-monitor-popover",children:[g.jsxs("div",{className:"flex items-start justify-between gap-3",children:[g.jsxs("div",{children:[g.jsx("div",{className:"text-sm font-medium text-foreground",children:"连接延迟"}),g.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:"数值越低,操作响应通常越快。"})]}),g.jsx(_t,{type:"button",variant:"ghost",size:"icon-xs","aria-label":"立即测速",onClick:()=>void _(),children:g.jsx(Ox,{className:"size-3","aria-hidden":"true"})})]}),g.jsx("div",{className:"mt-3 space-y-2",children:Object.keys(lM).map(T=>g.jsx(roe,{label:lM[T],measurement:i[T]},T))})]})]})}function roe({label:e,measurement:t}){const n=QB(t.state);return g.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:[g.jsx("div",{className:"min-w-0 truncate text-xs font-medium text-foreground",children:e}),g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("span",{className:Ye("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"}),g.jsx("span",{className:"min-w-[4rem] text-right font-mono text-xs text-foreground",children:Jse(t)})]})]})}const JB="/__dev_anywhere_debug/browser-state-dumps",ioe=1500,soe=10,sw=80,B1=500,ooe=["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"],aoe=["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 dM(){if(typeof window>"u")return"off";const e=a3("debugDump");return e==="auto"?"auto":e!==null||goe("debugInput")?"manual":"off"}function loe(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:hoe(),document:{title:document.title,readyState:document.readyState,visibilityState:document.visibilityState,activeElement:hM(document.activeElement),selection:foe(),focusedInputs:Array.from(document.querySelectorAll("input, textarea, select, [contenteditable]")).filter(i=>i===document.activeElement||i.matches(":focus")).map(i=>hM(i)).filter(i=>!!i),root:e3(document.documentElement,0,t),truncated:t.truncated,nodeCount:t.count},devAnywhere:{ptyDebug:fu(()=>{var i;return((i=n.__devAnywherePtyDebug)==null?void 0:i.call(n))??null}),ptyInputDebugSnapshot:fu(()=>n.__devAnywherePtyInputDebugSnapshot??null),ptyInputDebugText:n.__devAnywherePtyInputDebugText??null,ptyInputDebugEvents:fu(()=>n.__devAnywherePtyInputDebugEvents??null),ptyScrollTraceTail:fu(()=>fM(n.__devAnywherePtyScrollTrace)),jsonScrollTraceTail:fu(()=>fM(n.__devAnywhereJsonScrollTrace)),voicePilotDiagnostics:fu(()=>{var i;return((i=n.__devAnywhereVoicePilotDiagnostics)==null?void 0:i.snapshot())??null})}};return window.__devAnywhereLastBrowserStateDump=r,r}async function coe(e="manual"){const t=loe(e);return uoe(t)}async function uoe(e){const t=JSON.stringify(e,null,2),n=new Blob([t]).size;try{const r=await doe(t);return{status:"saved",path:r.path,bytes:r.bytes,endpoint:JB}}catch(r){const i=l3(r),s=poe(e.createdAt);return moe(s,t,"application/json")?{status:"downloaded",filename:s,bytes:n,endpointError:i}:{status:"failed",error:"无法保存或下载诊断包",endpointError:i}}}async function doe(e){const t=await fetch(JB,{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 e3(e,t,n){if(n.count>=ioe||t>soe)return n.truncated=!0,{kind:"truncated"};if(n.count+=1,e.nodeType===Node.TEXT_NODE){const u=pM(e.textContent??"");return u?{kind:"text",text:ey(u,B1)}:{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,sw))u.nodeType===Node.TEXT_NODE&&!pM(u.textContent??"")||r.push(e3(u,t+1,n));s.length>sw&&(i=s.length-sw,n.truncated=!0);const o={kind:"element",tag:e.tagName.toLowerCase(),path:o3(e),attrs:t3(e),rect:n3(e),scroll:r3(e),style:i3(e)},l=s3(e);return l&&(o.value=l),r.length>0&&(o.children=r),i>0&&(o.omittedChildren=i),o}function hM(e){if(!(e instanceof HTMLElement))return null;const t=s3(e);return{path:o3(e),tag:e.tagName.toLowerCase(),id:e.id||null,className:e.className||null,attrs:t3(e),rect:n3(e),scroll:r3(e),style:i3(e),...t?{value:t}:{}}}function hoe(){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 t3(e){const t={};for(const n of ooe){const r=e.getAttribute(n);r!==null&&(t[n]=ey(r,500))}return t}function n3(e){const t=e.getBoundingClientRect();return{x:Ki(t.x),y:Ki(t.y),width:Ki(t.width),height:Ki(t.height),top:Ki(t.top),right:Ki(t.right),bottom:Ki(t.bottom),left:Ki(t.left)}}function r3(e){return{top:Ki(e.scrollTop),left:Ki(e.scrollLeft),height:Ki(e.scrollHeight),width:Ki(e.scrollWidth),clientHeight:Ki(e.clientHeight),clientWidth:Ki(e.clientWidth)}}function i3(e){const t=window.getComputedStyle(e),n={};for(const r of aoe)n[r]=t.getPropertyValue(r);return n}function s3(e){if(!(!(e instanceof HTMLInputElement)&&!(e instanceof HTMLTextAreaElement)))return{length:e.value.length,preview:ey(e.value,B1),selectionStart:e.selectionStart,selectionEnd:e.selectionEnd}}function foe(){var e;try{return ey(((e=window.getSelection())==null?void 0:e.toString())??"",B1)}catch{return null}}function o3(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 poe(e){return`dev-anywhere-browser-state-${e.replace(/[:.]/g,"-")}.json`}function moe(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 goe(e){return a3(e)!==null}function a3(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 fM(e){return e?Qg(e.slice(-200)):null}function fu(e){try{return Qg(e())}catch(t){return{error:l3(t)}}}function Qg(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(Qg);if(typeof e=="object"){const t={};for(const[n,r]of Object.entries(e))t[n]=Qg(r);return t}return String(e)}function pM(e){return e.replace(/\s+/g," ").trim()}function ey(e,t){return e.length>t?`${e.slice(0,t)}...`:e}function Ki(e){return Math.round(e*100)/100}function l3(e){return e instanceof Error?e.message:String(e)}const voe=500,yoe=1e3,boe=60;function _oe(){const[e,t]=b.useState(()=>dM()),[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),h=b.useRef(null);b.useEffect(()=>{const _=()=>t(dM());return window.addEventListener("hashchange",_),window.addEventListener("popstate",_),()=>{window.removeEventListener("hashchange",_),window.removeEventListener("popstate",_)}},[]);const p=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 coe(_);return o.current=w,s(w),(_==="manual"||w.status==="failed")&&woe(w),w}finally{l.current=!1,r(!1)}},[]);if(b.useEffect(()=>(window.__devAnywhereDumpBrowserState=p,()=>{window.__devAnywhereDumpBrowserState===p&&delete window.__devAnywhereDumpBrowserState}),[p]),b.useEffect(()=>{var k,R;if(e!=="auto")return;const _=()=>{h.current!==null&&(window.clearTimeout(h.current),h.current=null)},w=A=>{d.current>=boe||(_(),h.current=window.setTimeout(()=>{h.current=null;const I=Date.now(),T=yoe-(I-u.current);if(T>0){h.current=window.setTimeout(()=>w(A),T);return}u.current=Date.now(),d.current+=1,p(`auto:${d.current}:${A}`)},voe))};w("initial");const x=["focusin","focusout","beforeinput","input","compositionstart","compositionupdate","compositionend","keydown","keyup","pointerdown","pointerup","resize","visibilitychange"],E=A=>w(A.type);return x.forEach(A=>window.addEventListener(A,E,!0)),(k=window.visualViewport)==null||k.addEventListener("resize",E),(R=window.visualViewport)==null||R.addEventListener("scroll",E),()=>{var A,I;_(),x.forEach(T=>window.removeEventListener(T,E,!0)),(A=window.visualViewport)==null||A.removeEventListener("resize",E),(I=window.visualViewport)==null||I.removeEventListener("scroll",E)}},[p,e]),e==="off")return null;const y=e==="auto"?"自动诊断中":"保存诊断",v=Soe(i);return g.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:[v?g.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:v}):null,g.jsxs(_t,{type:"button",size:"sm",variant:e==="auto"?"secondary":"outline",className:"h-9 rounded-md px-3 text-xs shadow-lg",onClick:()=>void p("manual"),disabled:n,"data-slot":"browser-state-dump",children:[n?g.jsx(Jl,{className:"size-3.5 animate-spin","aria-hidden":"true"}):g.jsx(x8,{className:"size-3.5","aria-hidden":"true"}),g.jsx("span",{children:y})]})]})}function woe(e){if(e.status==="saved"){nt.success(`诊断已保存: ${e.path}`);return}if(e.status==="downloaded"){nt.info(`诊断已下载: ${e.filename}`);return}nt.error(e.endpointError?`${e.error}: ${e.endpointError}`:e.error)}function Soe(e){return e?e.status==="saved"?`已保存 ${e.path}`:e.status==="downloaded"?`已下载 ${e.filename}`:`失败 ${e.endpointError??e.error}`:null}function xoe(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 j1(e){const{windowKey:t,storageKey:n,maxEntries:r=5e3,dedupeKey:i}=e,s=new Map,o=()=>typeof window>"u"?!1:xoe(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 h=l();if(i){const p=i(d);if(p!==null){const y=s.get(d.event);if(y&&i(y)===p&&h.includes(y)){y.t=d.t,y.repeat=(y.repeat??0)+1;const v=h.indexOf(y);v>=0&&v!==h.length-1&&(h.splice(v,1),h.push(y)),u(h);return}}}if(h.push(d),i&&s.set(d.event,d),h.length>r){const p=h.splice(0,h.length-r);if(i)for(const y of p)s.get(y.event)===y&&s.delete(y.event)}u(h)},getAll:l}}function An(e){return Math.round(e*10)/10}function Va(e){return e.length===0?"":`${An(Math.min(...e))}..${An(Math.max(...e))}`}function Mu(e){return[...new Set(e.filter(t=>t!==void 0).map(An))]}function c3(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 Eoe="dev_anywhere_pty_input_latency_trace",mM=80,Coe=1e4,koe=new TextDecoder;let Toe=0;const Xu=new Map,Cc=j1({windowKey:"__devAnywherePtyInputLatencyTrace",storageKey:Eoe,dedupeKey:e=>e.event.startsWith("input")?null:`${e.event}|${e.sessionId}|${e.outputSeq??""}|${e.pendingInputs??""}`});function Roe(){typeof window>"u"||(window.__devAnywherePtyInputLatencyReport=Ooe)}function Aoe(e,t){if(!Cc.isEnabled())return null;const n=`pty-in-${Date.now().toString(36)}-${++Toe}`,r=performance.now(),i={inputId:n,sessionId:e,data:t,kind:Loe(t),dataLength:t.length,startedAt:r,sentAt:null,firstOutputAt:null,echoMatchedAt:null,xtermWriteAt:null,paintAt:null},s=Xu.get(e)??[];return s.push(i),$1(s,r),Xu.set(e,s),Kf({t:r,event:"input:start",sessionId:e,inputId:n,inputKind:i.kind,dataLength:i.dataLength,pendingInputs:s.length}),{inputId:n,sessionId:e}}function gM(e,t){if(!e||!Cc.isEnabled())return;const n=performance.now(),r=Doe(e.sessionId,e.inputId);r&&(r.sentAt=n),Kf({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 Noe(e,t,n){if(!Cc.isEnabled())return;const r=performance.now(),i=F1(e,r),s=Boe(t),o=[],l=[];for(const u of i)u.firstOutputAt===null&&(u.firstOutputAt=r,o.push(u.inputId)),u.echoMatchedAt===null&&zoe(u)&&s.includes(u.data)&&(u.echoMatchedAt=r,l.push(u.inputId));Kf({t:r,event:"output:received",sessionId:e,outputSeq:n,bytes:t.byteLength,pendingInputs:i.length,deltaFromInputMs:H1(i,r),details:joe([o.length>0?`first=${o.length}`:"",l.length>0?`echo=${l.length}`:""])})}function Moe(e,t,n=1){if(!Cc.isEnabled())return;const r=performance.now(),i=F1(e,r),s=[];for(const o of i)o.xtermWriteAt===null&&(o.xtermWriteAt=r,s.push(o.inputId));Kf({t:r,event:"output:xterm-write",sessionId:e,bytes:t,chunkCount:n,pendingInputs:i.length,deltaFromInputMs:H1(i,r),details:s.length>0?`firstWrite=${s.length}`:""}),typeof requestAnimationFrame=="function"&&s.length>0&&requestAnimationFrame(()=>Poe(e,s))}function Ooe(){const e=Cc.getAll(),t=e.slice(-200),n=[...Xu.values()].flat(),r=n.slice(-80).map(s=>[s.inputId,s.sessionId,s.kind,s.dataLength,s.sentAt===null?"":An(s.sentAt-s.startedAt),s.firstOutputAt===null?"":An(s.firstOutputAt-s.startedAt),s.echoMatchedAt===null?"":An(s.echoMatchedAt-s.startedAt),s.xtermWriteAt===null?"":An(s.xtermWriteAt-s.startedAt),s.paintAt===null?"":An(s.paintAt-s.startedAt)].join(" ")),i=t.map(s=>[An(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?"":An(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(`
510
+ 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},ree="DialogDescriptionWarning",iee=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${OI(ree).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},s1=yI,see=_I,o1=SI,a1=xI,l1=EI,DI=kI,PI=RI,Dv=NI;function oee(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 aee(e){const[t,n]=b.useState(void 0);return Ci(()=>{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 lee=["top","right","bottom","left"],al=Math.min,ls=Math.max,Wg=Math.round,Bm=Math.floor,So=e=>({x:e,y:e}),cee={left:"right",right:"left",bottom:"top",top:"bottom"};function A0(e,t,n){return ls(e,al(t,n))}function ra(e,t){return typeof e=="function"?e(t):e}function ia(e){return e.split("-")[0]}function ad(e){return e.split("-")[1]}function c1(e){return e==="x"?"y":"x"}function u1(e){return e==="y"?"height":"width"}function _o(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function d1(e){return c1(_o(e))}function uee(e,t,n){n===void 0&&(n=!1);const r=ad(e),i=d1(e),s=u1(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(o=qg(o)),[o,qg(o)]}function dee(e){const t=qg(e);return[N0(e),t,N0(t)]}function N0(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const wN=["left","right"],SN=["right","left"],hee=["top","bottom"],fee=["bottom","top"];function pee(e,t,n){switch(e){case"top":case"bottom":return n?t?SN:wN:t?wN:SN;case"left":case"right":return t?hee:fee;default:return[]}}function mee(e,t,n,r){const i=ad(e);let s=pee(ia(e),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),t&&(s=s.concat(s.map(N0)))),s}function qg(e){const t=ia(e);return cee[t]+e.slice(t.length)}function gee(e){return{top:0,right:0,bottom:0,left:0,...e}}function LI(e){return typeof e!="number"?gee(e):{top:e,right:e,bottom:e,left:e}}function Vg(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 xN(e,t,n){let{reference:r,floating:i}=e;const s=_o(t),o=d1(t),l=u1(o),u=ia(t),d=s==="y",h=r.x+r.width/2-i.width/2,p=r.y+r.height/2-i.height/2,y=r[l]/2-i[l]/2;let v;switch(u){case"top":v={x:h,y:r.y-i.height};break;case"bottom":v={x:h,y:r.y+r.height};break;case"right":v={x:r.x+r.width,y:p};break;case"left":v={x:r.x-i.width,y:p};break;default:v={x:r.x,y:r.y}}switch(ad(t)){case"start":v[o]-=y*(n&&d?-1:1);break;case"end":v[o]+=y*(n&&d?-1:1);break}return v}async function vee(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:h="viewport",elementContext:p="floating",altBoundary:y=!1,padding:v=0}=ra(t,e),_=LI(v),x=l[y?p==="floating"?"reference":"floating":p],E=Vg(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(x)))==null||n?x:x.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:d,rootBoundary:h,strategy:u})),k=p==="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},I=Vg(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:k,offsetParent:R,strategy:u}):k);return{top:(E.top-I.top+_.top)/A.y,bottom:(I.bottom-E.bottom+_.bottom)/A.y,left:(E.left-I.left+_.left)/A.x,right:(I.right-E.right+_.right)/A.x}}const yee=50,bee=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,l=o.detectOverflow?o:{...o,detectOverflow:vee},u=await(o.isRTL==null?void 0:o.isRTL(t));let d=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:h,y:p}=xN(d,r,u),y=r,v=0;const _={};for(let w=0;w<s.length;w++){const x=s[w];if(!x)continue;const{name:E,fn:k}=x,{x:R,y:A,data:I,reset:T}=await k({x:h,y:p,initialPlacement:r,placement:y,strategy:i,middlewareData:_,rects:d,platform:l,elements:{reference:e,floating:t}});h=R??h,p=A??p,_[E]={..._[E],...I},T&&v<yee&&(v++,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:h,y:p}=xN(d,y,u)),w=-1)}return{x:h,y:p,placement:y,strategy:i,middlewareData:_}},_ee=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:h=0}=ra(e,t)||{};if(d==null)return{};const p=LI(h),y={x:n,y:r},v=d1(i),_=u1(v),w=await o.getDimensions(d),x=v==="y",E=x?"top":"left",k=x?"bottom":"right",R=x?"clientHeight":"clientWidth",A=s.reference[_]+s.reference[v]-y[v]-s.floating[_],I=y[v]-s.reference[v],T=await(o.getOffsetParent==null?void 0:o.getOffsetParent(d));let H=T?T[R]:0;(!H||!await(o.isElement==null?void 0:o.isElement(T)))&&(H=l.floating[R]||s.floating[_]);const D=A/2-I/2,W=H/2-w[_]/2-1,U=al(p[E],W),F=al(p[k],W),O=U,M=H-w[_]-F,B=H/2-w[_]/2+D,L=A0(O,B,M),N=!u.arrow&&ad(i)!=null&&B!==L&&s.reference[_]/2-(B<O?U:F)-w[_]/2<0,V=N?B<O?B-O:B-M:0;return{[v]:y[v]+V,data:{[v]:L,centerOffset:B-L-V,...N&&{alignmentOffset:V}},reset:N}}}),wee=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:h=!0,crossAxis:p=!0,fallbackPlacements:y,fallbackStrategy:v="bestFit",fallbackAxisSideDirection:_="none",flipAlignment:w=!0,...x}=ra(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const E=ia(i),k=_o(l),R=ia(l)===l,A=await(u.isRTL==null?void 0:u.isRTL(d.floating)),I=y||(R||!w?[qg(l)]:dee(l)),T=_!=="none";!y&&T&&I.push(...mee(l,w,_,A));const H=[l,...I],D=await u.detectOverflow(t,x),W=[];let U=((r=s.flip)==null?void 0:r.overflows)||[];if(h&&W.push(D[E]),p){const B=uee(i,o,A);W.push(D[B[0]],D[B[1]])}if(U=[...U,{placement:i,overflows:W}],!W.every(B=>B<=0)){var F,O;const B=(((F=s.flip)==null?void 0:F.index)||0)+1,L=H[B];if(L&&(!(p==="alignment"?k!==_o(L):!1)||U.every(Y=>_o(Y.placement)===k?Y.overflows[0]>0:!0)))return{data:{index:B,overflows:U},reset:{placement:L}};let N=(O=U.filter(V=>V.overflows[0]<=0).sort((V,Y)=>V.overflows[1]-Y.overflows[1])[0])==null?void 0:O.placement;if(!N)switch(v){case"bestFit":{var M;const V=(M=U.filter(Y=>{if(T){const $=_o(Y.placement);return $===k||$==="y"}return!0}).map(Y=>[Y.placement,Y.overflows.filter($=>$>0).reduce(($,P)=>$+P,0)]).sort((Y,$)=>Y[1]-$[1])[0])==null?void 0:M[0];V&&(N=V);break}case"initialPlacement":N=l;break}if(i!==N)return{reset:{placement:N}}}return{}}}};function EN(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function CN(e){return lee.some(t=>e[t]>=0)}const See=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...s}=ra(e,t);switch(i){case"referenceHidden":{const o=await r.detectOverflow(t,{...s,elementContext:"reference"}),l=EN(o,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:CN(l)}}}case"escaped":{const o=await r.detectOverflow(t,{...s,altBoundary:!0}),l=EN(o,n.floating);return{data:{escapedOffsets:l,escaped:CN(l)}}}default:return{}}}}},II=new Set(["left","top"]);async function xee(e,t){const{placement:n,platform:r,elements:i}=e,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=ia(n),l=ad(n),u=_o(n)==="y",d=II.has(o)?-1:1,h=s&&u?-1:1,p=ra(t,e);let{mainAxis:y,crossAxis:v,alignmentAxis:_}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return l&&typeof _=="number"&&(v=l==="end"?_*-1:_),u?{x:v*h,y:y*d}:{x:y*d,y:v*h}}const Eee=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 xee(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}}}}},Cee=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:E=>{let{x:k,y:R}=E;return{x:k,y:R}}},...d}=ra(e,t),h={x:n,y:r},p=await s.detectOverflow(t,d),y=_o(ia(i)),v=c1(y);let _=h[v],w=h[y];if(o){const E=v==="y"?"top":"left",k=v==="y"?"bottom":"right",R=_+p[E],A=_-p[k];_=A0(R,_,A)}if(l){const E=y==="y"?"top":"left",k=y==="y"?"bottom":"right",R=w+p[E],A=w-p[k];w=A0(R,w,A)}const x=u.fn({...t,[v]:_,[y]:w});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[v]:o,[y]:l}}}}}},kee=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}=ra(e,t),h={x:n,y:r},p=_o(i),y=c1(p);let v=h[y],_=h[p];const w=ra(l,t),x=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]+x.mainAxis,I=s.reference[y]+s.reference[R]-x.mainAxis;v<A?v=A:v>I&&(v=I)}if(d){var E,k;const R=y==="y"?"width":"height",A=II.has(ia(i)),I=s.reference[p]-s.floating[R]+(A&&((E=o.offset)==null?void 0:E[p])||0)+(A?0:x.crossAxis),T=s.reference[p]+s.reference[R]+(A?0:((k=o.offset)==null?void 0:k[p])||0)-(A?x.crossAxis:0);_<I?_=I:_>T&&(_=T)}return{[y]:v,[p]:_}}}},Tee=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}=ra(e,t),h=await o.detectOverflow(t,d),p=ia(i),y=ad(i),v=_o(i)==="y",{width:_,height:w}=s.floating;let x,E;p==="top"||p==="bottom"?(x=p,E=y===(await(o.isRTL==null?void 0:o.isRTL(l.floating))?"start":"end")?"left":"right"):(E=p,x=y==="end"?"top":"bottom");const k=w-h.top-h.bottom,R=_-h.left-h.right,A=al(w-h[x],k),I=al(_-h[E],R),T=!t.middlewareData.shift;let H=A,D=I;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(D=R),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(H=k),T&&!y){const U=ls(h.left,0),F=ls(h.right,0),O=ls(h.top,0),M=ls(h.bottom,0);v?D=_-2*(U!==0||F!==0?U+F:ls(h.left,h.right)):H=w-2*(O!==0||M!==0?O+M:ls(h.top,h.bottom))}await u({...t,availableWidth:D,availableHeight:H});const W=await o.getDimensions(l.floating);return _!==W.width||w!==W.height?{reset:{rects:!0}}:{}}}};function Pv(){return typeof window<"u"}function ld(e){return zI(e)?(e.nodeName||"").toLowerCase():"#document"}function cs(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ro(e){var t;return(t=(zI(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function zI(e){return Pv()?e instanceof Node||e instanceof cs(e).Node:!1}function Gs(e){return Pv()?e instanceof Element||e instanceof cs(e).Element:!1}function oa(e){return Pv()?e instanceof HTMLElement||e instanceof cs(e).HTMLElement:!1}function kN(e){return!Pv()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof cs(e).ShadowRoot}function Bf(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=Xs(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function Ree(e){return/^(table|td|th)$/.test(ld(e))}function Lv(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Aee=/transform|translate|scale|rotate|perspective|filter/,Nee=/paint|layout|strict|content/,Hl=e=>!!e&&e!=="none";let Y_;function h1(e){const t=Gs(e)?Xs(e):e;return Hl(t.transform)||Hl(t.translate)||Hl(t.scale)||Hl(t.rotate)||Hl(t.perspective)||!f1()&&(Hl(t.backdropFilter)||Hl(t.filter))||Aee.test(t.willChange||"")||Nee.test(t.contain||"")}function Mee(e){let t=ll(e);for(;oa(t)&&!Vu(t);){if(h1(t))return t;if(Lv(t))return null;t=ll(t)}return null}function f1(){return Y_==null&&(Y_=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Y_}function Vu(e){return/^(html|body|#document)$/.test(ld(e))}function Xs(e){return cs(e).getComputedStyle(e)}function Iv(e){return Gs(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ll(e){if(ld(e)==="html")return e;const t=e.assignedSlot||e.parentNode||kN(e)&&e.host||Ro(e);return kN(t)?t.host:t}function BI(e){const t=ll(e);return Vu(t)?e.ownerDocument?e.ownerDocument.body:e.body:oa(t)&&Bf(t)?t:BI(t)}function mf(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=BI(e),s=i===((r=e.ownerDocument)==null?void 0:r.body),o=cs(i);if(s){const l=M0(o);return t.concat(o,o.visualViewport||[],Bf(i)?i:[],l&&n?mf(l):[])}else return t.concat(i,mf(i,[],n))}function M0(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function jI(e){const t=Xs(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=oa(e),s=i?e.offsetWidth:n,o=i?e.offsetHeight:r,l=Wg(n)!==s||Wg(r)!==o;return l&&(n=s,r=o),{width:n,height:r,$:l}}function p1(e){return Gs(e)?e:e.contextElement}function ju(e){const t=p1(e);if(!oa(t))return So(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:s}=jI(t);let o=(s?Wg(n.width):n.width)/r,l=(s?Wg(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const Oee=So(0);function FI(e){const t=cs(e);return!f1()||!t.visualViewport?Oee:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Dee(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==cs(e)?!1:t}function ac(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),s=p1(e);let o=So(1);t&&(r?Gs(r)&&(o=ju(r)):o=ju(e));const l=Dee(s,n,r)?FI(s):So(0);let u=(i.left+l.x)/o.x,d=(i.top+l.y)/o.y,h=i.width/o.x,p=i.height/o.y;if(s){const y=cs(s),v=r&&Gs(r)?cs(r):r;let _=y,w=M0(_);for(;w&&r&&v!==_;){const x=ju(w),E=w.getBoundingClientRect(),k=Xs(w),R=E.left+(w.clientLeft+parseFloat(k.paddingLeft))*x.x,A=E.top+(w.clientTop+parseFloat(k.paddingTop))*x.y;u*=x.x,d*=x.y,h*=x.x,p*=x.y,u+=R,d+=A,_=cs(w),w=M0(_)}}return Vg({width:h,height:p,x:u,y:d})}function zv(e,t){const n=Iv(e).scrollLeft;return t?t.left+n:ac(Ro(e)).left+n}function $I(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-zv(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function Pee(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const s=i==="fixed",o=Ro(r),l=t?Lv(t.floating):!1;if(r===o||l&&s)return n;let u={scrollLeft:0,scrollTop:0},d=So(1);const h=So(0),p=oa(r);if((p||!p&&!s)&&((ld(r)!=="body"||Bf(o))&&(u=Iv(r)),p)){const v=ac(r);d=ju(r),h.x=v.x+r.clientLeft,h.y=v.y+r.clientTop}const y=o&&!p&&!s?$I(o,u):So(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-u.scrollLeft*d.x+h.x+y.x,y:n.y*d.y-u.scrollTop*d.y+h.y+y.y}}function Lee(e){return Array.from(e.getClientRects())}function Iee(e){const t=Ro(e),n=Iv(e),r=e.ownerDocument.body,i=ls(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=ls(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+zv(e);const l=-n.scrollTop;return Xs(r).direction==="rtl"&&(o+=ls(t.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:l}}const TN=25;function zee(e,t){const n=cs(e),r=Ro(e),i=n.visualViewport;let s=r.clientWidth,o=r.clientHeight,l=0,u=0;if(i){s=i.width,o=i.height;const h=f1();(!h||h&&t==="fixed")&&(l=i.offsetLeft,u=i.offsetTop)}const d=zv(r);if(d<=0){const h=r.ownerDocument,p=h.body,y=getComputedStyle(p),v=h.compatMode==="CSS1Compat"&&parseFloat(y.marginLeft)+parseFloat(y.marginRight)||0,_=Math.abs(r.clientWidth-p.clientWidth-v);_<=TN&&(s-=_)}else d<=TN&&(s+=d);return{width:s,height:o,x:l,y:u}}function Bee(e,t){const n=ac(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=oa(e)?ju(e):So(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 RN(e,t,n){let r;if(t==="viewport")r=zee(e,n);else if(t==="document")r=Iee(Ro(e));else if(Gs(t))r=Bee(t,n);else{const i=FI(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Vg(r)}function HI(e,t){const n=ll(e);return n===t||!Gs(n)||Vu(n)?!1:Xs(n).position==="fixed"||HI(n,t)}function jee(e,t){const n=t.get(e);if(n)return n;let r=mf(e,[],!1).filter(l=>Gs(l)&&ld(l)!=="body"),i=null;const s=Xs(e).position==="fixed";let o=s?ll(e):e;for(;Gs(o)&&!Vu(o);){const l=Xs(o),u=h1(o);!u&&l.position==="fixed"&&(i=null),(s?!u&&!i:!u&&l.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||Bf(o)&&!u&&HI(e,o))?r=r.filter(h=>h!==o):i=l,o=ll(o)}return t.set(e,r),r}function Fee(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[...n==="clippingAncestors"?Lv(t)?[]:jee(t,this._c):[].concat(n),r],l=RN(t,o[0],i);let u=l.top,d=l.right,h=l.bottom,p=l.left;for(let y=1;y<o.length;y++){const v=RN(t,o[y],i);u=ls(v.top,u),d=al(v.right,d),h=al(v.bottom,h),p=ls(v.left,p)}return{width:d-p,height:h-u,x:p,y:u}}function $ee(e){const{width:t,height:n}=jI(e);return{width:t,height:n}}function Hee(e,t,n){const r=oa(t),i=Ro(t),s=n==="fixed",o=ac(e,!0,s,t);let l={scrollLeft:0,scrollTop:0};const u=So(0);function d(){u.x=zv(i)}if(r||!r&&!s)if((ld(t)!=="body"||Bf(i))&&(l=Iv(t)),r){const v=ac(t,!0,s,t);u.x=v.x+t.clientLeft,u.y=v.y+t.clientTop}else i&&d();s&&!r&&i&&d();const h=i&&!r&&!s?$I(i,l):So(0),p=o.left+l.scrollLeft-u.x-h.x,y=o.top+l.scrollTop-u.y-h.y;return{x:p,y,width:o.width,height:o.height}}function K_(e){return Xs(e).position==="static"}function AN(e,t){if(!oa(e)||Xs(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ro(e)===n&&(n=n.ownerDocument.body),n}function UI(e,t){const n=cs(e);if(Lv(e))return n;if(!oa(e)){let i=ll(e);for(;i&&!Vu(i);){if(Gs(i)&&!K_(i))return i;i=ll(i)}return n}let r=AN(e,t);for(;r&&Ree(r)&&K_(r);)r=AN(r,t);return r&&Vu(r)&&K_(r)&&!h1(r)?n:r||Mee(e)||n}const Uee=async function(e){const t=this.getOffsetParent||UI,n=this.getDimensions,r=await n(e.floating);return{reference:Hee(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Wee(e){return Xs(e).direction==="rtl"}const qee={convertOffsetParentRelativeRectToViewportRelativeRect:Pee,getDocumentElement:Ro,getClippingRect:Fee,getOffsetParent:UI,getElementRects:Uee,getClientRects:Lee,getDimensions:$ee,getScale:ju,isElement:Gs,isRTL:Wee};function WI(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Vee(e,t){let n=null,r;const i=Ro(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:h,top:p,width:y,height:v}=d;if(l||t(),!y||!v)return;const _=Bm(p),w=Bm(i.clientWidth-(h+y)),x=Bm(i.clientHeight-(p+v)),E=Bm(h),R={rootMargin:-_+"px "+-w+"px "+-x+"px "+-E+"px",threshold:ls(0,al(1,u))||1};let A=!0;function I(T){const H=T[0].intersectionRatio;if(H!==u){if(!A)return o();H?o(!1,H):r=setTimeout(()=>{o(!1,1e-7)},1e3)}H===1&&!WI(d,e.getBoundingClientRect())&&o(),A=!1}try{n=new IntersectionObserver(I,{...R,root:i.ownerDocument})}catch{n=new IntersectionObserver(I,R)}n.observe(e)}return o(!0),s}function Yee(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=p1(e),h=i||s?[...d?mf(d):[],...t?mf(t):[]]:[];h.forEach(E=>{i&&E.addEventListener("scroll",n,{passive:!0}),s&&E.addEventListener("resize",n)});const p=d&&l?Vee(d,n):null;let y=-1,v=null;o&&(v=new ResizeObserver(E=>{let[k]=E;k&&k.target===d&&v&&t&&(v.unobserve(t),cancelAnimationFrame(y),y=requestAnimationFrame(()=>{var R;(R=v)==null||R.observe(t)})),n()}),d&&!u&&v.observe(d),t&&v.observe(t));let _,w=u?ac(e):null;u&&x();function x(){const E=ac(e);w&&!WI(w,E)&&n(),w=E,_=requestAnimationFrame(x)}return n(),()=>{var E;h.forEach(k=>{i&&k.removeEventListener("scroll",n),s&&k.removeEventListener("resize",n)}),p==null||p(),(E=v)==null||E.disconnect(),v=null,u&&cancelAnimationFrame(_)}}const Kee=Eee,Gee=Cee,Xee=wee,Zee=Tee,Qee=See,NN=_ee,Jee=kee,ete=(e,t,n)=>{const r=new Map,i={platform:qee,...n},s={...i.platform,_c:r};return bee(e,t,{...i,platform:s})};var tte=typeof document<"u",nte=function(){},bg=tte?b.useLayoutEffect:nte;function Yg(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(!Yg(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)&&!Yg(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function qI(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function MN(e,t){const n=qI(e);return Math.round(t*n)/n}function G_(e){const t=b.useRef(e);return bg(()=>{t.current=e}),t}function rte(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,[h,p]=b.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[y,v]=b.useState(r);Yg(y,r)||v(r);const[_,w]=b.useState(null),[x,E]=b.useState(null),k=b.useCallback(Y=>{Y!==T.current&&(T.current=Y,w(Y))},[]),R=b.useCallback(Y=>{Y!==H.current&&(H.current=Y,E(Y))},[]),A=s||_,I=o||x,T=b.useRef(null),H=b.useRef(null),D=b.useRef(h),W=u!=null,U=G_(u),F=G_(i),O=G_(d),M=b.useCallback(()=>{if(!T.current||!H.current)return;const Y={placement:t,strategy:n,middleware:y};F.current&&(Y.platform=F.current),ete(T.current,H.current,Y).then($=>{const P={...$,isPositioned:O.current!==!1};B.current&&!Yg(D.current,P)&&(D.current=P,id.flushSync(()=>{p(P)}))})},[y,t,n,F,O]);bg(()=>{d===!1&&D.current.isPositioned&&(D.current.isPositioned=!1,p(Y=>({...Y,isPositioned:!1})))},[d]);const B=b.useRef(!1);bg(()=>(B.current=!0,()=>{B.current=!1}),[]),bg(()=>{if(A&&(T.current=A),I&&(H.current=I),A&&I){if(U.current)return U.current(A,I,M);M()}},[A,I,M,U,W]);const L=b.useMemo(()=>({reference:T,floating:H,setReference:k,setFloating:R}),[k,R]),N=b.useMemo(()=>({reference:A,floating:I}),[A,I]),V=b.useMemo(()=>{const Y={position:n,left:0,top:0};if(!N.floating)return Y;const $=MN(N.floating,h.x),P=MN(N.floating,h.y);return l?{...Y,transform:"translate("+$+"px, "+P+"px)",...qI(N.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:$,top:P}},[n,l,N.floating,h.x,h.y]);return b.useMemo(()=>({...h,update:M,refs:L,elements:N,floatingStyles:V}),[h,M,L,N,V])}const ite=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?NN({element:r.current,padding:i}).fn(n):{}:r?NN({element:r,padding:i}).fn(n):{}}}},ste=(e,t)=>{const n=Kee(e);return{name:n.name,fn:n.fn,options:[e,t]}},ote=(e,t)=>{const n=Gee(e);return{name:n.name,fn:n.fn,options:[e,t]}},ate=(e,t)=>({fn:Jee(e).fn,options:[e,t]}),lte=(e,t)=>{const n=Xee(e);return{name:n.name,fn:n.fn,options:[e,t]}},cte=(e,t)=>{const n=Zee(e);return{name:n.name,fn:n.fn,options:[e,t]}},ute=(e,t)=>{const n=Qee(e);return{name:n.name,fn:n.fn,options:[e,t]}},dte=(e,t)=>{const n=ite(e);return{name:n.name,fn:n.fn,options:[e,t]}};var hte="Arrow",VI=b.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...s}=e;return g.jsx(Jt.svg,{...s,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:g.jsx("polygon",{points:"0,0 30,0 15,10"})})});VI.displayName=hte;var fte=VI,m1="Popper",[YI,yl]=sa(m1),[pte,KI]=YI(m1),GI=e=>{const{__scopePopper:t,children:n}=e,[r,i]=b.useState(null);return g.jsx(pte,{scope:t,anchor:r,onAnchorChange:i,children:n})};GI.displayName=m1;var XI="PopperAnchor",ZI=b.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...i}=e,s=KI(XI,n),o=b.useRef(null),l=zn(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:g.jsx(Jt.div,{...i,ref:l})});ZI.displayName=XI;var g1="PopperContent",[mte,gte]=YI(g1),QI=b.forwardRef((e,t)=>{var Q,me,ve,Ce,Me,Ve;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:s="center",alignOffset:o=0,arrowPadding:l=0,avoidCollisions:u=!0,collisionBoundary:d=[],collisionPadding:h=0,sticky:p="partial",hideWhenDetached:y=!1,updatePositionStrategy:v="optimized",onPlaced:_,...w}=e,x=KI(g1,n),[E,k]=b.useState(null),R=zn(t,Qe=>k(Qe)),[A,I]=b.useState(null),T=aee(A),H=(T==null?void 0:T.width)??0,D=(T==null?void 0:T.height)??0,W=r+(s!=="center"?"-"+s:""),U=typeof h=="number"?h:{top:0,right:0,bottom:0,left:0,...h},F=Array.isArray(d)?d:[d],O=F.length>0,M={padding:U,boundary:F.filter(yte),altBoundary:O},{refs:B,floatingStyles:L,placement:N,isPositioned:V,middlewareData:Y}=rte({strategy:"fixed",placement:W,whileElementsMounted:(...Qe)=>Yee(...Qe,{animationFrame:v==="always"}),elements:{reference:x.anchor},middleware:[ste({mainAxis:i+D,alignmentAxis:o}),u&&ote({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?ate():void 0,...M}),u&&lte({...M}),cte({...M,apply:({elements:Qe,rects:ct,availableWidth:Ot,availableHeight:he})=>{const{width:Ke,height:Rt}=ct.reference,ye=Qe.floating.style;ye.setProperty("--radix-popper-available-width",`${Ot}px`),ye.setProperty("--radix-popper-available-height",`${he}px`),ye.setProperty("--radix-popper-anchor-width",`${Ke}px`),ye.setProperty("--radix-popper-anchor-height",`${Rt}px`)}}),A&&dte({element:A,padding:l}),bte({arrowWidth:H,arrowHeight:D}),y&&ute({strategy:"referenceHidden",...M})]}),[$,P]=tz(N),q=Co(_);Ci(()=>{V&&(q==null||q())},[V,q]);const K=(Q=Y.arrow)==null?void 0:Q.x,z=(me=Y.arrow)==null?void 0:me.y,X=((ve=Y.arrow)==null?void 0:ve.centerOffset)!==0,[ee,te]=b.useState();return Ci(()=>{E&&te(window.getComputedStyle(E).zIndex)},[E]),g.jsx("div",{ref:B.setFloating,"data-radix-popper-content-wrapper":"",style:{...L,transform:V?L.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ee,"--radix-popper-transform-origin":[(Ce=Y.transformOrigin)==null?void 0:Ce.x,(Me=Y.transformOrigin)==null?void 0:Me.y].join(" "),...((Ve=Y.hide)==null?void 0:Ve.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:g.jsx(mte,{scope:n,placedSide:$,onArrowChange:I,arrowX:K,arrowY:z,shouldHideArrow:X,children:g.jsx(Jt.div,{"data-side":$,"data-align":P,...w,ref:R,style:{...w.style,animation:V?void 0:"none"}})})})});QI.displayName=g1;var JI="PopperArrow",vte={top:"bottom",right:"left",bottom:"top",left:"right"},ez=b.forwardRef(function(t,n){const{__scopePopper:r,...i}=t,s=gte(JI,r),o=vte[s.placedSide];return g.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:g.jsx(fte,{...i,ref:n,style:{...i.style,display:"block"}})})});ez.displayName=JI;function yte(e){return e!==null}var bte=e=>({name:"transformOrigin",options:e,fn(t){var x,E,k;const{placement:n,rects:r,middlewareData:i}=t,o=((x=i.arrow)==null?void 0:x.centerOffset)!==0,l=o?0:e.arrowWidth,u=o?0:e.arrowHeight,[d,h]=tz(n),p={start:"0%",center:"50%",end:"100%"}[h],y=(((E=i.arrow)==null?void 0:E.x)??0)+l/2,v=(((k=i.arrow)==null?void 0:k.y)??0)+u/2;let _="",w="";return d==="bottom"?(_=o?p:`${y}px`,w=`${-u}px`):d==="top"?(_=o?p:`${y}px`,w=`${r.floating.height+u}px`):d==="right"?(_=`${-u}px`,w=o?p:`${v}px`):d==="left"&&(_=`${r.floating.width+u}px`,w=o?p:`${v}px`),{data:{x:_,y:w}}}});function tz(e){const[t,n="center"]=e.split("-");return[t,n]}var Bv=GI,jf=ZI,jv=QI,Fv=ez,X_="rovingFocusGroup.onEntryFocus",_te={bubbles:!1,cancelable:!0},Ff="RovingFocusGroup",[O0,nz,wte]=e1(Ff),[Ste,rz]=sa(Ff,[wte]),[xte,Ete]=Ste(Ff),iz=b.forwardRef((e,t)=>g.jsx(O0.Provider,{scope:e.__scopeRovingFocusGroup,children:g.jsx(O0.Slot,{scope:e.__scopeRovingFocusGroup,children:g.jsx(Cte,{...e,ref:t})})}));iz.displayName=Ff;var Cte=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:s,currentTabStopId:o,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:u,onEntryFocus:d,preventScrollOnEntryFocus:h=!1,...p}=e,y=b.useRef(null),v=zn(t,y),_=t1(s),[w,x]=sc({prop:o,defaultProp:l??null,onChange:u,caller:Ff}),[E,k]=b.useState(!1),R=Co(d),A=nz(n),I=b.useRef(!1),[T,H]=b.useState(0);return b.useEffect(()=>{const D=y.current;if(D)return D.addEventListener(X_,R),()=>D.removeEventListener(X_,R)},[R]),g.jsx(xte,{scope:n,orientation:r,dir:_,loop:i,currentTabStopId:w,onItemFocus:b.useCallback(D=>x(D),[x]),onItemShiftTab:b.useCallback(()=>k(!0),[]),onFocusableItemAdd:b.useCallback(()=>H(D=>D+1),[]),onFocusableItemRemove:b.useCallback(()=>H(D=>D-1),[]),children:g.jsx(Jt.div,{tabIndex:E||T===0?-1:0,"data-orientation":r,...p,ref:v,style:{outline:"none",...e.style},onMouseDown:bt(e.onMouseDown,()=>{I.current=!0}),onFocus:bt(e.onFocus,D=>{const W=!I.current;if(D.target===D.currentTarget&&W&&!E){const U=new CustomEvent(X_,_te);if(D.currentTarget.dispatchEvent(U),!U.defaultPrevented){const F=A().filter(N=>N.focusable),O=F.find(N=>N.active),M=F.find(N=>N.id===w),L=[O,M,...F].filter(Boolean).map(N=>N.ref.current);az(L,h)}}I.current=!1}),onBlur:bt(e.onBlur,()=>k(!1))})})}),sz="RovingFocusGroupItem",oz=b.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:s,children:o,...l}=e,u=vi(),d=s||u,h=Ete(sz,n),p=h.currentTabStopId===d,y=nz(n),{onFocusableItemAdd:v,onFocusableItemRemove:_,currentTabStopId:w}=h;return b.useEffect(()=>{if(r)return v(),()=>_()},[r,v,_]),g.jsx(O0.ItemSlot,{scope:n,id:d,focusable:r,active:i,children:g.jsx(Jt.span,{tabIndex:p?0:-1,"data-orientation":h.orientation,...l,ref:t,onMouseDown:bt(e.onMouseDown,x=>{r?h.onItemFocus(d):x.preventDefault()}),onFocus:bt(e.onFocus,()=>h.onItemFocus(d)),onKeyDown:bt(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){h.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const E=Rte(x,h.orientation,h.dir);if(E!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let R=y().filter(A=>A.focusable).map(A=>A.ref.current);if(E==="last")R.reverse();else if(E==="prev"||E==="next"){E==="prev"&&R.reverse();const A=R.indexOf(x.currentTarget);R=h.loop?Ate(R,A+1):R.slice(A+1)}setTimeout(()=>az(R))}}),children:typeof o=="function"?o({isCurrentTabStop:p,hasTabStop:w!=null}):o})})});oz.displayName=sz;var kte={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Tte(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Rte(e,t,n){const r=Tte(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return kte[r]}function az(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Ate(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Nte=iz,Mte=oz,D0=["Enter"," "],Ote=["ArrowDown","PageUp","Home"],lz=["ArrowUp","PageDown","End"],Dte=[...Ote,...lz],Pte={ltr:[...D0,"ArrowRight"],rtl:[...D0,"ArrowLeft"]},Lte={ltr:["ArrowLeft"],rtl:["ArrowRight"]},$f="Menu",[gf,Ite,zte]=e1($f),[_c,cz]=sa($f,[zte,yl,rz]),$v=yl(),uz=rz(),[Bte,wc]=_c($f),[jte,Hf]=_c($f),dz=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,l=$v(t),[u,d]=b.useState(null),h=b.useRef(!1),p=Co(s),y=t1(i);return b.useEffect(()=>{const v=()=>{h.current=!0,document.addEventListener("pointerdown",_,{capture:!0,once:!0}),document.addEventListener("pointermove",_,{capture:!0,once:!0})},_=()=>h.current=!1;return document.addEventListener("keydown",v,{capture:!0}),()=>{document.removeEventListener("keydown",v,{capture:!0}),document.removeEventListener("pointerdown",_,{capture:!0}),document.removeEventListener("pointermove",_,{capture:!0})}},[]),g.jsx(Bv,{...l,children:g.jsx(Bte,{scope:t,open:n,onOpenChange:p,content:u,onContentChange:d,children:g.jsx(jte,{scope:t,onClose:b.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:h,dir:y,modal:o,children:r})})})};dz.displayName=$f;var Fte="MenuAnchor",v1=b.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=$v(n);return g.jsx(jf,{...i,...r,ref:t})});v1.displayName=Fte;var y1="MenuPortal",[$te,hz]=_c(y1,{forceMount:void 0}),fz=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=wc(y1,t);return g.jsx($te,{scope:t,forceMount:n,children:g.jsx(Ls,{present:n||s.open,children:g.jsx(od,{asChild:!0,container:i,children:r})})})};fz.displayName=y1;var Ns="MenuContent",[Hte,b1]=_c(Ns),pz=b.forwardRef((e,t)=>{const n=hz(Ns,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=wc(Ns,e.__scopeMenu),o=Hf(Ns,e.__scopeMenu);return g.jsx(gf.Provider,{scope:e.__scopeMenu,children:g.jsx(Ls,{present:r||s.open,children:g.jsx(gf.Slot,{scope:e.__scopeMenu,children:o.modal?g.jsx(Ute,{...i,ref:t}):g.jsx(Wte,{...i,ref:t})})})})}),Ute=b.forwardRef((e,t)=>{const n=wc(Ns,e.__scopeMenu),r=b.useRef(null),i=zn(t,r);return b.useEffect(()=>{const s=r.current;if(s)return Mv(s)},[]),g.jsx(_1,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:bt(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Wte=b.forwardRef((e,t)=>{const n=wc(Ns,e.__scopeMenu);return g.jsx(_1,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),qte=ol("MenuContent.ScrollLock"),_1=b.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEntryFocus:u,onEscapeKeyDown:d,onPointerDownOutside:h,onFocusOutside:p,onInteractOutside:y,onDismiss:v,disableOutsideScroll:_,...w}=e,x=wc(Ns,n),E=Hf(Ns,n),k=$v(n),R=uz(n),A=Ite(n),[I,T]=b.useState(null),H=b.useRef(null),D=zn(t,H,x.onContentChange),W=b.useRef(0),U=b.useRef(""),F=b.useRef(0),O=b.useRef(null),M=b.useRef("right"),B=b.useRef(0),L=_?zf:b.Fragment,N=_?{as:qte,allowPinchZoom:!0}:void 0,V=$=>{var Q,me;const P=U.current+$,q=A().filter(ve=>!ve.disabled),K=document.activeElement,z=(Q=q.find(ve=>ve.ref.current===K))==null?void 0:Q.textValue,X=q.map(ve=>ve.textValue),ee=rne(X,P,z),te=(me=q.find(ve=>ve.textValue===ee))==null?void 0:me.ref.current;(function ve(Ce){U.current=Ce,window.clearTimeout(W.current),Ce!==""&&(W.current=window.setTimeout(()=>ve(""),1e3))})(P),te&&setTimeout(()=>te.focus())};b.useEffect(()=>()=>window.clearTimeout(W.current),[]),Av();const Y=b.useCallback($=>{var q,K;return M.current===((q=O.current)==null?void 0:q.side)&&sne($,(K=O.current)==null?void 0:K.area)},[]);return g.jsx(Hte,{scope:n,searchRef:U,onItemEnter:b.useCallback($=>{Y($)&&$.preventDefault()},[Y]),onItemLeave:b.useCallback($=>{var P;Y($)||((P=H.current)==null||P.focus(),T(null))},[Y]),onTriggerLeave:b.useCallback($=>{Y($)&&$.preventDefault()},[Y]),pointerGraceTimerRef:F,onPointerGraceIntentChange:b.useCallback($=>{O.current=$},[]),children:g.jsx(L,{...N,children:g.jsx(If,{asChild:!0,trapped:i,onMountAutoFocus:bt(s,$=>{var P;$.preventDefault(),(P=H.current)==null||P.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:g.jsx(sd,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:d,onPointerDownOutside:h,onFocusOutside:p,onInteractOutside:y,onDismiss:v,children:g.jsx(Nte,{asChild:!0,...R,dir:E.dir,orientation:"vertical",loop:r,currentTabStopId:I,onCurrentTabStopIdChange:T,onEntryFocus:bt(u,$=>{E.isUsingKeyboardRef.current||$.preventDefault()}),preventScrollOnEntryFocus:!0,children:g.jsx(jv,{role:"menu","aria-orientation":"vertical","data-state":Nz(x.open),"data-radix-menu-content":"",dir:E.dir,...k,...w,ref:D,style:{outline:"none",...w.style},onKeyDown:bt(w.onKeyDown,$=>{const q=$.target.closest("[data-radix-menu-content]")===$.currentTarget,K=$.ctrlKey||$.altKey||$.metaKey,z=$.key.length===1;q&&($.key==="Tab"&&$.preventDefault(),!K&&z&&V($.key));const X=H.current;if($.target!==X||!Dte.includes($.key))return;$.preventDefault();const te=A().filter(Q=>!Q.disabled).map(Q=>Q.ref.current);lz.includes($.key)&&te.reverse(),tne(te)}),onBlur:bt(e.onBlur,$=>{$.currentTarget.contains($.target)||(window.clearTimeout(W.current),U.current="")}),onPointerMove:bt(e.onPointerMove,vf($=>{const P=$.target,q=B.current!==$.clientX;if($.currentTarget.contains(P)&&q){const K=$.clientX>B.current?"right":"left";M.current=K,B.current=$.clientX}}))})})})})})})});pz.displayName=Ns;var Vte="MenuGroup",w1=b.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return g.jsx(Jt.div,{role:"group",...r,ref:t})});w1.displayName=Vte;var Yte="MenuLabel",mz=b.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return g.jsx(Jt.div,{...r,ref:t})});mz.displayName=Yte;var Kg="MenuItem",ON="menu.itemSelect",Hv=b.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=b.useRef(null),o=Hf(Kg,e.__scopeMenu),l=b1(Kg,e.__scopeMenu),u=zn(t,s),d=b.useRef(!1),h=()=>{const p=s.current;if(!n&&p){const y=new CustomEvent(ON,{bubbles:!0,cancelable:!0});p.addEventListener(ON,v=>r==null?void 0:r(v),{once:!0}),nI(p,y),y.defaultPrevented?d.current=!1:o.onClose()}};return g.jsx(gz,{...i,ref:u,disabled:n,onClick:bt(e.onClick,h),onPointerDown:p=>{var y;(y=e.onPointerDown)==null||y.call(e,p),d.current=!0},onPointerUp:bt(e.onPointerUp,p=>{var y;d.current||(y=p.currentTarget)==null||y.click()}),onKeyDown:bt(e.onKeyDown,p=>{const y=l.searchRef.current!=="";n||y&&p.key===" "||D0.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});Hv.displayName=Kg;var gz=b.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=b1(Kg,n),l=uz(n),u=b.useRef(null),d=zn(t,u),[h,p]=b.useState(!1),[y,v]=b.useState("");return b.useEffect(()=>{const _=u.current;_&&v((_.textContent??"").trim())},[s.children]),g.jsx(gf.ItemSlot,{scope:n,disabled:r,textValue:i??y,children:g.jsx(Mte,{asChild:!0,...l,focusable:!r,children:g.jsx(Jt.div,{role:"menuitem","data-highlighted":h?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:d,onPointerMove:bt(e.onPointerMove,vf(_=>{r?o.onItemLeave(_):(o.onItemEnter(_),_.defaultPrevented||_.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:bt(e.onPointerLeave,vf(_=>o.onItemLeave(_))),onFocus:bt(e.onFocus,()=>p(!0)),onBlur:bt(e.onBlur,()=>p(!1))})})})}),Kte="MenuCheckboxItem",vz=b.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return g.jsx(Sz,{scope:e.__scopeMenu,checked:n,children:g.jsx(Hv,{role:"menuitemcheckbox","aria-checked":Gg(n)?"mixed":n,...i,ref:t,"data-state":x1(n),onSelect:bt(i.onSelect,()=>r==null?void 0:r(Gg(n)?!0:!n),{checkForDefaultPrevented:!1})})})});vz.displayName=Kte;var yz="MenuRadioGroup",[Gte,Xte]=_c(yz,{value:void 0,onValueChange:()=>{}}),bz=b.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=Co(r);return g.jsx(Gte,{scope:e.__scopeMenu,value:n,onValueChange:s,children:g.jsx(w1,{...i,ref:t})})});bz.displayName=yz;var _z="MenuRadioItem",wz=b.forwardRef((e,t)=>{const{value:n,...r}=e,i=Xte(_z,e.__scopeMenu),s=n===i.value;return g.jsx(Sz,{scope:e.__scopeMenu,checked:s,children:g.jsx(Hv,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":x1(s),onSelect:bt(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});wz.displayName=_z;var S1="MenuItemIndicator",[Sz,Zte]=_c(S1,{checked:!1}),xz=b.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=Zte(S1,n);return g.jsx(Ls,{present:r||Gg(s.checked)||s.checked===!0,children:g.jsx(Jt.span,{...i,ref:t,"data-state":x1(s.checked)})})});xz.displayName=S1;var Qte="MenuSeparator",Ez=b.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return g.jsx(Jt.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Ez.displayName=Qte;var Jte="MenuArrow",Cz=b.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=$v(n);return g.jsx(Fv,{...i,...r,ref:t})});Cz.displayName=Jte;var ene="MenuSub",[mRe,kz]=_c(ene),Ih="MenuSubTrigger",Tz=b.forwardRef((e,t)=>{const n=wc(Ih,e.__scopeMenu),r=Hf(Ih,e.__scopeMenu),i=kz(Ih,e.__scopeMenu),s=b1(Ih,e.__scopeMenu),o=b.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:u}=s,d={__scopeMenu:e.__scopeMenu},h=b.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return b.useEffect(()=>h,[h]),b.useEffect(()=>{const p=l.current;return()=>{window.clearTimeout(p),u(null)}},[l,u]),g.jsx(v1,{asChild:!0,...d,children:g.jsx(gz,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":Nz(n.open),...e,ref:na(t,i.onTriggerChange),onClick:p=>{var y;(y=e.onClick)==null||y.call(e,p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:bt(e.onPointerMove,vf(p=>{s.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(s.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),h()},100))})),onPointerLeave:bt(e.onPointerLeave,vf(p=>{var v,_;h();const y=(v=n.content)==null?void 0:v.getBoundingClientRect();if(y){const w=(_=n.content)==null?void 0:_.dataset.side,x=w==="right",E=x?-5:5,k=y[x?"left":"right"],R=y[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:p.clientX+E,y:p.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(p),p.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:bt(e.onKeyDown,p=>{var v;const y=s.searchRef.current!=="";e.disabled||y&&p.key===" "||Pte[r.dir].includes(p.key)&&(n.onOpenChange(!0),(v=n.content)==null||v.focus(),p.preventDefault())})})})});Tz.displayName=Ih;var Rz="MenuSubContent",Az=b.forwardRef((e,t)=>{const n=hz(Ns,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=wc(Ns,e.__scopeMenu),o=Hf(Ns,e.__scopeMenu),l=kz(Rz,e.__scopeMenu),u=b.useRef(null),d=zn(t,u);return g.jsx(gf.Provider,{scope:e.__scopeMenu,children:g.jsx(Ls,{present:r||s.open,children:g.jsx(gf.Slot,{scope:e.__scopeMenu,children:g.jsx(_1,{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:h=>{var p;o.isUsingKeyboardRef.current&&((p=u.current)==null||p.focus()),h.preventDefault()},onCloseAutoFocus:h=>h.preventDefault(),onFocusOutside:bt(e.onFocusOutside,h=>{h.target!==l.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:bt(e.onEscapeKeyDown,h=>{o.onClose(),h.preventDefault()}),onKeyDown:bt(e.onKeyDown,h=>{var v;const p=h.currentTarget.contains(h.target),y=Lte[o.dir].includes(h.key);p&&y&&(s.onOpenChange(!1),(v=l.trigger)==null||v.focus(),h.preventDefault())})})})})})});Az.displayName=Rz;function Nz(e){return e?"open":"closed"}function Gg(e){return e==="indeterminate"}function x1(e){return Gg(e)?"indeterminate":e?"checked":"unchecked"}function tne(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function nne(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function rne(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=nne(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 ine(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,h=l.y,p=u.x,y=u.y;h>r!=y>r&&n<(p-d)*(r-h)/(y-h)+d&&(i=!i)}return i}function sne(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return ine(n,t)}function vf(e){return t=>t.pointerType==="mouse"?e(t):void 0}var one=dz,ane=v1,lne=fz,cne=pz,une=w1,dne=mz,hne=Hv,fne=vz,pne=bz,mne=wz,gne=xz,vne=Ez,yne=Cz,bne=Tz,_ne=Az,Uv="DropdownMenu",[wne]=sa(Uv,[cz]),Li=cz(),[Sne,Mz]=wne(Uv),Oz=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:l=!0}=e,u=Li(t),d=b.useRef(null),[h,p]=sc({prop:i,defaultProp:s??!1,onChange:o,caller:Uv});return g.jsx(Sne,{scope:t,triggerId:vi(),triggerRef:d,contentId:vi(),open:h,onOpenChange:p,onOpenToggle:b.useCallback(()=>p(y=>!y),[p]),modal:l,children:g.jsx(one,{...u,open:h,onOpenChange:p,dir:r,modal:l,children:n})})};Oz.displayName=Uv;var Dz="DropdownMenuTrigger",Pz=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,s=Mz(Dz,n),o=Li(n);return g.jsx(ane,{asChild:!0,...o,children:g.jsx(Jt.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:na(t,s.triggerRef),onPointerDown:bt(e.onPointerDown,l=>{!r&&l.button===0&&l.ctrlKey===!1&&(s.onOpenToggle(),s.open||l.preventDefault())}),onKeyDown:bt(e.onKeyDown,l=>{r||(["Enter"," "].includes(l.key)&&s.onOpenToggle(),l.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(l.key)&&l.preventDefault())})})})});Pz.displayName=Dz;var xne="DropdownMenuPortal",Lz=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Li(t);return g.jsx(lne,{...r,...n})};Lz.displayName=xne;var Iz="DropdownMenuContent",zz=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mz(Iz,n),s=Li(n),o=b.useRef(!1);return g.jsx(cne,{id:i.contentId,"aria-labelledby":i.triggerId,...s,...r,ref:t,onCloseAutoFocus:bt(e.onCloseAutoFocus,l=>{var u;o.current||(u=i.triggerRef.current)==null||u.focus(),o.current=!1,l.preventDefault()}),onInteractOutside:bt(e.onInteractOutside,l=>{const u=l.detail.originalEvent,d=u.button===0&&u.ctrlKey===!0,h=u.button===2||d;(!i.modal||h)&&(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)"}})});zz.displayName=Iz;var Ene="DropdownMenuGroup",Cne=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Li(n);return g.jsx(une,{...i,...r,ref:t})});Cne.displayName=Ene;var kne="DropdownMenuLabel",Bz=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Li(n);return g.jsx(dne,{...i,...r,ref:t})});Bz.displayName=kne;var Tne="DropdownMenuItem",jz=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Li(n);return g.jsx(hne,{...i,...r,ref:t})});jz.displayName=Tne;var Rne="DropdownMenuCheckboxItem",Fz=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Li(n);return g.jsx(fne,{...i,...r,ref:t})});Fz.displayName=Rne;var Ane="DropdownMenuRadioGroup",Nne=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Li(n);return g.jsx(pne,{...i,...r,ref:t})});Nne.displayName=Ane;var Mne="DropdownMenuRadioItem",One=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Li(n);return g.jsx(mne,{...i,...r,ref:t})});One.displayName=Mne;var Dne="DropdownMenuItemIndicator",$z=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Li(n);return g.jsx(gne,{...i,...r,ref:t})});$z.displayName=Dne;var Pne="DropdownMenuSeparator",Hz=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Li(n);return g.jsx(vne,{...i,...r,ref:t})});Hz.displayName=Pne;var Lne="DropdownMenuArrow",Ine=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Li(n);return g.jsx(yne,{...i,...r,ref:t})});Ine.displayName=Lne;var zne="DropdownMenuSubTrigger",Bne=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Li(n);return g.jsx(bne,{...i,...r,ref:t})});Bne.displayName=zne;var jne="DropdownMenuSubContent",Fne=b.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Li(n);return g.jsx(_ne,{...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)"}})});Fne.displayName=jne;var $ne=Oz,Hne=Pz,Une=Lz,Wne=zz,qne=Bz,Vne=jz,Yne=Fz,Kne=$z,Gne=Hz;function DN(e,[t,n]){return Math.min(n,Math.max(t,e))}var Wv="Popover",[Uz]=sa(Wv,[yl]),Uf=yl(),[Xne,bl]=Uz(Wv),Wz=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:o=!1}=e,l=Uf(t),u=b.useRef(null),[d,h]=b.useState(!1),[p,y]=sc({prop:r,defaultProp:i??!1,onChange:s,caller:Wv});return g.jsx(Bv,{...l,children:g.jsx(Xne,{scope:t,contentId:vi(),triggerRef:u,open:p,onOpenChange:y,onOpenToggle:b.useCallback(()=>y(v=>!v),[y]),hasCustomAnchor:d,onCustomAnchorAdd:b.useCallback(()=>h(!0),[]),onCustomAnchorRemove:b.useCallback(()=>h(!1),[]),modal:o,children:n})})};Wz.displayName=Wv;var qz="PopoverAnchor",Zne=b.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=bl(qz,n),s=Uf(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:l}=i;return b.useEffect(()=>(o(),()=>l()),[o,l]),g.jsx(jf,{...s,...r,ref:t})});Zne.displayName=qz;var Vz="PopoverTrigger",Yz=b.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=bl(Vz,n),s=Uf(n),o=zn(t,i.triggerRef),l=g.jsx(Jt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Qz(i.open),...r,ref:o,onClick:bt(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?l:g.jsx(jf,{asChild:!0,...s,children:l})});Yz.displayName=Vz;var E1="PopoverPortal",[Qne,Jne]=Uz(E1,{forceMount:void 0}),Kz=e=>{const{__scopePopover:t,forceMount:n,children:r,container:i}=e,s=bl(E1,t);return g.jsx(Qne,{scope:t,forceMount:n,children:g.jsx(Ls,{present:n||s.open,children:g.jsx(od,{asChild:!0,container:i,children:r})})})};Kz.displayName=E1;var Yu="PopoverContent",Gz=b.forwardRef((e,t)=>{const n=Jne(Yu,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,s=bl(Yu,e.__scopePopover);return g.jsx(Ls,{present:r||s.open,children:s.modal?g.jsx(tre,{...i,ref:t}):g.jsx(nre,{...i,ref:t})})});Gz.displayName=Yu;var ere=ol("PopoverContent.RemoveScroll"),tre=b.forwardRef((e,t)=>{const n=bl(Yu,e.__scopePopover),r=b.useRef(null),i=zn(t,r),s=b.useRef(!1);return b.useEffect(()=>{const o=r.current;if(o)return Mv(o)},[]),g.jsx(zf,{as:ere,allowPinchZoom:!0,children:g.jsx(Xz,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:bt(e.onCloseAutoFocus,o=>{var l;o.preventDefault(),s.current||(l=n.triggerRef.current)==null||l.focus()}),onPointerDownOutside:bt(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:bt(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),nre=b.forwardRef((e,t)=>{const n=bl(Yu,e.__scopePopover),r=b.useRef(!1),i=b.useRef(!1);return g.jsx(Xz,{...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()}})}),Xz=b.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:o,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:h,...p}=e,y=bl(Yu,n),v=Uf(n);return Av(),g.jsx(If,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:g.jsx(sd,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:h,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onDismiss:()=>y.onOpenChange(!1),children:g.jsx(jv,{"data-state":Qz(y.open),role:"dialog",id:y.contentId,...v,...p,ref:t,style:{...p.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)"}})})})}),Zz="PopoverClose",rre=b.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=bl(Zz,n);return g.jsx(Jt.button,{type:"button",...r,ref:t,onClick:bt(e.onClick,()=>i.onOpenChange(!1))})});rre.displayName=Zz;var ire="PopoverArrow",sre=b.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Uf(n);return g.jsx(Fv,{...i,...r,ref:t})});sre.displayName=ire;function Qz(e){return e?"open":"closed"}var ore=Wz,are=Yz,lre=Kz,cre=Gz,ure=[" ","Enter","ArrowUp","ArrowDown"],dre=[" ","Enter"],lc="Select",[qv,Vv,hre]=e1(lc),[cd]=sa(lc,[hre,yl]),Yv=yl(),[fre,_l]=cd(lc),[pre,mre]=cd(lc),Jz=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:s,value:o,defaultValue:l,onValueChange:u,dir:d,name:h,autoComplete:p,disabled:y,required:v,form:_}=e,w=Yv(t),[x,E]=b.useState(null),[k,R]=b.useState(null),[A,I]=b.useState(!1),T=t1(d),[H,D]=sc({prop:r,defaultProp:i??!1,onChange:s,caller:lc}),[W,U]=sc({prop:o,defaultProp:l,onChange:u,caller:lc}),F=b.useRef(null),O=x?_||!!x.closest("form"):!0,[M,B]=b.useState(new Set),L=Array.from(M).map(N=>N.props.value).join(";");return g.jsx(Bv,{...w,children:g.jsxs(fre,{required:v,scope:t,trigger:x,onTriggerChange:E,valueNode:k,onValueNodeChange:R,valueNodeHasChildren:A,onValueNodeHasChildrenChange:I,contentId:vi(),value:W,onValueChange:U,open:H,onOpenChange:D,dir:T,triggerPointerDownPosRef:F,disabled:y,children:[g.jsx(qv.Provider,{scope:t,children:g.jsx(pre,{scope:e.__scopeSelect,onNativeOptionAdd:b.useCallback(N=>{B(V=>new Set(V).add(N))},[]),onNativeOptionRemove:b.useCallback(N=>{B(V=>{const Y=new Set(V);return Y.delete(N),Y})},[]),children:n})}),O?g.jsxs(wB,{"aria-hidden":!0,required:v,tabIndex:-1,name:h,autoComplete:p,value:W,onChange:N=>U(N.target.value),disabled:y,form:_,children:[W===void 0?g.jsx("option",{value:""}):null,Array.from(M)]},L):null]})})};Jz.displayName=lc;var eB="SelectTrigger",tB=b.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...i}=e,s=Yv(n),o=_l(eB,n),l=o.disabled||r,u=zn(t,o.onTriggerChange),d=Vv(n),h=b.useRef("touch"),[p,y,v]=xB(w=>{const x=d().filter(R=>!R.disabled),E=x.find(R=>R.value===o.value),k=EB(x,w,E);k!==void 0&&o.onValueChange(k.value)}),_=w=>{l||(o.onOpenChange(!0),v()),w&&(o.triggerPointerDownPosRef.current={x:Math.round(w.pageX),y:Math.round(w.pageY)})};return g.jsx(jf,{asChild:!0,...s,children:g.jsx(Jt.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":SB(o.value)?"":void 0,...i,ref:u,onClick:bt(i.onClick,w=>{w.currentTarget.focus(),h.current!=="mouse"&&_(w)}),onPointerDown:bt(i.onPointerDown,w=>{h.current=w.pointerType;const x=w.target;x.hasPointerCapture(w.pointerId)&&x.releasePointerCapture(w.pointerId),w.button===0&&w.ctrlKey===!1&&w.pointerType==="mouse"&&(_(w),w.preventDefault())}),onKeyDown:bt(i.onKeyDown,w=>{const x=p.current!=="";!(w.ctrlKey||w.altKey||w.metaKey)&&w.key.length===1&&y(w.key),!(x&&w.key===" ")&&ure.includes(w.key)&&(_(),w.preventDefault())})})})});tB.displayName=eB;var nB="SelectValue",rB=b.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:i,children:s,placeholder:o="",...l}=e,u=_l(nB,n),{onValueNodeHasChildrenChange:d}=u,h=s!==void 0,p=zn(t,u.onValueNodeChange);return Ci(()=>{d(h)},[d,h]),g.jsx(Jt.span,{...l,ref:p,style:{pointerEvents:"none"},children:SB(u.value)?g.jsx(g.Fragment,{children:o}):s})});rB.displayName=nB;var gre="SelectIcon",iB=b.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...i}=e;return g.jsx(Jt.span,{"aria-hidden":!0,...i,ref:t,children:r||"▼"})});iB.displayName=gre;var vre="SelectPortal",sB=e=>g.jsx(od,{asChild:!0,...e});sB.displayName=vre;var cc="SelectContent",oB=b.forwardRef((e,t)=>{const n=_l(cc,e.__scopeSelect),[r,i]=b.useState();if(Ci(()=>{i(new DocumentFragment)},[]),!n.open){const s=r;return s?id.createPortal(g.jsx(aB,{scope:e.__scopeSelect,children:g.jsx(qv.Slot,{scope:e.__scopeSelect,children:g.jsx("div",{children:e.children})})}),s):null}return g.jsx(lB,{...e,ref:t})});oB.displayName=cc;var Us=10,[aB,wl]=cd(cc),yre="SelectContentImpl",bre=ol("SelectContent.RemoveScroll"),lB=b.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:s,onPointerDownOutside:o,side:l,sideOffset:u,align:d,alignOffset:h,arrowPadding:p,collisionBoundary:y,collisionPadding:v,sticky:_,hideWhenDetached:w,avoidCollisions:x,...E}=e,k=_l(cc,n),[R,A]=b.useState(null),[I,T]=b.useState(null),H=zn(t,Q=>A(Q)),[D,W]=b.useState(null),[U,F]=b.useState(null),O=Vv(n),[M,B]=b.useState(!1),L=b.useRef(!1);b.useEffect(()=>{if(R)return Mv(R)},[R]),Av();const N=b.useCallback(Q=>{const[me,...ve]=O().map(Ve=>Ve.ref.current),[Ce]=ve.slice(-1),Me=document.activeElement;for(const Ve of Q)if(Ve===Me||(Ve==null||Ve.scrollIntoView({block:"nearest"}),Ve===me&&I&&(I.scrollTop=0),Ve===Ce&&I&&(I.scrollTop=I.scrollHeight),Ve==null||Ve.focus(),document.activeElement!==Me))return},[O,I]),V=b.useCallback(()=>N([D,R]),[N,D,R]);b.useEffect(()=>{M&&V()},[M,V]);const{onOpenChange:Y,triggerPointerDownPosRef:$}=k;b.useEffect(()=>{if(R){let Q={x:0,y:0};const me=Ce=>{var Me,Ve;Q={x:Math.abs(Math.round(Ce.pageX)-(((Me=$.current)==null?void 0:Me.x)??0)),y:Math.abs(Math.round(Ce.pageY)-(((Ve=$.current)==null?void 0:Ve.y)??0))}},ve=Ce=>{Q.x<=10&&Q.y<=10?Ce.preventDefault():R.contains(Ce.target)||Y(!1),document.removeEventListener("pointermove",me),$.current=null};return $.current!==null&&(document.addEventListener("pointermove",me),document.addEventListener("pointerup",ve,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",me),document.removeEventListener("pointerup",ve,{capture:!0})}}},[R,Y,$]),b.useEffect(()=>{const Q=()=>Y(!1);return window.addEventListener("blur",Q),window.addEventListener("resize",Q),()=>{window.removeEventListener("blur",Q),window.removeEventListener("resize",Q)}},[Y]);const[P,q]=xB(Q=>{const me=O().filter(Me=>!Me.disabled),ve=me.find(Me=>Me.ref.current===document.activeElement),Ce=EB(me,Q,ve);Ce&&setTimeout(()=>Ce.ref.current.focus())}),K=b.useCallback((Q,me,ve)=>{const Ce=!L.current&&!ve;(k.value!==void 0&&k.value===me||Ce)&&(W(Q),Ce&&(L.current=!0))},[k.value]),z=b.useCallback(()=>R==null?void 0:R.focus(),[R]),X=b.useCallback((Q,me,ve)=>{const Ce=!L.current&&!ve;(k.value!==void 0&&k.value===me||Ce)&&F(Q)},[k.value]),ee=r==="popper"?P0:cB,te=ee===P0?{side:l,sideOffset:u,align:d,alignOffset:h,arrowPadding:p,collisionBoundary:y,collisionPadding:v,sticky:_,hideWhenDetached:w,avoidCollisions:x}:{};return g.jsx(aB,{scope:n,content:R,viewport:I,onViewportChange:T,itemRefCallback:K,selectedItem:D,onItemLeave:z,itemTextRefCallback:X,focusSelectedItem:V,selectedItemText:U,position:r,isPositioned:M,searchRef:P,children:g.jsx(zf,{as:bre,allowPinchZoom:!0,children:g.jsx(If,{asChild:!0,trapped:k.open,onMountAutoFocus:Q=>{Q.preventDefault()},onUnmountAutoFocus:bt(i,Q=>{var me;(me=k.trigger)==null||me.focus({preventScroll:!0}),Q.preventDefault()}),children:g.jsx(sd,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:Q=>Q.preventDefault(),onDismiss:()=>k.onOpenChange(!1),children:g.jsx(ee,{role:"listbox",id:k.contentId,"data-state":k.open?"open":"closed",dir:k.dir,onContextMenu:Q=>Q.preventDefault(),...E,...te,onPlaced:()=>B(!0),ref:H,style:{display:"flex",flexDirection:"column",outline:"none",...E.style},onKeyDown:bt(E.onKeyDown,Q=>{const me=Q.ctrlKey||Q.altKey||Q.metaKey;if(Q.key==="Tab"&&Q.preventDefault(),!me&&Q.key.length===1&&q(Q.key),["ArrowUp","ArrowDown","Home","End"].includes(Q.key)){let Ce=O().filter(Me=>!Me.disabled).map(Me=>Me.ref.current);if(["ArrowUp","End"].includes(Q.key)&&(Ce=Ce.slice().reverse()),["ArrowUp","ArrowDown"].includes(Q.key)){const Me=Q.target,Ve=Ce.indexOf(Me);Ce=Ce.slice(Ve+1)}setTimeout(()=>N(Ce)),Q.preventDefault()}})})})})})})});lB.displayName=yre;var _re="SelectItemAlignedPosition",cB=b.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...i}=e,s=_l(cc,n),o=wl(cc,n),[l,u]=b.useState(null),[d,h]=b.useState(null),p=zn(t,H=>h(H)),y=Vv(n),v=b.useRef(!1),_=b.useRef(!0),{viewport:w,selectedItem:x,selectedItemText:E,focusSelectedItem:k}=o,R=b.useCallback(()=>{if(s.trigger&&s.valueNode&&l&&d&&w&&x&&E){const H=s.trigger.getBoundingClientRect(),D=d.getBoundingClientRect(),W=s.valueNode.getBoundingClientRect(),U=E.getBoundingClientRect();if(s.dir!=="rtl"){const Me=U.left-D.left,Ve=W.left-Me,Qe=H.left-Ve,ct=H.width+Qe,Ot=Math.max(ct,D.width),he=window.innerWidth-Us,Ke=DN(Ve,[Us,Math.max(Us,he-Ot)]);l.style.minWidth=ct+"px",l.style.left=Ke+"px"}else{const Me=D.right-U.right,Ve=window.innerWidth-W.right-Me,Qe=window.innerWidth-H.right-Ve,ct=H.width+Qe,Ot=Math.max(ct,D.width),he=window.innerWidth-Us,Ke=DN(Ve,[Us,Math.max(Us,he-Ot)]);l.style.minWidth=ct+"px",l.style.right=Ke+"px"}const F=y(),O=window.innerHeight-Us*2,M=w.scrollHeight,B=window.getComputedStyle(d),L=parseInt(B.borderTopWidth,10),N=parseInt(B.paddingTop,10),V=parseInt(B.borderBottomWidth,10),Y=parseInt(B.paddingBottom,10),$=L+N+M+Y+V,P=Math.min(x.offsetHeight*5,$),q=window.getComputedStyle(w),K=parseInt(q.paddingTop,10),z=parseInt(q.paddingBottom,10),X=H.top+H.height/2-Us,ee=O-X,te=x.offsetHeight/2,Q=x.offsetTop+te,me=L+N+Q,ve=$-me;if(me<=X){const Me=F.length>0&&x===F[F.length-1].ref.current;l.style.bottom="0px";const Ve=d.clientHeight-w.offsetTop-w.offsetHeight,Qe=Math.max(ee,te+(Me?z:0)+Ve+V),ct=me+Qe;l.style.height=ct+"px"}else{const Me=F.length>0&&x===F[0].ref.current;l.style.top="0px";const Qe=Math.max(X,L+w.offsetTop+(Me?K:0)+te)+ve;l.style.height=Qe+"px",w.scrollTop=me-X+w.offsetTop}l.style.margin=`${Us}px 0`,l.style.minHeight=P+"px",l.style.maxHeight=O+"px",r==null||r(),requestAnimationFrame(()=>v.current=!0)}},[y,s.trigger,s.valueNode,l,d,w,x,E,s.dir,r]);Ci(()=>R(),[R]);const[A,I]=b.useState();Ci(()=>{d&&I(window.getComputedStyle(d).zIndex)},[d]);const T=b.useCallback(H=>{H&&_.current===!0&&(R(),k==null||k(),_.current=!1)},[R,k]);return g.jsx(Sre,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:v,onScrollButtonChange:T,children:g.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:A},children:g.jsx(Jt.div,{...i,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})});cB.displayName=_re;var wre="SelectPopperPosition",P0=b.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:i=Us,...s}=e,o=Yv(n);return g.jsx(jv,{...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)"}})});P0.displayName=wre;var[Sre,C1]=cd(cc,{}),L0="SelectViewport",uB=b.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...i}=e,s=wl(L0,n),o=C1(L0,n),l=zn(t,s.onViewportChange),u=b.useRef(0);return g.jsxs(g.Fragment,{children:[g.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}),g.jsx(qv.Slot,{scope:n,children:g.jsx(Jt.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:bt(i.onScroll,d=>{const h=d.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:y}=o;if(y!=null&&y.current&&p){const v=Math.abs(u.current-h.scrollTop);if(v>0){const _=window.innerHeight-Us*2,w=parseFloat(p.style.minHeight),x=parseFloat(p.style.height),E=Math.max(w,x);if(E<_){const k=E+v,R=Math.min(_,k),A=k-R;p.style.height=R+"px",p.style.bottom==="0px"&&(h.scrollTop=A>0?A:0,p.style.justifyContent="flex-end")}}}u.current=h.scrollTop})})})]})});uB.displayName=L0;var dB="SelectGroup",[xre,Ere]=cd(dB),Cre=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=vi();return g.jsx(xre,{scope:n,id:i,children:g.jsx(Jt.div,{role:"group","aria-labelledby":i,...r,ref:t})})});Cre.displayName=dB;var hB="SelectLabel",kre=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=Ere(hB,n);return g.jsx(Jt.div,{id:i.id,...r,ref:t})});kre.displayName=hB;var Xg="SelectItem",[Tre,fB]=cd(Xg),pB=b.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:i=!1,textValue:s,...o}=e,l=_l(Xg,n),u=wl(Xg,n),d=l.value===r,[h,p]=b.useState(s??""),[y,v]=b.useState(!1),_=zn(t,k=>{var R;return(R=u.itemRefCallback)==null?void 0:R.call(u,k,r,i)}),w=vi(),x=b.useRef("touch"),E=()=>{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 g.jsx(Tre,{scope:n,value:r,disabled:i,textId:w,isSelected:d,onItemTextChange:b.useCallback(k=>{p(R=>R||((k==null?void 0:k.textContent)??"").trim())},[]),children:g.jsx(qv.ItemSlot,{scope:n,value:r,disabled:i,textValue:h,children:g.jsx(Jt.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:bt(o.onFocus,()=>v(!0)),onBlur:bt(o.onBlur,()=>v(!1)),onClick:bt(o.onClick,()=>{x.current!=="mouse"&&E()}),onPointerUp:bt(o.onPointerUp,()=>{x.current==="mouse"&&E()}),onPointerDown:bt(o.onPointerDown,k=>{x.current=k.pointerType}),onPointerMove:bt(o.onPointerMove,k=>{var R;x.current=k.pointerType,i?(R=u.onItemLeave)==null||R.call(u):x.current==="mouse"&&k.currentTarget.focus({preventScroll:!0})}),onPointerLeave:bt(o.onPointerLeave,k=>{var R;k.currentTarget===document.activeElement&&((R=u.onItemLeave)==null||R.call(u))}),onKeyDown:bt(o.onKeyDown,k=>{var A;((A=u.searchRef)==null?void 0:A.current)!==""&&k.key===" "||(dre.includes(k.key)&&E(),k.key===" "&&k.preventDefault())})})})})});pB.displayName=Xg;var zh="SelectItemText",mB=b.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:i,...s}=e,o=_l(zh,n),l=wl(zh,n),u=fB(zh,n),d=mre(zh,n),[h,p]=b.useState(null),y=zn(t,E=>p(E),u.onItemTextChange,E=>{var k;return(k=l.itemTextRefCallback)==null?void 0:k.call(l,E,u.value,u.disabled)}),v=h==null?void 0:h.textContent,_=b.useMemo(()=>g.jsx("option",{value:u.value,disabled:u.disabled,children:v},u.value),[u.disabled,u.value,v]),{onNativeOptionAdd:w,onNativeOptionRemove:x}=d;return Ci(()=>(w(_),()=>x(_)),[w,x,_]),g.jsxs(g.Fragment,{children:[g.jsx(Jt.span,{id:u.textId,...s,ref:y}),u.isSelected&&o.valueNode&&!o.valueNodeHasChildren?id.createPortal(s.children,o.valueNode):null]})});mB.displayName=zh;var gB="SelectItemIndicator",vB=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return fB(gB,n).isSelected?g.jsx(Jt.span,{"aria-hidden":!0,...r,ref:t}):null});vB.displayName=gB;var I0="SelectScrollUpButton",yB=b.forwardRef((e,t)=>{const n=wl(I0,e.__scopeSelect),r=C1(I0,e.__scopeSelect),[i,s]=b.useState(!1),o=zn(t,r.onScrollButtonChange);return Ci(()=>{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?g.jsx(_B,{...e,ref:o,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=n;l&&u&&(l.scrollTop=l.scrollTop-u.offsetHeight)}}):null});yB.displayName=I0;var z0="SelectScrollDownButton",bB=b.forwardRef((e,t)=>{const n=wl(z0,e.__scopeSelect),r=C1(z0,e.__scopeSelect),[i,s]=b.useState(!1),o=zn(t,r.onScrollButtonChange);return Ci(()=>{if(n.viewport&&n.isPositioned){let l=function(){const d=u.scrollHeight-u.clientHeight,h=Math.ceil(u.scrollTop)<d;s(h)};const u=n.viewport;return l(),u.addEventListener("scroll",l),()=>u.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),i?g.jsx(_B,{...e,ref:o,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=n;l&&u&&(l.scrollTop=l.scrollTop+u.offsetHeight)}}):null});bB.displayName=z0;var _B=b.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...i}=e,s=wl("SelectScrollButton",n),o=b.useRef(null),l=Vv(n),u=b.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return b.useEffect(()=>()=>u(),[u]),Ci(()=>{var h;const d=l().find(p=>p.ref.current===document.activeElement);(h=d==null?void 0:d.ref.current)==null||h.scrollIntoView({block:"nearest"})},[l]),g.jsx(Jt.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:bt(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:bt(i.onPointerMove,()=>{var d;(d=s.onItemLeave)==null||d.call(s),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:bt(i.onPointerLeave,()=>{u()})})}),Rre="SelectSeparator",Are=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return g.jsx(Jt.div,{"aria-hidden":!0,...r,ref:t})});Are.displayName=Rre;var B0="SelectArrow",Nre=b.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=Yv(n),s=_l(B0,n),o=wl(B0,n);return s.open&&o.position==="popper"?g.jsx(Fv,{...i,...r,ref:t}):null});Nre.displayName=B0;var Mre="SelectBubbleInput",wB=b.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const i=b.useRef(null),s=zn(r,i),o=oee(t);return b.useEffect(()=>{const l=i.current;if(!l)return;const u=window.HTMLSelectElement.prototype,h=Object.getOwnPropertyDescriptor(u,"value").set;if(o!==t&&h){const p=new Event("change",{bubbles:!0});h.call(l,t),l.dispatchEvent(p)}},[o,t]),g.jsx(Jt.select,{...n,style:{...rI,...n.style},ref:s,defaultValue:t})});wB.displayName=Mre;function SB(e){return e===""||e===void 0}function xB(e){const t=Co(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 EB(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=Ore(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 Ore(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Dre=Jz,Pre=tB,Lre=rB,Ire=iB,zre=sB,Bre=oB,jre=uB,Fre=pB,$re=mB,Hre=vB,Ure=yB,Wre=bB,[Kv]=sa("Tooltip",[yl]),Gv=yl(),CB="TooltipProvider",qre=700,j0="tooltip.open",[Vre,k1]=Kv(CB),kB=e=>{const{__scopeTooltip:t,delayDuration:n=qre,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)},[]),g.jsx(Vre,{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})};kB.displayName=CB;var yf="Tooltip",[Yre,Wf]=Kv(yf),TB=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:l}=e,u=k1(yf,e.__scopeTooltip),d=Gv(t),[h,p]=b.useState(null),y=vi(),v=b.useRef(0),_=o??u.disableHoverableContent,w=l??u.delayDuration,x=b.useRef(!1),[E,k]=sc({prop:r,defaultProp:i??!1,onChange:H=>{H?(u.onOpen(),document.dispatchEvent(new CustomEvent(j0))):u.onClose(),s==null||s(H)},caller:yf}),R=b.useMemo(()=>E?x.current?"delayed-open":"instant-open":"closed",[E]),A=b.useCallback(()=>{window.clearTimeout(v.current),v.current=0,x.current=!1,k(!0)},[k]),I=b.useCallback(()=>{window.clearTimeout(v.current),v.current=0,k(!1)},[k]),T=b.useCallback(()=>{window.clearTimeout(v.current),v.current=window.setTimeout(()=>{x.current=!0,k(!0),v.current=0},w)},[w,k]);return b.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=0)},[]),g.jsx(Bv,{...d,children:g.jsx(Yre,{scope:t,contentId:y,open:E,stateAttribute:R,trigger:h,onTriggerChange:p,onTriggerEnter:b.useCallback(()=>{u.isOpenDelayedRef.current?T():A()},[u.isOpenDelayedRef,T,A]),onTriggerLeave:b.useCallback(()=>{_?I():(window.clearTimeout(v.current),v.current=0)},[I,_]),onOpen:A,onClose:I,disableHoverableContent:_,children:n})})};TB.displayName=yf;var F0="TooltipTrigger",RB=b.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Wf(F0,n),s=k1(F0,n),o=Gv(n),l=b.useRef(null),u=zn(t,l,i.onTriggerChange),d=b.useRef(!1),h=b.useRef(!1),p=b.useCallback(()=>d.current=!1,[]);return b.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),g.jsx(jf,{asChild:!0,...o,children:g.jsx(Jt.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:u,onPointerMove:bt(e.onPointerMove,y=>{y.pointerType!=="touch"&&!h.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),h.current=!0)}),onPointerLeave:bt(e.onPointerLeave,()=>{i.onTriggerLeave(),h.current=!1}),onPointerDown:bt(e.onPointerDown,()=>{i.open&&i.onClose(),d.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:bt(e.onFocus,()=>{d.current||i.onOpen()}),onBlur:bt(e.onBlur,i.onClose),onClick:bt(e.onClick,i.onClose)})})});RB.displayName=F0;var T1="TooltipPortal",[Kre,Gre]=Kv(T1,{forceMount:void 0}),AB=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,s=Wf(T1,t);return g.jsx(Kre,{scope:t,forceMount:n,children:g.jsx(Ls,{present:n||s.open,children:g.jsx(od,{asChild:!0,container:i,children:r})})})};AB.displayName=T1;var Ku="TooltipContent",NB=b.forwardRef((e,t)=>{const n=Gre(Ku,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,o=Wf(Ku,e.__scopeTooltip);return g.jsx(Ls,{present:r||o.open,children:o.disableHoverableContent?g.jsx(MB,{side:i,...s,ref:t}):g.jsx(Xre,{side:i,...s,ref:t})})}),Xre=b.forwardRef((e,t)=>{const n=Wf(Ku,e.__scopeTooltip),r=k1(Ku,e.__scopeTooltip),i=b.useRef(null),s=zn(t,i),[o,l]=b.useState(null),{trigger:u,onClose:d}=n,h=i.current,{onPointerInTransitChange:p}=r,y=b.useCallback(()=>{l(null),p(!1)},[p]),v=b.useCallback((_,w)=>{const x=_.currentTarget,E={x:_.clientX,y:_.clientY},k=eie(E,x.getBoundingClientRect()),R=tie(E,k),A=nie(w.getBoundingClientRect()),I=iie([...R,...A]);l(I),p(!0)},[p]);return b.useEffect(()=>()=>y(),[y]),b.useEffect(()=>{if(u&&h){const _=x=>v(x,h),w=x=>v(x,u);return u.addEventListener("pointerleave",_),h.addEventListener("pointerleave",w),()=>{u.removeEventListener("pointerleave",_),h.removeEventListener("pointerleave",w)}}},[u,h,v,y]),b.useEffect(()=>{if(o){const _=w=>{const x=w.target,E={x:w.clientX,y:w.clientY},k=(u==null?void 0:u.contains(x))||(h==null?void 0:h.contains(x)),R=!rie(E,o);k?y():R&&(y(),d())};return document.addEventListener("pointermove",_),()=>document.removeEventListener("pointermove",_)}},[u,h,o,d,y]),g.jsx(MB,{...e,ref:s})}),[Zre,Qre]=Kv(yf,{isInside:!1}),Jre=OQ("TooltipContent"),MB=b.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...l}=e,u=Wf(Ku,n),d=Gv(n),{onClose:h}=u;return b.useEffect(()=>(document.addEventListener(j0,h),()=>document.removeEventListener(j0,h)),[h]),b.useEffect(()=>{if(u.trigger){const p=y=>{const v=y.target;v!=null&&v.contains(u.trigger)&&h()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[u.trigger,h]),g.jsx(sd,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:p=>p.preventDefault(),onDismiss:h,children:g.jsxs(jv,{"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:[g.jsx(Jre,{children:r}),g.jsx(Zre,{scope:n,isInside:!0,children:g.jsx(sI,{id:u.contentId,role:"tooltip",children:i||r})})]})})});NB.displayName=Ku;var OB="TooltipArrow",DB=b.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Gv(n);return Qre(OB,n).isInside?null:g.jsx(Fv,{...i,...r,ref:t})});DB.displayName=OB;function eie(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 tie(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 nie(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 rie(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,h=l.y,p=u.x,y=u.y;h>r!=y>r&&n<(p-d)*(r-h)/(y-h)+d&&(i=!i)}return i}function iie(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),sie(t)}function sie(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 oie=kB,aie=TB,lie=RB,cie=AB,uie=NB,die=DB;function R1({...e}){return g.jsx(ore,{"data-slot":"popover",...e})}function A1({...e}){return g.jsx(are,{"data-slot":"popover-trigger",...e})}function N1({className:e,align:t="center",sideOffset:n=4,...r}){return g.jsx(lre,{children:g.jsx(cre,{"data-slot":"popover-content",align:t,sideOffset:n,className:Ye("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),...r})})}const hie={"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 tc({variant:e,action:t}){const{heading:n,body:r}=hie[e];return e==="no-messages"?g.jsx("div",{className:"flex h-full w-full items-center justify-center animate-in fade-in-0 duration-200 motion-reduce:animate-none",children:g.jsx("p",{className:"text-sm text-muted-foreground",children:n})}):g.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:[g.jsx("h2",{className:"text-2xl font-semibold",children:n}),r&&g.jsx("p",{className:"max-w-md text-sm text-muted-foreground",children:r}),t&&g.jsx("div",{children:t})]})}const fie={online:"bg-[var(--color-status-success)]",offline:"bg-[var(--muted-foreground)]",connecting:"bg-[var(--color-status-working)] animate-pulse"},pie={online:"开发机在线",offline:"开发机离线",connecting:"正在连接开发机"};function PN({status:e,className:t}){return g.jsx("span",{className:Ye("inline-block w-2 h-2 rounded-full shrink-0",fie[e],t),role:"status","aria-label":pie[e]})}function PB({layout:e,variant:t="default"}){const n=Ne(_=>_.proxies),r=Ne(_=>_.proxyListLoaded),i=Ne(_=>_.relayClientAuthIssue),s=Ne(_=>_.selectedProxyId),o=Ne(_=>_.proxySwitchTarget),l=Pi(),u=Qs(),[d,h]=b.useState(!1);async function p(_,w){if(o)return;const x=Pt;if(!x){nt.error("请先连接开发机");return}const E=w??_,k=s!==null&&s!==_;Ne.getState().setProxySwitchTarget({proxyId:_,name:E});try{const R=await x.selectProxy(_);if(!R.success){nt.error(`无法连接 ${E}:${R.error??"未知错误"}`);return}k&&($t.getState().prepareForProxySwitch(E),ii.getState().prepareForProxySwitch()),hr("local",dn.proxyId,_),Ne.getState().setProxy(_,w??null),Ne.getState().setProxyOnline(!0),Ne.getState().transitionToPhase("session_browsing"),x.sendControl({type:"session_list"}),x.requestProxyInfo().then(A=>{if(Ne.getState().selectedProxyId!==_)return;const I=ii.getState();I.setHomePath(A.homePath),I.setAgentCli(A.agentCli)}).catch(A=>{console.error("[proxy-switcher] post-bind proxy info fetch failed",A)}),x.requestAgentStatuses().then(A=>{if(Ne.getState().selectedProxyId!==_)return;const I=$t.getState();for(const T of A)I.setAgentStatus(T.sessionId,T.payload)}).catch(A=>{console.error("[proxy-switcher] post-bind data fetch failed",A)}),x.requestSessionHistory().then(A=>{Ne.getState().selectedProxyId===_&&$t.getState().setHistorySessions(A)}).catch(A=>{console.error("[proxy-switcher] post-bind data fetch failed",A)}),h(!1),(e==="page"||l.pathname.startsWith("/chat/"))&&u("/sessions")}catch(R){const A=R instanceof Error?R.message:"未知错误";nt.error(`无法连接 ${E}:${A}`)}finally{Ne.getState().setProxySwitchTarget(null)}}if(e==="page")return i==="missing_client_token"?g.jsx(tc,{variant:"client-token-missing"}):i==="invalid_client_token"?g.jsx(tc,{variant:"client-token-invalid"}):r?n.length===0?g.jsx(tc,{variant:"no-proxy"}):g.jsxs("div",{className:"flex flex-col gap-3 p-4 h-full overflow-auto",children:[g.jsx("h3",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"可连接开发机"}),g.jsx("ul",{role:"list",className:"flex flex-col gap-2",children:n.map(_=>{const w=(o==null?void 0:o.proxyId)===_.proxyId,x=o!==null;return g.jsx("li",{children:g.jsxs("button",{type:"button","data-slot":"proxy-item","data-proxy-id":_.proxyId,"data-online":_.online,"data-selecting":w||void 0,disabled:!_.online||x,"aria-busy":w||void 0,onClick:()=>p(_.proxyId,_.name),className:Ye("w-full flex items-center gap-3 px-3 h-11 min-h-[44px] rounded-md border bg-card transition-colors text-left disabled:cursor-not-allowed disabled:hover:bg-card",w?"border-primary/40 bg-accent text-accent-foreground":"border-border hover:bg-accent",x&&!w?"opacity-50":"",_.online?"":"opacity-50"),"aria-pressed":s===_.proxyId,title:_.online?void 0:"这台开发机离线,暂时无法连接",children:[g.jsx(PN,{status:_.online?"online":"offline"}),g.jsx("span",{className:"text-sm font-normal flex-1 truncate min-w-0",children:_.name??_.proxyId}),w?g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:"正在连接"}),g.jsx(Jl,{className:"h-4 w-4 animate-spin text-primary shrink-0","aria-hidden":!0})]}):s===_.proxyId?g.jsx(ta,{className:"h-4 w-4 text-primary shrink-0","aria-label":"已选"}):null,!_.online&&!w&&g.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:"离线"})]})},_.proxyId)})})]}):g.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:[g.jsx(Jl,{className:"h-5 w-5 animate-spin","aria-hidden":!0}),g.jsx("p",{className:"text-sm",children:"连接中..."})]});const y=n.find(_=>_.proxyId===s),v=(y==null?void 0:y.name)??(y==null?void 0:y.proxyId)??"未选择开发机";return g.jsxs(R1,{open:d,onOpenChange:h,children:[g.jsx(A1,{asChild:!0,children:g.jsxs("button",{type:"button","data-slot":"proxy-switcher-trigger",className:Ye("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 h-10 w-full items-center gap-2 rounded-md border border-border bg-background px-4 hover:bg-accent"),"aria-label":`当前连接:${v}`,children:[t==="default"&&g.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":!0}),g.jsx("span",{className:Ye("truncate",t==="sidebarChrome"?"min-w-0 text-base font-semibold leading-none":"flex-1 text-center text-sm font-normal"),children:v}),g.jsx(pl,{className:"h-4 w-4 text-muted-foreground shrink-0 transition-transform group-data-[state=open]:rotate-180","aria-hidden":!0})]})}),g.jsx(N1,{align:"start",className:"w-[260px] p-1",children:n.length===0?g.jsx("div",{className:"text-xs text-muted-foreground p-2",children:"暂无可连接开发机"}):g.jsx("ul",{role:"list",className:"flex flex-col",children:n.map(_=>{const w=(o==null?void 0:o.proxyId)===_.proxyId,x=o!==null;return g.jsx("li",{children:g.jsxs("button",{type:"button","data-slot":"proxy-item","data-proxy-id":_.proxyId,"data-online":_.online,"data-selecting":w||void 0,disabled:!_.online||x,"aria-busy":w||void 0,onClick:()=>p(_.proxyId,_.name),className:Ye("w-full flex items-center gap-2 px-2 h-9 rounded-md transition-colors text-left disabled:cursor-not-allowed disabled:hover:bg-transparent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",w?"bg-accent text-accent-foreground":"hover:bg-accent",x&&!w?"opacity-50":"",_.online?"":"opacity-50"),"aria-pressed":s===_.proxyId,title:_.online?void 0:"这台开发机离线",children:[g.jsx(PN,{status:_.online?"online":"offline"}),g.jsx("span",{className:"text-sm font-normal flex-1 truncate min-w-0",children:_.name??_.proxyId}),w?g.jsx(Jl,{className:"h-4 w-4 animate-spin text-primary shrink-0","aria-label":"正在连接"}):s===_.proxyId?g.jsx(ta,{className:"h-4 w-4 text-primary shrink-0","aria-label":"已选"}):null,!_.online&&s!==_.proxyId&&!w&&g.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:"离线"})]})},_.proxyId)})})})]})}const LN=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,IN=jP,mie=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return IN(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 h=n==null?void 0:n[d],p=s==null?void 0:s[d];if(h===null)return null;const y=LN(h)||LN(p);return i[d][y]}),l=n&&Object.entries(n).reduce((d,h)=>{let[p,y]=h;return y===void 0||(d[p]=y),d},{}),u=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((d,h)=>{let{class:p,className:y,...v}=h;return Object.entries(v).every(_=>{let[w,x]=_;return Array.isArray(x)?x.includes({...s,...l}[w]):{...s,...l}[w]===x})?[...d,p,y]:d},[]);return IN(e,o,u,n==null?void 0:n.class,n==null?void 0:n.className)},gie=mie("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 _t({className:e,variant:t="default",size:n="default",asChild:r=!1,...i}){const s=r?NQ:"button";return g.jsx(s,{"data-slot":"button","data-variant":t,"data-size":n,className:Ye(gie({variant:t,size:n,className:e})),...i})}function vie({delayDuration:e=0,...t}){return g.jsx(oie,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function qf({...e}){return g.jsx(aie,{"data-slot":"tooltip",...e})}function Vf({...e}){return g.jsx(lie,{"data-slot":"tooltip-trigger",...e})}function Yf({className:e,sideOffset:t=0,children:n,hideArrow:r=!1,...i}){return g.jsx(cie,{children:g.jsxs(uie,{"data-slot":"tooltip-content",sideOffset:t,className:Ye("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&&g.jsx(die,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})}function Xv({...e}){return g.jsx(s1,{"data-slot":"sheet",...e})}function yie({...e}){return g.jsx(see,{"data-slot":"sheet-trigger",...e})}function bie({...e}){return g.jsx(o1,{"data-slot":"sheet-portal",...e})}function _ie({className:e,...t}){return g.jsx(a1,{"data-slot":"sheet-overlay",className:Ye("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 Zv({className:e,overlayClassName:t,children:n,side:r="right",showCloseButton:i=!0,focusSurfaceOnOpen:s=!1,onOpenAutoFocus:o,...l}){return g.jsxs(bie,{children:[g.jsx(_ie,{className:t}),g.jsxs(l1,{"data-slot":"sheet-content",className:Ye("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:u=>{o==null||o(u),!(!s||u.defaultPrevented)&&(u.preventDefault(),u.currentTarget.focus({preventScroll:!0}))},...l,children:[n,i&&g.jsxs(Dv,{"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:[g.jsx(vc,{className:"size-4"}),g.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function M1({className:e,...t}){return g.jsx("div",{"data-slot":"sheet-header",className:Ye("flex flex-col gap-1.5 p-4",e),...t})}function Qv({className:e,...t}){return g.jsx(DI,{"data-slot":"sheet-title",className:Ye("font-semibold text-foreground",e),...t})}function wie({className:e,...t}){return g.jsx(PI,{"data-slot":"sheet-description",className:Ye("text-sm text-muted-foreground",e),...t})}function O1({...e}){return g.jsx($ne,{"data-slot":"dropdown-menu",...e})}function D1({...e}){return g.jsx(Hne,{"data-slot":"dropdown-menu-trigger",...e})}function P1({className:e,sideOffset:t=4,...n}){return g.jsx(Une,{children:g.jsx(Wne,{"data-slot":"dropdown-menu-content",sideOffset:t,className:Ye("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),...n})})}function yo({className:e,inset:t,variant:n="default",...r}){return g.jsx(Vne,{"data-slot":"dropdown-menu-item","data-inset":t,"data-variant":n,className:Ye("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 Z_({className:e,children:t,checked:n,...r}){return g.jsxs(Yne,{"data-slot":"dropdown-menu-checkbox-item",className:Ye("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:[g.jsx("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:g.jsx(Kne,{children:g.jsx(ta,{className:"size-4"})})}),t]})}function jm({className:e,inset:t,...n}){return g.jsx(qne,{"data-slot":"dropdown-menu-label","data-inset":t,className:Ye("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",e),...n})}function Q_({className:e,...t}){return g.jsx(Gne,{"data-slot":"dropdown-menu-separator",className:Ye("-mx-1 my-1 h-px bg-border",e),...t})}const Sie={claude:"Claude Code",codex:"Codex"},zN=["claude","codex"];function Jv(e){return Sie[e]}function LB(e,t){return zN.indexOf(e)-zN.indexOf(t)}function $0(e){return e.provider??"claude"}const H0=60*1e3,U0=60*H0,xie=24*U0;function IB(e,t=Date.now()){const n=t-e;if(n<H0)return"刚刚";if(n<U0)return`${Math.floor(n/H0)} 分钟前`;if(n<xie)return`${Math.floor(n/U0)} 小时前`;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 BN={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 W0(e){return e.kind!=="terminal"?BN[e.state]:e.state==="terminated"?BN.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 Eie({session:e}){const t=W0(e);return g.jsx("span",{className:Ye("inline-block size-2 rounded-full shrink-0",t.dot),"aria-label":`会话状态:${t.label}`,role:"status"})}function Cie({mode:e}){if(e!=="pty"&&e!=="json")return null;const t=e==="json"?"聊天视图":"终端视图",n=e==="json"?Mx:Dx;return g.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:g.jsx(n,{className:"size-3.5","aria-hidden":"true"})})}function kie({session:e,selected:t,now:n,onClick:r,onRename:i,onTerminate:s}){const o=e.lastActive,l=e.cwd??e.name??e.sessionId,u=Tv(e.name),d=Xx(e),h=e.nameLocked&&e.name?e.name:d||(u==="New Session"?e.sessionId.slice(0,8):u),p=!!e.mode||!!e.provider||o!==void 0,y=o!==void 0?IB(o,n):null,v=e.mode==="pty"&&e.ptyOwner==="local-terminal",_=e.kind==="terminal"?"终止终端":v?"断开远程连接":"终止会话";return g.jsxs("li",{className:Ye("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&&g.jsx("span",{className:"dev-sidebar-active-indicator absolute left-0 top-0 bottom-0 w-[2px]","aria-hidden":"true"}),g.jsxs("button",{type:"button",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:[g.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[g.jsx(Eie,{session:e}),g.jsx("span",{className:"text-sm font-normal truncate flex-1",title:l,children:h})]}),p&&g.jsxs("span",{className:"flex items-center gap-1.5 text-xs leading-5 h-5",children:[e.mode&&g.jsx(Cie,{mode:e.mode}),e.mode&&g.jsx("span",{className:"text-muted-foreground/60 shrink-0","aria-hidden":"true",children:"·"}),e.provider&&e.kind!=="terminal"&&g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"font-mono text-muted-foreground shrink-0",children:Jv(e.provider)}),g.jsx("span",{className:"text-muted-foreground/60 shrink-0","aria-hidden":"true",children:"·"})]}),g.jsx("span",{className:Ye("shrink-0",W0(e).text),children:W0(e).label}),y&&g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"text-muted-foreground/60 shrink-0","aria-hidden":"true",children:"·"}),g.jsx("span",{className:"text-muted-foreground shrink-0 tabular-nums",children:y})]})]})]}),(i||s)&&g.jsxs(O1,{children:[g.jsx(D1,{asChild:!0,children:g.jsx(_t,{variant:"ghost",size:"icon-xs",className:"size-11 md:size-6","aria-label":"会话操作","data-slot":"session-row-menu-trigger",onClick:w=>w.stopPropagation(),children:g.jsx(y8,{"aria-hidden":"true"})})}),g.jsxs(P1,{align:"end","data-slot":"session-row-menu",children:[i&&g.jsx(yo,{"data-slot":"session-row-rename-item",onSelect:w=>{w.stopPropagation(),i()},children:"重命名"}),s&&g.jsx(yo,{variant:"destructive","data-slot":"session-row-terminate-item",onSelect:w=>{w.stopPropagation(),s()},children:_})]})]})]})}function Sc({...e}){return g.jsx(s1,{"data-slot":"dialog",...e})}function Tie({...e}){return g.jsx(o1,{"data-slot":"dialog-portal",...e})}function Rie({...e}){return g.jsx(Dv,{"data-slot":"dialog-close",...e})}function Aie({className:e,...t}){return g.jsx(a1,{"data-slot":"dialog-overlay",className:Ye("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 xc({className:e,children:t,showCloseButton:n=!0,focusSurfaceOnOpen:r=!1,onOpenAutoFocus:i,...s}){return g.jsxs(Tie,{"data-slot":"dialog-portal",children:[g.jsx(Aie,{}),g.jsxs(l1,{"data-slot":"dialog-content",className:Ye("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:o=>{i==null||i(o),!(!r||o.defaultPrevented)&&(o.preventDefault(),o.currentTarget.focus({preventScroll:!0}))},...s,children:[t,n&&g.jsxs(Dv,{"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:[g.jsx(vc,{}),g.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Ec({className:e,...t}){return g.jsx("div",{"data-slot":"dialog-header",className:Ye("flex flex-col gap-2 text-center sm:text-left",e),...t})}function Gu({className:e,showCloseButton:t=!1,children:n,...r}){return g.jsxs("div",{"data-slot":"dialog-footer",className:Ye("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end max-sm:[&_button]:min-h-11",e),...r,children:[n,t&&g.jsx(Dv,{asChild:!0,children:g.jsx(_t,{variant:"outline",children:"Close"})})]})}function cl({className:e,...t}){return g.jsx(DI,{"data-slot":"dialog-title",className:Ye("text-lg leading-none font-semibold",e),...t})}function uc({className:e,...t}){return g.jsx(PI,{"data-slot":"dialog-description",className:Ye("text-sm text-muted-foreground",e),...t})}function ul(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 Nie({session:e,now:t,disabled:n,loading:r,onClick:i,modeTag:s}){const o=g.jsx(Mie,{title:e.title,modeTag:s}),l=g.jsx("span",{className:"text-xs text-muted-foreground tabular-nums",children:IB(e.updatedAt,t)}),u=g.jsxs("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[o,l]});return g.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:g.jsxs("button",{type:"button",onClick:i,disabled:n,"data-slot":"history-row-primary",className:Ye("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,g.jsx(W9,{className:Ye("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 Mie({title:e,modeTag:t}){return g.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[g.jsx("span",{className:"text-sm font-normal truncate min-w-0",title:e,children:e}),t&&g.jsx(Oie,{mode:t})]})}function Oie({mode:e}){const t=e==="json"?"聊天视图":"终端视图",n=e==="json"?Mx:Dx;return g.jsx("span",{"data-slot":"history-mode-tag","data-mode":e,role:"img","aria-label":t,title:t,className:Ye("inline-flex size-5 shrink-0 items-center justify-center rounded border","border-border bg-muted/50 text-muted-foreground"),children:g.jsx(n,{className:"size-3","aria-hidden":"true"})})}function zB({providerLabel:e}){return g.jsx("div",{className:"grid min-w-0 gap-4","data-slot":"bypass-permission-warning",role:"alert",children:g.jsxs("div",{className:"flex min-w-0 items-start gap-3 text-sm",children:[g.jsx(_7,{className:"mt-0.5 size-5 shrink-0 text-destructive","aria-hidden":"true"}),g.jsxs("div",{className:"grid min-w-0 gap-2",children:[g.jsxs("p",{className:"font-medium text-foreground",children:[e," 将不再请求工具审批。"]}),g.jsx("p",{className:"text-muted-foreground",children:"Agent 可以直接执行命令、修改或删除文件,并可能绕过部分沙箱保护。"})]})]})})}function Die({now:e}){const t=$t(F=>F.historySessions),[n,r]=b.useState(null),[i,s]=b.useState(null),[o,l]=b.useState("json"),[u,d]=b.useState("default"),[h,p]=b.useState(!1),[y,v]=b.useState(!1),[_,w]=b.useState(new Set),[x,E]=b.useState(new Set),k=Qs(),R=b.useMemo(()=>{const F=new Map;for(const O of t){const M=$0(O);let B=F.get(M);B||(B=new Map,F.set(M,B));const L=BB(O.projectDir),N=B.get(L);N?N.sessions.push(O):B.set(L,{dir:L,sessions:[O]})}return Array.from(F.entries()).sort(([O],[M])=>LB(O,M)).map(([O,M])=>({provider:O,sessions:Array.from(M.values()).flatMap(B=>B.sessions),projects:Array.from(M.values()).map(B=>({dir:B.dir,shortDir:Tv(B.dir),sessions:B.sessions}))}))},[t]);function A(F){s(F),l(Pie(F)),d("default")}async function I(F,O,M){if(n)return;const B=Pt;if(!B){nt.error("请先连接开发机");return}r(F.id);const L=$0(F);try{const N=await B.createSession({cwd:F.projectDir,mode:O,provider:L,resumeSessionId:F.id,...M?{permissionMode:M}:{}});if(N.error||!N.sessionId){nt.error(`恢复失败:${N.error??"未知错误"}`);return}const V={sessionId:N.sessionId,state:"idle",mode:N.mode??O,provider:N.provider??"claude"};$t.getState().addSession(V),k(`/chat/${N.sessionId}?mode=${N.mode??O}`),s(null)}catch(N){nt.error(`恢复失败:${N instanceof Error?N.message:String(N)}`)}finally{r(null)}}function T(){const F=Pt;!F||h||(p(!0),F.requestSessionHistory().then(O=>$t.getState().setHistorySessions(O)).catch(O=>{nt.error(O instanceof Error?O.message:String(O))}).finally(()=>{p(!1)}))}function H(F,O){const M=jN(F,O);E(B=>{const L=new Set(B);return L.has(M)?L.delete(M):L.add(M),L})}function D(F){w(O=>{const M=new Set(O);return M.has(F)?M.delete(F):M.add(F),M})}const W=t.length>0,U=i?jB():[];return g.jsxs("div",{"data-slot":"history-list",className:"flex flex-col",children:[g.jsxs("div",{className:"flex min-h-[36px] w-full items-center gap-1.5 px-4 py-1.5",children:[g.jsxs("button",{type:"button",onClick:()=>W&&v(F=>!F),disabled:!W,"aria-expanded":W?y:void 0,"data-slot":"history-section-header","data-expanded":y,className:Ye("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:[g.jsxs("h3",{className:"min-w-0 text-sm font-semibold text-foreground",children:["全部会话",W?g.jsxs("span",{className:"ml-1 text-muted-foreground/70 font-normal",children:["· ",t.length]}):null]}),W?g.jsx(Zh,{className:Ye("size-3.5 shrink-0 text-muted-foreground/80 transition-transform",y&&"rotate-90"),"aria-hidden":"true"}):null]}),g.jsx(_t,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"刷新全部会话","aria-busy":h,title:"刷新",onClick:T,disabled:h,"data-slot":"history-refresh",children:g.jsx(Ox,{className:Ye("size-3.5",h&&"animate-spin"),"aria-hidden":"true"})})]}),!W&&g.jsx("div",{className:"px-4 py-3 text-sm text-muted-foreground/70","data-slot":"history-empty",children:"暂无会话记录"}),W&&y&&g.jsx("ul",{role:"list",className:"flex flex-col",children:R.map(F=>{const O=_.has(F.provider);return g.jsxs("li",{children:[g.jsxs("button",{type:"button",onClick:()=>D(F.provider),"aria-expanded":!O,"data-slot":"history-provider-header","data-expanded":!O,className:Ye("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:[g.jsx("span",{className:"font-mono",children:Jv(F.provider)}),g.jsx("span",{className:"h-px flex-1 bg-border/70","aria-hidden":"true"}),g.jsx("span",{className:"tabular-nums",children:F.sessions.length}),g.jsx(Zh,{className:Ye("size-3.5 shrink-0 text-muted-foreground/80 transition-transform",!O&&"rotate-90"),"aria-hidden":"true"})]}),!O&&g.jsx("ul",{role:"list",className:"flex flex-col",children:F.projects.map(M=>{const B=jN(F.provider,M.dir),L=x.has(B);return g.jsxs("li",{children:[g.jsxs("button",{type:"button",onClick:()=>H(F.provider,M.dir),"aria-expanded":L,"data-slot":"history-group-header","data-expanded":L,className:Ye("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:[g.jsx("span",{className:"text-sm font-mono truncate flex-1 min-w-0",title:M.dir,children:M.shortDir}),g.jsx("span",{className:"text-xs text-muted-foreground/80 tabular-nums shrink-0",children:M.sessions.length}),g.jsx(Zh,{className:Ye("size-3.5 shrink-0 text-muted-foreground/80 transition-transform",L&&"rotate-90"),"aria-hidden":"true"})]}),L&&g.jsx("ul",{role:"list",className:"flex flex-col",children:M.sessions.map(N=>g.jsx(Nie,{session:N,now:e,disabled:n!==null,loading:n===N.id,onClick:()=>A(N),modeTag:N.preferredMode},N.id))})]},B)})})]},F.provider)})}),g.jsx(Lie,{session:i,open:i!==null,modes:U,mode:o,permissionMode:u,submitting:n!==null,onOpenChange:F=>{F||s(null)},onModeChange:l,onPermissionModeChange:d,onConfirm:()=>{i&&I(i,o,u)}})]})}function jN(e,t){return`${e}:${BB(t)}`}function BB(e){const t=e.trim();return!t||t==="/"?t||"/":t.replace(/\/+$/,"")||"/"}function jB(){return["json","pty"]}function Pie(e){const t=jB();return e.preferredMode&&t.includes(e.preferredMode)?e.preferredMode:t[0]??"json"}function Lie({session:e,open:t,modes:n,mode:r,permissionMode:i,submitting:s,onOpenChange:o,onModeChange:l,onPermissionModeChange:u,onConfirm:d}){const[h,p]=b.useState(!1),y=i==="bypassPermissions",v=ul("(min-width: 768px)");b.useEffect(()=>{t||p(!1)},[t]);const _=h?g.jsx(zB,{providerLabel:e?Jv($0(e)):"Agent"}):g.jsxs("div",{className:"grid min-w-0 gap-4",children:[g.jsxs("div",{className:"grid min-w-0 gap-2",children:[g.jsx("span",{className:"text-sm font-medium",children:"模式"}),g.jsxs("div",{role:"radiogroup","aria-label":"恢复模式",className:"grid min-w-0 grid-cols-2 gap-2",children:[n.includes("json")&&g.jsx(FN,{checked:r==="json",label:"聊天",icon:g.jsx(Mx,{className:"size-4","aria-hidden":"true"}),disabled:s,onClick:()=>l("json")}),n.includes("pty")&&g.jsx(FN,{checked:r==="pty",label:"终端",icon:g.jsx(Dx,{className:"size-4","aria-hidden":"true"}),disabled:s,onClick:()=>l("pty")})]})]}),g.jsxs("div",{className:"grid min-w-0 gap-2",children:[g.jsx("span",{className:"text-sm font-medium",children:"权限模式"}),g.jsxs("div",{role:"radiogroup","aria-label":"权限模式",className:"grid min-w-0 gap-2",children:[g.jsx(J_,{checked:i==="default",label:"严格审批",description:"所有需要权限的操作都要确认。",disabled:s,onClick:()=>u("default")}),g.jsx(J_,{checked:i==="auto",label:"自动判定",description:"交给 Agent CLI 的原生策略判断。",disabled:s,onClick:()=>u("auto")}),g.jsx(J_,{checked:i==="bypassPermissions",label:"跳过全部审批",description:"危险模式,会跳过工具审批和部分沙箱保护。",destructive:!0,disabled:s,onClick:()=>u("bypassPermissions")})]})]})]}),w=g.jsxs(g.Fragment,{children:[g.jsx(_t,{type:"button",variant:"ghost",disabled:s,onClick:()=>{h?p(!1):o(!1)},children:h?"返回":"取消"}),g.jsx(_t,{type:"button",variant:h?"destructive":"default",disabled:s,onClick:()=>{if(y&&!h){p(!0);return}d()},"data-slot":h?"bypass-permission-confirm":void 0,children:s?"恢复中...":h?"确认":"恢复"})]});return v?g.jsx(Sc,{open:t,onOpenChange:o,children:g.jsxs(xc,{focusSurfaceOnOpen:!0,className:"min-w-0 sm:max-w-md","data-slot":"history-restore-dialog",children:[g.jsxs(Ec,{className:"min-w-0",children:[g.jsx(cl,{children:h?"跳过全部审批?":"恢复会话"}),g.jsx(uc,{className:"min-w-0 truncate pr-10 sm:pr-0",title:e==null?void 0:e.title,children:(e==null?void 0:e.title)??""})]}),_,g.jsx(Gu,{children:w})]})}):g.jsx(Xv,{open:t,onOpenChange:o,children:g.jsxs(Zv,{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:[g.jsxs(M1,{className:"min-w-0 shrink-0 px-4 pb-2 pt-4 text-left",children:[g.jsx(Qv,{children:h?"跳过全部审批?":"恢复会话"}),g.jsx(wie,{className:"min-w-0 truncate pr-10",title:e==null?void 0:e.title,children:(e==null?void 0:e.title)??""})]}),g.jsx("div",{className:"min-h-0 overflow-y-auto px-4 pb-3","data-slot":"history-restore-body",children:_}),g.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:g.jsx("div",{className:"flex flex-col-reverse gap-2 [&_button]:min-h-11 [&_button]:w-full",children:w})})]})})}function FN({checked:e,label:t,icon:n,disabled:r,onClick:i}){return g.jsxs("button",{type:"button",role:"radio","aria-label":t,"aria-checked":e,disabled:r,onClick:i,className:Ye("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,g.jsx("span",{className:"min-w-0 text-center",children:t}),g.jsx(ta,{className:Ye("size-3.5 justify-self-end transition-opacity",e?"opacity-100":"opacity-0"),"aria-hidden":"true"})]})}function J_({checked:e,label:t,description:n,destructive:r,disabled:i,onClick:s}){return g.jsxs("button",{type:"button",role:"radio","aria-label":t,"aria-checked":e,disabled:i,onClick:s,className:Ye("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:[g.jsx("span",{className:Ye("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&&g.jsx("span",{className:Ye("size-2 rounded-full",r?"bg-destructive":"bg-primary")})}),g.jsxs("span",{className:"grid min-w-0 gap-1",children:[g.jsx("span",{className:Ye("text-sm font-medium",r?"text-destructive":"text-foreground"),children:t}),g.jsx("span",{className:"min-w-0 break-words text-xs leading-5 text-muted-foreground",children:n})]}),e&&g.jsx(ta,{className:Ye("mt-0.5 size-4 shrink-0",r?"text-destructive":"text-primary"),"aria-hidden":"true"})]})}function Iie({...e}){return g.jsx(Dre,{"data-slot":"select",...e})}function zie({...e}){return g.jsx(Lre,{"data-slot":"select-value",...e})}function Bie({className:e,size:t="default",children:n,...r}){return g.jsxs(Pre,{"data-slot":"select-trigger","data-size":t,className:Ye("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,g.jsx(Ire,{asChild:!0,children:g.jsx(pl,{className:"size-4 opacity-50"})})]})}function jie({className:e,children:t,position:n="item-aligned",align:r="center",...i}){return g.jsx(zre,{children:g.jsxs(Bre,{"data-slot":"select-content",className:Ye("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,...i,children:[g.jsx($ie,{}),g.jsx(jre,{className:Ye("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),g.jsx(Hie,{})]})})}function Fie({className:e,children:t,...n}){return g.jsxs(Fre,{"data-slot":"select-item",className:Ye("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:[g.jsx("span",{"data-slot":"select-item-indicator",className:"absolute right-2 flex size-3.5 items-center justify-center",children:g.jsx(Hre,{children:g.jsx(ta,{className:"size-4"})})}),g.jsx($re,{children:t})]})}function $ie({className:e,...t}){return g.jsx(Ure,{"data-slot":"select-scroll-up-button",className:Ye("flex cursor-default items-center justify-center py-1",e),...t,children:g.jsx(Nx,{className:"size-4"})})}function Hie({className:e,...t}){return g.jsx(Wre,{"data-slot":"select-scroll-down-button",className:Ye("flex cursor-default items-center justify-center py-1",e),...t,children:g.jsx(pl,{className:"size-4"})})}function L1(e){return!e||e.endsWith("/")?e:`${e}/`}function Uie(e){const t=e.split("@").pop()??"",n=t.lastIndexOf("/");return n>=0?t.slice(n+1).toLowerCase():t.toLowerCase()}function Wie(e){const t=e.split("@").pop()??"",n=t.lastIndexOf("/");return n>=0?t.slice(0,n+1):""}function qie(e,t,n){var o;if(t==="insert")return{currentPath:Wie(e)||"./",query:Uie(e)};if(!e)return{currentPath:"./",query:""};const r=e.replace(/\/+$/,"")||"/";if(e.endsWith("/")||r===(n==null?void 0:n.baseCwd)||((o=n==null?void 0:n.knownDirs)==null?void 0:o.has(r)))return{currentPath:L1(r),query:""};const s=e.lastIndexOf("/");return{currentPath:s>=0?e.slice(0,s+1):"./",query:s>=0?e.slice(s+1).toLowerCase():e.toLowerCase()}}function Vie(e,t){if(t.startsWith("/"))return t.replace(/\/+$/,"")||"/";if(!e)return"";const n=t.replace(/^\.\//,"").replace(/\/+$/,"");return n?`${e}/${n}`:e}function Yie(e,t){return`${L1(e)}${t.name}${t.isDir?"/":""}`}function $N(e,t){const n=e.trim().replace(/\/+$/,"")||"/",r=t.trim().replace(/^\/+|\/+$/g,"");return!n.startsWith("/")||!r||t.trim().startsWith("/")||r.split("/").some(i=>i===""||i==="."||i==="..")?null:n==="/"?`/${r}`:`${n}/${r}`}const FB=b.forwardRef(function({filter:t,onSelect:n,onCreateDirectory:r,mode:i="insert",placement:s="floating",dirsOnly:o=!1,title:l},u){const d=ii($=>$.tree),h=ii($=>$.cwd),p=ii($=>$.homePath),y=i==="insert"?h:p||h,v=b.useMemo(()=>new Set(d.keys()),[d]),_=b.useMemo(()=>qie(t,i,{baseCwd:y,knownDirs:v}),[t,i,y,v]),w=_.currentPath,x=b.useMemo(()=>Vie(y,w),[y,w]),E=_.query,k=b.useRef(new Set),[R,A]=b.useState(!1),[I,T]=b.useState(""),[H,D]=b.useState(!1);b.useEffect(()=>{if(!x||d.has(x)||k.current.has(x))return;const $=Pt;if(!$)return;let P=!1;return k.current.add(x),$.requestDirectoryList(x).then(q=>{P||ii.getState().setDirEntries(q.path,q.entries)}).catch(()=>{P||ii.getState().setDirEntries(x,[])}).finally(()=>{k.current.delete(x)}),()=>{P=!0}},[x,d]);const W=!d.has(x),U=b.useMemo(()=>{let $=d.get(x)??[];return o&&($=$.filter(P=>P.isDir)),E&&($=$.filter(P=>P.name.toLowerCase().includes(E))),$},[d,x,E,o]),[F,O]=b.useState(0);b.useEffect(()=>O(0),[w,E]),b.useEffect(()=>{A(!1),T("")},[x]),b.useEffect(()=>{F>=U.length&&U.length>0&&O(U.length-1)},[U.length,F]);const M=b.useRef(null),B=b.useRef(!1);b.useEffect(()=>{var P;if(!B.current)return;B.current=!1;const $=(P=M.current)==null?void 0:P.querySelector(`[data-entry-index="${F}"]`);$==null||$.scrollIntoView({block:"nearest"})},[F]);const L=b.useCallback($=>{const P=Yie(w,$);return i==="insert"?P.replace(/^\.\//,""):P},[w,i]);async function N(){const $=$N(x,I);if(!(!$||!r)){D(!0);try{const P=await r($);if(!P)return;T(""),A(!1),n(L1(P))}finally{D(!1)}}}b.useImperativeHandle(u,()=>({handleKey($){return U.length===0?!1:$.key==="ArrowDown"?(B.current=!0,O(P=>Math.min(U.length-1,P+1)),!0):$.key==="ArrowUp"?(B.current=!0,O(P=>Math.max(0,P-1)),!0):$.key==="Enter"&&!$.nativeEvent.isComposing?(n(L(U[F])),!0):!1}}),[U,F,L,n]);const V=s==="inline"?"relative w-full bg-popover border border-border rounded-md overflow-hidden":i==="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",Y=s==="inline"?"h-44 overflow-y-auto overscroll-contain":i==="select"?"max-h-44 overflow-y-auto overscroll-contain":"max-h-60 overflow-y-auto overscroll-contain";return g.jsxs("div",{className:V,"data-slot":"file-path-picker","data-mode":i,"data-placement":s,children:[i==="select"&&l?g.jsxs("div",{className:"border-b border-border/70 px-3 py-2",children:[g.jsxs("div",{className:"flex items-center justify-between gap-3",children:[g.jsx("span",{className:"text-xs text-muted-foreground",children:l}),r?g.jsx("button",{type:"button",className:"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 disabled:cursor-not-allowed disabled:opacity-50",disabled:!x||H,onClick:()=>A($=>!$),children:"新建目录"}):null]}),R?g.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[g.jsx("input",{type:"text",value:I,onChange:$=>T($.target.value),onKeyDown:$=>{$.key==="Enter"&&!$.nativeEvent.isComposing&&($.preventDefault(),N()),$.key==="Escape"&&(A(!1),T(""))},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}),g.jsx("button",{type:"button",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:!$N(x,I)||H,onClick:()=>void N(),children:H?"创建中...":"创建目录"})]}):null]}):null,g.jsx("div",{className:Y,children:U.length===0?g.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:W?"加载中...":"没有匹配的路径"}):g.jsx("ul",{ref:M,role:"list",className:"flex flex-col",children:U.map(($,P)=>g.jsx("li",{children:g.jsx("button",{type:"button",onClick:()=>n(L($)),onMouseEnter:()=>O(P),className:Ye("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",P===F&&"bg-[color-mix(in_srgb,var(--primary)_15%,transparent)]",$.isDir&&"font-semibold"),"data-slot":"file-entry","data-entry-type":$.isDir?"dir":"file","data-entry-index":P,children:g.jsxs("span",{className:"font-mono text-[13px]",children:[$.name,$.isDir?"/":""]})})},$.name))})})]})}),HN="工作目录不存在或不可访问:",Kie=[{value:"default",label:"严格审批"},{value:"auto",label:"自动判定"},{value:"acceptEdits",label:"自动接受编辑"},{value:"plan",label:"只读规划"},{value:"bypassPermissions",label:"跳过全部审批"}],$B=[{value:"default",label:"严格审批"},{value:"auto",label:"自动判定"},{value:"bypassPermissions",label:"跳过全部审批"}],ea={claude:"Claude Code",codex:"Codex"};function Gie(e,t){return t!==Zr.PATH_NOT_FOUND||!e.startsWith(HN)?null:e.slice(HN.length).trim()||null}function Zg(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 Xie(e,t){return t.title?t.disabled?`${ea[e]}:${t.title}`:`${ea[e]} 路径:${t.title}`:`${ea[e]}:${t.label}`}function Zie(e,t){return e!=="codex"||$B.some(n=>n.value===t)?t:"default"}async function Qie({relay:e,agentCli:t,form:n,timeoutMs:r=Kx}){var d,h;const i=n.cwd.trim();if(!i)return{type:"validation_error",message:"请输入工作目录"};if(!e)return{type:"relay_missing",message:"请先连接开发机"};if(Zg(n.provider,t).disabled){const p=(d=t==null?void 0:t[n.provider])==null?void 0:d.error;return{type:"provider_unavailable",message:p?`${ea[n.provider]} 不可用:${p}`:`${ea[n.provider]} 暂不可用`}}const o=n.mode,l=n.provider,u=n.name.trim();try{const p=await e.createSession({kind:"agent",cwd:i,name:u||void 0,mode:o,provider:l,permissionMode:n.permissionMode},r);if(p.error||!p.sessionId){const w=Gie(p.error??"",p.errorCode);return w?{type:"missing_cwd",path:w,message:"找不到这个工作目录"}:{type:"create_error",message:`创建失败:${p.error??"未知错误"}`}}const y=p.mode??o,v=((h=p.name)==null?void 0:h.trim())||void 0;return{type:"success",session:{sessionId:p.sessionId,...p.kind!==void 0?{kind:p.kind}:{},name:v,...p.nameLocked!==void 0?{nameLocked:p.nameLocked}:{},state:"idle",mode:y,provider:p.provider??l,...p.ptyOwner!==void 0?{ptyOwner:p.ptyOwner}:{}},route:`/chat/${p.sessionId}?mode=${y}`}}catch(p){return{type:"exception",message:p instanceof Error?p.message:String(p)}}}async function Jie({relay:e,timeoutMs:t=Kx}){var n;if(!e)return{type:"relay_missing",message:"请先连接开发机"};try{const r=await e.createSession({kind:"terminal",mode:"pty"},t);return r.error||!r.sessionId?{type:"create_error",message:`创建终端失败:${r.error??"未知错误"}`}:{type:"success",session:{sessionId:r.sessionId,kind:"terminal",name:((n=r.name)==null?void 0:n.trim())||void 0,...r.nameLocked!==void 0?{nameLocked:r.nameLocked}:{},state:"idle",mode:"pty",provider:r.provider??"claude",...r.ptyOwner!==void 0?{ptyOwner:r.ptyOwner}:{}},route:`/chat/${r.sessionId}?mode=pty`}}catch(r){return{type:"exception",message:r instanceof Error?r.message:String(r)}}}function ese({agentCli:e,provider:t,isDesktop:n,editingCliProvider:r,cliPathInput:i,savingCliPath:s,onProviderChange:o,onOpenCliPathEditor:l,onCliPathInputChange:u,onCancelCliPathEditor:d,onSaveCliPath:h}){const p=Zg("claude",e),y=Zg("codex",e),v=e==null?void 0:e[t];return g.jsxs("section",{"aria-label":"Agent CLI",className:"flex min-w-0 flex-col gap-2",children:[g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsx("span",{className:"text-sm",children:"Agent CLI"}),g.jsx("span",{className:"text-xs text-muted-foreground",children:"选择要启动的 CLI"})]}),g.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-2 sm:grid-cols-2",children:[g.jsx(UN,{provider:"claude",selected:t==="claude",status:p,agentCliLoaded:!!e,onClick:()=>o("claude")}),g.jsx(UN,{provider:"codex",selected:t==="codex",status:y,agentCliLoaded:!!e,onClick:()=>o("codex")})]}),g.jsx("div",{className:"relative min-w-0 rounded-md border border-border bg-muted/20 px-3 py-2.5 md:p-3","data-slot":"agent-cli-path-card",children:r===t?g.jsx(tse,{provider:r,agentCli:e,cliPathInput:i,savingCliPath:s,onCliPathInputChange:u,onCancel:d,onSave:h}):g.jsx(nse,{provider:t,selectedCli:v,isDesktop:n,onOpenCliPathEditor:l})})]})}function UN({provider:e,selected:t,status:n,agentCliLoaded:r,onClick:i}){return g.jsxs(qf,{children:[g.jsx(Vf,{asChild:!0,children:g.jsxs("button",{type:"button","aria-pressed":t,"aria-label":ea[e],onClick:i,className:Ye("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",t?"border-primary/70 bg-primary/10":"border-border bg-muted/20"),children:[g.jsx("span",{className:"text-sm font-medium",children:ea[e]}),g.jsx("span",{className:Ye("text-xs text-muted-foreground",n.disabled&&r&&"text-destructive"),children:n.label})]})}),g.jsx(Yf,{side:"top",className:"max-w-[min(520px,calc(100vw-2rem))]",children:g.jsx("span",{className:"break-all font-mono text-xs",children:Xie(e,n)})})]})}function tse({provider:e,agentCli:t,cliPathInput:n,savingCliPath:r,onCliPathInputChange:i,onCancel:s,onSave:o}){return g.jsxs(g.Fragment,{children:[g.jsx("p",{className:"mb-1 text-xs text-muted-foreground",children:"CLI 路径"}),g.jsxs("div",{className:"flex min-w-0 flex-col gap-2 sm:flex-row sm:items-center",children:[g.jsxs("label",{className:"min-w-0 flex-1",children:[g.jsx("span",{className:"sr-only",children:"CLI 路径"}),g.jsx("input",{type:"text",list:`agent-cli-path-${e}`,value:n,onChange:l=>i(l.target.value),onKeyDown:l=>{l.key==="Enter"&&(l.preventDefault(),o()),l.key==="Escape"&&(l.preventDefault(),s())},placeholder:e==="claude"?"/path/to/claude":"/path/to/codex",className:"min-h-11 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 md:h-10 md:min-h-0 md:text-sm"}),g.jsx("datalist",{id:`agent-cli-path-${e}`,children:((t==null?void 0:t[e].suggestions)??[]).map(l=>g.jsx("option",{value:l},l))})]}),g.jsxs("div",{className:"flex shrink-0 justify-end gap-2",children:[g.jsx(_t,{type:"button",variant:"ghost",className:"min-h-11 shrink-0 rounded px-2.5 text-xs font-medium text-muted-foreground hover:text-foreground md:h-8 md:min-h-0",onClick:s,disabled:r,children:"取消"}),g.jsx(_t,{type:"button",className:"min-h-11 shrink-0 rounded px-2.5 text-xs font-medium md:h-8 md:min-h-0",onClick:o,disabled:r||!n.trim(),children:r?"保存中...":"保存路径"})]})]})]})}function nse({provider:e,selectedCli:t,isDesktop:n,onOpenCliPathEditor:r}){return n?g.jsxs(g.Fragment,{children:[g.jsx("p",{className:"mb-1 text-xs text-muted-foreground",children:"CLI 路径"}),g.jsxs("div",{className:"flex min-w-0 flex-col gap-2 md:flex-row md:items-center",children:[g.jsx("p",{className:Ye("flex h-10 min-w-0 flex-1 items-center truncate font-mono text-sm",t!=null&&t.available?"text-foreground":"text-destructive"),title:(t==null?void 0:t.command)??(t==null?void 0:t.error),children:(t==null?void 0:t.command)??(t==null?void 0:t.error)??"等待检测结果"}),g.jsx(_t,{type:"button",variant:"outline",className:"h-8 min-h-0 shrink-0 self-end rounded px-2.5 text-xs font-medium text-muted-foreground hover:text-foreground sm:self-auto",onClick:()=>r(e),children:"指定路径"})]})]}):g.jsxs(g.Fragment,{children:[g.jsx("p",{className:"pr-11 text-xs text-muted-foreground",children:"CLI 路径"}),g.jsx(_t,{type:"button",variant:"ghost",size:"icon",className:"absolute right-1 top-1/2 size-11 -translate-y-1/2 rounded-full text-muted-foreground hover:bg-accent/70 hover:text-foreground","aria-label":"指定路径",onClick:()=>r(e),children:g.jsx(G8,{className:"size-4","aria-hidden":"true"})}),g.jsx("p",{className:Ye("mt-1 min-w-0 break-all pr-11 font-mono text-sm leading-5",t!=null&&t.available?"text-foreground":"text-destructive"),title:(t==null?void 0:t.command)??(t==null?void 0:t.error),children:(t==null?void 0:t.command)??(t==null?void 0:t.error)??"等待检测结果"})]})}function Bh({open:e,onOpenChange:t}){const[n,r]=b.useState(""),[i,s]=b.useState(""),[o,l]=b.useState("claude"),[u,d]=b.useState("pty"),[h,p]=b.useState("default"),[y,v]=b.useState(!1),[_,w]=b.useState(!1),[x,E]=b.useState(null),[k,R]=b.useState(!1),[A,I]=b.useState(null),[T,H]=b.useState(""),[D,W]=b.useState(!1),U=b.useRef(null),F=b.useRef(e);F.current=e;const O=Qs(),M=ii(Ce=>Ce.homePath),B=ii(Ce=>Ce.agentCli),L=ul("(min-width: 768px)");b.useEffect(()=>{e&&!i&&M&&s(M)},[e,M,i]),b.useEffect(()=>{if(!e||M&&B)return;const Ce=Pt==null?void 0:Pt.requestProxyInfo();Ce&&Ce.then(Me=>{const Ve=ii.getState();Ve.setHomePath(Me.homePath),Ve.setAgentCli(Me.agentCli)}).catch(Me=>{console.error("[create-session-dialog] requestProxyInfo failed",Me)})},[e,M,B]),b.useEffect(()=>{if(!k)return;function Ce(Me){var Qe;const Ve=Me.target;Ve instanceof Node&&((Qe=U.current)!=null&&Qe.contains(Ve))||window.setTimeout(()=>R(!1),0)}return document.addEventListener("pointerdown",Ce,!0),()=>document.removeEventListener("pointerdown",Ce,!0)},[k]);function N(){r(""),s(""),R(!1),l("claude"),d("pty"),p("default"),v(!1),E(null),I(null),H(""),W(!1)}function V(){if(h==="bypassPermissions"){v(!0);return}z()}async function Y(){await z(),F.current&&v(!1)}const $=o==="codex"?$B:Kie,P=Zg(o,B),q=_||D||P.disabled;function K(Ce){const Me=Zie(Ce,h);Me!==h&&p(Me)}async function z(Ce){E(null),w(!0);try{const Me=await Qie({relay:Pt,agentCli:B,form:{cwd:Ce??i,name:n,provider:o,permissionMode:h,mode:u}});if(Me.type==="success"){if($t.getState().addSession(Me.session),!F.current)return;t(!1),N(),O(Me.route);return}if(Me.type==="missing_cwd"&&E(Me.path),nt.error(Me.message),Me.type==="validation_error"||Me.type==="relay_missing")return}finally{w(!1)}}async function X(Ce){const Me=Pt;if(!Me)return nt.error("请先连接开发机"),null;try{const Ve=await Me.createDirectory(Ce);return Ve.success?(s(Ve.path),E(null),nt.success("目录已创建"),Ve.path):(nt.error(`目录创建失败:${Ve.error??"未知错误"}`),null)}catch(Ve){return nt.error(Ve instanceof Error?Ve.message:String(Ve)),null}}function ee(Ce){var Ve;const Me=B==null?void 0:B[Ce];I(Ce),H((Me==null?void 0:Me.command)??((Ve=Me==null?void 0:Me.suggestions)==null?void 0:Ve[0])??"")}async function te(){if(!A)return;const Ce=T.trim();if(!Ce){nt.error("请输入 Agent CLI 路径");return}const Me=Pt;if(!Me){nt.error("请先连接开发机");return}W(!0);try{const Ve=await Me.updateAgentCliPath(A,Ce);if(Ve.error||!Ve.agentCli){nt.error(`路径保存失败:${Ve.error??"未知错误"}`);return}ii.getState().setAgentCli(Ve.agentCli),nt.success(`${ea[A]} 路径已保存`),I(null),H("")}catch(Ve){nt.error(Ve instanceof Error?Ve.message:String(Ve))}finally{W(!1)}}function Q(Ce){d(Ce),K(o)}function me(Ce){var Ve;const Me=Ce.relatedTarget;Me instanceof Node&&((Ve=U.current)!=null&&Ve.contains(Me))||window.setTimeout(()=>R(!1),0)}const ve=y?g.jsxs("div",{className:"grid min-w-0 gap-5","data-slot":"bypass-permission-confirmation",children:[g.jsx(zB,{providerLabel:ea[o]}),g.jsxs(Gu,{children:[g.jsx(_t,{type:"button",variant:"ghost",className:"min-h-11 md:min-h-0",onClick:()=>v(!1),disabled:_,children:"返回"}),g.jsx(_t,{type:"button",variant:"destructive",className:"min-h-11 md:min-h-0",onClick:()=>void Y(),disabled:_,"data-slot":"bypass-permission-confirm",children:_?"创建中...":"确认"})]})]}):g.jsxs("form",{className:"flex min-w-0 flex-col gap-4","data-slot":"create-session-form",autoComplete:"off",onSubmit:Ce=>{Ce.preventDefault(),V()},children:[g.jsxs("label",{className:"flex min-w-0 flex-col gap-1",children:[g.jsx("span",{className:"text-sm",children:"名称(可选)"}),g.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:"自动生成"})]}),g.jsxs("div",{ref:U,className:"relative flex min-w-0 flex-col gap-2",onBlur:me,children:[g.jsx("span",{id:"create-session-cwd-label",className:"text-sm",children:"工作目录"}),g.jsx("input",{id:"create-session-cwd",type:"text","aria-labelledby":"create-session-cwd-label",name:"dev-anywhere-session-cwd",autoComplete:"off",autoCorrect:"off",spellCheck:!1,value:i,onFocus:()=>R(!0),onChange:Ce=>{s(Ce.target.value),E(null)},placeholder:"输入绝对路径",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 md:h-9 md:min-h-0 md:text-sm"}),k?g.jsx(FB,{mode:"select",dirsOnly:!0,filter:i,title:"选择下一级目录",onCreateDirectory:X,onSelect:Ce=>{s(Ce),E(null),R(!0)}}):null]}),x?g.jsxs("section",{role:"status","aria-live":"polite",className:"rounded-md border border-primary/50 bg-primary/10 p-3",children:[g.jsx("p",{className:"text-sm font-medium",children:"工作目录不存在"}),g.jsx("p",{className:"mt-1 break-all font-mono text-xs text-muted-foreground",children:x})]}):null,g.jsxs("section",{"aria-label":"交互方式",className:"flex min-w-0 flex-col gap-2",children:[g.jsx("span",{className:"text-sm",children:"交互方式"}),g.jsxs("div",{className:"grid min-w-0 grid-cols-1 gap-2 sm:grid-cols-2",children:[g.jsxs("button",{type:"button","aria-pressed":u==="pty",onClick:()=>Q("pty"),className:Ye("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:[g.jsx("span",{className:"text-sm font-medium",children:"终端模式"}),g.jsx("span",{className:"text-xs text-muted-foreground",children:"像本地终端一样操作"})]}),g.jsxs("button",{type:"button","aria-pressed":u==="json",onClick:()=>Q("json"),className:Ye("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:[g.jsx("span",{className:"text-sm font-medium",children:"聊天模式"}),g.jsx("span",{className:"text-xs text-muted-foreground",children:"气泡式对话,支持 Voice Pilot"})]})]})]}),g.jsx(ese,{agentCli:B,provider:o,isDesktop:L,editingCliProvider:A,cliPathInput:T,savingCliPath:D,onProviderChange:Ce=>{l(Ce),K(Ce)},onOpenCliPathEditor:ee,onCliPathInputChange:H,onCancelCliPathEditor:()=>{I(null),H("")},onSaveCliPath:()=>void te()}),g.jsxs("label",{className:"flex min-w-0 flex-col gap-2",children:[g.jsx("span",{className:"text-sm",children:"权限模式"}),g.jsxs(Iie,{value:h,onValueChange:Ce=>p(Ce),children:[g.jsx(Bie,{className:"w-full",children:g.jsx(zie,{})}),g.jsx(jie,{children:$.map(Ce=>g.jsx(Fie,{value:Ce.value,children:Ce.label},Ce.value))})]})]}),g.jsxs(Gu,{children:[g.jsx(_t,{type:"button",variant:"ghost",className:"min-h-11 md:min-h-0",onClick:()=>t(!1),disabled:_,children:"取消"}),g.jsx(_t,{type:"submit",className:"min-h-11 md:min-h-0",disabled:q,children:_?"创建中...":"创建"})]})]});return L?g.jsx(Sc,{open:e,onOpenChange:t,children:g.jsxs(xc,{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:[g.jsx(Ec,{children:g.jsx(cl,{children:y?"跳过全部审批?":"新建会话"})}),ve]})}):g.jsx(Xv,{open:e,onOpenChange:t,children:g.jsxs(Zv,{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:[g.jsx(M1,{className:"px-0 pb-1 pt-0 text-left",children:g.jsx(Qv,{children:y?"跳过全部审批?":"新建会话"})}),ve]})})}function jh({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),[h,p]=b.useState(!1);b.useEffect(()=>{e&&(l(s),d(null),p(!1))},[s,e]);async function y(v){v.preventDefault();const _=o.trim();if(!_){d("会话标题不能为空");return}if(t){p(!0);try{await i(t,_),r(!1)}catch(w){d(w instanceof Error?w.message:String(w))}finally{p(!1)}}}return g.jsx(Sc,{open:e,onOpenChange:r,children:g.jsx(xc,{className:"sm:max-w-md","data-slot":"session-rename-dialog",children:g.jsxs("form",{className:"grid gap-4",onSubmit:v=>void y(v),children:[g.jsxs(Ec,{children:[g.jsx(cl,{children:"重命名会话"}),g.jsx(uc,{children:"自定义名称会显示在会话列表和顶部标题中。"})]}),g.jsxs("div",{className:"grid gap-2",children:[g.jsx("label",{htmlFor:"session-rename-title",className:"text-sm font-medium",children:"会话标题"}),g.jsx("input",{id:"session-rename-title",value:o,autoFocus:!0,maxLength:100,"aria-invalid":!!u,"aria-describedby":u?"session-rename-error":void 0,className:Ye("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:h,onChange:v=>{l(v.target.value),u&&d(null)}}),u?g.jsx("p",{id:"session-rename-error",className:"text-sm text-destructive",children:u}):null]}),g.jsxs(Gu,{children:[g.jsx(_t,{type:"button",variant:"outline",onClick:()=>r(!1),children:"取消"}),g.jsx(_t,{type:"submit",disabled:h,children:"保存"})]})]})})})}function rse(e){return(e==null?void 0:e.mode)==="pty"&&e.ptyOwner==="local-terminal"}function ise(e){return(e==null?void 0:e.kind)==="terminal"}function sse(e){return rse(e)?{title:"断开远程连接?",description:"这只会断开当前页面和本地终端的连接,本地终端里的 Claude Code/Codex 会继续运行。重新接入前,页面不能继续查看或输入这个会话。",confirmLabel:"断开远程连接",destructive:!1}:ise(e)?{title:"终止终端?",description:"这会停止当前终端进程,并清理这个终端会话的运行状态。终止后不能继续输入,也无法恢复正在执行的命令。",confirmLabel:"终止终端",destructive:!0}:{title:"终止会话?",description:"这会停止当前 Agent 进程,并清理这个会话的运行状态。终止后不能继续输入,也无法恢复正在执行的任务。",confirmLabel:"终止会话",destructive:!0}}function Fm({open:e,session:t,onOpenChange:n,onConfirm:r}){const i=sse(t);function s(){t&&(r(t),n(!1))}return g.jsx(Sc,{open:e,onOpenChange:n,children:g.jsxs(xc,{"data-slot":"session-termination-dialog",children:[g.jsxs(Ec,{children:[g.jsx(cl,{children:i.title}),g.jsx(uc,{children:i.description})]}),g.jsxs(Gu,{children:[g.jsx(_t,{type:"button",variant:"ghost",onClick:()=>n(!1),children:"取消"}),g.jsx(_t,{type:"button",variant:i.destructive?"destructive":"default",onClick:s,"data-slot":"session-termination-confirm",children:i.confirmLabel})]})]})})}function HB(e){var t,n,r,i,s,o,l,u,d,h,p,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"||((h=e.agentStatus)==null?void 0:h.phase)==="tool_use"||((p=e.agentStatus)==null?void 0:p.phase)==="outputting"||((y=e.ptyState)==null?void 0:y.state)==="working"?"working":"idle"}function ose(e){if(e.session.state==="error")return"error";const t=HB(e);return t==="disconnected"?e.session.state:t}function UB({layout:e}){const t=$t(X=>X.sessions),n=$t(X=>X.sessionListLoaded),r=$t(X=>X.agentStatusBySessionId),i=$t(X=>X.ptyStateBySessionId),s=$t(X=>X.renameSession),o=Qt(X=>X.bySessionId),l=_U("/chat/:id"),u=(l==null?void 0:l.params.id)??null,d=Ne(X=>!!X.selectedProxyId),h=Ne(X=>X.proxyListLoaded),p=Ne(X=>X.proxySwitchTarget),y=$t(X=>X.loadingProxyName),v=p!==null||!h||d&&!n,_=(p==null?void 0:p.name)??y,w=_?`正在连接 ${_}...`:"连接中...",x=Qs(),[E,k]=b.useState(!1),[R,A]=b.useState(!1),[I,T]=b.useState(null),[H,D]=b.useState(null),{creatingTerminal:W,createTerminal:U}=WB(),[F,O]=b.useState(new Set),[M,B]=b.useState(()=>Date.now());b.useEffect(()=>{const X=setInterval(()=>B(Date.now()),6e4);return()=>clearInterval(X)},[]);function L(X,ee){x(`/chat/${X}?mode=${ee??"json"}`,{replace:!1})}function N(X){const ee=X.sessionId,te=Pt;if(!te){nt.error("请先连接开发机");return}te.sendControl({type:"session_terminate",sessionId:ee}),$t.getState().removeSession(ee),Qt.getState().clearSession(ee),ee===u&&x("/sessions"),(X==null?void 0:X.mode)==="pty"&&X.ptyOwner==="local-terminal"?nt.info("已断开页面连接,本地终端仍在运行"):nt.info("正在终止会话",{duration:1500})}async function V(X,ee){const te=Pt;if(!te)throw new Error("请先连接开发机");const Q=await te.renameSession(X,ee);if(!Q.success)throw new Error(Q.error??"重命名失败");s(X,Q.name??ee),nt.success("已重命名会话")}function Y(X){O(ee=>{const te=new Set(ee);return te.has(X)?te.delete(X):te.add(X),te})}function $(X){var Q;const ee=X.mode==="json"&&(((Q=o[X.sessionId])==null?void 0:Q.pendingApprovals.some(me=>me.status==="pending"))??!1),te=ose({session:X,agentStatus:r[X.sessionId],ptyState:i[X.sessionId],hasPendingApproval:ee});return te===X.state?X:{...X,state:te}}const P=t.length>0;if(e==="sidebar"&&(v||!d))return g.jsxs(g.Fragment,{children:[g.jsx("div",{className:"px-4 py-3 text-sm text-muted-foreground/70","data-slot":v?"session-list-loading":void 0,role:v?"status":void 0,"aria-live":v?"polite":void 0,children:v?w:"请先连接开发机"}),g.jsx(Bh,{open:E,onOpenChange:k}),g.jsx(Fm,{open:H!==null,session:H,onOpenChange:X=>{X||D(null)},onConfirm:N}),g.jsx(jh,{open:I!==null,sessionId:(I==null?void 0:I.sessionId)??null,initialName:I==null?void 0:I.name,onOpenChange:X=>{X||T(null)},onRename:V})]});if(e==="page"&&v)return g.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:[g.jsx(Jl,{className:"h-5 w-5 animate-spin","aria-hidden":!0}),g.jsx("p",{className:"max-w-[min(24rem,calc(100%-2rem))] truncate text-sm",children:w})]});if(e==="page"&&!d)return g.jsxs("div",{className:"flex flex-col h-full",children:[g.jsx("div",{className:"flex-1",children:g.jsx(tc,{variant:"no-proxy"})}),g.jsx(Bh,{open:E,onOpenChange:k}),g.jsx(Fm,{open:H!==null,session:H,onOpenChange:X=>{X||D(null)},onConfirm:N}),g.jsx(jh,{open:I!==null,sessionId:(I==null?void 0:I.sessionId)??null,initialName:I==null?void 0:I.name,onOpenChange:X=>{X||T(null)},onRename:V})]});const q=g.jsxs("h3",{className:"px-4 pt-3 pb-2 text-sm font-semibold text-foreground","data-slot":"active-section-header",children:["活跃会话",P?g.jsxs("span",{className:"ml-1 text-muted-foreground/70 font-normal",children:["· ",t.length]}):null]}),K=P?g.jsx("ul",{role:"list",className:"flex flex-col w-full min-w-0",children:ase(t).map(X=>g.jsxs("li",{children:[g.jsxs("button",{type:"button",onClick:()=>Y(X.provider),"aria-expanded":!F.has(X.provider),className:Ye("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:[g.jsx("span",{className:"font-mono",children:lse(X.provider)}),g.jsx("span",{className:"h-px flex-1 bg-border/70","aria-hidden":"true"}),g.jsx("span",{className:"tabular-nums",children:X.sessions.length}),g.jsx(Zh,{className:Ye("size-3.5 shrink-0 text-muted-foreground/80 transition-transform",!F.has(X.provider)&&"rotate-90"),"aria-hidden":"true"})]}),F.has(X.provider)?null:g.jsx("ul",{role:"list",className:"flex flex-col",children:X.sessions.map(ee=>g.jsx(kie,{session:$(ee),selected:ee.sessionId===u,now:M,onClick:()=>L(ee.sessionId,ee.mode),onRename:()=>T(ee),onTerminate:()=>D(ee)},ee.sessionId))})]},X.provider))}):g.jsx("div",{className:"px-4 py-3 text-sm text-muted-foreground/70","data-slot":"active-empty",children:"暂无活跃会话"}),z=g.jsx(Die,{now:M});return e==="page"?g.jsxs("div",{className:"flex flex-col h-full",children:[g.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto overscroll-contain",children:[q,K,z]}),g.jsx("div",{className:"px-4 pt-4 pb-[calc(env(safe-area-inset-bottom)+1rem)] border-t border-border",children:g.jsxs(_t,{className:"min-h-11 w-full md:min-h-0","data-slot":"create-session-mobile-trigger",onClick:()=>A(!0),children:[g.jsx(RP,{"aria-hidden":"true"}),"新建"]})}),g.jsx(use,{open:R,creatingTerminal:W,onOpenChange:A,onCreateAgent:()=>{A(!1),k(!0)},onCreateTerminal:()=>void U(()=>A(!1))}),g.jsx(Bh,{open:E,onOpenChange:k}),g.jsx(Fm,{open:H!==null,session:H,onOpenChange:X=>{X||D(null)},onConfirm:N}),g.jsx(jh,{open:I!==null,sessionId:(I==null?void 0:I.sessionId)??null,initialName:I==null?void 0:I.name,onOpenChange:X=>{X||T(null)},onRename:V})]}):g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"dev-sidebar-scroll h-full overflow-y-auto overscroll-contain",children:[q,K,z]}),g.jsx(Bh,{open:E,onOpenChange:k}),g.jsx(Fm,{open:H!==null,session:H,onOpenChange:X=>{X||D(null)},onConfirm:N}),g.jsx(jh,{open:I!==null,sessionId:(I==null?void 0:I.sessionId)??null,initialName:I==null?void 0:I.name,onOpenChange:X=>{X||T(null)},onRename:V})]})}function ase(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])=>cse(n,r)).map(([n,r])=>({provider:n,sessions:r}))}function lse(e){return e==="terminal"?"终端":Jv(e)}function cse(e,t){return e===t?0:e==="terminal"?-1:t==="terminal"?1:LB(e,t)}function WB(){const e=Qs(),[t,n]=b.useState(!1);async function r(i){if(!t){n(!0);try{const s=await Jie({relay:Pt});if(s.type!=="success"){nt.error(s.message);return}$t.getState().addSession(s.session),i==null||i(),e(s.route)}finally{n(!1)}}}return{creatingTerminal:t,createTerminal:r}}function WN({compact:e=!1}){const[t,n]=b.useState(!1),[r,i]=b.useState(!1),s=b.useRef(!1),o=Ne(E=>!!E.selectedProxyId),l=Ne(E=>E.proxySwitchTarget!==null),u=o&&!l,{creatingTerminal:d,createTerminal:h}=WB();function p(){i(!0),window.setTimeout(()=>i(!1),2e3)}function y(){if(!u){p();return}s.current=!0,n(!0)}function v(){if(!u){p();return}s.current=!0,h()}function _(E){E.preventDefault(),p()}const w=g.jsxs(_t,{variant:"outline","data-slot":"create-session-trigger",className:Ye(e?"h-11 w-11 justify-center border-border px-0":"h-[46px] w-full justify-center gap-2 border-border px-3",!u&&"opacity-50 hover:bg-background"),"aria-label":"新建会话","aria-disabled":!u,onClick:u?void 0:_,children:[g.jsx(RP,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),!e&&g.jsx("span",{className:"truncate",children:"新建"})]}),x=u?g.jsxs(O1,{children:[g.jsx(D1,{asChild:!0,children:w}),g.jsxs(P1,{align:e?"end":"start",className:"w-52","data-slot":"create-session-type-menu",onCloseAutoFocus:E=>{s.current&&(s.current=!1,E.preventDefault())},children:[g.jsxs(yo,{className:"min-h-9 gap-2.5","data-slot":"create-agent-session-item",onSelect:y,children:[g.jsx(TP,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),"Agent 会话"]}),g.jsxs(yo,{className:"min-h-9 gap-2.5","data-slot":"create-terminal-session-item",disabled:d,onSelect:v,children:[g.jsx(cf,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),d?"正在创建终端会话...":"终端会话"]})]})]}):w;return g.jsxs(g.Fragment,{children:[u?x:g.jsxs(qf,{open:u?void 0:r,onOpenChange:u?void 0:i,children:[g.jsx(Vf,{asChild:!0,children:x}),g.jsx(Yf,{side:"top",children:l?"正在切换开发机":"请先连接开发机"})]}),g.jsx(Bh,{open:t,onOpenChange:n})]})}function use({open:e,creatingTerminal:t,onOpenChange:n,onCreateAgent:r,onCreateTerminal:i}){const s=b.useRef(!1);function o(l){s.current=!0,l()}return g.jsx(Xv,{open:e,onOpenChange:n,children:g.jsxs(Zv,{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:l=>{s.current&&(s.current=!1,l.preventDefault())},children:[g.jsx(M1,{className:"px-1 pb-1 pt-0 text-left",children:g.jsx(Qv,{children:"新建"})}),g.jsxs("div",{className:"grid gap-2 pb-1","data-slot":"create-session-type-options",children:[g.jsxs(_t,{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:()=>o(r),children:[g.jsx(TP,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),"Agent 会话"]}),g.jsxs(_t,{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:()=>o(i),children:[g.jsx(cf,{className:"size-4 text-muted-foreground","aria-hidden":"true"}),t?"正在创建终端会话...":"终端会话"]})]})]})})}const dse="0.5.28",hse={version:dse},fse={playback:"playback",capture:"play-and-record"};function pse(){return typeof navigator>"u"?null:navigator.audioSession??null}function mse(){return{setMode:()=>{},release:()=>{}}}class gse{constructor(t=pse){yt(this,"leases",new Map);yt(this,"session",null);yt(this,"baselineType",null);yt(this,"nextLeaseId",1);yt(this,"nextOrder",1);this.getAudioSession=t}acquire(t){const n=this.getAudioSession();if(!n)return mse();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(fse[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 I1=new gse,q0=64,qN=-60,qB=32;function VN(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-qN)/-qN));return e<0?-r:r}function YN(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,h=-1;for(let p=l;p<u;p+=1){const y=i.getInt16(p*2,!0)/32768;d=Math.min(d,y),h=Math.max(h,y)}s.push({min:d,max:h})}return s}function vse(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 yse(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 VB{constructor(t,n=24e3,r={}){yt(this,"nextStartTime",0);yt(this,"activityEndToken",0);yt(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=vse(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*qB/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,h=Math.max(0,(d-this.context.currentTime)*1e3),p=t.slice(l*Int16Array.BYTES_PER_ELEMENT,u*Int16Array.BYTES_PER_ELEMENT),y=yse(n.subarray(l,u));this.scheduleTimer(()=>{var v,_,w,x;(_=(v=this.options).onActivityLevel)==null||_.call(v,y),(x=(w=this.options).onPlaybackChunk)==null||x.call(w,p)},h)}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 ew={provider:"aliyun-bailian",configured:!1,region:"cn",asrModel:"qwen3-asr-flash-realtime",ttsModel:"cosyvoice-v3-flash",ttsVoice:"longanyang",turnIdleSeconds:3},KN="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",bse=800,GN=300,_se=1600;function V0(e,t){return e.filter(n=>!n.model||n.model===t)}function XN({label:e,children:t,help:n}){return g.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:[g.jsx("span",{className:"block text-[13px] font-medium leading-none text-muted-foreground",children:e}),g.jsx("div",{className:"mt-2 min-w-0",children:t}),n?g.jsx("span",{className:"mt-2 block text-xs leading-relaxed text-muted-foreground",children:n}):null]})}function $m({label:e,value:t,options:n,onChange:r,placeholder:i="请选择",help:s}){const[o,l]=b.useState(!1),u=b.useId(),d=n.find(v=>v.value===t),h=(d==null?void 0:d.label)??(t||i),p=n.filter(v=>!v.disabled),y=!!YB(h).detail;return g.jsxs("div",{className:"min-w-0 rounded-lg border border-border/75 bg-card/55 p-3.5 sm:p-3",onBlur:v=>{v.currentTarget.contains(v.relatedTarget)||l(!1)},children:[g.jsx("div",{id:u,className:"text-[13px] font-medium leading-none text-muted-foreground",children:e}),g.jsxs("button",{type:"button","aria-labelledby":u,"aria-haspopup":"listbox","aria-expanded":o,disabled:p.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(v=>!v),"data-slot":"voice-settings-choice-trigger",children:[g.jsx(ZN,{label:h,muted:!d&&!t}),g.jsx(pl,{className:`size-4 shrink-0 text-muted-foreground transition-transform ${o?"rotate-180":""}`,"aria-hidden":"true"})]}),o?g.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(v=>{const _=v.value===t;return g.jsxs("button",{type:"button",role:"option","aria-label":v.label,"aria-selected":_,disabled:v.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:()=>{v.disabled||(r(v.value),l(!1))},children:[g.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center text-primary",children:_?g.jsx(ta,{className:"size-4","aria-hidden":"true"}):null}),g.jsx(ZN,{label:v.label})]},v.value)})}):null,s?g.jsx("div",{className:"mt-2 text-xs leading-relaxed text-muted-foreground",children:s}):null]})}function ZN({label:e,muted:t=!1}){const n=YB(e);return g.jsxs("span",{className:"min-w-0 flex-1",children:[g.jsx("span",{className:`block truncate text-base leading-6 md:text-sm ${t?"text-muted-foreground":"text-foreground"}`,children:n.title}),n.detail?g.jsx("span",{className:"mt-0.5 block truncate text-xs leading-4 text-muted-foreground",children:n.detail}):null]})}function wse({scrollRef:e}={}){const[t,n]=b.useState(ew),[r,i]=b.useState(String(ew.turnIdleSeconds)),[s,o]=b.useState(()=>Rm()),[l,u]=b.useState(""),[d,h]=b.useState(!1),[p,y]=b.useState(!1),[v,_]=b.useState({kind:"idle"}),w=b.useRef(null),x=b.useRef(null),E=b.useRef(null),k=b.useRef(null),R=b.useRef(null);b.useEffect(()=>{const te=Pt;if(!te){_({kind:"error",message:"请先连接 Relay 服务器"});return}let Q=!1;return _({kind:"loading"}),te.requestVoiceConfig().then(me=>{if(!Q){if(me.error||!me.config){_({kind:"error",message:me.error??"读取语音设置失败"});return}n(me.config),i(String(me.config.turnIdleSeconds)),u(""),h(!1),y(!0),_({kind:"idle"})}}).catch(me=>{Q||_({kind:"error",message:me instanceof Error?me.message:"读取语音设置失败"})}),()=>{Q=!0}},[]),b.useEffect(()=>{const te=Pt;if(!te||!p)return;let Q=!1;return te.requestVoiceCapabilities({region:t.region}).then(me=>{if(!Q){if(me.error||!me.capabilities){o(Rm());return}o(me.capabilities)}}).catch(()=>{Q||o(Rm())}),()=>{Q=!0}},[t.region,p]),b.useEffect(()=>()=>{K(),z()},[]);const A=b.useMemo(()=>v.kind==="loading"?"读取中...":v.kind==="saving"?"保存中...":v.kind==="testing"?"正在测试语音合成":v.kind==="playingTest"?"正在播放测试音频":v.kind==="testPassed"?"测试通过":v.kind==="saved"?"已保存":v.kind==="error"?v.message:null,[v]),I=v.kind==="saving"||v.kind==="loading"||v.kind==="testing"||v.kind==="playingTest",T=b.useMemo(()=>V0(s.ttsVoices,t.ttsModel),[s.ttsVoices,t.ttsModel]),D=T.some(te=>te.value===t.ttsVoice)?t.ttsVoice:"",W=T.length===0?"当前模型暂无可用音色":D?null:"请选择可用音色",U=b.useMemo(()=>Cse(r),[r]),F=U?null:"请输入正整数秒数",O=W??F,M=I||!!O,B=b.useMemo(()=>[{value:"cn",label:"中国大陆"},{value:"intl",label:"国际"}],[]),L=b.useMemo(()=>eM(s.asrModels,t.asrModel),[s.asrModels,t.asrModel]),N=b.useMemo(()=>kse(s.ttsModels,s.ttsVoices,t.ttsModel),[s.ttsModels,s.ttsVoices,t.ttsModel]),V=b.useMemo(()=>eM(T,D),[T,D]);function Y(){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:U??ew.turnIdleSeconds}}async function $(){if(I)return;if(O){_({kind:"error",message:O});return}const te=Pt;if(!te){_({kind:"error",message:"请先连接 Relay 服务器"});return}const Q=Y();z(),_({kind:"saving"});const me=performance.now();try{const ve=await te.updateVoiceConfig(Q),Ce=performance.now()-me;if(Ce<GN&&await Ese(GN-Ce),!ve.success||ve.error||!ve.config){_({kind:"error",message:ve.error??"保存语音设置失败"});return}n(ve.config),i(String(ve.config.turnIdleSeconds)),u(""),h(!1),_({kind:"saved"}),R.current=setTimeout(()=>{R.current=null,_(Me=>Me.kind==="saved"?{kind:"idle"}:Me)},_se),te.requestVoiceCapabilities({region:ve.config.region}).then(Me=>{Me.capabilities&&o(Me.capabilities)}).catch(()=>{o(Rm())})}catch(ve){_({kind:"error",message:ve instanceof Error?ve.message:"保存语音设置失败"})}}async function P(){if(I)return;if(O){_({kind:"error",message:O});return}const te=Pt;if(!te){_({kind:"error",message:"请先连接 Relay 服务器"});return}let Q;try{Q=q()}catch(me){_({kind:"error",message:JN(me)});return}_({kind:"testing"});try{const[me]=await Promise.all([te.testVoiceConfig(Y()),Q.ready]);if(!me.success||me.error){K(),_({kind:"error",message:me.error??"语音配置测试失败"});return}const ve=await X(me,Q.context);_({kind:"playingTest",transcript:me.transcript}),k.current=setTimeout(()=>{k.current=null,K(),_({kind:"testPassed",transcript:me.transcript})},ve)}catch(me){K(),_({kind:"error",message:JN(me)})}}function q(){K();const te=I1.acquire("playback");x.current=te;try{const Q=xse();return w.current=Q,{context:Q,ready:QN(Q)}}catch(Q){throw te.release(),x.current=null,Q}}function K(){var te,Q,me;k.current&&(clearTimeout(k.current),k.current=null),(te=E.current)==null||te.stop(),E.current=null,(Q=w.current)==null||Q.close(),w.current=null,(me=x.current)==null||me.release(),x.current=null}function z(){R.current&&(clearTimeout(R.current),R.current=null)}async function X(te,Q){if(!te.audioBase64)throw new Error("语音测试未返回可播放音频");if(te.audioEncoding&&te.audioEncoding!=="pcm_s16le")throw new Error("测试音频格式暂不支持");const me=te.audioSampleRate??24e3,ve=Sse(te.audioBase64);if(ve.byteLength===0||ve.byteLength%2!==0)throw new Error("测试音频数据无效");await QN(Q);const Ce=new VB(Q,me);E.current=Ce,Ce.enqueue(ve);const Me=Math.ceil(ve.byteLength/2/me*1e3);return Math.max(bse,Me)}function ee(te){var Q;return((Q=V0(s.ttsVoices,te)[0])==null?void 0:Q.value)??""}return g.jsxs("form",{className:"flex min-h-0 min-w-0 flex-1 flex-col","data-slot":"voice-settings-panel",autoComplete:"off",onSubmit:te=>{te.preventDefault(),$()},children:[g.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:g.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:g.jsxs("div",{className:"space-y-3","data-slot":"voice-settings-fields",children:[g.jsx("div",{className:"grid gap-2 rounded-lg border border-border/75 bg-card/55 p-3.5 sm:p-3",children:g.jsxs("div",{className:"flex items-center justify-between gap-3",children:[g.jsxs("div",{className:"min-w-0",children:[g.jsx("div",{className:"text-[13px] font-medium leading-none text-muted-foreground",children:"服务商"}),g.jsx("div",{className:"mt-2 truncate text-base font-medium text-foreground md:text-sm",children:"阿里云百炼"})]}),g.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"})]})}),g.jsx(XN,{label:"阿里云百炼 API Key",help:d?"保存后会清空已保存的 key":null,children:g.jsxs("div",{className:"flex min-w-0 gap-2",children:[g.jsxs("div",{className:"relative min-w-0 flex-1",children:[g.jsx(MP,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground","aria-hidden":"true"}),g.jsx("input",{"aria-label":"阿里云百炼 API Key",type:"password",name:"dev-anywhere-bailian-api-key",autoComplete:"off",value:l,onChange:te=>{u(te.target.value),h(!1)},placeholder:d?"保存后清空":t.configured?"••••••••••••••••":"输入 API Key",className:`${KN} w-full pl-9`})]}),t.configured&&g.jsxs(_t,{type:"button",variant:"outline",className:"min-h-11 shrink-0 px-3 md:h-9 md:min-h-0",onClick:()=>{u(""),h(!0)},children:[g.jsx(y7,{className:"size-4","aria-hidden":"true"}),"清空"]})]})}),g.jsx($m,{label:"地域",value:t.region,options:B,onChange:te=>n(Q=>({...Q,region:te==="intl"?"intl":"cn"}))}),g.jsx($m,{label:"语音识别模型",value:t.asrModel,options:L,onChange:te=>n(Q=>({...Q,asrModel:te}))}),g.jsx($m,{label:"语音合成模型",value:t.ttsModel,options:N,onChange:te=>n(Q=>({...Q,ttsModel:te,ttsVoice:ee(te)}))}),g.jsx($m,{label:"语音音色",value:D,options:V,placeholder:T.length===0?"暂无可用音色":"请选择音色",onChange:te=>n(Q=>({...Q,ttsVoice:te})),help:W}),g.jsx(XN,{label:"结束停顿时间(秒)",help:F,children:g.jsx("input",{"aria-label":"结束停顿时间(秒)",type:"number",min:1,step:1,inputMode:"numeric",value:r,onChange:te=>i(te.target.value),className:`${KN} w-full`})})]})})}),g.jsxs("div",{className:"bg-background/95 px-4 pb-3.5 pt-0 backdrop-blur sm:px-5","data-slot":"voice-settings-footer",children:[g.jsx("div",{className:"mr-4 border-t border-border/70","data-slot":"voice-settings-footer-divider"}),g.jsxs("div",{className:"mt-3.5 flex items-center justify-end gap-2",children:[A?g.jsx("div",{role:v.kind==="error"?"alert":"status","aria-live":"polite",className:v.kind==="error"?"min-w-0 flex-1 text-sm text-destructive":"min-w-0 flex-1 text-sm text-muted-foreground",children:A}):null,g.jsxs(_t,{type:"button",variant:"outline",disabled:M,onClick:()=>void P(),children:[g.jsx(PP,{className:"size-4","aria-hidden":"true"}),"测试"]}),g.jsxs(_t,{type:"submit",disabled:M,children:[g.jsx(s7,{className:"size-4","aria-hidden":"true"}),v.kind==="saving"?"保存中...":"保存"]})]})]})]})}function Sse(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 xse(){const e=window,t=e.AudioContext??e.webkitAudioContext;if(!t)throw new Error("当前浏览器不支持音频播放");return new t}async function QN(e){if(e.state!=="running")try{await e.resume()}catch{throw new Error("浏览器阻止了测试音频播放,请再次点击测试")}if(e.state!=="running")throw new Error("浏览器阻止了测试音频播放,请再次点击测试")}function JN(e){return e instanceof Error?e.message:"语音配置测试失败"}function Ese(e){return new Promise(t=>setTimeout(t,e))}function Cse(e){const t=e.trim();if(!/^[1-9]\d*$/.test(t))return null;const n=Number(t);return Number.isSafeInteger(n)?n:null}function eM(e,t){const n=e.map(r=>({value:r.value,label:KB(r)}));return!t||n.some(r=>r.value===t)?n:[{value:t,label:t},...n]}function kse(e,t,n){const r=e.map(i=>{const s=V0(t,i.value).length===0;return{value:i.value,label:`${KB(i)}${s?" · 暂无音色":""}`,disabled:s}});return!n||r.some(i=>i.value===n)?r:[{value:n,label:`${n} · 暂无音色`,disabled:!0},...r]}function YB(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 KB(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 Tse=[{value:"auto",label:"跟随系统"},{value:"light",label:"浅色"},{value:"dark",label:"深色"}],Rse=[{value:"auto",label:"自动"},{value:"touch",label:"触控优先"},{value:"hardware",label:"实体键盘优先"}],z1="dev-render-scroll min-h-0 space-y-3 overflow-y-auto overscroll-contain pr-4 sm:pr-1";function GB(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 Ase(e){const t=e||window.location.origin;return new URL("/health",t).toString()}function Nse(e){return e==="version"?"版本":e==="relay-token"?"Relay Token":e==="clients"?"客户端管理":"设置 Voice Pilot"}function Mse(e){return e==="version"?"Web 与 Relay 服务器版本。":e==="relay-token"?"连接受保护的 Relay 服务器,保存后立即重连。":e==="clients"?"管理当前连接的 Web 客户端。":"连接语音服务后,即可以语音交互的形式驱动会话。"}function Y0({open:e,onOpenChange:t}){const n=Ne(W=>W.relayUrl),r=Ne(W=>W.latencyMonitorEnabled),i=Ne(W=>W.setLatencyMonitorEnabled),s=Ne(W=>W.sessionIdleNotificationsEnabled),o=Ne(W=>W.setSessionIdleNotificationsEnabled),l=Ne(W=>W.inputModePreference),u=Ne(W=>W.setInputModePreference),d=Ne(W=>W.themePreference),h=Ne(W=>W.setThemePreference),p=Ne(W=>W.ptyScrollTraceEnabled),y=Ne(W=>W.setPtyScrollTraceEnabled),[v,_]=b.useState("menu"),[w,x]=b.useState({kind:"idle"}),E=b.useRef(null),k=b.useRef(null),R=EQ(),A=b.useMemo(()=>kv().osName==="iPad",[]),I=b.useCallback(async W=>{if(!W){o(!1);return}const U=await JZ();if(U==="granted"){o(!0);return}if(U==="denied"){nt.error("浏览器未授予通知权限,请在浏览器设置中允许通知");return}if(U==="default"){nt.info("未授予通知权限,会话通知保持关闭");return}nt.error("当前浏览器不支持系统通知")},[o]),T=b.useCallback(async W=>{x({kind:"loading"});try{const U=await fetch(Ase(n),{cache:"no-store",signal:W});if(!U.ok)throw new Error(`HTTP ${U.status}`);const F=await U.json();if(F.status!=="ok")throw new Error("状态异常");x({kind:"ready",version:F.version??"未知",uptime:F.uptime??0})}catch(U){if(U instanceof DOMException&&U.name==="AbortError")return;x({kind:"error",message:U instanceof Error?"当前 Relay 服务器无法读取版本":"读取失败"})}},[n]);b.useEffect(()=>{if(!e){_("menu");return}},[e]),b.useEffect(()=>{if(!e||v!=="version")return;const W=new AbortController;return T(W.signal),()=>W.abort()},[T,e,v]),b.useEffect(()=>{if(!e||v!=="voice")return;const W=window.requestAnimationFrame(()=>{var U;(U=E.current)==null||U.focus({preventScroll:!0}),k.current&&(k.current.scrollTop=0)});return()=>window.cancelAnimationFrame(W)},[e,v]);const H=w.kind==="ready"?w.version:w.kind==="loading"?"读取中...":w.kind==="error"?"读取失败":"未读取",D=w.kind==="ready"?`运行 ${GB(w.uptime)}`:w.kind==="error"?w.message:"从当前 Relay 服务器 /health 读取";return g.jsx(Sc,{open:e,onOpenChange:t,children:g.jsxs(xc,{className:Ye("grid max-h-[calc(100dvh-1rem)] grid-rows-[auto_minmax(0,1fr)] overflow-hidden p-4 sm:max-w-[440px] sm:p-6",v==="voice"&&"max-h-[min(760px,calc(100dvh-1rem))] !gap-0 !p-0 sm:max-w-[480px]",v==="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":v,focusSurfaceOnOpen:!0,ref:E,showCloseButton:v==="menu",children:[g.jsx(Ec,{className:Ye(v==="menu"&&"pr-12 text-left",v!=="menu"&&"text-left",v==="voice"&&"gap-0 px-4 pb-0 pt-3.5 text-left sm:px-5 sm:pt-4"),children:v!=="menu"?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"flex items-start gap-2",children:[g.jsx(_t,{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:g.jsx(_v,{className:"size-4","aria-hidden":"true"})}),g.jsxs("div",{className:"min-w-0 space-y-1.5 pt-0.5 text-left",children:[g.jsx(cl,{children:Nse(v)}),g.jsx(uc,{className:"max-w-[28rem] leading-5",children:Mse(v)})]})]}),v==="voice"?g.jsx("div",{className:"mr-4 mt-3.5 border-t border-border/70","data-slot":"voice-settings-header-divider"}):null]}):g.jsxs(g.Fragment,{children:[g.jsx(cl,{children:"设置"}),g.jsx(uc,{children:"连接、外观、通知和高级诊断选项。"})]})}),v==="version"?g.jsx(Ose,{relayVersion:H,relayDetail:D,relayMuted:w.kind==="error"}):v==="relay-token"?g.jsx(Pse,{saved:R}):v==="clients"?g.jsx(jse,{}):v==="voice"?g.jsx(wse,{scrollRef:k}):g.jsx(Dse,{relayTokenSaved:R,themePreference:d,onThemePreferenceChange:h,inputModePreference:l,onInputModePreferenceChange:u,showInputModeSetting:A,sessionIdleNotificationsEnabled:s,onSessionIdleNotificationsEnabledChange:I,ptyScrollTraceEnabled:p,onPtyScrollTraceEnabledChange:y,latencyMonitorEnabled:r,onLatencyMonitorEnabledChange:i,onOpenVoice:()=>_("voice"),onOpenRelayToken:()=>_("relay-token"),onOpenClients:()=>_("clients"),onOpenVersion:()=>_("version")})]})})}function Ose({relayVersion:e,relayDetail:t,relayMuted:n}){return g.jsxs("div",{className:z1,"data-slot":"settings-dialog-body",children:[g.jsx(nM,{icon:g.jsx(DP,{className:"size-4","aria-hidden":"true"}),label:"Web",value:hse.version,detail:"当前浏览器加载的版本"}),g.jsx(nM,{icon:g.jsx(LP,{className:"size-4","aria-hidden":"true"}),label:"Relay 服务器",value:e,detail:t,muted:n})]})}function Dse({relayTokenSaved:e,themePreference:t,onThemePreferenceChange:n,inputModePreference:r,onInputModePreferenceChange:i,showInputModeSetting:s,sessionIdleNotificationsEnabled:o,onSessionIdleNotificationsEnabledChange:l,ptyScrollTraceEnabled:u,onPtyScrollTraceEnabledChange:d,latencyMonitorEnabled:h,onLatencyMonitorEnabledChange:p,onOpenVoice:y,onOpenRelayToken:v,onOpenClients:_,onOpenVersion:w}){return g.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:[g.jsxs(du,{title:"服务",children:[g.jsx(Hm,{icon:g.jsx(K9,{className:"size-4","aria-hidden":"true"}),label:"Voice Pilot",detail:"用语音输入、听取回复和处理审批",onClick:y}),g.jsx(Hm,{icon:g.jsx(MP,{className:"size-4","aria-hidden":"true"}),label:"Relay Token",detail:`${e?"已保存":"未设置"} · 受保护的 Relay 服务器`,onClick:v}),g.jsx(Hm,{icon:g.jsx(C7,{className:"size-4","aria-hidden":"true"}),label:"客户端管理",detail:"已连接的浏览器页面和设备",onClick:_})]}),g.jsx(du,{title:"外观",children:g.jsx(tM,{icon:g.jsx(m7,{className:"size-4","aria-hidden":"true"}),label:"主题",value:t,options:Tse,onValueChange:n})}),g.jsx(du,{title:"通知",children:g.jsx(nw,{icon:g.jsx(X9,{className:"size-4","aria-hidden":"true"}),label:"会话空闲通知",detail:"会话从工作中转为空闲时发送浏览器通知",checked:o,onCheckedChange:l})}),s?g.jsx(du,{title:"交互",children:g.jsx(tM,{icon:g.jsx(OP,{className:"size-4","aria-hidden":"true"}),label:"输入方式",detail:"默认自动识别软键盘和实体键盘;必要时可强制一种方式",value:r,options:Rse,onValueChange:i})}):null,g.jsxs(du,{title:"高级诊断",children:[g.jsx(nw,{icon:g.jsx(cf,{className:"size-4","aria-hidden":"true"}),label:"PTY 滚动追踪",detail:"记录终端滚动和视口同步现场,方便复制诊断报告",checked:u,onCheckedChange:d}),g.jsx(nw,{icon:g.jsx(CP,{className:"size-4","aria-hidden":"true"}),label:"延迟监控",detail:"显示可拖动的连接延迟浮窗",checked:h,onCheckedChange:p})]}),g.jsx(du,{title:"关于",children:g.jsx(Hm,{icon:g.jsx(LP,{className:"size-4","aria-hidden":"true"}),label:"版本",onClick:w})})]})}function du({title:e,children:t}){return g.jsxs("section",{className:"space-y-2","data-slot":"settings-section",children:[g.jsx("h3",{className:"px-1 text-xs font-medium text-muted-foreground",children:e}),g.jsx("div",{className:"overflow-hidden rounded-lg border border-border bg-card/55 divide-y divide-border/70",children:t})]})}function tM({icon:e,label:t,detail:n,value:r,options:i,onValueChange:s}){const o=b.useId(),l=b.useId();return g.jsxs("div",{className:"flex w-full items-start gap-3 px-3 py-3 text-left","data-slot":"settings-choice-item",children:[g.jsx("div",{className:"flex size-8 shrink-0 items-center justify-center rounded-md bg-background/55 text-muted-foreground",children:e}),g.jsxs("div",{className:"min-w-0 flex-1",children:[g.jsx("div",{id:o,className:"text-sm font-medium text-foreground",children:t}),n?g.jsx("div",{id:l,className:"mt-1 text-xs text-muted-foreground",children:n}):null,g.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 g.jsx("button",{type:"button",role:"radio","aria-checked":d,className:Ye("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 Pse({saved:e}){const t=b.useId(),n=b.useId(),[r,i]=b.useState(""),[s,o]=b.useState(null),l=()=>{eI().catch(h=>{o(h instanceof Error?h.message:"Relay 重连失败。")})},u=()=>{const h=r.trim();if(!h){o("请输入 token。");return}if(!QL(h)){const p="Relay Token 保存失败,请检查浏览器存储权限。";o(p),nt.error(p);return}o(null),nt.success("Relay Token 已保存,正在重新连接"),l()},d=()=>{JL(),l()};return g.jsxs("form",{className:z1,"data-slot":"settings-dialog-body",onSubmit:h=>{h.preventDefault(),u()},children:[g.jsxs("div",{className:"rounded-md border border-border bg-card/70 p-3","data-slot":"relay-token-card",children:[g.jsx("label",{htmlFor:t,className:"text-sm font-medium text-foreground",children:"Token"}),g.jsx("input",{id:t,type:"password",value:r,onChange:h=>{i(h.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?g.jsx("p",{id:n,className:"mt-2 text-xs text-destructive",children:s}):null]}),g.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[e?g.jsx(_t,{type:"button",variant:"outline",onClick:d,children:"清空"}):null,g.jsx(_t,{type:"submit",disabled:!r.trim(),children:"保存"})]})]})}function Lse(e){return e.length<=16?e:`${e.slice(0,8)}...${e.slice(-4)}`}function Ise(e,t){var r;return((r=t.get(e))==null?void 0:r.trim())||Lse(e)}function zse(e){return NX(e)}function Bse(e){const t=Math.max(0,Math.floor((Date.now()-e)/1e3));return GB(t)}function tw({label:e,value:t,title:n}){return g.jsxs("div",{className:"grid grid-cols-[3.75rem_minmax(0,1fr)] items-baseline gap-2 text-xs leading-5",children:[g.jsx("span",{className:"shrink-0 text-muted-foreground/80",children:e}),g.jsx("span",{className:"min-w-0 truncate text-muted-foreground",title:n??t,children:t})]})}function jse(){const e=Ne(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]),h=b.useCallback(async()=>{const y=Pt;if(!y){n([]),o("Relay 未连接。"),i(!1);return}i(!0),o(null);try{n(await y.requestRelayClients())}catch(v){o(v instanceof Error?v.message:"读取客户端列表失败。")}finally{i(!1)}},[]);b.useEffect(()=>{h()},[h]);const p=b.useCallback(async y=>{const v=Pt;if(!v){o("Relay 未连接。");return}u(y),o(null);try{const _=await v.kickRelayClient(y);if(!_.success){o(_.error??"断开客户端失败。");return}n(w=>w.filter(x=>x.clientId!==y))}catch(_){o(_ instanceof Error?_.message:"断开客户端失败。")}finally{u(null)}},[]);return g.jsxs("div",{className:z1,"data-slot":"settings-dialog-body",children:[g.jsxs("div",{className:"flex min-h-9 items-center gap-2","data-slot":"relay-clients-toolbar",children:[g.jsx("div",{className:"text-sm font-medium text-foreground",children:r?"正在读取客户端":`${t.length} 个在线客户端`}),g.jsx(_t,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"刷新客户端列表",title:"刷新",onClick:()=>void h(),disabled:r,"data-slot":"relay-clients-refresh",children:g.jsx(Ox,{className:Ye("size-3.5",r&&"animate-spin"),"aria-hidden":"true"})})]}),s?g.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?g.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 v=y.current===!0,_=l===y.clientId;return g.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:g.jsxs("div",{className:"grid gap-3 sm:grid-cols-[minmax(0,1fr)_7.5rem] sm:items-start",children:[g.jsxs("div",{className:"min-w-0 space-y-1.5",children:[g.jsx("div",{className:"min-w-0",children:g.jsx("div",{className:"truncate text-sm font-medium leading-5 text-foreground",children:zse(y)})}),g.jsxs("div",{className:"space-y-1",children:[g.jsx(tw,{label:"已连接",value:Bse(y.connectedAt)}),y.proxyId?g.jsx(tw,{label:"连接到",value:Ise(y.proxyId,d),title:y.proxyId}):null,y.remoteAddress?g.jsx(tw,{label:"来源 IP",value:y.remoteAddress}):null]})]}),v?g.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:"当前设备"}):g.jsxs(_t,{type:"button",variant:"outline",size:"sm",className:"h-9 w-full justify-center",disabled:_,onClick:()=>void p(y.clientId),"data-slot":"relay-client-action",children:[g.jsx(L8,{className:"size-3.5","aria-hidden":"true"}),_?"断开中...":"断开"]})]})},y.clientId)})]})}function nw({icon:e,label:t,detail:n,checked:r,onCheckedChange:i}){const s=b.useId(),o=b.useId();return g.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:[g.jsx("div",{className:Ye("flex size-8 shrink-0 items-center justify-center rounded-md bg-background/55 transition-colors",r?"text-primary":"text-muted-foreground"),children:e}),g.jsxs("div",{className:"min-w-0 flex-1",children:[g.jsx("div",{id:s,className:"text-sm font-medium text-foreground",children:t}),g.jsx("div",{id:o,className:"mt-1 text-xs text-muted-foreground",children:n})]}),g.jsx("span",{className:Ye("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:g.jsx("span",{className:Ye("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 Hm({icon:e,label:t,detail:n,onClick:r}){const i=b.useId(),s=b.useId();return g.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:[g.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}),g.jsxs("div",{className:"min-w-0 flex-1",children:[g.jsx("div",{id:i,className:"text-sm font-medium text-foreground",children:t}),n?g.jsx("div",{id:s,className:"mt-1 text-xs text-muted-foreground",children:n}):null]}),g.jsx(Zh,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"})]})}function nM({icon:e,label:t,value:n,detail:r,muted:i=!1}){return g.jsxs("div",{className:"flex gap-3 rounded-md border border-border bg-card/70 p-3",children:[g.jsx("div",{className:Ye("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}),g.jsxs("div",{className:"min-w-0 flex-1",children:[g.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[g.jsx("div",{className:"text-sm text-muted-foreground",children:t}),g.jsx("div",{className:"min-w-0 truncate font-mono text-sm text-foreground",children:n})]}),g.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:r})]})]})}const Fse="xterm-helper-textarea";function $se(e=document.activeElement){return!(e instanceof HTMLElement)||!e.classList.contains(Fse)?!1:(e.blur(),!0)}function rM(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&&Hse(r,n))return!0;if(r===t)break;r=r.parentElement}return!1}function Hse(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 Use({releasePtyFocus:e=!0,containVerticalScroll:t=!0}={}){const n=b.useRef(null),r=b.useCallback(()=>{e&&$se()},[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 h=(n.current??u.clientY)-u.clientY;n.current=u.clientY,rM(l.target,l.currentTarget,h)||l.preventDefault()},[t]),o=b.useCallback(l=>{r(),t&&(rM(l.target,l.currentTarget,l.deltaY)||l.preventDefault())},[t,r]);return{onPointerDownCapture:r,onTouchStartCapture:i,onTouchMoveCapture:s,onWheelCapture:o}}function Wse({className:e}){const t=Ne(o=>o.sidebarCollapsed),n=Ne(o=>o.toggleSidebarCollapsed),[r,i]=b.useState(!1),s=Use();return t?g.jsxs(g.Fragment,{children:[g.jsxs("nav",{className:Ye("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:[g.jsx(sM,{collapsed:!0,onClick:n}),g.jsx("div",{className:"mt-3 h-px w-5 bg-border/70","aria-hidden":"true"}),g.jsxs("div",{className:"mt-auto flex flex-col gap-2",children:[g.jsx(iM,{compact:!0,tooltipSide:"right",onClick:()=>i(!0)}),g.jsx(WN,{compact:!0})]})]}),g.jsx(Y0,{open:r,onOpenChange:i})]}):g.jsxs(g.Fragment,{children:[g.jsxs("nav",{className:Ye("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:[g.jsx("div",{className:"dev-sidebar-fade p-2.5","data-slot":"sidebar-proxy-switcher",children:g.jsxs("div",{className:"dev-sidebar-chrome rounded-lg border p-3",children:[g.jsxs("div",{className:"flex items-center justify-between gap-3",children:[g.jsx(eL,{className:"text-[13px]",slot:"sidebar-brand"}),g.jsx(sM,{collapsed:!1,onClick:n})]}),g.jsx("div",{className:"mt-2.5",children:g.jsx(PB,{layout:"dropdown",variant:"sidebarChrome"})})]})}),g.jsx("div",{className:"dev-sidebar-fade flex min-h-0 flex-1 flex-col overflow-hidden","data-slot":"sidebar-session-list",children:g.jsx("div",{className:"flex-1 min-h-0",children:g.jsx(UB,{layout:"sidebar"})})}),g.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:[g.jsx("div",{className:"min-w-0 flex-1",children:g.jsx(WN,{})}),g.jsx("div",{className:"min-w-0 flex-1",children:g.jsx(iM,{onClick:()=>i(!0)})})]})]}),g.jsx(Y0,{open:r,onOpenChange:i})]})}function iM({compact:e=!1,tooltipSide:t="top",onClick:n}){return g.jsxs(qf,{delayDuration:500,children:[g.jsx(Vf,{asChild:!0,children:g.jsxs("button",{type:"button","aria-label":"设置","data-slot":"sidebar-settings-trigger",onClick:n,className:Ye("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:[g.jsx(IP,{className:"size-4","aria-hidden":"true"}),!e&&g.jsx("span",{className:"truncate text-sm font-medium",children:"设置"})]})}),g.jsx(Yf,{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 sM({collapsed:e,onClick:t}){const n=e?"展开侧边栏":"收起侧边栏",r=e?q8:U8;return g.jsxs(qf,{delayDuration:500,children:[g.jsx(Vf,{asChild:!0,children:g.jsx("button",{type:"button","aria-label":n,"data-slot":e?"sidebar-expand-trigger":"sidebar-collapse-trigger",onClick:t,className:Ye("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:g.jsx(r,{className:Ye("size-3.5 transition-transform",e&&"group-hover:translate-x-0.5",!e&&"group-hover:-translate-x-0.5"),"aria-hidden":"true"})})}),g.jsx(Yf,{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 qse=1500,Vse=300,oM=70,aM=35;function XB({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 h=setInterval(()=>s(p=>!p),530);return()=>clearInterval(h)},[]),b.useEffect(()=>{let h;const p=()=>e[u.current%e.length],y=()=>{const v=o.current;if(v==="typing"){const _=p();l.current<_.length?(l.current+=1,r(_.slice(0,l.current)),h=setTimeout(y,oM)):(o.current="paused",h=setTimeout(y,qse))}else v==="paused"?(o.current="deleting",h=setTimeout(y,aM)):v==="deleting"?l.current>0?(l.current-=1,r(p().slice(0,l.current)),h=setTimeout(y,aM)):(u.current+=1,o.current="waiting",h=setTimeout(y,Vse)):(o.current="typing",h=setTimeout(y,oM))};return h=setTimeout(y,500),()=>clearTimeout(h)},[e]);const d=n.startsWith("DEV")?3:n.length<=3&&"DEV".startsWith(n)?n.length:0;return g.jsxs("div",{className:`font-mono leading-tight select-none ${t??""}`,"data-slot":"brand-typewriter",children:[g.jsx("span",{className:"text-green-500",children:"> "}),g.jsx("span",{className:"text-primary","data-slot":"brand-typewriter-dev",children:n.slice(0,d)}),g.jsx("span",{className:"text-foreground/90",children:n.slice(d)}),g.jsx("span",{className:`text-primary ${i?"opacity-100":"opacity-0"}`,children:"_"})]})}const ZB=["DEV Anywhere","/unlimited @anytime"];function Yse({subtitle:e,action:t}){return g.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:g.jsxs("div",{className:"dev-mobile-brand-content min-w-0 space-y-3 pr-12",children:[g.jsx(XB,{texts:ZB,className:"dev-mobile-brand-typewriter max-w-full overflow-hidden text-ellipsis whitespace-nowrap font-bold tracking-normal"}),g.jsx("p",{className:"dev-mobile-brand-subtitle max-w-[34rem] text-sm leading-5 text-muted-foreground",children:e}),t?g.jsx("div",{className:"dev-mobile-brand-action flex max-w-full min-w-0 pt-1",children:t}):null]})})}const Kse=3e3,Gse=1e4,Um=12,Xse=4,lM={webRelay:"浏览器 ↔ Relay 服务器",relayProxy:"Relay 服务器 ↔ 开发机",webProxy:"浏览器 ↔ 开发机"},Zse={webRelay:{state:"idle"},relayProxy:{state:"idle"},webProxy:{state:"idle"}};function rw(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 hu(e){return{state:"unavailable",error:e,updatedAt:Date.now()}}function Fh(e){return e===void 0||!Number.isFinite(e)?"--":`${Math.max(0,Math.round(e))}ms`}function cM(e){switch(e){case"bad":return 4;case"unavailable":return 3;case"warn":return 2;case"measuring":return 1;default:return 0}}function QB(e){return e==="bad"||e==="unavailable"?"bad":e==="warn"?"warn":e==="ok"?"ok":"neutral"}function Qse(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 Jse(e){return e.state==="measuring"?"检测中":e.state==="unavailable"?e.error??"不可用":e.rttMs!==void 0?Fh(e.rttMs):"等待检测"}function eoe(){const e=Ei("local",dn.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 uM(e){hr("local",dn.latencyMonitorPosition,JSON.stringify(e))}function toe(){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 iw(e,t){const n=toe(),r=Um,i=Um,s=Math.max(r,n.width-t.width-Um),o=Math.max(i,n.height-t.height-Um);return{x:Math.min(s,Math.max(r,Math.round(e.x))),y:Math.min(o,Math.max(i,Math.round(e.y)))}}function noe(){const e=Ne(T=>T.latencyMonitorEnabled),t=Ne(T=>T.connected),n=Ne(T=>T.proxyOnline),r=Ne(T=>T.selectedProxyId),[i,s]=b.useState(Zse),[o,l]=b.useState(()=>eoe()),u=b.useRef(!1),d=b.useRef(null),h=b.useRef(null),p=b.useRef(!1),y=b.useMemo(()=>(Object.values(i).sort((T,H)=>cM(H.state)-cM(T.state))[0]??{state:"idle"}).state,[i]),v=QB(y);async function _(){if(u.current)return;const T=Pt;if(!T||!t){const U=hu("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"}:hu("未连接开发机"),webProxy:n?{...U.webProxy,state:"measuring"}:hu("未连接开发机")}));const[H,D,W]=await Promise.allSettled([T.measureWebRelayLatency(),n?T.measureRelayProxyLatency():Promise.resolve({success:!1}),n?T.measureWebProxyLatency():Promise.resolve({success:!1})]);s({webRelay:H.status==="fulfilled"?rw(H.value):hu(H.reason instanceof Error?H.reason.message:"测速失败"),relayProxy:D.status==="fulfilled"?rw(D.value):hu(D.reason instanceof Error?D.reason.message:"测速失败"),webProxy:W.status==="fulfilled"?rw(W.value):hu(W.reason instanceof Error?W.reason.message:"测速失败")}),u.current=!1}if(b.useEffect(()=>{if(!e)return;let T=!1,H=null;const D=async()=>{await _(),!T&&(H=setTimeout(D,document.hidden?Gse:Kse))};return D(),()=>{T=!0,u.current=!1,H&&clearTimeout(H)}},[e,t,n,r]),b.useEffect(()=>{if(!e||!o)return;const T=d.current;if(!T)return;const H=T.getBoundingClientRect(),D=iw(o,{width:H.width,height:H.height});D.x===o.x&&D.y===o.y||(l(D),uM(D))},[e,o]),!e)return null;const w=i.webProxy.rttMs!==void 0?i.webProxy:i.relayProxy,x=o!==null?{left:`${o.x}px`,top:`${o.y}px`}:void 0;function E(T){var D,W;if(T.button!==0)return;const H=T.currentTarget.getBoundingClientRect();h.current={pointerId:T.pointerId,startX:T.clientX,startY:T.clientY,originX:H.left,originY:H.top,width:H.width,height:H.height,dragging:!1},(W=(D=T.currentTarget).setPointerCapture)==null||W.call(D,T.pointerId)}function k(T){const H=h.current;if(!H||H.pointerId!==T.pointerId)return;const D=T.clientX-H.startX,W=T.clientY-H.startY;if(!H.dragging&&Math.hypot(D,W)<Xse)return;H.dragging=!0,T.preventDefault();const U=iw({x:H.originX+D,y:H.originY+W},{width:H.width,height:H.height});l(U)}function R(T){var F,O;const H=h.current;if(!H||H.pointerId!==T.pointerId||(h.current=null,(O=(F=T.currentTarget).releasePointerCapture)==null||O.call(F,T.pointerId),!H.dragging))return;T.preventDefault(),p.current=!0,window.setTimeout(()=>{p.current=!1},200);const D=T.clientX-H.startX,W=T.clientY-H.startY,U=iw({x:H.originX+D,y:H.originY+W},{width:H.width,height:H.height});l(U),uM(U)}function A(T){var D,W;const H=h.current;!H||H.pointerId!==T.pointerId||(h.current=null,(W=(D=T.currentTarget).releasePointerCapture)==null||W.call(D,T.pointerId))}function I(T){p.current&&(p.current=!1,T.preventDefault(),T.stopPropagation())}return g.jsxs(R1,{children:[g.jsx(A1,{asChild:!0,children:g.jsxs("button",{ref:d,type:"button",className:Ye("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",Qse(v)),style:x,"data-slot":"latency-monitor-trigger","aria-label":`延迟监控,Relay 服务器 ${Fh(i.webRelay.rttMs)},开发机 ${Fh(w.rttMs)}`,onPointerDown:E,onPointerMove:k,onPointerUp:R,onPointerCancel:A,onClickCapture:I,children:[g.jsx(CP,{className:"size-3.5","aria-hidden":"true"}),g.jsx("span",{className:"font-medium text-foreground",children:"延迟"}),g.jsxs("span",{className:"hidden text-muted-foreground sm:inline",children:["Relay ",Fh(i.webRelay.rttMs)]}),g.jsxs("span",{className:"text-muted-foreground",children:["开发机 ",Fh(w.rttMs)]}),g.jsx(pl,{className:"size-3 text-muted-foreground","aria-hidden":"true"})]})}),g.jsxs(N1,{align:"end",className:"w-[320px] p-3","data-slot":"latency-monitor-popover",children:[g.jsxs("div",{className:"flex items-start justify-between gap-3",children:[g.jsxs("div",{children:[g.jsx("div",{className:"text-sm font-medium text-foreground",children:"连接延迟"}),g.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:"数值越低,操作响应通常越快。"})]}),g.jsx(_t,{type:"button",variant:"ghost",size:"icon-xs","aria-label":"立即测速",onClick:()=>void _(),children:g.jsx(Ox,{className:"size-3","aria-hidden":"true"})})]}),g.jsx("div",{className:"mt-3 space-y-2",children:Object.keys(lM).map(T=>g.jsx(roe,{label:lM[T],measurement:i[T]},T))})]})]})}function roe({label:e,measurement:t}){const n=QB(t.state);return g.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:[g.jsx("div",{className:"min-w-0 truncate text-xs font-medium text-foreground",children:e}),g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("span",{className:Ye("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"}),g.jsx("span",{className:"min-w-[4rem] text-right font-mono text-xs text-foreground",children:Jse(t)})]})]})}const JB="/__dev_anywhere_debug/browser-state-dumps",ioe=1500,soe=10,sw=80,B1=500,ooe=["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"],aoe=["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 dM(){if(typeof window>"u")return"off";const e=a3("debugDump");return e==="auto"?"auto":e!==null||goe("debugInput")?"manual":"off"}function loe(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:hoe(),document:{title:document.title,readyState:document.readyState,visibilityState:document.visibilityState,activeElement:hM(document.activeElement),selection:foe(),focusedInputs:Array.from(document.querySelectorAll("input, textarea, select, [contenteditable]")).filter(i=>i===document.activeElement||i.matches(":focus")).map(i=>hM(i)).filter(i=>!!i),root:e3(document.documentElement,0,t),truncated:t.truncated,nodeCount:t.count},devAnywhere:{ptyDebug:fu(()=>{var i;return((i=n.__devAnywherePtyDebug)==null?void 0:i.call(n))??null}),ptyInputDebugSnapshot:fu(()=>n.__devAnywherePtyInputDebugSnapshot??null),ptyInputDebugText:n.__devAnywherePtyInputDebugText??null,ptyInputDebugEvents:fu(()=>n.__devAnywherePtyInputDebugEvents??null),ptyScrollTraceTail:fu(()=>fM(n.__devAnywherePtyScrollTrace)),jsonScrollTraceTail:fu(()=>fM(n.__devAnywhereJsonScrollTrace)),voicePilotDiagnostics:fu(()=>{var i;return((i=n.__devAnywhereVoicePilotDiagnostics)==null?void 0:i.snapshot())??null})}};return window.__devAnywhereLastBrowserStateDump=r,r}async function coe(e="manual"){const t=loe(e);return uoe(t)}async function uoe(e){const t=JSON.stringify(e,null,2),n=new Blob([t]).size;try{const r=await doe(t);return{status:"saved",path:r.path,bytes:r.bytes,endpoint:JB}}catch(r){const i=l3(r),s=poe(e.createdAt);return moe(s,t,"application/json")?{status:"downloaded",filename:s,bytes:n,endpointError:i}:{status:"failed",error:"无法保存或下载诊断包",endpointError:i}}}async function doe(e){const t=await fetch(JB,{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 e3(e,t,n){if(n.count>=ioe||t>soe)return n.truncated=!0,{kind:"truncated"};if(n.count+=1,e.nodeType===Node.TEXT_NODE){const u=pM(e.textContent??"");return u?{kind:"text",text:ey(u,B1)}:{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,sw))u.nodeType===Node.TEXT_NODE&&!pM(u.textContent??"")||r.push(e3(u,t+1,n));s.length>sw&&(i=s.length-sw,n.truncated=!0);const o={kind:"element",tag:e.tagName.toLowerCase(),path:o3(e),attrs:t3(e),rect:n3(e),scroll:r3(e),style:i3(e)},l=s3(e);return l&&(o.value=l),r.length>0&&(o.children=r),i>0&&(o.omittedChildren=i),o}function hM(e){if(!(e instanceof HTMLElement))return null;const t=s3(e);return{path:o3(e),tag:e.tagName.toLowerCase(),id:e.id||null,className:e.className||null,attrs:t3(e),rect:n3(e),scroll:r3(e),style:i3(e),...t?{value:t}:{}}}function hoe(){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 t3(e){const t={};for(const n of ooe){const r=e.getAttribute(n);r!==null&&(t[n]=ey(r,500))}return t}function n3(e){const t=e.getBoundingClientRect();return{x:Ki(t.x),y:Ki(t.y),width:Ki(t.width),height:Ki(t.height),top:Ki(t.top),right:Ki(t.right),bottom:Ki(t.bottom),left:Ki(t.left)}}function r3(e){return{top:Ki(e.scrollTop),left:Ki(e.scrollLeft),height:Ki(e.scrollHeight),width:Ki(e.scrollWidth),clientHeight:Ki(e.clientHeight),clientWidth:Ki(e.clientWidth)}}function i3(e){const t=window.getComputedStyle(e),n={};for(const r of aoe)n[r]=t.getPropertyValue(r);return n}function s3(e){if(!(!(e instanceof HTMLInputElement)&&!(e instanceof HTMLTextAreaElement)))return{length:e.value.length,preview:ey(e.value,B1),selectionStart:e.selectionStart,selectionEnd:e.selectionEnd}}function foe(){var e;try{return ey(((e=window.getSelection())==null?void 0:e.toString())??"",B1)}catch{return null}}function o3(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 poe(e){return`dev-anywhere-browser-state-${e.replace(/[:.]/g,"-")}.json`}function moe(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 goe(e){return a3(e)!==null}function a3(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 fM(e){return e?Qg(e.slice(-200)):null}function fu(e){try{return Qg(e())}catch(t){return{error:l3(t)}}}function Qg(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(Qg);if(typeof e=="object"){const t={};for(const[n,r]of Object.entries(e))t[n]=Qg(r);return t}return String(e)}function pM(e){return e.replace(/\s+/g," ").trim()}function ey(e,t){return e.length>t?`${e.slice(0,t)}...`:e}function Ki(e){return Math.round(e*100)/100}function l3(e){return e instanceof Error?e.message:String(e)}const voe=500,yoe=1e3,boe=60;function _oe(){const[e,t]=b.useState(()=>dM()),[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),h=b.useRef(null);b.useEffect(()=>{const _=()=>t(dM());return window.addEventListener("hashchange",_),window.addEventListener("popstate",_),()=>{window.removeEventListener("hashchange",_),window.removeEventListener("popstate",_)}},[]);const p=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 coe(_);return o.current=w,s(w),(_==="manual"||w.status==="failed")&&woe(w),w}finally{l.current=!1,r(!1)}},[]);if(b.useEffect(()=>(window.__devAnywhereDumpBrowserState=p,()=>{window.__devAnywhereDumpBrowserState===p&&delete window.__devAnywhereDumpBrowserState}),[p]),b.useEffect(()=>{var k,R;if(e!=="auto")return;const _=()=>{h.current!==null&&(window.clearTimeout(h.current),h.current=null)},w=A=>{d.current>=boe||(_(),h.current=window.setTimeout(()=>{h.current=null;const I=Date.now(),T=yoe-(I-u.current);if(T>0){h.current=window.setTimeout(()=>w(A),T);return}u.current=Date.now(),d.current+=1,p(`auto:${d.current}:${A}`)},voe))};w("initial");const x=["focusin","focusout","beforeinput","input","compositionstart","compositionupdate","compositionend","keydown","keyup","pointerdown","pointerup","resize","visibilitychange"],E=A=>w(A.type);return x.forEach(A=>window.addEventListener(A,E,!0)),(k=window.visualViewport)==null||k.addEventListener("resize",E),(R=window.visualViewport)==null||R.addEventListener("scroll",E),()=>{var A,I;_(),x.forEach(T=>window.removeEventListener(T,E,!0)),(A=window.visualViewport)==null||A.removeEventListener("resize",E),(I=window.visualViewport)==null||I.removeEventListener("scroll",E)}},[p,e]),e==="off")return null;const y=e==="auto"?"自动诊断中":"保存诊断",v=Soe(i);return g.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:[v?g.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:v}):null,g.jsxs(_t,{type:"button",size:"sm",variant:e==="auto"?"secondary":"outline",className:"h-9 rounded-md px-3 text-xs shadow-lg",onClick:()=>void p("manual"),disabled:n,"data-slot":"browser-state-dump",children:[n?g.jsx(Jl,{className:"size-3.5 animate-spin","aria-hidden":"true"}):g.jsx(x8,{className:"size-3.5","aria-hidden":"true"}),g.jsx("span",{children:y})]})]})}function woe(e){if(e.status==="saved"){nt.success(`诊断已保存: ${e.path}`);return}if(e.status==="downloaded"){nt.info(`诊断已下载: ${e.filename}`);return}nt.error(e.endpointError?`${e.error}: ${e.endpointError}`:e.error)}function Soe(e){return e?e.status==="saved"?`已保存 ${e.path}`:e.status==="downloaded"?`已下载 ${e.filename}`:`失败 ${e.endpointError??e.error}`:null}function xoe(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 j1(e){const{windowKey:t,storageKey:n,maxEntries:r=5e3,dedupeKey:i}=e,s=new Map,o=()=>typeof window>"u"?!1:xoe(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 h=l();if(i){const p=i(d);if(p!==null){const y=s.get(d.event);if(y&&i(y)===p&&h.includes(y)){y.t=d.t,y.repeat=(y.repeat??0)+1;const v=h.indexOf(y);v>=0&&v!==h.length-1&&(h.splice(v,1),h.push(y)),u(h);return}}}if(h.push(d),i&&s.set(d.event,d),h.length>r){const p=h.splice(0,h.length-r);if(i)for(const y of p)s.get(y.event)===y&&s.delete(y.event)}u(h)},getAll:l}}function An(e){return Math.round(e*10)/10}function Va(e){return e.length===0?"":`${An(Math.min(...e))}..${An(Math.max(...e))}`}function Mu(e){return[...new Set(e.filter(t=>t!==void 0).map(An))]}function c3(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 Eoe="dev_anywhere_pty_input_latency_trace",mM=80,Coe=1e4,koe=new TextDecoder;let Toe=0;const Xu=new Map,Cc=j1({windowKey:"__devAnywherePtyInputLatencyTrace",storageKey:Eoe,dedupeKey:e=>e.event.startsWith("input")?null:`${e.event}|${e.sessionId}|${e.outputSeq??""}|${e.pendingInputs??""}`});function Roe(){typeof window>"u"||(window.__devAnywherePtyInputLatencyReport=Ooe)}function Aoe(e,t){if(!Cc.isEnabled())return null;const n=`pty-in-${Date.now().toString(36)}-${++Toe}`,r=performance.now(),i={inputId:n,sessionId:e,data:t,kind:Loe(t),dataLength:t.length,startedAt:r,sentAt:null,firstOutputAt:null,echoMatchedAt:null,xtermWriteAt:null,paintAt:null},s=Xu.get(e)??[];return s.push(i),$1(s,r),Xu.set(e,s),Kf({t:r,event:"input:start",sessionId:e,inputId:n,inputKind:i.kind,dataLength:i.dataLength,pendingInputs:s.length}),{inputId:n,sessionId:e}}function gM(e,t){if(!e||!Cc.isEnabled())return;const n=performance.now(),r=Doe(e.sessionId,e.inputId);r&&(r.sentAt=n),Kf({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 Noe(e,t,n){if(!Cc.isEnabled())return;const r=performance.now(),i=F1(e,r),s=Boe(t),o=[],l=[];for(const u of i)u.firstOutputAt===null&&(u.firstOutputAt=r,o.push(u.inputId)),u.echoMatchedAt===null&&zoe(u)&&s.includes(u.data)&&(u.echoMatchedAt=r,l.push(u.inputId));Kf({t:r,event:"output:received",sessionId:e,outputSeq:n,bytes:t.byteLength,pendingInputs:i.length,deltaFromInputMs:H1(i,r),details:joe([o.length>0?`first=${o.length}`:"",l.length>0?`echo=${l.length}`:""])})}function Moe(e,t,n=1){if(!Cc.isEnabled())return;const r=performance.now(),i=F1(e,r),s=[];for(const o of i)o.xtermWriteAt===null&&(o.xtermWriteAt=r,s.push(o.inputId));Kf({t:r,event:"output:xterm-write",sessionId:e,bytes:t,chunkCount:n,pendingInputs:i.length,deltaFromInputMs:H1(i,r),details:s.length>0?`firstWrite=${s.length}`:""}),typeof requestAnimationFrame=="function"&&s.length>0&&requestAnimationFrame(()=>Poe(e,s))}function Ooe(){const e=Cc.getAll(),t=e.slice(-200),n=[...Xu.values()].flat(),r=n.slice(-80).map(s=>[s.inputId,s.sessionId,s.kind,s.dataLength,s.sentAt===null?"":An(s.sentAt-s.startedAt),s.firstOutputAt===null?"":An(s.firstOutputAt-s.startedAt),s.echoMatchedAt===null?"":An(s.echoMatchedAt-s.startedAt),s.xtermWriteAt===null?"":An(s.xtermWriteAt-s.startedAt),s.paintAt===null?"":An(s.paintAt-s.startedAt)].join(" ")),i=t.map(s=>[An(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?"":An(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(`
511
511
  `)}function Kf(e){Cc.append(e)}function F1(e,t){const n=Xu.get(e)??[];return $1(n,t),Xu.set(e,n),n}function $1(e,t){for(let n=e.length-1;n>=0;n-=1){const r=e[n],i=r.paintAt!==null,s=t-r.startedAt>Coe;(i||s)&&e.splice(n,1)}e.length>mM&&e.splice(0,e.length-mM)}function Doe(e,t){return(Xu.get(e)??[]).find(n=>n.inputId===t)??null}function Poe(e,t){if(!Cc.isEnabled())return;const n=performance.now(),r=F1(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)}Kf({t:n,event:"output:paint",sessionId:e,pendingInputs:r.length,deltaFromInputMs:H1(r,n),details:i>0?`paint=${i}`:""}),$1(r,n)}function H1(e,t){const n=e[0];return n?t-n.startedAt:null}function Loe(e){return e==="\r"||e===`
512
512
  `?"enter":e.startsWith("\x1B")?"escape":Ioe(e)?"control":e.length>16?"paste":/[\r\n]/.test(e)?"mixed":"printable"}function Ioe(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 zoe(e){return e.kind==="printable"&&e.data.length>0&&e.data.length<=16}function Boe(e){try{return koe.decode(e)}catch{return""}}function joe(e){return e.filter(Boolean).join(" ")}function Ys(e,t){if(!e||!t)return;const n=Aoe(e,t),r=ec;if(!r){gM(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});gM(n,{sent:s,queueWhenDisconnected:!0,details:s?"sent-open-socket":"queued-or-dropped"})}const vM=-1;function Foe({sessionId:e,enabled:t,waiting:n,approvalSeq:r,sendRawInput:i=Ys}){const s=b.useRef(void 0),o=b.useRef(e);b.useEffect(()=>{if(o.current!==e&&(o.current=e,s.current=void 0),!n){s.current=void 0;return}if(r===void 0){if(s.current!==void 0)return;s.current=vM,i(e,"\r");return}if(s.current===vM){s.current=r;return}s.current!==r&&(s.current=r,i(e,"\r"))},[r,t,i,e,n])}function $oe(e){var r,i,s;if(!e.connected||!e.proxyOnline||e.session.mode!=="pty"||e.session.kind==="terminal"||e.session.state==="idle"||e.session.state==="error"||e.session.state==="terminated")return null;const t=Bx(e.proxyId,e.session.sessionId);return!t||!e.autoYesBySessionKey[t]||!(e.session.state==="waiting_approval"||((r=e.agentStatus)==null?void 0:r.phase)==="waiting_permission"||((i=e.ptyState)==null?void 0:i.state)==="approval_wait")?null:{key:t,sessionId:e.session.sessionId,waiting:!0,approvalSeq:((s=e.ptyState)==null?void 0:s.state)==="approval_wait"?e.ptyState.seq:void 0}}function Hoe({target:e,sendRawInput:t}){return Foe({sessionId:e.sessionId,enabled:!0,waiting:e.waiting,approvalSeq:e.approvalSeq,sendRawInput:t}),null}function Uoe({sendRawInput:e=Ys}){const t=Ne(d=>d.connected),n=Ne(d=>d.proxyOnline),r=Ne(d=>d.selectedProxyId),i=$t(d=>d.sessions),s=$t(d=>d.ptyStateBySessionId),o=$t(d=>d.agentStatusBySessionId),l=$t(d=>d.ptyAutoYesBySessionKey),u=i.map(d=>$oe({proxyId:r,session:d,ptyState:s[d.sessionId],agentStatus:o[d.sessionId],autoYesBySessionKey:l,connected:t,proxyOnline:n})).filter(d=>d!==null);return g.jsx(g.Fragment,{children:u.map(d=>g.jsx(Hoe,{target:d,sendRawInput:e},d.key))})}function Woe(e,t,n){const r=e.some(s=>s.sessionId===t)?e.map(s=>s.sessionId===t?{...s,touchedAt:n.now}:s):[...e,{sessionId:t,touchedAt:n.now}];if(r.length<=n.capacity)return r;const i=r.filter(s=>s.sessionId!==n.activeSessionId).sort((s,o)=>s.touchedAt-o.touchedAt)[0];return i?r.filter(s=>s.sessionId!==i.sessionId):r.slice(-3)}var Zl=function(e,t){return Number(e.toFixed(t))},qoe=function(e,t){return t},Pn=function(e,t,n){n&&typeof n=="function"&&n(e,t)},Voe=function(e){return-Math.cos(e*Math.PI)/2+.5},Yoe=function(e){return e},Koe=function(e){return e*e},Goe=function(e){return e*(2-e)},Xoe=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},Zoe=function(e){return e*e*e},Qoe=function(e){return--e*e*e+1},Joe=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},eae=function(e){return e*e*e*e},tae=function(e){return 1- --e*e*e*e},nae=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},rae=function(e){return e*e*e*e*e},iae=function(e){return 1+--e*e*e*e*e},sae=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},u3={easeOut:Voe,linear:Yoe,easeInQuad:Koe,easeOutQuad:Goe,easeInOutQuad:Xoe,easeInCubic:Zoe,easeOutCubic:Qoe,easeInOutCubic:Joe,easeInQuart:eae,easeOutQuart:tae,easeInOutQuart:nae,easeInQuint:rae,easeOutQuint:iae,easeInOutQuint:sae},d3=function(e){typeof e=="number"&&cancelAnimationFrame(e)},Vs=function(e){e.mounted&&(d3(e.animation),e.isAnimating=!1,e.animation=null,e.velocity=null)};function h3(e,t,n,r){if(e.mounted){var i=new Date().getTime(),s=1;Vs(e),e.animation=function(){if(!e.mounted)return d3(e.animation);var o=new Date().getTime()-i,l=o/n,u=u3[t],d=u(l);o>=n?(r(s),e.animation=null):e.animation&&(r(d),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function oae(e){var t=e.scale,n=e.positionX,r=e.positionY;return!(Number.isNaN(t)||Number.isNaN(n)||Number.isNaN(r))}function Sl(e,t,n,r){var i=oae(t);if(!(!e.mounted||!i)){var s=e.setState,o=e.state,l=o.scale,u=o.positionX,d=o.positionY,h=t.scale-l,p=t.positionX-u,y=t.positionY-d;n===0?s(t.scale,t.positionX,t.positionY):h3(e,r,n,function(v){v!==1?e.isAnimating=!0:e.isAnimating=!1;var _=l+h*v,w=u+p*v,x=d+y*v;s(_,w,x)})}}function aae(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,h=i-u;return{wrapperWidth:r,wrapperHeight:i,newContentWidth:l,newDiffWidth:d,newContentHeight:u,newDiffHeight:h}}var lae=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,h=l,p=r-i-u,y=u;return{minPositionX:d,maxPositionX:h,minPositionY:p,maxPositionY:y,scaleWidthFactor:l,scaleHeightFactor:u}},U1=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=aae(n,r,t),u=l.wrapperWidth,d=l.wrapperHeight,h=l.newContentWidth,p=l.newContentHeight,y=l.newDiffWidth,v=l.newDiffHeight,_=lae(u,h,y,d,p,v,!!s),w=u>=h&&d>=p;o&&w&&!s&&(_.minPositionX=0,_.maxPositionX=0,_.minPositionY=0,_.maxPositionY=0);var x=e.setup,E=x.minPositionX,k=x.maxPositionX,R=x.minPositionY,A=x.maxPositionY;return E!=null&&(_.minPositionX=u*(1-t)+E*t),k!=null&&(_.maxPositionX=k*t),R!=null&&(_.minPositionY=d*(1-t)+R*t),A!=null&&(_.maxPositionY=A*t),_},bf=function(e,t,n,r){return r?e<t?Zl(t,2):e>n?Zl(n,2):Zl(e,2):Zl(e,2)},Zu=function(e,t){var n=U1(e,t);return e.bounds=n,n};function Gf(e,t,n,r,i,s,o){var l=n.minPositionX,u=n.minPositionY,d=n.maxPositionX,h=n.maxPositionY,p=0,y=0;o&&(p=i,y=s);var v=bf(e,l-p,d+p,r),_=bf(t,u-y,h+y,r);return{x:v,y:_}}function ty(e,t,n,r,i,s){var o=e.state,l=o.scale,u=o.positionX,d=o.positionY,h=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 p=u-t*h,y=d-n*h,v=Gf(p,y,i,s,0,0,null);return v}var yM=1e-7;function Xf(e,t,n,r,i){var s=i?r:0,o=Math.max(t-s,yM),l=n+s;return!Number.isNaN(n)&&e>=l?l:!Number.isNaN(t)&&e<=o?o:Math.max(e,yM)}var bM=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(h){return h instanceof Element?i==null?void 0:i.contains(h):!1}):i==null?void 0:i.contains(s),u=r&&s&&l;if(!u)return!1;var d=Zf(s,n);return!(d||s.getAttribute("draggable")==="true"||s.getAttribute("contenteditable")==="true"||s.isContentEditable)},_M=function(e){var t=e.isInitialized,n=e.isPanning,r=e.setup,i=r.panning.disabled,s=t&&n&&!i;return!!s},cae=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}},uae=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 dae(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 h=e.bounds,p=h.maxPositionX,y=h.minPositionX,v=h.maxPositionY,_=h.minPositionY,w=n>p||n<y,x=r>v||r<_,E=n>p?d.offsetWidth:e.setup.minPositionX||0,k=r>v?d.offsetHeight:e.setup.minPositionY||0,R=ty(e,E,k,i,e.bounds,l||u),A=R.x,I=R.y;return{scale:i,positionX:w?A:n,positionY:x?I:r}}}function f3(e,t,n,r,i){var s=e.setup.limitToBounds,o=e.wrapperComponent,l=e.bounds,u=e.state,d=u.scale,h=u.positionX,p=u.positionY;if(!(o===null||l===null||t===h&&n===p)){var y=Gf(t,n,l,s,r,i,o),v=y.x,_=y.y;e.setState(d,v,_)}}var hae=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 h=t-r.x,p=n-r.y,y=o?u:h,v=l?d:p;return{x:y,y:v}},dl=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},el;(function(e){e.TRACK_PAD="track_pad",e.MOUSE="mouse",e.TOUCH="touch"})(el||(el={}));var fae=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 h=n.offsetWidth<r.offsetWidth*u||n.offsetHeight<r.offsetHeight*u;return h},pae=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 mae(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 wM(e,t,n,r,i,s,o,l,u,d){if(i){if(t>o&&n>o){var h=o+(e-o)*d;return h>u?u:h<o?o:h}if(t<s&&n<s){var h=s+(e-s)*d;return h<l?l:h>s?s:h}}return r?t:bf(e,s,o,i)}function gae(e){var t=1,n=e.offsetWidth/window.innerWidth;return Number.isNaN(n)?t:Math.min(t,n)}var ow=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 vae(e,t,n){var r,i,s=fae(e);if(s){var o=e.lastMousePosition,l=e.velocityTime,u=e.setup,d=e.wrapperComponent,h=u.velocityAnimation,p=h.maxStrengthMouse,y=h.maxStrengthTouch,v=h.sensitivityTouch,_=h.sensitivityMouse,w=Date.now();if(o&&l&&d){var x=gae(d),E=(r={},r[el.TOUCH]=v,r[el.MOUSE]=_,r)[n],k=(i={},i[el.TOUCH]=y,i[el.MOUSE]=p,i)[n],R=t.x-o.x,A=t.y-o.y,I=ow(R/x,k,E),T=ow(A/x,k,E),H=w-l,D=R*R+A*A,W=ow(Math.sqrt(D)/H,k,E);e.velocity={velocityX:I,velocityY:T,total:W}}e.lastMousePosition=t,e.velocityTime=w}}function yae(e){var t=e.velocity,n=e.bounds,r=e.setup,i=e.wrapperComponent,s=pae(e);if(!(!s||!t||!n||!i)){var o=t.velocityX,l=t.velocityY,u=t.total,d=n.maxPositionX,h=n.minPositionX,p=n.maxPositionY,y=n.minPositionY,v=r.limitToBounds,_=r.autoAlignment,w=r.zoomAnimation,x=r.panning,E=x.lockAxisY,k=x.lockAxisX,R=w.animationType,A=_.sizeX,I=_.sizeY,T=_.velocityAlignmentTime,H=T,D=mae(e,u),W=Math.max(D,H),U=dl(e,A),F=dl(e,I),O=U*i.offsetWidth/100,M=F*i.offsetHeight/100,B=d+O,L=h-O,N=p+M,V=y-M,Y=e.state,$=new Date().getTime();h3(e,R,W,function(P){var q=e.state,K=q.scale,z=q.positionX,X=q.positionY,ee=new Date().getTime()-$,te=ee/H,Q=u3[_.animationType],me=1-Q(Math.min(1,te)),ve=1-P,Ce=z+o*ve,Me=X+l*ve,Ve=wM(Ce,Y.positionX,z,k,v,h,d,L,B,me),Qe=wM(Me,Y.positionY,X,E,v,y,p,V,N,me);if(z!==Ce||X!==Me){e.setState(K,Ve,Qe);var ct=e.props.onPanning;ct&&ct(Nn(e),{})}})}}function SM(e,t){var n=e.state,r=n.scale,i=n.positionX,s=n.positionY;e.panStartPosition={x:i,y:s},Vs(e),Zu(e,r),window.TouchEvent!==void 0&&t instanceof TouchEvent?uae(e,t):cae(e,t)}function p3(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,h=s.animationType,p=o||n<i||!l&&!u;if(!p){var y=dae(e);y&&Sl(e,y,d,h)}}function xM(e,t,n,r){var i=e.startCoords,s=e.setup,o=s.autoAlignment,l=o.sizeX,u=o.sizeY;if(i){var d=hae(e,t,n),h=d.x,p=d.y,y=dl(e,l),v=dl(e,u);vae(e,{x:h,y:p},r),f3(e,h,p,y,v)}}function bae(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 h=o-d.x,p=l-d.y;if(h*h+p*p<=25)return}e.isAnimating=!1,e.animation=null;var y=(r==null?void 0:r.offsetWidth)||0,v=(r==null?void 0:r.offsetHeight)||0,_=((i==null?void 0:i.offsetWidth)||0)*u,w=((i==null?void 0:i.offsetHeight)||0)*u,x=!e.setup.limitToBounds||y<_||v<w,E=!t&&n&&n.total>.1&&x;E?yae(e):p3(e)}}function W1(e,t,n,r){var i=e.setup,s=i.minScale,o=i.maxScale,l=i.limitToBounds,u=Xf(Zl(t,2),s,o,0,!1),d=Zu(e,u),h=ty(e,n,r,u,d,l),p=h.x,y=h.y;return{scale:u,positionX:p,positionY:y}}function q1(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,h=d.disabled,p=d.animationTime,y=d.animationType,v=r>=o&&r<=l,_=h||v;if((r>=1||u)&&p3(e),!(_||!i||!e.mounted)){var w=t||i.offsetWidth/2,x=n||i.offsetHeight/2,E=r<o?o:l,k=W1(e,E,w,x);k&&Sl(e,k,p,y)}}var Rs=function(){return Rs=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},Rs.apply(this,arguments)};function EM(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 aw={scale:1,positionX:0,positionY:0},Gl={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"}},K0={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},m3=function(e){var t,n,r,i,s,o,l,u,d,h=Math.max((t=e.minScale)!==null&&t!==void 0?t:Gl.minScale,1e-7),p=(n=e.maxScale)!==null&&n!==void 0?n:Gl.maxScale,y=(r=e.initialScale)!==null&&r!==void 0?r:aw.scale,v=Math.min(Math.max(y,h),p),_=bf((i=e.initialPositionX)!==null&&i!==void 0?i:aw.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=bf((l=e.initialPositionY)!==null&&l!==void 0?l:aw.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:v,scale:v,positionX:_,positionY:w}},CM=function(e){var t=Rs({},Gl);return Object.keys(e).forEach(function(n){var r=n,i=typeof e[r]<"u",s=typeof Gl[r]<"u";if(s&&i){var o=Object.prototype.toString.call(Gl[r]),l=o==="[object Object]",u=o==="[object Array]";l?t[r]=Rs(Rs({},Gl[r]),e[r]):u?t[r]=EM(EM([],Gl[r],!0),e[r]):t[r]=e[r]}}),t.minScale<=0&&(t.minScale=1e-7),t},g3=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,h=u.size;if(!i)throw new Error("Wrapper is not mounted");var p=d?r*Math.exp(t*n):r+t*n,y=Xf(Zl(p,3),l,o,h,!1);return y};function v3(e,t,n,r,i){var s,o,l=e.wrapperComponent,u=e.state,d=u.scale,h=u.positionX,p=u.positionY,y=e.setup.zoomAnimation;if(!l)return console.error("No WrapperComponent found");var v=y.disabled?0:r,_=l.offsetWidth,w=l.offsetHeight,x=(_/2-h)/d,E=(w/2-p)/d,k=g3(e,t,n),R=W1(e,k,x,E);if(!R)return console.error("Error during zoom event. New transformation state was not calculated.");var A=e.props,I=A.onZoomStart,T=A.onZoom,H=A.onZoomStop,D=new MouseEvent("mousemove",{bubbles:!0}),W=Nn(e);Pn(W,D,I),Pn(W,D,T),Sl(e,R,v,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&&Pn(Nn(e),D,H)},v)}function y3(e,t,n,r){var i,s,o=e.setup,l=e.wrapperComponent,u=e.contentComponent,d=o.limitToBounds,h=o.centerOnInit,p=m3(e.props),y=e.state,v=y.scale,_=y.positionX,w=y.positionY;if(l){var x=p.positionX,E=p.positionY;if(h&&u){var k=V1(p.scale,l,u);x=k.positionX,E=k.positionY}var R=U1(e,p.scale),A=Gf(x,E,R,d,0,0,l),I={scale:p.scale,positionX:A.x,positionY:A.y};if(!(v===p.scale&&_===p.positionX&&w===p.positionY)){r==null||r();var T=e.props,H=T.onZoomStart,D=T.onZoom,W=T.onZoomStop,U=new MouseEvent("mousemove",{bubbles:!0}),F=Nn(e);Pn(F,U,H),Pn(F,U,D),Sl(e,I,t,n);var O=(s=(i=l.ownerDocument)===null||i===void 0?void 0:i.defaultView)!==null&&s!==void 0?s:typeof window<"u"?window:null;O&&O.setTimeout(function(){e.mounted&&Pn(Nn(e),U,W)},t)}}}function _ae(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 wae(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,h=u.minScale,p=u.maxScale;if(!s||!o)return l;var y=s.getBoundingClientRect(),v=t.getBoundingClientRect(),_=_ae(t,s,o,l),w=_.x,x=_.y,E=v.width/l.scale,k=v.height/l.scale,R=s.offsetWidth/E,A=s.offsetHeight/k,I=Xf(n||Math.min(R,A),h,p,0,!1),T=(y.width-E*I)/2,H=(y.height-k*I)/2,D=(y.left-w)*I+T+r,W=(y.top-x)*I+H+i,U=U1(e,I),F=Gf(D,W,U,d,0,0,s),O=F.x,M=F.y;return{positionX:O,positionY:M,scale:I}}var Sae=function(e){return function(t,n,r){t===void 0&&(t=.5),n===void 0&&(n=300),r===void 0&&(r="easeOut"),v3(e,1,t,n,r)}},xae=function(e){return function(t,n,r){t===void 0&&(t=.5),n===void 0&&(n=300),r===void 0&&(r="easeOut"),v3(e,-1,t,n,r)}},Eae=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,h=e.wrapperComponent,p=e.contentComponent,y=e.setup.disabled;if(!(y||!h||!p)){var v={positionX:Number.isNaN(t)?l:t,positionY:Number.isNaN(n)?u:n,scale:Number.isNaN(r)?d:r};Sl(e,v,i,s)}}},Cae=function(e){return function(t,n){t===void 0&&(t=200),n===void 0&&(n="easeOut"),y3(e,t,n)}},kae=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=V1(t||i.scale,s,o);Sl(e,l,n,r)}}},Tae=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),Vs(e);var l=e.wrapperComponent,u=typeof t=="string"?document.getElementById(t):t;if(l&&u&&l.contains(u)){var d=wae(e,u,n,s,o);Sl(e,d,r,i)}}},G0=function(e){return{instance:e,state:e.state,zoomIn:Sae(e),zoomOut:xae(e),setTransform:Eae(e),resetTransform:Cae(e),centerView:kae(e),zoomToElement:Tae(e)}},Rae=function(e){return{instance:e,state:e.state}},Nn=function(e){var t={};return Object.assign(t,Rae(e)),Object.assign(t,G0(e)),t},lw=!1;function cw(){try{var e={get passive(){return lw=!0,!1}};return e}catch{return lw=!1,lw}}var Wm=".".concat(K0.wrapperClass),Zf=function(e,t){return t.some(function(n){return e.matches("".concat(Wm," ").concat(n,", ").concat(Wm," .").concat(n,", ").concat(Wm," ").concat(n," *, ").concat(Wm," .").concat(n," *"))})},_f=function(e){e&&clearTimeout(e)},Aae=function(e){return Number.parseFloat(e.toFixed(8))},b3=function(e,t,n){var r=Aae(n);return"translate(".concat(e,"px, ").concat(t,"px) scale(").concat(r,")")},V1=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 Nae(e,t){e!=null&&(typeof e=="function"?e(t):e.current=t)}function Mae(e){return function(t){e.forEach(function(n){typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var _3=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,h=l&&!u&&!r&&d;if(!h||i&&!t.ctrlKey||s&&t.ctrlKey)return!1;var p=Zf(d,o);if(p)return!1;var y=e.isPressingKeys(e.setup.wheel.activationKeys);return!!y},Oae=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=_3(e,t);if(l)return!1;var u=t.target,d=Zf(u,o);if(d)return!1;var h=e.isPressingKeys(s);return!!h},Dae=function(e){return e?e.deltaY<0?1:-1:0};function Pae(e,t){var n=Dae(e),r=qoe(t,n);return r}function w3(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 Lae=function(e,t,n,r,i){var s=e.state.scale,o=e.wrapperComponent,l=e.setup,u=l.maxScale,d=l.minScale,h=l.zoomAnimation,p=l.disablePadding,y=h.size,v=h.disabled;if(!o)throw new Error("Wrapper is not mounted");var _=s+t*n,w=r?!1:!v,x=Xf(_,d,u,y,w&&!p);return x},S3=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},Iae=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=Zf(o,i);return!u},zae=function(e){var t=e.setup.pinch.disabled,n=e.isInitialized,r=e.pinchStartDistance,i=n&&!t&&r!==null;return!!i},Bae=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}},x3=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))},jae=5,Fae=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,h=l.size,p=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 v=t/r,_=v*n,w=(_-n)*(y/jae),x=n+w,E=x===1/0?0:Zl(x,10);return Xf(E,o,s,h,!p&&!u)},E3=160,C3=100,$ae=function(e,t){var n=e.props,r=n.onWheelStart,i=n.onZoomStart;e.wheelStopEventTimer||(Vs(e),Pn(Nn(e),t,r),Pn(Nn(e),t,i))},Hae=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,h=o.centerZoomedOut,p=o.zoomAnimation,y=o.wheel,v=o.disablePadding,_=o.smooth,w=p.size,x=p.disabled,E=y.step;if(!s)throw new Error("Component not mounted");t.preventDefault(),t.stopPropagation();var k=Pae(t,null),R=_?E*Math.abs(t.deltaY):E,A=Lae(e,k,R,!t.ctrlKey);if(u!==A){var I=Zu(e,A),T=w3(t,s,u),H=x||w===0||h||v,D=d&&H,W=ty(e,T.x,T.y,A,I,D),U=W.x,F=W.y;e.previousWheelEvent=t,e.setState(A,U,F),Pn(Nn(e),t,r),Pn(Nn(e),t,i)}},Uae=function(e,t){var n=e.props,r=n.onWheelStop,i=n.onZoomStop;_f(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(q1(e,t.x,t.y),e.wheelAnimationTimer=null)},C3);var s=S3(e,t);s&&(_f(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,Pn(Nn(e),t,r),Pn(Nn(e),t,i))},E3))},Wae=function(e,t){var n=e.props,r=n.onWheelStart,i=n.onPanningStart;e.wheelStopEventTimer||(Vs(e),Pn(Nn(e),t,r),Pn(Nn(e),t,i))},qae=function(e,t){var n=e.props,r=n.onWheelStop,i=n.onPanningStop;_f(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(q1(e,t.x,t.y),e.wheelAnimationTimer=null)},C3);var s=S3(e,t);s&&(_f(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,Pn(Nn(e),t,r),Pn(Nn(e),t,i))},E3))},k3=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}},Vae=function(e,t){var n=x3(t);e.pinchStartDistance=n,e.lastDistance=n,e.pinchStartScale=e.state.scale,e.isPanning=!1,e.isPinching=!0,e.pinchPreviousCenter=k3(t),Vs(e)},Yae=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,h=l.zoomAnimation,p=l.autoAlignment,y=l.pinch,v=l.panning,_=h.disabled,w=h.size,x=y.allowPanning;if(!(r===null||!n)){var E=Bae(t,o,n);if(!(!Number.isFinite(E.x)||!Number.isFinite(E.y))){var k=x3(t),R=Fae(e,k),A=k3(t),I=o/R,T=(A.x-((s==null?void 0:s.x)||0))*I,H=(A.y-((s==null?void 0:s.y)||0))*I;if(!(R===o&&T===0&&H===0)){e.pinchPreviousCenter=A;var D=Zu(e,R),W=_||w===0||d,U=u&&W,F=ty(e,E.x,E.y,R,D,U),O=F.x,M=F.y;if(e.pinchMidpoint=E,e.lastDistance=k,v.disabled||!x)e.setState(R,O,M);else{var B=p.sizeX,L=p.sizeY,N=dl(e,B,R),V=dl(e,L,R),Y=O+T,$=M+H,P=Gf(Y,$,D,u,N,V,i),q=P.x,K=P.y;e.setState(R,q,K)}}}}},Kae=function(e){var t=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,e.isPinching=!1,q1(e,t==null?void 0:t.x,t==null?void 0:t.y)},T3=function(e,t){var n=e.props.onZoomStop,r=e.setup.doubleClick.animationTime;_f(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,Pn(Nn(e),t,n)},r)},Gae=function(e,t){var n=e.props,r=n.onZoomStart,i=n.onZoom,s=e.setup.doubleClick,o=s.animationTime,l=s.animationType;Pn(Nn(e),t,r),y3(e,o,l,function(){return Pn(Nn(e),t,i)}),T3(e,t)};function Xae(e,t){return e==="toggle"?t===1?1:-1:e==="zoomOut"?-1:1}function Zae(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,h=n.doubleClick,p=h.disabled,y=h.mode,v=h.step,_=h.animationTime,w=h.animationType;if(!p&&!r){if(y==="reset")return Gae(e,t);if(!s)return console.error("No ContentComponent found");var x=Xae(y,e.state.scale),E=g3(e,x,v);if(o!==E){Pn(Nn(e),t,u);var k=w3(t,s,o),R=W1(e,E,k.x,k.y);if(!R)return console.error("Error during zoom event. New transformation state was not calculated.");Pn(Nn(e),t,d),Sl(e,R,_,w),T3(e,t)}}}var Qae=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),h=n&&u&&d&&!o;if(!h)return!1;var p=Zf(u,l);return!p},Jae=(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&&Zu(n,n.state.scale),n.setup=CM(r)},this.initializeWindowEvents=function(){var r,i,s,o,l=cw(),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=cw(),d=(r=n.wrapperComponent)===null||r===void 0?void 0:r.ownerDocument,h=d==null?void 0:d.defaultView;h==null||h.removeEventListener("mousedown",n.onPanningStart,u),h==null||h.removeEventListener("mousemove",n.onPanning,u),h==null||h.removeEventListener("mouseup",n.onPanningStop,u),d==null||d.removeEventListener("mouseleave",n.clearPanning,u),h==null||h.removeEventListener("keyup",n.setKeyUnPressed,u),h==null||h.removeEventListener("keydown",n.setKeyPressed,u),h==null||h.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),Vs(n),(l=n.observer)===null||l===void 0||l.disconnect()},this.handleInitializeWrapperEvents=function(r){var i=cw();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(Nn(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(Nn(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=_3(n,r);s&&($ae(n,r),Hae(n,r),Uae(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=Oae(n,r);if(u){r.preventDefault(),r.stopPropagation();var d=n.state,h=d.positionX,p=d.positionY,y=h-r.deltaX,v=p-r.deltaY,_=o?h:y,w=l?p:v,x=n.setup.autoAlignment,E=x.sizeX,k=x.sizeY,R=dl(n,E),A=dl(n,k);_===h&&w===p||(Wae(n,r),f3(n,_,w,R,A),Pn(Nn(n),r,i),qae(n,r))}},this.onPanningStart=function(r){var i=n.setup.disabled,s=n.props.onPanningStart;if(!i){n.syncModifierKeys(r);var o=bM(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(),Vs(n),SM(n,r),Pn(Nn(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=_M(n);if(o){var l=n.isPressingKeys(n.setup.panning.activationKeys);l&&(r.preventDefault(),r.stopPropagation(),xM(n,r.clientX,r.clientY,el.MOUSE),Pn(Nn(n),r,s))}}},this.onPanningStop=function(r){var i=n.setup.panning.velocityDisabled,s=n.props.onPanningStop;n.isPanning&&(bae(n,i),Pn(Nn(n),r,s))},this.onPinchStart=function(r){var i=n.setup.disabled,s=n.props.onPinchStart;if(!i){var o=Iae(n,r);o&&(Vae(n,r),Vs(n),Pn(Nn(n),r,s))}},this.onPinch=function(r){var i=n.setup.disabled,s=n.props.onPinch;if(!i){var o=zae(n);o&&(r.preventDefault(),r.stopPropagation(),Yae(n,r),Pn(Nn(n),r,s))}},this.onPinchStop=function(r){var i=n.props.onPinchStop;n.pinchStartScale&&(Kae(n),Pn(Nn(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,Vs(n);var h=r.touches,p=h.length===1,y=h.length===2,v=bM(n,r);if(p){if(!v)return;Vs(n),SM(n,r),Pn(Nn(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=_M(n);if(!o)return;r.cancelable&&r.preventDefault(),r.stopPropagation();var l=r.touches[0];xM(n,l.clientX,l.clientY,el.TOUCH),Pn(Nn(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=Qae(n,r);s&&Zae(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=V1(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):b3(r,i,s)},this.getContext=function(){return Nn(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:Nn(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=Nn(n);n.onChangeCallbacks.forEach(function(d){return d(u)}),Pn(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,Zu(n,n.state.scale),n.handleInitializeWrapperEvents(r),n.handleInitialize(i),n.initializeWindowEvents(),n.isInitialized=!0;var s=Nn(n);Pn(s,void 0,n.props.onInit),Nae(n.props.ref,s)},this.props=t,this.setup=CM(this.props),this.state=m3(this.props)}return e})(),ny=Je.createContext(null),ele=function(e,t){return typeof e=="function"?e(t):e},tle=Je.forwardRef(function(e,t){var n=b.useRef(new Jae(e)).current,r=ele(e.children,G0(n));return b.useImperativeHandle(t,function(){return G0(n)},[n]),b.useEffect(function(){n.update(e)},[n,e]),g.jsx(ny.Provider,Rs({value:n},{children:r}))});Je.forwardRef(function(e,t){var n=b.useRef(null),r=b.useContext(ny);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]),g.jsx("div",Rs({},e,{ref:Mae([n,t])}))});function nle(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 rle=`.transform-component-module_wrapper__SPB86 {
513
513
  position: relative;
@@ -638,63 +638,63 @@ WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){t
638
638
 
639
639
  `+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)}},Ghe=new Khe;function Nw(e){Xhe(e)||Ghe.onUnexpectedError(e)}var BS="Canceled";function Xhe(e){return e instanceof Zhe?!0:e instanceof Error&&e.name===BS&&e.message===BS}var Zhe=class extends Error{constructor(){super(BS),this.name=this.message}},R2=class jS extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof jS)return t;let n=new jS;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}};function Qhe(e,t){let n=this,r=!1,i;return function(){return r||(r=!0,t||(i=e.apply(n,arguments))),i}}var Jhe;(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})(Jhe||(Jhe={}));var j5;(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 I=A.length-1;I>=0;I--)yield A[I]}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 h(A,I){let T=0;for(let H of A)if(I(H,T++))return!0;return!1}e.some=h;function p(A,I){for(let T of A)if(I(T))return T}e.find=p;function*y(A,I){for(let T of A)I(T)&&(yield T)}e.filter=y;function*v(A,I){let T=0;for(let H of A)yield I(H,T++)}e.map=v;function*_(A,I){let T=0;for(let H of A)yield*I(H,T++)}e.flatMap=_;function*w(...A){for(let I of A)yield*I}e.concat=w;function x(A,I,T){let H=T;for(let D of A)H=I(H,D);return H}e.reduce=x;function*E(A,I,T=A.length){for(I<0&&(I+=A.length),T<0?T+=A.length:T>A.length&&(T=A.length);I<T;I++)yield A[I]}e.slice=E;function k(A,I=Number.POSITIVE_INFINITY){let T=[];if(I===0)return[T,A];let H=A[Symbol.iterator]();for(let D=0;D<I;D++){let W=H.next();if(W.done)return[T,e.empty()];T.push(W.value)}return[T,{[Symbol.iterator](){return H}}]}e.consume=k;async function R(A){let I=[];for await(let T of A)I.push(T);return Promise.resolve(I)}e.asyncToArray=R})(j5||(j5={}));function F5(e){if(j5.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 efe(...e){return $5(()=>F5(e))}function $5(e){return{dispose:Qhe(()=>{e()})}}var H5=class U5{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{F5(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?U5.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)}};H5.DISABLE_DISPOSED_WARNING=!1;var aE=H5,ov=class{constructor(){this._store=new aE,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)}};ov.None=Object.freeze({dispose(){}});var tfe=globalThis.performance&&typeof globalThis.performance.now=="function",nfe=class W5{static create(t){return new W5(t)}constructor(t){this._now=tfe&&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}},rfe;(e=>{e.None=()=>ov.None;function t(O,M){return p(O,()=>{},0,void 0,!0,void 0,M)}e.defer=t;function n(O){return(M,B=null,L)=>{let N=!1,V;return V=O(Y=>{if(!N)return V?V.dispose():N=!0,M.call(B,Y)},null,L),N&&V.dispose(),V}}e.once=n;function r(O,M,B){return d((L,N=null,V)=>O(Y=>L.call(N,M(Y)),null,V),B)}e.map=r;function i(O,M,B){return d((L,N=null,V)=>O(Y=>{M(Y),L.call(N,Y)},null,V),B)}e.forEach=i;function s(O,M,B){return d((L,N=null,V)=>O(Y=>M(Y)&&L.call(N,Y),null,V),B)}e.filter=s;function o(O){return O}e.signal=o;function l(...O){return(M,B=null,L)=>{let N=efe(...O.map(V=>V(Y=>M.call(B,Y))));return h(N,L)}}e.any=l;function u(O,M,B,L){let N=B;return r(O,V=>(N=M(N,V),N),L)}e.reduce=u;function d(O,M){let B,L={onWillAddFirstListener(){B=O(N.fire,N)},onDidRemoveLastListener(){B==null||B.dispose()}},N=new Wa(L);return M==null||M.add(N),N.event}function h(O,M){return M instanceof Array?M.push(O):M&&M.add(O),O}function p(O,M,B=100,L=!1,N=!1,V,Y){let $,P,q,K=0,z,X={leakWarningThreshold:V,onWillAddFirstListener(){$=O(te=>{K++,P=M(P,te),L&&!q&&(ee.fire(P),P=void 0),z=()=>{let Q=P;P=void 0,q=void 0,(!L||K>1)&&ee.fire(Q),K=0},typeof B=="number"?(clearTimeout(q),q=setTimeout(z,B)):q===void 0&&(q=0,queueMicrotask(z))})},onWillRemoveListener(){N&&K>0&&(z==null||z())},onDidRemoveLastListener(){z=void 0,$.dispose()}},ee=new Wa(X);return Y==null||Y.add(ee),ee.event}e.debounce=p;function y(O,M=0,B){return e.debounce(O,(L,N)=>L?(L.push(N),L):[N],M,void 0,!0,void 0,B)}e.accumulate=y;function v(O,M=(L,N)=>L===N,B){let L=!0,N;return s(O,V=>{let Y=L||!M(V,N);return L=!1,N=V,Y},B)}e.latch=v;function _(O,M,B){return[e.filter(O,M,B),e.filter(O,L=>!M(L),B)]}e.split=_;function w(O,M=!1,B=[],L){let N=B.slice(),V=O(P=>{N?N.push(P):$.fire(P)});L&&L.add(V);let Y=()=>{N==null||N.forEach(P=>$.fire(P)),N=null},$=new Wa({onWillAddFirstListener(){V||(V=O(P=>$.fire(P)),L&&L.add(V))},onDidAddFirstListener(){N&&(M?setTimeout(Y):Y())},onDidRemoveLastListener(){V&&V.dispose(),V=null}});return L&&L.add($),$.event}e.buffer=w;function x(O,M){return(B,L,N)=>{let V=M(new k);return O(function(Y){let $=V.evaluate(Y);$!==E&&B.call(L,$)},void 0,N)}}e.chain=x;let E=Symbol("HaltChainable");class k{constructor(){this.steps=[]}map(M){return this.steps.push(M),this}forEach(M){return this.steps.push(B=>(M(B),B)),this}filter(M){return this.steps.push(B=>M(B)?B:E),this}reduce(M,B){let L=B;return this.steps.push(N=>(L=M(L,N),L)),this}latch(M=(B,L)=>B===L){let B=!0,L;return this.steps.push(N=>{let V=B||!M(N,L);return B=!1,L=N,V?N:E}),this}evaluate(M){for(let B of this.steps)if(M=B(M),M===E)break;return M}}function R(O,M,B=L=>L){let L=(...$)=>Y.fire(B(...$)),N=()=>O.on(M,L),V=()=>O.removeListener(M,L),Y=new Wa({onWillAddFirstListener:N,onDidRemoveLastListener:V});return Y.event}e.fromNodeEventEmitter=R;function A(O,M,B=L=>L){let L=(...$)=>Y.fire(B(...$)),N=()=>O.addEventListener(M,L),V=()=>O.removeEventListener(M,L),Y=new Wa({onWillAddFirstListener:N,onDidRemoveLastListener:V});return Y.event}e.fromDOMEventEmitter=A;function I(O){return new Promise(M=>n(O)(M))}e.toPromise=I;function T(O){let M=new Wa;return O.then(B=>{M.fire(B)},()=>{M.fire(void 0)}).finally(()=>{M.dispose()}),M.event}e.fromPromise=T;function H(O,M){return O(B=>M.fire(B))}e.forward=H;function D(O,M,B){return M(B),O(L=>M(L))}e.runAndSubscribe=D;class W{constructor(M,B){this._observable=M,this._counter=0,this._hasChanged=!1;let L={onWillAddFirstListener:()=>{M.addObserver(this)},onDidRemoveLastListener:()=>{M.removeObserver(this)}};this.emitter=new Wa(L),B&&B.add(this.emitter)}beginUpdate(M){this._counter++}handlePossibleChange(M){}handleChange(M,B){this._hasChanged=!0}endUpdate(M){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function U(O,M){return new W(O,M).emitter.event}e.fromObservable=U;function F(O){return(M,B,L)=>{let N=0,V=!1,Y={beginUpdate(){N++},endUpdate(){N--,N===0&&(O.reportChanges(),V&&(V=!1,M.call(B)))},handlePossibleChange(){},handleChange(){V=!0}};O.addObserver(Y),O.reportChanges();let $={dispose(){O.removeObserver(Y)}};return L instanceof aE?L.add($):Array.isArray(L)&&L.push($),$}}e.fromObservableLight=F})(rfe||(rfe={}));var FS=class $S{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${$S._idPool++}`,$S.all.add(this)}start(t){this._stopWatch=new nfe,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}}};FS.all=new Set,FS._idPool=0;var ife=FS,sfe=-1,q5=class V5{constructor(t,n,r=(V5._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 lfe(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}};q5._idPool=1;var ofe=q5,afe=class Y5{constructor(t){this.value=t}static create(){let t=new Error;return new Y5(t.stack??"")}print(){console.warn(this.value.split(`
640
640
  `).slice(2).join(`
641
- `))}},lfe=class extends Error{constructor(t,n){super(t),this.name="ListenerLeakError",this.stack=n}},cfe=class extends Error{constructor(t,n){super(t),this.name="ListenerRefusalError",this.stack=n}},ufe=0,Mw=class{constructor(t){this.value=t,this.id=ufe++}},dfe=2,hfe,Wa=class{constructor(e){var t,n,r,i;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new ofe((e==null?void 0:e.onListenerError)??Nw,((n=this._options)==null?void 0:n.leakWarningThreshold)??sfe):void 0,this._perfMon=(r=this._options)!=null&&r._profName?new ife(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,h;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let p=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(p);let y=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],v=new cfe(`${p}. HINT: Stack shows most frequent listener (${y[1]}-times)`,y[0]);return(((o=this._options)==null?void 0:o.onListenerError)||Nw)(v),ov.None}if(this._disposed)return ov.None;t&&(e=e.bind(t));let r=new Mw(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=afe.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Mw?(this._deliveryQueue??(this._deliveryQueue=new ffe),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,(h=(d=this._options)==null?void 0:d.onDidAddFirstListener)==null||h.call(d,this)),this._size++;let s=$5(()=>{i==null||i(),this._removeListener(r)});return n instanceof aE?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*dfe<=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)||Nw;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 Mw)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}},ffe=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}},Fu=class Ag{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Wa,this.onChange=this._onChange.event;let t=new Yhe;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=Ag.extractWidth(l);Ag.extractShouldJoin(l)&&(u-=Ag.extractWidth(r)),n+=u,r=l}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},lE=0,K5=-3,Cf=class{constructor(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}},pfe=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 Cf,this.dtree=new Cf}},G5=new Cf,X5=new Cf,cE=new Uint8Array(30),uE=new Uint16Array(30),Z5=new Uint8Array(30),Q5=new Uint16Array(30),mfe=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),A2=new Cf,lo=new Uint8Array(320);function J5(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 gfe(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 N2=new Uint16Array(16);function Ow(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)N2[i]=s,s+=e.table[i];for(i=0;i<r;++i)t[n+i]&&(e.trans[N2[t[n+i]]++]=i)}function vfe(e){e.bitcount--||(e.tag=e.source[e.sourceIndex++],e.bitcount=7);var t=e.tag&1;return e.tag>>>=1,t}function vo(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 HS(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 yfe(e,t,n){var r,i,s,o,l,u;for(r=vo(e,5,257),i=vo(e,5,1),s=vo(e,4,4),o=0;o<19;++o)lo[o]=0;for(o=0;o<s;++o){var d=vo(e,3,0);lo[mfe[o]]=d}for(Ow(A2,lo,0,19),l=0;l<r+i;){var h=HS(e,A2);switch(h){case 16:var p=lo[l-1];for(u=vo(e,2,3);u;--u)lo[l++]=p;break;case 17:for(u=vo(e,3,3);u;--u)lo[l++]=0;break;case 18:for(u=vo(e,7,11);u;--u)lo[l++]=0;break;default:lo[l++]=h;break}}Ow(t,lo,0,r),Ow(n,lo,r,i)}function M2(e,t,n){for(;;){var r=HS(e,t);if(r===256)return lE;if(r<256)e.dest[e.destLen++]=r;else{var i,s,o,l;for(r-=257,i=vo(e,cE[r],uE[r]),s=HS(e,n),o=e.destLen-vo(e,Z5[s],Q5[s]),l=o;l<o+i;++l)e.dest[e.destLen++]=e.dest[l]}}}function bfe(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 K5;for(e.sourceIndex+=4,r=t;r;--r)e.dest[e.destLen++]=e.source[e.sourceIndex++];return e.bitcount=0,lE}function _fe(e,t){var n=new pfe(e,t),r,i,s;do{switch(r=vfe(n),i=vo(n,2,0),i){case 0:s=bfe(n);break;case 1:s=M2(n,G5,X5);break;case 2:yfe(n,n.ltree,n.dtree),s=M2(n,n.ltree,n.dtree);break;default:s=K5}if(s!==lE)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}gfe(G5,X5);J5(cE,uE,4,3);J5(Z5,Q5,2,1);cE[28]=0;uE[28]=258;var O2=_fe,dE=11,ic=5,wfe=dE-ic,Sfe=65536>>dE,xfe=1<<wfe,Efe=xfe-1,Ng=2,Cfe=1<<ic,Dw=Cfe-1,ej=65536>>ic,kfe=1024>>ic,Tfe=ej+kfe,Rfe=Tfe,Afe=32,Nfe=Rfe+Afe,Mfe=1<<Ng,Ofe=new Uint8Array(new Uint32Array([305419896]).buffer)[0]===18,Dfe=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=O2(e,new Uint8Array(n)),e=O2(e,new Uint8Array(n)),Ofe){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>>ic]<<Ng)+(e&Dw),this.data[t]):e<=65535?(t=(this.data[ej+(e-55296>>ic)]<<Ng)+(e&Dw),this.data[t]):e<this.highStart?(t=this.data[Nfe-Sfe+(e>>dE)],t=this.data[t+(e>>ic&Efe)],t=(t<<Ng)+(e&Dw),this.data[t]):this.data[this.data.length-Mfe]}},Pfe=Dfe,Lfe="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 Ife(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 zfe=new Pfe(Ife(Lfe)),US=15,WS=0,Bfe=48,jfe=4,Ffe=0,tj=1,nj=2,qS=3,$fe=4,Pw=5,Lw=6,Iw=7,D2=8,zw=9,P2=10,Hfe=11,Ufe=32;function L2(e){return(e&Bfe)>>jfe}function Wfe(e,t){let n=(e&US)>>WS,r=(t&US)>>WS;return qfe(n,r)?r===qS?Ufe:r+16:r-16}function qfe(e,t){return e>=Pw&&e<=zw&&(e==Pw&&(t==Pw||t==Lw||t==D2||t==zw)||(e==D2||e==Lw)&&(t==Lw||t==Iw)||(e==zw||e==Iw)&&t==Iw)||t==nj||t==P2||e==tj||t==$fe||e==P2&&t==Hfe||t==qS&&e==qS}function I2(e){return zfe.get(e)}var rj=class ij{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 ij._plainNarrowProperties;let r=I2(t),i=L2(r),s=!1;if(i>=2?i=i===3||this.ambiguousCharsAreWide||t===65039?2:1:i=1,n!==0){let o=Fu.extractWidth(n);this.handleGraphemes?r=Wfe(Fu.extractCharKind(n),r):r=i===0?1:0,s=r>0,s&&(o>i?i=o:r===32&&(i=2))}return Fu.createPropertyValue(r,i,s)}wcwidth(t){let n=I2(t),r=L2(n),i=(n&US)>>WS;return i===nj||i===tj?0:r>=2&&(r===3||this.ambiguousCharsAreWide)?2:1}};rj._plainNarrowProperties=Fu.createPropertyValue(Ffe,1,!1);var z2=rj,Vfe=class{constructor(){this._oldVersion=""}activate(e){this._provider15||(this._provider15=new z2(!1)),this._provider15Graphemes||(this._provider15Graphemes=new z2(!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 Yfe={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"},Kfe={matchBackground:"#264F78",matchBorder:"#3B8EEA",matchOverviewRuler:"#3B8EEA",activeMatchBackground:"#7A4E00",activeMatchBorder:"#F5F543",activeMatchColorOverviewRuler:"#F5F543"},Gfe="─│╭╮╰╯";function Xfe(e={}){return{scrollback:5e3,fontFamily:iL,fontSize:e.fontSize??Hu,cursorBlink:!0,cursorStyle:"block",cursorInactiveStyle:"none",disableStdin:!1,theme:Yfe,allowProposedApi:!0}}async function sj(e,t={}){await document.fonts.ready;const n=t.fontSize??Hu;try{await document.fonts.load(`${n}px "Sarasa Fixed SC"`,Gfe)}catch{}const r=new Ohe(Xfe(t)),i=new zhe,s=new Whe,o=new Vfe;r.loadAddon(i),r.loadAddon(s),r.loadAddon(o),e.replaceChildren(),r.open(e);const l=()=>{r.refresh(0,r.rows-1)},u=()=>{document.visibilityState==="visible"&&r.refresh(0,r.rows-1)},d=()=>{r.refresh(0,r.rows-1)},h=()=>{r.refresh(0,r.rows-1)};return document.fonts.addEventListener("loadingdone",l),document.addEventListener("visibilitychange",u),window.addEventListener("pageshow",d),window.addEventListener("focus",h),{terminal:r,serializeAddon:i,dispose:()=>{document.fonts.removeEventListener("loadingdone",l),document.removeEventListener("visibilitychange",u),window.removeEventListener("pageshow",d),window.removeEventListener("focus",h),r.dispose()}}}function Zfe(e,t,n){return e.options.fontSize===t?!1:(e.options.fontSize=t,requestAnimationFrame(()=>n==null?void 0:n()),!0)}const oj="pty-review-snapshot";function Qfe(e){return Array.from(e.children).find(t=>t instanceof HTMLElement&&t.classList.contains("xterm-rows")&&t.dataset.slot!==oj)??null}function Jfe(e,t){const n=document.createElement("div");return n.dataset.slot=oj,n.setAttribute("aria-hidden","true"),Object.assign(n.style,{position:"absolute",top:"0",right:"0",left:"0",height:t.style.height||"100%",overflow:"hidden",pointerEvents:"none",backgroundColor:getComputedStyle(e).backgroundColor}),n.append(t),n}function epe(e){for(const t of e.querySelectorAll("span[style]")){const n=t.style.opacity;if(!n||n==="1")continue;t.style.removeProperty("opacity");const r=document.createElement("span");r.style.opacity=n,r.append(...Array.from(t.childNodes)),t.append(r)}}function tpe(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 npe(e,t,n){const i=new DOMParser().parseFromString(e,"text/html").querySelector("pre > div");if(!i)return null;const s=document.importNode(i,!0);s.className=t.className,s.removeAttribute("id"),tpe(s),epe(s);const o=getComputedStyle(t),l=n>0?t.clientHeight/n:0,u=s.childElementCount;Object.assign(s.style,{position:"absolute",top:"0",left:"0",width:"100%",height:`${u*l}px`,fontFamily:o.fontFamily,fontSize:o.fontSize,fontWeight:o.fontWeight,fontVariantLigatures:o.fontVariantLigatures,letterSpacing:o.letterSpacing,whiteSpace:"pre"});for(const d of Array.from(s.children))d instanceof HTMLElement&&Object.assign(d.style,{height:`${l}px`,lineHeight:`${l}px`,overflow:"hidden",whiteSpace:"pre"});return s}function rpe(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(h=>h instanceof HTMLElement&&h.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{captureRange:(l,u)=>{const d=e.querySelector(".xterm-screen"),h=d?Qfe(d):null;if(!d||!h||!t.serializeRangeAsHtml||u<=0)return!1;const p=t.serializeRangeAsHtml(l,l+u),y=npe(p,h,u);if(!y)return!1;const v=Jfe(d,y);return i(v),!0},clear:s,dispose:s}}const aj=28,lj=14;function Jm(e,t,n){const r=Math.min(1,Math.max(0,1-e/t));return Math.ceil(n*r)}function cj({pointerX:e,pointerY:t,rect:n,scrollLeft:r,scrollTop:i,scrollWidth:s,scrollHeight:o,clientWidth:l,clientHeight:u,edgePx:d=aj,maxSpeedPx:h=lj}){let p=0;const y=e-n.left,v=n.right-e;if(y<d&&r>0)p=-Jm(y,d,h);else if(v<d){const E=Math.max(0,s-l);r<E&&(p=Jm(v,d,h))}let _=0;const w=t-n.top,x=n.bottom-t;if(w<d&&i>0)_=-Jm(w,d,h);else if(x<d){const E=Math.max(0,o-u);i<E&&(_=Jm(x,d,h))}return{dx:p,dy:_}}const ipe=aj,spe=lj;function ope(e){var T,H,D,W;const{container:t,host:n,edgePx:r=ipe,maxSpeedPx:i=spe,onHorizontalScrollIntent:s,requestFrame:o=U=>requestAnimationFrame(U),cancelFrame:l=U=>cancelAnimationFrame(U)}=e;let u=!1,d=0,h=0,p=null,y=0,v="unknown",_=null,w=null,x=null;const E=()=>{if(x&&x.isConnected)return x;const U=n.querySelector(".xterm-screen");return x=U??n,v=U?"xterm-screen":"host",x},k=()=>{u=!1,p!==null&&(l(p),p=null)},R=()=>{if(p=null,!u)return;const U=t.getBoundingClientRect(),{dx:F,dy:O}=cj({pointerX:d,pointerY:h,rect:U,scrollLeft:t.scrollLeft,scrollTop:t.scrollTop,scrollWidth:t.scrollWidth,scrollHeight:t.scrollHeight,clientWidth:t.clientWidth,clientHeight:t.clientHeight,edgePx:r,maxSpeedPx:i});F!==0&&(s==null||s(`dragSelectAutoscroll dx=${Math.round(F)}`),t.scrollLeft+=F),O!==0&&(t.scrollTop+=O),(F!==0||O!==0)&&(E().dispatchEvent(new MouseEvent("mousemove",{clientX:d,clientY:h,bubbles:!0,cancelable:!0})),y+=1,_={dx:F,dy:O},w=Date.now()),p=o(R)},A=U=>{U.pointerType==="mouse"&&U.button===0&&(u=!0,d=U.clientX,h=U.clientY,p===null&&(p=o(R)))},I=U=>{u&&(d=U.clientX,h=U.clientY)};return t.addEventListener("pointerdown",A),(T=globalThis.addEventListener)==null||T.call(globalThis,"pointermove",I),(H=globalThis.addEventListener)==null||H.call(globalThis,"pointerup",k),(D=globalThis.addEventListener)==null||D.call(globalThis,"pointercancel",k),(W=globalThis.addEventListener)==null||W.call(globalThis,"blur",k),{dispose(){var U,F,O,M;k(),t.removeEventListener("pointerdown",A),(U=globalThis.removeEventListener)==null||U.call(globalThis,"pointermove",I),(F=globalThis.removeEventListener)==null||F.call(globalThis,"pointerup",k),(O=globalThis.removeEventListener)==null||O.call(globalThis,"pointercancel",k),(M=globalThis.removeEventListener)==null||M.call(globalThis,"blur",k)},getDebugSnapshot(){return{dragging:u,pointerX:d,pointerY:h,dispatchCount:y,dispatchTargetTag:v,lastScrollDelta:_,lastDispatchedAt:w}}}}const ape=16,lpe=16,cpe=16;function uj(e){const t=Array.from(e);return t.length!==1?!1:/^[\p{P}\p{S}]$/u.test(t[0])}function upe(e){if(e.length!==1)return!1;const t=e.charCodeAt(0);return t>=48&&t<=57}function dpe(e){for(const t of e){const n=t.codePointAt(0);if(n!==void 0&&n>127)return!0}return!1}function hpe(e,t){return t.physicalKeyboardMode!==!0||e.length===0?!1:e===" "||dpe(e)?!0:Array.from(e).every(uj)}function fpe(e,t={}){return e.type!=="keydown"||e.ctrlKey||e.metaKey||e.altKey||e.isComposing||t.imeComposing?!1:uj(e.key)||t.physicalKeyboardMode===!0&&(e.key===" "||upe(e.key))}function ppe(e){return e.type!=="keydown"||!e.ctrlKey||e.metaKey||e.altKey||e.shiftKey?!1:e.key===" "||e.key==="Spacebar"||e.code==="Space"}function mpe(e){return e.type!=="keydown"?!1:e.metaKey}function dj(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 hj(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 gpe(){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 vpe(e){const t=dj(e),n=gpe();return e.setAttribute("autocapitalize","off"),e.setAttribute("autocomplete","off"),e.setAttribute("autocorrect","off"),e.spellcheck=!1,n&&(e.style.colorScheme=n),()=>hj(e,t)}function ype(e){const t=dj(e);return e.setAttribute("enterkeyhint","send"),()=>{hj(e,t)}}function bpe(e,t,n={}){var L,N,V,Y;let r,i,s,o=!1,l;const u=()=>{var $;return(($=n.isPhysicalKeyboardMode)==null?void 0:$.call(n))??n.physicalKeyboardMode===!0},d=()=>{var $;return(($=n.getPlainEnterBehavior)==null?void 0:$.call(n))??n.plainEnterBehavior??"submit"},h=e.textarea?vpe(e.textarea):void 0,p=u()&&e.textarea?ype(e.textarea):void 0,y=()=>{const $=e.textarea;!$||l||(l=setTimeout(()=>{l=void 0,o||($.value="")},0))},v=$=>{var P;if(n.isInputEnabled&&!n.isInputEnabled()){y();return}Ys(t,$),(P=n.onRawInput)==null||P.call(n,$),y()},_=$=>{v($)},w=()=>{i&&(clearTimeout(i.timer),i=void 0)},x=()=>{s&&(clearTimeout(s.timer),s=void 0)},E=$=>{if(x(),!$)return;const P={data:$,timer:setTimeout(()=>{s===P&&(s=void 0)},cpe)};s=P},k=$=>{E(`${(s==null?void 0:s.data)??""}${$}`)},R=$=>!s||!$||!s.data.startsWith($)?!1:(E(s.data.slice($.length)),!0),A=($,P)=>{w();const q={data:$,keydownText:P,timer:setTimeout(()=>{i===q&&(i=void 0)},lpe)};i=q},I=($,P)=>{const q=$.startsWith(P.data)?P.data:$.startsWith(P.keydownText)?P.keydownText:"";return q?$.slice(q.length):$},T=($,P,q)=>I($,{data:q,keydownText:P.keydownText}),H=($,P)=>{let q=!1;for(const K of $.bufferedXtermData){let z=K;if(!q){const X=T(K,$,P);X!==K&&(z=X,q=!0)}z&&_(z)}},D=$=>{const P=r;P&&(r=void 0,clearTimeout(P.timer),v($),A($,P.keydownText),H(P,$))},W=$=>{r&&D(r.keydownText),w();const P={bufferedXtermData:[],keydownText:$,timer:setTimeout(()=>{r===P&&D($)},ape)};r=P},U=$=>hpe($,{physicalKeyboardMode:u()})?R($)?(y(),!0):(v($),A($,$),!0):!1,F=$=>{const P=$,q=P.data??"";if(!P.isComposing&&r&&q){D(q);return}P.isComposing||P.inputType!=="insertText"&&P.inputType!=="insertCompositionText"||U(q)},O=()=>{o=!0,l&&(clearTimeout(l),l=void 0);const $=e.textarea;$&&($.value="")},M=$=>{o=!1,r&&$.data&&D($.data)},B=e.onData($=>{if(r){r.bufferedXtermData.push($);return}if(i){const P=I($,i);w(),P&&_(P);return}_($),k($)});return(L=e.textarea)==null||L.addEventListener("input",F),(N=e.textarea)==null||N.addEventListener("compositionstart",O,!0),(V=e.textarea)==null||V.addEventListener("compositionend",M),(Y=e.attachCustomKeyEventHandler)==null||Y.call(e,$=>u()&&(ppe($)||mpe($))?!1:fpe($,{physicalKeyboardMode:u(),imeComposing:o})?(W($.key),!1):$.type!=="keydown"||$.key!=="Enter"?!0:d()==="linefeed"!==$.shiftKey?(v(`
642
- `),$.preventDefault(),!1):!0),{dispose:()=>{var $,P,q;B.dispose(),($=e.textarea)==null||$.removeEventListener("input",F),(P=e.textarea)==null||P.removeEventListener("compositionstart",O,!0),(q=e.textarea)==null||q.removeEventListener("compositionend",M),r&&(clearTimeout(r.timer),r=void 0),l&&(clearTimeout(l),l=void 0),p==null||p(),h==null||h(),w(),x()}}}function fj(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=t<0?1:Math.max(1,t+1),l=r?Math.max(0,s-o*e.cellH):0,u=Math.max(0,e.bufferLength-e.rows),d=u*e.cellH+i;if(i>0&&n>i&&e.cursorY!==void 0){const p=Math.max(0,Math.min(e.rows-1,e.cursorY)),y=u*e.cellH,v=y+n-i,_=y+p*e.cellH-(i-e.cellH)/2;return{spacerHeight:Math.max(y,Math.min(v,_))+i,spacerWidth:e.cols*e.cellW,hostWidth:e.cols*e.cellW,hostHeight:n,hostPaddingTop:l}}return{spacerHeight:Math.max(e.bufferLength*e.cellH,d),spacerWidth:e.cols*e.cellW,hostWidth:e.cols*e.cellW,hostHeight:n,hostPaddingTop:l}}function hE(e){const t=e.paddingTop+e.cursorBufferRow*e.cellH,n=e.containerScrollTop+e.paddingTop,r=e.containerScrollTop+e.containerClientHeight-e.paddingBottom,i=Math.max(1,e.atBottomThreshold),s=e.cellH>0&&t>=n-i&&t+e.cellH<=r+i,o=Math.max(0,e.containerScrollHeight-e.containerClientHeight),l=e.rows*e.cellH,u=e.cellH>0&&l>e.visibleContentHeight;let d,h;if(u){d=s;const p=t-e.paddingTop-(e.visibleContentHeight-e.cellH)/2,v=Math.max(0,e.bufferLength-e.rows)*e.cellH;h=Math.max(v,Math.min(o,p))}else d=e.containerScrollTop+e.containerClientHeight>=e.containerScrollHeight-e.atBottomThreshold,h=o;return{isAtBottom:d,bottomScrollTop:h,cursorInViewport:s}}function pj(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 B2(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 _pe(e,t){return t<=0?0:Math.max(0,e)*t}function wpe(){return{intent:!1,lastUserInputAt:null,unmarkedOriginLeft:null,lastSeenLeft:0,pendingFollowLeft:null}}function Spe(e,t){return{...e,intent:t,unmarkedOriginLeft:t?e.unmarkedOriginLeft:null}}function Mg(e,t){return{state:{...Spe(e,!1),lastUserInputAt:null,pendingFollowLeft:null,...t.scrollLeft!==void 0?{lastSeenLeft:t.scrollLeft}:{}},trace:e.intent?{kind:"clear",details:t.details}:null}}function xpe(e,t){return{state:{...e,intent:!0,lastUserInputAt:t.now,unmarkedOriginLeft:null},trace:e.intent?null:{kind:"set",details:t.details}}}function Epe(e,t){return{...e,pendingFollowLeft:t}}function Cpe(e,t){if(!t.hasOverflow)return{...Mg(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,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,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 kpe({syncingExternal:e,effectiveScrollTop:t,pendingFollowTop:n,pendingProgrammaticTop:r,atBottom:i,canPassiveFollow:s,tolerancePx:o=1}){if(e)return{action:"external-sync",nextPendingFollowTop:n,nextPendingProgrammaticTop:r};if(n!==null&&Math.abs(t-n)<=o)return{action:"programmatic-follow",nextPendingFollowTop:null,nextPendingProgrammaticTop:null};const u=r!==null&&Math.abs(t-r)<=o&&s;return!i&&u?{action:"programmatic-drift",nextPendingFollowTop:null,nextPendingProgrammaticTop:null}:{action:"continue",nextPendingFollowTop:null,nextPendingProgrammaticTop:null}}function Tpe(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 Rpe(e){return!(e.bottomScrollTop<e.domMaxScrollTop-1)||e.rawScrollTop<=e.bottomScrollTop+1?{action:"keep",scrollTop:e.rawScrollTop}:{action:"clamp",scrollTop:e.bottomScrollTop}}function Ape({container:e,term:t,onWheel:n,onTouchStart:r,onTouchMove:i,onTouchEnd:s,onTouchCancel:o,onContainerScroll:l,onTermScroll:u,onRender:d,onRelayout:h,onWriteParsed:p}){var x;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),v=t.onRender(d),_=p?(x=t.onWriteParsed)==null?void 0:x.call(t,p):void 0,w=new ResizeObserver(h);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(),v.dispose(),_==null||_.dispose(),w.disconnect()}}}function Npe({container:e,host:t,term:n,atBottomThreshold:r,getDims:i,getVerticalInsets:s,getPrevCursorBufferRow:o,getPendingProgrammaticScrollTop:l,getPendingFollowCursorScrollTop:u,getPendingFollowCursorScrollLeft:d,getPendingContainerSyncRetry:h,getHorizontalIntent:p,getVerticalIntent:y,getUserHasVerticalScrollIntent:v}){var T,H;let _=null,w=null;const x=()=>{var B;const D=document.activeElement;if(!D)return null;const W=D.getAttribute("aria-label")??"",U=D.tagName,F=typeof D.closest=="function"?((B=D.closest("[data-slot]"))==null?void 0:B.getAttribute("data-slot"))??"":"",O=D.id?`#${D.id}`:"",M=typeof D.className=="string"&&D.className?"."+D.className.split(/\s+/).filter(Boolean).slice(0,2).join("."):"";return W?`${W}|${U}${O}${M}{${F}}`:`${U}${O}${M}{${F}}`},E=(D,W={})=>{if(!dw())return;const U=e.getBoundingClientRect(),F=t.getBoundingClientRect(),O=window.visualViewport,{cellH:M,cellW:B}=i(),{paddingTop:L,paddingBottom:N}=s(),V=Math.max(0,e.clientHeight-L-N),Y=n.buffer.active,$=Y.baseY+Y.cursorY,P=hE({rows:n.rows,cellH:M,bufferLength:Y.length,cursorBufferRow:$,visibleContentHeight:V,paddingTop:L,paddingBottom:N,containerScrollTop:e.scrollTop,containerScrollHeight:e.scrollHeight,containerClientHeight:e.clientHeight,atBottomThreshold:r}),q=o(),K=q===null?null:$-q,z=W.cursorDeltaRows!==void 0?W.cursorDeltaRows:K,X=W.scrollDeltaToAnchor!==void 0?W.scrollDeltaToAnchor:e.scrollTop-P.bottomScrollTop,ee=Ws(t.style.top),te=M>0?pj({ydisp:Y.viewportY,rows:n.rows,cellH:M,visibleContentHeight:V}):0,Q=Ws(t.style.height),me=e.scrollTop,ve=me+e.clientHeight,Ce=ee+Q,Me=Math.max(0,Math.min(ve,Ce)-Math.max(me,ee)),Ve=y();yle({t:performance.now(),event:D,scope:W.scope,action:W.action,reason:W.reason,scrollTop:e.scrollTop,scrollLeft:e.scrollLeft,scrollHeight:e.scrollHeight,scrollWidth:e.scrollWidth,clientHeight:e.clientHeight,clientWidth:e.clientWidth,innerHeight:window.innerHeight,visualViewportHeight:O==null?void 0:O.height,visualViewportOffsetTop:O==null?void 0:O.offsetTop,containerTop:U.top,containerBottom:U.bottom,hostRectTop:F.top,hostRectBottom:F.bottom,viewportY:Y.viewportY,bufferLength:Y.length,hostTop:t.style.top,cellH:M,cellW:B,cursorX:Y.cursorX,cursorY:Y.cursorY,cursorBufferRow:$,cursorDeltaRows:z,cursorInViewport:P.cursorInViewport,anchorBottomScrollTop:P.bottomScrollTop,scrollDeltaToAnchor:X,pendingProgrammaticScrollTop:l(),pendingFollowCursorScrollTop:u(),pendingFollowCursorScrollLeft:d(),pendingContainerSyncRetry:h(),horizontalIntent:p(),intentMode:Ve.mode,intentSource:Ve.source,intentTransition:Ve.lastTransitionId,prevCursorBufferRow:q,hostTopDrift:ee-te,viewportHostCoverage:e.clientHeight>0?Me/e.clientHeight:0,focus:x(),atBottom:P.isAtBottom,touchActive:Ve.touchActive,userIntent:v(),...W})},k=D=>{if(!dw())return;const W=window.visualViewport;if(!W)return;const U=_===null?0:W.height-_,F=w===null?0:W.offsetTop-w;_=W.height,w=W.offsetTop,E(D,{vvHeightDelta:U,vvOffsetDelta:F})},R=()=>k("vv:resize"),A=()=>k("vv:scroll"),I=D=>{var B;if(!dw())return;const W=D.target,U=W===e||W instanceof Node&&e.contains(W),F=W&&typeof W.closest=="function"?((B=W.closest("[data-slot]"))==null?void 0:B.getAttribute("data-slot"))??"":"",O=(W==null?void 0:W.tagName)??"",M=W&&typeof W.className=="string"&&W.className?"."+W.className.split(/\s+/).filter(Boolean).slice(0,2).join("."):"";E(`wheel:window deltaY=${Math.round(D.deltaY)} reachesContainer=${U?1:0} prevented=${D.defaultPrevented?1:0} target=${O}${M}{${F}}`)};return(T=window.visualViewport)==null||T.addEventListener("resize",R),(H=window.visualViewport)==null||H.addEventListener("scroll",A),window.addEventListener("wheel",I,{passive:!0,capture:!0}),{trace:E,dispose:()=>{var D,W;(D=window.visualViewport)==null||D.removeEventListener("resize",R),(W=window.visualViewport)==null||W.removeEventListener("scroll",A),window.removeEventListener("wheel",I,{capture:!0})}}}function mj(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 Bw=e=>e.mode==="reviewing",wh=e=>e.mode==="following"&&!e.touchActive;function Mpe(e,t){return e==="following"&&t==="reviewing"?"set":e==="reviewing"&&t==="following"?"clear":"keep"}function Kr(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:Mpe(e.mode,t.mode),reason:n}}}function Sh(e,t,n,r){return{...e,mode:"reviewing",source:t,lastScrollTop:n,lastTransitionId:r}}function jw(e,t,n,r){return{...e,mode:"following",source:t,lastScrollTop:n,lastTransitionId:r}}function Ope(e){throw new Error(`Unhandled PTY vertical intent event: ${JSON.stringify(e)}`)}function Dpe(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)?Kr(e,{...o,mode:"following",source:"none",lastTransitionId:`${r}.bottom-down`},`scrollTop=${t.scrollTop} atBottom=true`):Kr(e,{...o,lastTransitionId:`${r}.not-bottom`},`scrollTop=${t.scrollTop} atBottom=${t.atCursorAwareBottom}`)}function Ppe(e,t,n={}){const r=n.atBottomThreshold??8;switch(t.type){case"attach":{const i=mj({initialIntent:t.initialIntent,scrollTop:t.scrollTop});return Kr(e,i,`initialIntent=${t.initialIntent}`)}case"scroll-to-bottom":return t.force?Kr(e,jw({...e,touchActive:!1,touchStartY:null,touchStartScrollTop:null,touchReviewNotified:!1},"programmatic-bottom",e.lastScrollTop,"bottom.force"),`reason=${t.reason} force=true`):Kr(e,{...e,lastTransitionId:`bottom.passive.${e.mode}`},`reason=${t.reason} force=false`);case"scroll-to-ratio":return Kr(e,Sh(e,"ratio-scroll",t.scrollTop,"ratio.reviewing"),`ratio=${t.ratio}`);case"wheel":return t.nextScrollTop===t.previousScrollTop?Kr(e,{...e,lastTransitionId:"wheel.clamped",lastScrollTop:t.nextScrollTop},`delta=${t.deltaY}`):t.deltaY<0?Kr(e,Sh(e,"wheel",t.nextScrollTop,"wheel.up"),`delta=${t.deltaY}`):t.deltaY>0&&t.reachedCursorAwareBottom?Kr(e,jw(e,"none",t.nextScrollTop,"wheel.down.bottom"),`delta=${t.deltaY}`):Kr(e,Sh(e,"wheel",t.nextScrollTop,"wheel.down.not-bottom"),`delta=${t.deltaY}`);case"container-scroll":return t.source!=="user"?Kr(e,{...e,lastScrollTop:t.scrollTop,lastTransitionId:`container.${t.source}`},`source=${t.source} scrollTop=${t.scrollTop}`):t.atCursorAwareBottom?t.verticalDelta>r&&e.mode==="reviewing"&&!e.touchActive?Kr(e,jw(e,"none",t.scrollTop,"container.user.bottom-down"),`delta=${t.verticalDelta} threshold=${r}`):Kr(e,{...e,lastScrollTop:t.scrollTop,lastTransitionId:"container.user.bottom-small-delta"},`delta=${t.verticalDelta} threshold=${r}`):Kr(e,Sh(e,"native-scroll",t.scrollTop,"container.user.away"),`scrollTop=${t.scrollTop} atBottom=false`);case"touch-start":return Kr(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?Kr(e,{...Sh(e,"touch",e.lastScrollTop,"touch.move.review"),touchReviewNotified:!0},`movement=${i} threshold=${t.reviewThresholdPx}`,!0):i>=t.reviewThresholdPx?Kr(e,{...e,lastTransitionId:"touch.move.reviewing"},`movement=${i} threshold=${t.reviewThresholdPx}`):Kr(e,{...e,lastTransitionId:"touch.move.below-threshold"},`movement=${i} threshold=${t.reviewThresholdPx}`)}case"touch-end":case"touch-cancel":return Dpe(e,t,r);default:return Ope(t)}}const Gr={bottom:{defaultThresholdPx:8},horizontal:{nativeIntentThresholdPx:48,cursorFollowRightMarginColumns:8},rawInput:{recentLayoutDriftMs:1e3},touch:{scrollJumpMinThresholdPx:512,hostTopJumpMinThresholdPx:64,gestureSlopPx:16,horizontalGestureSlopPx:6,horizontalLockRatio:1,verticalLockRatio:1.25,nativeScrollRecentMs:500}};function Lpe({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 Ipe({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 zpe({touchActive:e,touchStartScrollTop:t,touchStartY:n,currentY:r,touchStartedAtCursorAwareBottom:i,bottomScrollTop:s,domMaxScrollTop:o}){if(!e||t===null||n===null||r===null)return!1;const l=Math.min(o,s),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 Bpe({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 jpe({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 Fpe(){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 $pe(){return{startedAtCursorAwareBottom:!1,startClientX:null,startScrollLeft:null,lastClientY:null,lastGestureAt:null,lastHorizontalGestureAt:null,gestureMode:null}}function Hpe(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"}}function Upe(e,t){return{...e,lastGestureAt:t}}function j2(e,t){return{...e,lastHorizontalGestureAt:t}}function Wpe(e,t){return{...e,lastClientY:t.currentY,lastGestureAt:t.now}}function qpe(e,t){return!t.touchActive||e.gestureMode!==null||t.currentY===null?e:{...e,gestureMode:"pending"}}function F2(e,t){return e.gestureMode===t?e:{...e,gestureMode:t}}function Vpe(e){return{...e,startedAtCursorAwareBottom:!1,startClientX:null,startScrollLeft:null,lastClientY:null,gestureMode:null}}function Ype({container:e,atBottomThreshold:t,trace:n,getPageResumePending:r,getVerticalIntent:i,dispatchVerticalIntent:s,getCurrentAnchor:o,getLastSeenScrollTop:l,hasHorizontalOverflow:u,clearHorizontalIntentIfUnscrollable:d,markHorizontalUserInput:h,onTouchBoundaryPrevent:p,notifyAtBottom:y,flushPendingTouchScrollNotify:v}){let _=$pe();const w=D=>{const W=D??_.lastClientY,U=o(),F=Math.max(0,e.scrollHeight-e.clientHeight),O=i();return zpe({touchActive:O.touchActive,touchStartScrollTop:O.touchStartScrollTop,touchStartY:O.touchStartY,currentY:W,touchStartedAtCursorAwareBottom:_.startedAtCursorAwareBottom,bottomScrollTop:U.bottomScrollTop,domMaxScrollTop:F})},x=(D,W)=>Ipe({startX:_.startClientX,startY:i().touchStartY,currentX:D,currentY:W}),E=D=>{const W=Math.max(0,e.scrollWidth-e.clientWidth);return Bpe({touchActive:i().touchActive,touchStartClientX:_.startClientX,touchStartScrollLeft:_.startScrollLeft,currentX:D,maxScrollLeft:W})},k=(D,W,U,F,O)=>D?[`raw=${Math.round(W)}`,`effective=${Math.round(U)}`,`prev=${Math.round(F)}`,`delta=${Math.round(O)}`,`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)}`,`max=${Math.round(D.cursorAwareMaxScrollTop)}`].join(" "):null,R=D=>{var M;if(r()){n("touchstart:page-resume-pending");return}const W=((M=D.touches)==null?void 0:M[0])??null,U=(W==null?void 0:W.clientX)??null,F=(W==null?void 0:W.clientY)??null;d("touchstart");const O=o();_=Hpe(_,{startedAtCursorAwareBottom:O.isAtBottom,startClientX:U,startClientY:F,startScrollLeft:e.scrollLeft,now:performance.now()}),s({type:"touch-start",clientY:F,scrollTop:e.scrollTop}),n("touchstart",{details:[`startX=${U??"null"}`,`startY=${F??"null"}`,`startScroll=${Math.round(e.scrollTop)}`,`bottom=${Math.round(O.bottomScrollTop)}`,`atBottom=${O.isAtBottom?1:0}`].join(" ")})},A=D=>{var Y;if(r()){n("touchmove:page-resume-pending");return}const W=((Y=D.touches)==null?void 0:Y[0])??null,U=(W==null?void 0:W.clientX)??null,F=(W==null?void 0:W.clientY)??null,O=performance.now();_=Wpe(_,{currentY:F,now:O});const M=x(U,F);n("touchmove",{details:F===null?"currentY=null":k(w(F),e.scrollTop,e.scrollTop,l(),e.scrollTop-l())??[`mode=${_.gestureMode??"none"}`,`currentY=${Math.round(F)}`,M?`dx=${Math.round(M.dx)} dy=${Math.round(M.dy)} distance=${Math.round(M.distance)}`:null].filter(Boolean).join(" ")});const B=u();if(B||d("touchmove"),_=qpe(_,{touchActive:i().touchActive,currentY:F}),_.gestureMode==="pending"&&M){const $=B&&M.absDx>=Gr.touch.horizontalGestureSlopPx&&M.absDx>M.absDy*Gr.touch.horizontalLockRatio,P=M.absDy>=Gr.touch.gestureSlopPx&&(!B||M.absDy>M.absDx*Gr.touch.verticalLockRatio);if($)_=F2(_,"horizontal"),_=j2(_,O),n("touchmove:horizontal-lock",{details:`dx=${Math.round(M.dx)} dy=${Math.round(M.dy)} distance=${Math.round(M.distance)}`});else if(P)_=F2(_,"vertical"),n("touchmove:vertical-lock",{details:`dx=${Math.round(M.dx)} dy=${Math.round(M.dy)} distance=${Math.round(M.distance)} threshold=${Gr.touch.gestureSlopPx}`});else{n("touchmove:pending",{details:[`dx=${Math.round(M.dx)}`,`dy=${Math.round(M.dy)}`,`distance=${Math.round(M.distance)}`,`hThreshold=${Gr.touch.horizontalGestureSlopPx}`,`vThreshold=${Gr.touch.gestureSlopPx}`].join(" ")}),M.absDy<Gr.touch.gestureSlopPx&&s({type:"touch-move",clientY:F,reviewThresholdPx:Gr.touch.gestureSlopPx});return}}if(_.gestureMode==="horizontal"){const $=E(U);if(!B||!$){d("touchmove-horizontal"),n("touchmove:horizontal-native",{details:M?`blocked dx=${Math.round(M.dx)} dy=${Math.round(M.dy)} distance=${Math.round(M.distance)}`:"blocked movement=null"});return}M&&(_=j2(_,O),h(`site=touchmove-horizontal dx=${Math.round(M.absDx)} dy=${Math.round(M.absDy)}`)),n("touchmove:horizontal-native",{details:[`scrollLeft=${Math.round(e.scrollLeft)}`,`expected=${Math.round($.expectedScrollLeft)}`,`startScrollLeft=${Math.round($.touchStartScrollLeft)}`,`startX=${Math.round($.touchStartX)}`,`currentX=${Math.round($.currentX)}`,`touchDeltaX=${Math.round($.touchDeltaX)}`,`max=${Math.round($.maxScrollLeft)}`].join(" ")});return}if(_.gestureMode!=="vertical")return;const L=w(F);if(L&&n("touchmove:vertical-native",{details:[`scrollTop=${Math.round(e.scrollTop)}`,`expected=${Math.round(L.expectedScrollTop)}`,`startScroll=${Math.round(L.touchStartScrollTop)}`,`base=${Math.round(L.gestureBaseScrollTop)}`,`startY=${Math.round(L.touchStartY)}`,`currentY=${Math.round(L.currentY)}`,`touchDeltaY=${Math.round(L.touchDeltaY)}`].join(" ")}),L&&_.startedAtCursorAwareBottom&&L.expectedScrollTop>=L.cursorAwareMaxScrollTop-t&&F!==null&&F<=L.touchStartY){n("touchmove:bottom-boundary-follow");return}s({type:"touch-move",clientY:F,reviewThresholdPx:Gr.touch.gestureSlopPx}).notifyTouchReviewStart&&(p==null||p(),n("touchmove:review"))},I=D=>{const W=e.scrollTop,U=o(),F=jpe({touchStartScrollTop:i().touchStartScrollTop,liveScrollTop:W,atBottomThreshold:t,touchStartedAtCursorAwareBottom:_.startedAtCursorAwareBottom,anchorIsAtBottom:U.isAtBottom,reviewedDuringTouch:i().touchReviewNotified});_=Vpe(_),s({type:D,scrollTop:W,atCursorAwareBottom:F.atCursorAwareBottomForIntent,releaseOnSemanticBottom:F.releaseOnSemanticBottom}),_=Upe(_,performance.now()),v(),y()};return{onTouchStart:R,onTouchMove:A,onTouchEnd:()=>{if(r()){n("touchend:page-resume-pending");return}I("touch-end"),n("touchend")},onTouchCancel:()=>{if(r()){n("touchcancel:page-resume-pending");return}I("touch-cancel"),n("touchcancel")},isRecentNativeScroll:()=>i().touchActive||_.lastGestureAt!==null&&performance.now()-_.lastGestureAt<=Gr.touch.nativeScrollRecentMs,isRecentHorizontalGesture:()=>_.lastHorizontalGestureAt!==null&&performance.now()-_.lastHorizontalGestureAt<=Gr.touch.nativeScrollRecentMs,getScrollExpectation:w,describeScrollExpectation:k,getState:()=>_}}function fE(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 Kpe(e,t){for(let n=t-1;n>=0;n--){const r=e.viewportY+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}function Gpe(e){const{container:t,spacer:n,host:r,term:i,hasNewFrame:s,consumeNewFrame:o,hasNewFramesWhileAway:l,setNewFramesWhileAway:u,onAtBottomChange:d,onScrollStateChange:h,initialUserHasVerticalScrollIntent:p=!1,onUserVerticalScrollIntentChange:y,onTouchReviewStart:v,onTouchBoundaryPrevent:_,onReviewSnapshotCapture:w,onReviewSnapshotClear:x,atBottomThreshold:E=Gr.bottom.defaultThresholdPx}=e,k=()=>fE(r,i)??{cellH:0,cellW:0},R=()=>{const se=getComputedStyle(t);return{paddingTop:Ws(se.paddingTop),paddingBottom:Ws(se.paddingBottom)}},A=Fpe(),I=(se,fe,Oe)=>{A.set(se,fe,Oe)},T={external:!1,internal:!1};let H=null,D="",W=mj({initialIntent:p,scrollTop:t.scrollTop}),U=null,F=null,O=!1,M=null,B=wpe(),L=0,N=!1,V=null,Y=null,$=null,P=null,q=p,K=!1,z=null;const X=()=>Bw(W),ee=()=>X()&&K,te=Npe({container:t,host:r,term:i,atBottomThreshold:E,getDims:k,getVerticalInsets:R,getPrevCursorBufferRow:()=>V,getPendingProgrammaticScrollTop:()=>U,getPendingFollowCursorScrollTop:()=>M,getPendingFollowCursorScrollLeft:()=>B.pendingFollowLeft,getPendingContainerSyncRetry:()=>O,getHorizontalIntent:()=>B.intent,getVerticalIntent:()=>W,getUserHasVerticalScrollIntent:()=>X()}),Q=te.trace,me=se=>{if(se){if(se.kind==="ignore"){Q("horizontal-intent:ignore",{details:se.details});return}Q(`horizontal-intent:${se.kind}`,{details:se.details})}},ve=()=>t.scrollWidth>t.clientWidth+E,Ce=se=>{if(ve())return!1;const fe=Mg(B,{details:`site=${se} reason=not-scrollable scrollWidth=${t.scrollWidth} clientWidth=${t.clientWidth}`,scrollLeft:t.scrollLeft});return B=fe.state,me(fe.trace),t.scrollLeft!==0&&(t.scrollLeft=0,B={...B,lastSeenLeft:0}),!0},Me=se=>{if(!ve()){Ce("markHorizontalUserInput");return}const fe=xpe(B,{now:performance.now(),details:se});B=fe.state,me(fe.trace)},Ve=()=>({scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,scrollHeight:t.scrollHeight,scrollWidth:t.scrollWidth,clientHeight:t.clientHeight,clientWidth:t.clientWidth,scrollable:t.scrollHeight>t.clientHeight+E,horizontalScrollable:ve()}),Qe=()=>{if(!h)return;const se=Ve(),fe=[se.scrollTop,se.scrollLeft,se.scrollHeight,se.scrollWidth,se.clientHeight,se.clientWidth,se.scrollable,se.horizontalScrollable].join(":");fe!==D&&(D=fe,h(se))},ct=()=>{const{cellH:se}=k(),{paddingTop:fe,paddingBottom:Oe}=R(),Ue=i.buffer.active;return hE({rows:i.rows,cellH:se,bufferLength:Ue.length,cursorBufferRow:Ue.baseY+Ue.cursorY,visibleContentHeight:Math.max(0,t.clientHeight-fe-Oe),paddingTop:fe,paddingBottom:Oe,containerScrollTop:t.scrollTop,containerScrollHeight:t.scrollHeight,containerClientHeight:t.clientHeight,atBottomThreshold:E})},Ot=()=>{const se=ct().isAtBottom;H!==se&&(H=se,d==null||d(se))},he=()=>{Ot(),Qe()},Ke=()=>W.touchActive,Rt=()=>{$!==null&&(P==null||P($),$=null,P=null)},ye=()=>{if($!==null)return;const se=()=>{$=null,P=null,he()};if(typeof window.requestAnimationFrame=="function"){$=window.requestAnimationFrame(se),P=typeof window.cancelAnimationFrame=="function"?fe=>window.cancelAnimationFrame(fe):null;return}$=window.setTimeout(se,16),P=fe=>window.clearTimeout(fe)},He=()=>{$!==null&&(Rt(),he())},Ge=(se="rawInput")=>{Y=performance.now(),Q(`rawInputFollow:scheduled[${se}]`)},be=()=>{Y=performance.now(),Q("rawInputFollow:fire")},Xe=se=>{const fe=(w==null?void 0:w(se,i.rows))===!0;return fe&&(K=!0),fe},rt=()=>{if(!X()||!q)return;const{cellH:se}=k();if(!(se<=0)){if(!z){const fe=Bt(t.scrollTop,se);z={scrollTop:t.scrollTop,ydisp:fe,cellH:se};const Oe=Xe(fe);q=!Oe,Oe||(z=null);return}q=!Xe(_e(t.scrollTop,se))}},pt=()=>{q=!0,rt()},le=se=>{const fe=Bw(W),Oe=Ppe(W,se,{atBottomThreshold:E});W=Oe.state,Oe.trace&&Q(`intent:${Oe.trace.action}`,{details:`id=${Oe.trace.id} reason=${Oe.trace.reason}`});const Ue=Bw(W);if(fe!==Ue)if(y==null||y(Ue),Ue){q=!0;const{cellH:ft}=k();if(ft>0){const gt=Bt(t.scrollTop,ft);z={scrollTop:t.scrollTop,ydisp:gt,cellH:ft};const kt=Xe(gt);q=!kt,kt||(z=null)}}else q=!1,K=!1,z=null,x==null||x();return Oe.notifyTouchReviewStart&&(v==null||v()),Oe},Ae=(se,fe,Oe)=>{if(fe<=0)return;const Ue=Oe??(()=>{const{paddingTop:Tt,paddingBottom:Ht}=R();return Math.max(0,t.clientHeight-Tt-Ht)})(),ft=pj({ydisp:se,rows:i.rows,cellH:fe,visibleContentHeight:Ue}),gt=r.style.top,kt=`${ft}px`;I(r,"position","absolute"),I(r,"left","0px"),I(r,"top",kt),gt!==kt&&Q("host-position",{ydisp:se,details:`${gt||"0px"}->${kt}`})},Ze=(se="internal",fe={})=>{const Oe=Math.max(0,i.buffer.active.length-i.rows),Ue=ct(),ft=Tpe({force:fe.force??!1,reviewing:X()||W.touchActive,viewportY:i.buffer.active.viewportY,expectedYdisp:Oe,scrollTop:t.scrollTop,bottomScrollTop:Ue.bottomScrollTop,atBottom:Ue.isAtBottom}).action;if(ft==="blocked-by-review")return;if(ft==="noop"){O=!1;return}Q(`scroll-to-bottom:start[${se}]`),le({type:"scroll-to-bottom",force:fe.force??!1,reason:se});const gt=Math.max(0,i.buffer.active.length-i.rows);T.internal=!0;try{i.scrollToLine(gt)}finally{T.internal=!1}const{cellH:kt}=k();kt!==0&&Ae(gt,kt);const Tt=ct().bottomScrollTop;t.scrollTop=Tt,U=Tt,V=i.buffer.active.baseY+i.buffer.active.cursorY,he(),O=!1,Q("scroll-to-bottom:end",{ydisp:gt})},tt=()=>{N=!0,Q("page-resume:prepare-follow"),X()&&le({type:"scroll-to-bottom",force:!0,reason:"pageResumePrepare"})},dt=()=>{tt(),ze(),Ze("pageResume",{force:!0}),vn("pageResume"),N=!1},Dt=se=>{Q("scroll-to-ratio:start");const fe=Math.max(0,t.scrollHeight-t.clientHeight),Oe=Math.max(0,Math.min(1,se)),Ue=fe*Oe;le({type:"scroll-to-ratio",ratio:Oe,scrollTop:Ue}),q=!0,t.scrollTop=Ue,Be()},Wt=se=>{if(se===0)return;Q("wheel");const fe=Math.max(0,t.scrollHeight-t.clientHeight),Oe=Math.min(fe,ct().bottomScrollTop);if(Oe<=0){Q("wheel:max-zero");return}const Ue=t.scrollTop,ft=Math.max(0,Math.min(Oe,Ue+se));if(ft===Ue){Q("wheel:clamped"),he();return}q=!0,t.scrollTop=ft,L=ft,Be(),le({type:"wheel",deltaY:se,previousScrollTop:Ue,nextScrollTop:ft,reachedCursorAwareBottom:ft>Ue&&ft>=Oe-E&&ct().isAtBottom})},tn=se=>{if(!ve()){Ce("scrollToXRatio"),he();return}const fe=Math.max(0,t.scrollWidth-t.clientWidth),Oe=Math.max(0,Math.min(1,se));t.scrollLeft=fe*Oe,Me(`site=scrollToXRatio ratio=${Oe}`),B={...B,lastSeenLeft:t.scrollLeft},he()},vn=(se="external",fe={})=>{const Oe=t.scrollLeft,Ue=Mg(B,{details:`site=resetHorizontalScroll reason=${se}`,scrollLeft:0});B=Ue.state,me(Ue.trace),Oe!==0&&(t.scrollLeft=0),fe.holdUntilCursorVisible&&Me(`site=resetHorizontalScroll-hold reason=${se}`),Q(`horizontal-scroll-reset[${se}]`,{details:`scrollLeft=${Oe}->${t.scrollLeft}`}),he()},un=(se="external")=>{Me(`site=${se}`)};let Zt=0,Xn=null,Kt=-1;const Zn=()=>{const se=i.buffer.active,fe=`${Zt}:${se.viewportY}:${se.length}:${i.rows}`;return fe===Xn||(Kt=Kpe(se,i.rows),Xn=fe),Kt},ze=()=>{const{cellH:se,cellW:fe}=k();if(se===0||fe===0)return;const{paddingTop:Oe,paddingBottom:Ue}=R(),ft=Math.max(0,t.clientHeight-Oe-Ue),gt=i.buffer.active,kt=Zn(),Tt=fj({bufferLength:gt.length,rows:i.rows,cols:i.cols,viewportY:gt.viewportY,cursorY:gt.cursorY,cellH:se,cellW:fe,visibleContentHeight:ft},kt);Tt&&(I(n,"overflow","hidden"),I(n,"height",`${Tt.spacerHeight}px`),I(n,"width",`${Tt.spacerWidth}px`),I(r,"width",`${Tt.hostWidth}px`),I(r,"height",`${Tt.hostHeight}px`),I(r,"paddingTop",`${Tt.hostPaddingTop}px`),F=performance.now(),ee()||Ae(gt.viewportY,se,ft))},et=(se,fe,Oe={})=>{if(se===i.buffer.active.viewportY){Oe.deferHostUntilRender||Ae(se,fe);return}T.internal=!0;try{if(Oe.deferHostUntilRender){i.scrollToLine(se);return}Ae(se,fe),i.scrollToLine(se)}finally{T.internal=!1}},Et=()=>s()?W.touchActive&&!X()?"deferred":(o(),wh(W)?(Ze("pendingFrame"),"followed"):(l()||u(!0),"marked")):"none";function Bt(se,fe){const Oe=i.buffer.active;return B2(se,{bufferLength:Oe.length,rows:i.rows,cols:i.cols,viewportY:Oe.viewportY,cellH:fe}).ydisp}function J(se){!X()||!z||z.cellH!==se&&(z={scrollTop:t.scrollTop,ydisp:z.ydisp,cellH:se})}function _e(se,fe){if(J(fe),!z)return Bt(se,fe);const Oe=Math.max(0,i.buffer.active.length-i.rows),Ue=Math.floor((se-z.scrollTop)/fe);return Math.max(0,Math.min(Oe,z.ydisp+Ue))}const Be=(se={})=>{Rt(),Q("container-sync:start");const{cellH:fe}=k();if(fe===0){O=!0;return}O=!1;const Oe=_e(t.scrollTop,fe),Ue=X();Ue&&(q||!K)&&Xe(Oe)&&(q=!1),et(Oe,fe,{deferHostUntilRender:(se.deferHostUntilRender??Ke())&&!(Ue&&K)}),he(),Q("container-sync:end",{ydisp:Oe})},ht=()=>W.touchActive||ie.isRecentNativeScroll(),jt=se=>{if(!ht())return!1;const{cellH:fe}=k();if(fe===0)return!1;const Oe=_e(se,fe);return Oe!==i.buffer.active.viewportY?!1:(ye(),Q("container-sync:skip[same-row-touch]",{ydisp:Oe,details:`scrollTop=${Math.round(se)} viewportY=${i.buffer.active.viewportY}`}),!0)},re=se=>{const fe=Math.max(0,t.scrollHeight-t.clientHeight),Oe=ct(),Ue=Rpe({rawScrollTop:se,bottomScrollTop:Oe.bottomScrollTop,domMaxScrollTop:fe});return Ue.action==="keep"||(Q("container-scroll:clamp-cursor-bottom",{details:`prev=${se} next=${Ue.scrollTop} domMax=${fe}`}),t.scrollTop=Ue.scrollTop,U=null,M=null),Ue.scrollTop},ie=Ype({container:t,atBottomThreshold:E,trace:Q,getPageResumePending:()=>N,getVerticalIntent:()=>W,dispatchVerticalIntent:le,getCurrentAnchor:ct,getLastSeenScrollTop:()=>L,hasHorizontalOverflow:ve,clearHorizontalIntentIfUnscrollable:Ce,markHorizontalUserInput:Me,onTouchBoundaryPrevent:_,notifyAtBottom:Ot,flushPendingTouchScrollNotify:He}),de=()=>B.intent?ie.getState().gestureMode==="horizontal"||ie.isRecentHorizontalGesture():!1,pe=se=>{const fe=ie.getScrollExpectation();if(!fe)return!1;const{touchStartScrollTop:Oe,touchStartY:Ue,currentY:ft,gestureBaseScrollTop:gt,expectedScrollTop:kt}=fe,Tt=Math.abs(ft-Ue)>.5,Ht=se<=E&&gt>t.clientHeight,yn=parseFloat(r.style.top||"0"),oi=ct(),fn=ie.getState().startedAtCursorAwareBottom&&Number.isFinite(yn)&&Math.abs(se-yn)<=E&&Math.abs(oi.bottomScrollTop-yn)<=t.clientHeight+E&&Math.abs(kt-se)>Gr.touch.hostTopJumpMinThresholdPx;if(!Tt&&!Ht&&!fn)return!1;const $e=Math.max(Gr.touch.scrollJumpMinThresholdPx,t.clientHeight*1.25);return!fn&&Math.abs(se-kt)<=$e?!1:(Q("container-scroll:restore-touch-impossible-jump",{details:[`scrollTop=${Math.round(se)}`,`expected=${Math.round(kt)}`,`diff=${Math.round(se-kt)}`,`threshold=${Math.round($e)}`,`touchStart=${Math.round(Oe)}`,fn?"hostTop=1":null,`startY=${Math.round(Ue)}`,`currentY=${Math.round(ft)}`].filter(Boolean).join(" ")}),t.scrollTop=kt,L=kt,Be({deferHostUntilRender:!0}),!0)},Z=(se,fe,Oe)=>{if(fe||W.touchActive||!wh(W)||!(Y!==null&&performance.now()-Y<=Gr.rawInput.recentLayoutDriftMs))return!1;const ft=ct();return Q("container-scroll:restore-raw-input-layout-bottom",{details:`scrollTop=${se} bottom=${ft.bottomScrollTop}`}),le({type:"container-scroll",source:"programmatic-bottom",scrollTop:se,atCursorAwareBottom:fe,verticalDelta:Oe}),Ze("rawInputLayoutDrift"),!0},ne=()=>{Q("container-scroll");const se=Cpe(B,{hasOverflow:ve(),scrollLeft:t.scrollLeft,now:performance.now(),nativeIntentThresholdPx:Gr.horizontal.nativeIntentThresholdPx});B=se.state,me(se.trace),se.resetScrollLeft&&(t.scrollLeft=0);const fe=t.scrollTop,Oe=L,Ue=fe-L,ft=re(fe);if(W.touchActive){const Tt=ie.getScrollExpectation();Q("container-scroll:touch-active",{details:ie.describeScrollExpectation(Tt,fe,ft,Oe,Ue)??`raw=${Math.round(fe)} effective=${Math.round(ft)}`})}L=ft;const gt=kpe({syncingExternal:T.external,effectiveScrollTop:ft,pendingFollowTop:M,pendingProgrammaticTop:U,atBottom:ct().isAtBottom,canPassiveFollow:wh(W)});if(M=gt.nextPendingFollowTop,U=gt.nextPendingProgrammaticTop,gt.action==="external-sync"){le({type:"container-scroll",source:"external-sync",scrollTop:ft,atCursorAwareBottom:ct().isAtBottom,verticalDelta:Ue}),he();return}if(gt.action==="programmatic-follow"){le({type:"container-scroll",source:"programmatic-follow",scrollTop:ft,atCursorAwareBottom:ct().isAtBottom,verticalDelta:Ue}),he();return}const kt=ct().isAtBottom;if(gt.action==="programmatic-drift"){le({type:"container-scroll",source:"programmatic-bottom",scrollTop:ft,atCursorAwareBottom:kt,verticalDelta:Ue}),Ze("programmaticDrift");return}if(!pe(ft)&&!Z(ft,kt,Ue)){if(N){Q("container-scroll:page-resume-pending",{details:`scrollTop=${ft} bottom=${ct().bottomScrollTop}`}),le({type:"container-scroll",source:"programmatic-bottom",scrollTop:ft,atCursorAwareBottom:kt,verticalDelta:Ue}),Be();return}le({type:"container-scroll",source:"user",scrollTop:ft,atCursorAwareBottom:kt,verticalDelta:Ue}),X()&&Ue!==0&&(q=!0),!jt(ft)&&Be()}},ae=()=>{if(Q("term-scroll"),!T.internal){T.external=!0;try{ze();const se=Et();if(se==="followed")return;if(se==="none"&&wh(W)){Ze("termScroll");return}if(ee()){se==="marked"&&ct().cursorInViewport&&(q=!0),he();return}const{cellH:fe}=k();if(fe!==0){const Oe=i.buffer.active,{ydisp:Ue}=B2(t.scrollTop,{bufferLength:Oe.length,rows:i.rows,cols:i.cols,viewportY:Oe.viewportY,cellH:fe,cellW:1});et(Ue,fe)}he()}finally{T.external=!1}}},Te=()=>{ze();const se=Et();if(se==="followed")return;if(se==="none"&&wh(W)){Ze("relayout");return}if(ee()){he();return}const{cellH:fe}=k();if(fe!==0)if(O)Q("pending-sync-retry-fire"),Be();else{const Oe=_e(t.scrollTop,fe),Ue=_pe(i.buffer.active.viewportY,fe);Oe!==i.buffer.active.viewportY?t.scrollTop=Ue:Math.abs(t.scrollTop-Ue)>1&&Q("relayout:preserve-host-offset",{details:`scrollTop=${Math.round(t.scrollTop)} viewportTop=${Math.round(Ue)} ydisp=${Oe}`}),Ae(i.buffer.active.viewportY,fe)}he()},je=()=>{const{cellH:se}=k(),{paddingTop:fe,paddingBottom:Oe}=R(),Ue=Math.max(0,t.clientHeight-fe-Oe),ft=i.buffer.active,gt=ft.baseY+ft.cursorY,kt=V,Tt=ct(),Ht=Lpe({reviewing:X()||W.touchActive,cellH:se,rows:i.rows,visibleContentHeight:Ue,cursorBufferRow:gt,prevCursorBufferRow:V,cursorInViewport:Tt.cursorInViewport,targetScrollTop:Tt.bottomScrollTop,currentScrollTop:t.scrollTop});if(Ht.reason==="intent"){V=Ht.nextPrevCursorBufferRow,Q("followCursorY:skip",{details:Ht.reason});return}if(Ht.reason==="cellH=0"){Q("followCursorY:skip",{details:Ht.reason});return}if(Ht.reason==="shortHost"){V=Ht.nextPrevCursorBufferRow,Q("followCursorY:skip",{details:Ht.reason});return}if(Ht.reason==="same-row"){Q("followCursorY:skip[same-row]",{cursorDeltaRows:Ht.cursorDeltaRows,details:`cursorRow=${gt} same-row`});return}if(V=Ht.nextPrevCursorBufferRow,Ht.reason==="inViewport"){Q("followCursorY:skip",{cursorDeltaRows:Ht.cursorDeltaRows,details:`cursorRow=${kt??"null"}->${gt} inViewport`});return}if(Ht.reason==="aligned"){Q("followCursorY:skip",{cursorDeltaRows:Ht.cursorDeltaRows,details:`cursorRow=${kt??"null"}->${gt} aligned`});return}if(Ht.action!=="follow")return;M=Ht.targetScrollTop;const yn=t.scrollTop;t.scrollTop=Ht.targetScrollTop,Q("followCursorY:hit",{cursorDeltaRows:Ht.cursorDeltaRows,scrollDeltaToAnchor:yn-Ht.targetScrollTop,details:`cursorRow=${kt??"null"}->${gt} scrollTop=${Math.round(yn)}->${Math.round(Ht.targetScrollTop)}`})},st=()=>{if(!ve()){Ce("followCursorX");return}const{cellW:se}=k();if(se<=0)return;const fe=i.buffer.active.cursorX*se,Oe=t.scrollLeft,Ue=Oe+t.clientWidth;if(fe>=Oe&&fe<=Ue){if(de()){Q("followCursorX:skip",{details:`horizontalTouchIntent cursorPx=${fe} viewport=${Oe}..${Ue}`});return}const rr=Mg(B,{details:`site=followCursorX cursorPx=${fe} viewport=${Oe}..${Ue}`,scrollLeft:t.scrollLeft});if(B=rr.state,me(rr.trace),rr.trace){Q("followCursorX:skip",{details:"cursorInViewport"});return}}if(B.intent){Q("followCursorX:skip",{details:`horizontalIntent cursorPx=${fe} viewport=${Oe}..${Ue}`});return}const gt=Math.min(t.clientWidth/2,Gr.horizontal.cursorFollowRightMarginColumns*se),kt=Ue-gt;if(!(fe<Oe||fe>=kt)){Q("followCursorX:skip",{details:`cursorSafe cursorPx=${fe} viewport=${Oe}..${Ue} rightBoundary=${kt}`});return}const Ht=Math.max(0,fe-t.clientWidth/2),yn=Math.max(0,t.scrollWidth-t.clientWidth),oi=Math.min(yn,Ht);B=Epe(B,oi),t.scrollLeft=oi,Q("followCursorX:hit",{details:`cursorPx=${fe} viewport=${Oe}..${Ue} rightBoundary=${kt} target=${oi}`})},ue=()=>{Q("render"),ze(),O&&(Q("pending-sync-retry-fire"),Be());const se=Et();st(),je(),X()&&(se==="marked"&&ct().cursorInViewport&&(q=!0),rt()),he()};ze(),X()?he():Ze("init");const ke=Ape({container:t,term:i,onWheel:se=>{ve()&&Math.abs(se.deltaX)>0&&Math.abs(se.deltaX)>=Math.abs(se.deltaY)&&Me(`site=wheel deltaX=${se.deltaX}`),se.deltaY!==0&&(Q("wheel:enter"),se.preventDefault(),se.stopPropagation(),Wt(se.deltaY))},onTouchStart:ie.onTouchStart,onTouchMove:ie.onTouchMove,onTouchEnd:()=>{ie.onTouchEnd(),Te()},onTouchCancel:()=>{ie.onTouchCancel(),Te()},onContainerScroll:ne,onTermScroll:ae,onRender:ue,onRelayout:Te,onWriteParsed:()=>{Zt+=1}});return{dispose:()=>{ke.dispose(),te.dispose(),Rt(),x==null||x()},relayout:Te,scrollToBottom:Ze,preparePageResumeRestore:tt,restorePageResume:dt,scrollToRatio:Dt,scrollToXRatio:tn,resetHorizontalScroll:vn,markHorizontalScrollIntent:un,traceRawInputFollowScheduled:Ge,traceRawInputFollowFire:be,refreshReviewSnapshot:pt,getDebugProbe:()=>{const{cellH:se,cellW:fe}=k(),{paddingTop:Oe,paddingBottom:Ue}=R();return{cellH:se,cellW:fe,paddingTop:Oe,paddingBottom:Ue,canvasLastY:se>0&&fe>0?Zn():-1,userHasVerticalScrollIntent:X(),verticalIntentMode:W.mode,verticalIntentSource:W.source,verticalIntentTransitionId:W.lastTransitionId,userHasHorizontalScrollIntent:B.intent,pendingProgrammaticScrollTop:U,pendingFollowCursorScrollTop:M,pendingFollowCursorScrollLeft:B.pendingFollowLeft,prevCursorBufferRow:V,lastSeenScrollTop:L,lastSeenScrollLeft:B.lastSeenLeft,touchScrollActive:W.touchActive,touchScrollGestureMode:ie.getState().gestureMode,syncingInternal:T.internal,syncingExternal:T.external,atBottomThreshold:E,lastSpacerUpdateAt:F,pendingContainerSyncRetry:O}}}}function Xpe(e,t={}){const{onFramePending:n,onFrameWritten:r,schedule:i=v=>requestAnimationFrame(v),cancel:s=v=>cancelAnimationFrame(v)}=t;let o=null,l=!1,u=[],d=[];const h=()=>{u=[],d=[],o!==null&&(s(o),o=null)},p=()=>{if(o=null,l||u.length===0)return;const v=u,_=d;u=[],d=[];const w=v.reduce((k,R)=>k+R.byteLength,0),x=new Uint8Array(w);let E=0;for(const k of v)x.set(k,E),E+=k.byteLength;e.write(x,()=>{for(const k of _)k();r==null||r()})},y=()=>{l||o!==null||u.length===0||(o=i(p))};return{target:{reset:()=>{h(),e.reset()},resize:(v,_)=>e.resize(v,_),write:(v,_)=>{if(typeof v=="string"){e.write(v,_);return}const w=u.length===0;u.push(v),_&&d.push(_),w&&(n==null||n()),y()}},clear:h,dispose:()=>{l=!0,h()}}}const $2=5e3,Zpe=1e3;function Qpe(){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 Jpe=Qpe();let eme=0;function tme(e={}){let t=0;const n=`${Jpe}-${++eme}`,r=e.requestIdFactory??(()=>`pty-snapshot-${n}-${++t}`);let i=null,s=!1,o=[];const l=new Map;let u=0,d=0;const h=p=>{let y=0,v=u+1;for(;l.has(v);){const _=l.get(v);l.delete(v),u=v,p.write(_),y+=1,v+=1}return y};return{startSnapshotRequest(){const p=r();return i=p,s=!1,o=[],l.clear(),d+=1,p},hasAppliedSnapshot(){return s},hasPendingGap(){return s&&l.size>0},handleBinaryFrame(p,y){if(!s)return o.push(p),o.length>$2&&o.splice(0,o.length-$2),{written:!1,hasGap:!1};if(p.outputSeq<=u)return{written:!1,hasGap:!1};if(l.set(p.outputSeq,p.data),l.size>Zpe){const _=l.keys().next().value;_!==void 0&&l.delete(_)}return{written:h(y)>0,hasGap:l.size>0}},applySnapshot(p,y,v){if(!i)return{applied:!1,reason:"no_active_request"};if(p.requestId!==i)return{applied:!1,reason:"stale_snapshot"};const _=o;o=[],l.clear(),i=null,s=!0,u=p.outputSeq,d+=1;const w=d,x=_.filter(E=>E.outputSeq>p.outputSeq).sort((E,k)=>E.outputSeq-k.outputSeq);return y.reset(),y.resize(p.cols,p.rows),y.write(p.data,()=>{if(w===d){for(const E of x)l.set(E.outputSeq,E.data);h(y),v==null||v(l.size>0)}}),{applied:!0,replayedFrames:x.length}}}}function nme(e){const{sessionId:t,ws:n,relay:r,target:i,retryDelayMs:s=3e4,slowNoticeDelayMs:o=1e4,gapRecoveryDelayMs:l=2e3,scheduleReady:u=$=>requestAnimationFrame($),scheduleFrameFlush:d,cancelFrameFlush:h,onFramePending:p,onFrameWritten:y,onReady:v,onSubscribeDelayed:_,onSubscribeStarted:w,onGapRecovery:x}=e,E=tme(),R=Xpe({reset:()=>i.reset(),resize:($,P)=>i.resize($,P),write:($,P)=>{i.write($,()=>{$ instanceof Uint8Array&&Moe(t,$.byteLength),P==null||P()})}},{onFramePending:p,onFrameWritten:y,schedule:d,cancel:h});let A=!1,I=null,T=null,H=null,D=!1;const W=()=>{I&&(clearTimeout(I),I=null)},U=()=>{T&&(clearTimeout(T),T=null)},F=()=>{H&&(clearTimeout(H),H=null)},O=()=>{H||(H=setTimeout(()=>{H=null,!(A||!E.hasPendingGap())&&(x==null||x(),N())},l))},M=()=>{const $=E.startSnapshotRequest();n.send(JSON.stringify({type:"session_subscribe",sessionId:t,requestId:$}))},B=()=>{I=setTimeout(()=>{I=null,!(A||E.hasAppliedSnapshot())&&(M(),B())},s)},L=()=>{T=setTimeout(()=>{T=null,!(A||E.hasAppliedSnapshot()||D)&&(D=!0,_==null||_())},o)},N=()=>{A||(W(),U(),F(),R.clear(),D=!1,w==null||w(),M(),B(),L())},V=n.subscribeBinary(t,($,P)=>{if(A)return;Noe(t,$,P),E.handleBinaryFrame({data:$,outputSeq:P},R.target).hasGap?O():F()}),Y=r.onMessage($=>{if(A||$.sessionId!==t)return;if($.type==="terminal_resize"){R.target.resize($.cols,$.rows),N();return}$.type!=="session_snapshot"||!E.applySnapshot({requestId:$.requestId,cols:$.cols,rows:$.rows,data:$.data,outputSeq:$.outputSeq},R.target,q=>{A||(q?O():F())}).applied||(W(),U(),u(()=>{A||v==null||v()}))});return N(),{dispose:()=>{A=!0,W(),U(),F(),R.dispose(),V(),Y()}}}function rme(e){const{host:t,sessionId:n,ws:r,relay:i,createTerminal:s,attachRawInput:o,attachTransport:l=nme,scheduleAutoFocus:u=D=>requestAnimationFrame(D),onTerminalReady:d,onFramePending:h,onFrameWritten:p,onRawInput:y,isInputEnabled:v,canFocus:_=()=>!0,onReady:w,onSubscribeStarted:x,onSubscribeDelayed:E,onError:k}=e;let R=!1,A=null,I=null,T=null,H=null;return(async()=>{try{const D=await s(t);if(R){D.dispose();return}A=D.dispose,I=o(D.terminal,n,{onRawInput:y,...v?{isInputEnabled:v}:{}}).dispose;const W=()=>{_()&&D.terminal.focus()};t.addEventListener("pointerdown",W,{passive:!0}),H=()=>t.removeEventListener("pointerdown",W),d==null||d(D.terminal),u(()=>{R||W()}),T=l({sessionId:n,ws:r,relay:i,target:D.terminal,onFramePending:h,onFrameWritten:p,onReady:w,onSubscribeStarted:x,onSubscribeDelayed:E})}catch(D){console.error("[pty-terminal-controller] initialization failed",D),k==null||k(D)}})(),{dispose:()=>{R=!0,T==null||T.dispose(),H==null||H(),I==null||I(),A==null||A()}}}function pE(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 ime=new RegExp("(?<![\\p{L}\\p{N}@:/.-])(?:~\\/|[^\\s`\"'<>,。;:!?、@])[^\\s`\"'<>,。;:!?、@]*?\\.(?:png|jpe?g|webp|gif)(?=$|[\\s`\"'<>),;:!?,。;:!?、]|\\.(?:$|[\\s`\"'<>),;:!?,。;:!?、]))","giu"),sme=new RegExp("(?<![A-Za-z0-9._+-])@(?:~\\/|[^\\s`\"'<>,。;:!?、@])[^\\s`\"'<>,。;:!?、@]*?\\.(?:png|jpe?g|webp|gif)(?=$|[\\s`\"'<>),;:!?,。;:!?、]|\\.(?:$|[\\s`\"'<>),;:!?,。;:!?、]))","giu"),ome=new RegExp("(?<![\\p{L}\\p{N}@:/.-])(?:~\\/|\\.{1,2}\\/|\\/|[^\\s`\"'<>,。;:!?、/@]+\\/)[^\\n\\r\\t`\"'<>,。;:!?、@]*?\\.(?:png|jpe?g|webp|gif)(?=$|[\\s`\"'<>),;:!?,。;:!?、])","giu"),ame=new RegExp("(?<![A-Za-z0-9._+-])@(?:~\\/|[^\\s`\"'<>,。;:!?、@])[^\\n\\r\\t`\"'<>,。;:!?、@]*?\\.(?:png|jpe?g|webp|gif)(?=$|[\\s`\"'<>),;:!?,。;:!?、])","giu"),lme=/\.(?:png|jpe?g|webp|gif)$/i;function gj(e){return e.replace(/^@/,"").replace(/^[([{]+/,"").replace(/[)\].,;:!?,。;:!?、]+$/u,"")}function cme(e){if(e.includes("/"))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 vj(e){const t=gj(e);return/^[a-z][a-z0-9+.-]*:\/\//i.test(t)||pE(t)||!lme.test(t)?!1:cme(t)}function yj(e){const t=[];for(const r of[ame,ome,sme,ime])for(const i of e.matchAll(r)){const s=i[0]??"",o=i.index??-1;if(o<0)continue;const l=gj(s);vj(l)&&t.push({path:l,start:o,end:o+s.length})}t.sort((r,i)=>r.start-i.start||i.end-r.end);const n=[];for(const r of t)n.some(i=>r.start<i.end&&r.end>i.start)||n.push(r);return n}function ume(e){const t=new Set,n=[];for(const{path:r}of yj(e))t.has(r)||(t.add(r),n.push(r));return n}const av=16,dme=8,hme=/(?:^|[\s([{@])@?(?:\/|\.\/|\.\.\/|~\/|[^\s`"'<>,。;:!?、/@]+\/)[^\n`"'<>,。;:!?、@]*$/u,fme=/^[^\n\r\t`"'<>,。;:!?、@]+$/u;function bj(e,t,n){const r=[mme(e,t),...gme(e,t)].filter(o=>o!==null),i=new Set,s=r.flatMap(o=>{const l=o.parts.map(u=>u.text).join("");return pme(l,n).map(u=>{const d=_me(o.parts,u.startIndex),h=wme(o.parts,u.endIndex);return!d||!h?null:{path:u.path,startLineNumber:d.lineNumber,startColumn:d.column,endLineNumber:h.lineNumber,endColumn:h.column,segments:Sme(o.parts,u.startIndex,u.endIndex)}}).filter(u=>u!==null).filter(u=>t>=u.startLineNumber&&t<=u.endLineNumber).filter(u=>{const d=`${u.path}:${u.startLineNumber}:${u.startColumn}:${u.endLineNumber}:${u.endColumn}`;return i.has(d)?!1:(i.add(d),!0)})});return s.filter(o=>!s.some(l=>l!==o&&H2(l.startLineNumber,l.startColumn,o.startLineNumber,o.startColumn)<=0&&H2(l.endLineNumber,l.endColumn,o.endLineNumber,o.endColumn)>=0&&(l.startLineNumber!==o.startLineNumber||l.startColumn!==o.startColumn||l.endLineNumber!==o.endLineNumber||l.endColumn!==o.endColumn)))}function H2(e,t,n,r){return e-n||t-r}function _j(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 pme(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 mme(e,t){const n=e.buffer.active;let r=t,i=t;for(let s=0;s<av;s+=1){const o=n.getLine(r-1);if(!(o!=null&&o.isWrapped)||r<=1)break;r-=1}for(let s=0;s<av;s+=1){const o=n.getLine(i);if(!(o!=null&&o.isWrapped))break;i+=1}return VS(e,r,i)}function VS(e,t,n){const r=e.buffer.active;let i=n??t;if(n===void 0)for(let o=0;o<av;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 gme(e,t){const n=e.buffer.active,r=[],i=Math.max(1,t-av);for(let s=i;s<=t;s+=1){const o=n.getLine(s-1);if(!o||o.isWrapped)continue;const l=vme(e,s);l&&t>=l.startLineNumber&&t<=l.endLineNumber&&r.push(l)}return r}function vme(e,t){const n=VS(e,t);if(!n)return null;const r=n.parts.map(l=>l.text).join("");if(!hme.test(r))return null;const i=[...n.parts];let s=n.endLineNumber,o=!1;for(let l=0;l<dme;l+=1){const u=s+1,d=VS(e,u);if(!d)break;const h=d.parts[0];if(!h)break;const p=yme(h.sourceText),y=h.sourceText.slice(p);if(!bme(p,y))break;i.push({...h,sourceStartIndex:p,text:y}),i.push(...d.parts.slice(1)),o=!0,s=d.endLineNumber}return o?{startLineNumber:t,endLineNumber:s,parts:i}:null}function yme(e){var t;return((t=e.match(/^\s*/))==null?void 0:t[0].length)??0}function bme(e,t){return e<2||!t||t.startsWith("-")||t.startsWith("•")||t.startsWith("›")||t.includes("://")?!1:fme.test(t)}function _me(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:YS(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:YS(s.sourceText,s.sourceStartIndex)}:null}n-=i.text.length}}return null}function wme(e,t){let n=t-1;for(const r of e){if(n<r.text.length)return{lineNumber:r.lineNumber,column:mE(r.sourceText.slice(0,r.sourceStartIndex+n+1))};n-=r.text.length}return null}function Sme(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,h=u-i;r.push({lineNumber:s.lineNumber,startColumn:YS(s.sourceText,s.sourceStartIndex+d),endColumn:mE(s.sourceText.slice(0,s.sourceStartIndex+h))})}i=o}return r}function YS(e,t){return mE(e.slice(0,t))+1}function mE(e){let t=0;for(const n of e)t+=xme(n.codePointAt(0)??0);return t}function xme(e){return e===0||e<32||e>=127&&e<160||Eme(e)?0:Cme(e)?2:1}function Eme(e){return e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071}function Cme(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 wj(e,t){return bj(e,t,ume)}function kme(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 Tme(e,t){const n={provideLinks(i,s){const o=wj(e,i);if(o.length===0){s(void 0);return}const l=o.reduce((u,d)=>{for(const h of _j(d))h.start.y!==i||h.end.y!==i||u.push({text:d.path,range:h,decorations:{underline:!0,pointerCursor:!0},activate:p=>{kme(p)&&t(d.path)}});return u},[]);s(l.length>0?l:void 0)}},r=e.registerLinkProvider(n);return{dispose:()=>r.dispose(),provider:n}}const Rme=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 gE(e){const n=(e.split(/[/?#]/,1)[0]??"").split(".");if(n.length<2)return!1;const r=(n.at(-1)??"").toLowerCase();return Rme.has(r)?n.every(i=>/^[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?$/.test(i)):!1}const Ame=new RegExp("(?<![\\p{L}\\p{N}@:/.-])(?:~\\/|[^\\s`\"'<>,。;:!?、@])[^\\s`\"'<>,。;:!?、@]*\\.[\\p{L}\\p{N}]{1,16}(?=[\\s`\"'<>),.;:!?,。;:!?、]|$)","giu"),Nme=new RegExp("(?<![A-Za-z0-9._+-])@(?:~\\/|[^\\s`\"'<>,。;:!?、@])[^\\s`\"'<>,。;:!?、@]*\\.[\\p{L}\\p{N}]{1,16}(?=[\\s`\"'<>),.;:!?,。;:!?、]|$)","giu"),Mme=new RegExp("(?<![\\p{L}\\p{N}@:/.-])(?:~\\/|\\.{1,2}\\/|\\/|[^\\s`\"'<>,。;:!?、/@]+\\/)[^\\n\\r\\t`\"'<>,。;:!?、@]*?\\.[\\p{L}\\p{N}]{1,16}(?=$|[\\s`\"'<>),;:!?,。;:!?、])","giu"),Ome=new RegExp("(?<![A-Za-z0-9._+-])@(?:~\\/|[^\\s`\"'<>,。;:!?、@])[^\\n\\r\\t`\"'<>,。;:!?、@]*?\\.[\\p{L}\\p{N}]{1,16}(?=$|[\\s`\"'<>),;:!?,。;:!?、])","giu"),Dme=/\.(?:png|jpe?g|webp|gif)$/i,Pme=/\.[\p{L}\p{N}]{1,16}$/u,Lme=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 Sj(e){return e.replace(/^@/,"").replace(/^[([{]+/,"").replace(/[)\].,;:!?,。;:!?、]+$/u,"")}function Ime(e){const t=e.split("/").pop()??e;if(/^\d+(?:\.\d+)+$/.test(t))return!1;if(e.includes("/"))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 zme(e){return e.includes("/")?!1:gE(e)}function Bme(e){return e.includes("/")}function jme(e,t){return Bme(e)||t?!0:Lme.has(e.toLowerCase())}function xj(e,t={}){const n=Sj(e);return/^[a-z][a-z0-9+.-]*:\/\//i.test(n)||pE(n)||!t.allowBare&&zme(n)||Dme.test(n)||!Pme.test(n)||!jme(n,t.allowBare===!0)||n.split("/").includes("...")?!1:Ime(n)}function Ej(e){const t=[];for(const r of[Ome,Mme,Nme,Ame])for(const i of e.matchAll(r)){const s=i[0]??"",o=i.index??-1;if(o<0)continue;const l=Sj(s);xj(l,{allowBare:s.startsWith("@")})&&t.push({path:l,start:o,end:o+s.length})}t.sort((r,i)=>r.start-i.start||i.end-r.end);const n=[];for(const r of t)n.some(i=>r.start<i.end&&r.end>i.start)||n.push(r);return n}function Fme(e){const t=new Set,n=[];for(const{path:r}of Ej(e))t.has(r)||(t.add(r),n.push(r));return n}const $me=750;function Cj(e,t){return bj(e,t,Fme)}function Hme(e){return e.metaKey||e.ctrlKey}function Ume(e,t){let n=null;const r=(o,l)=>{if(!Hme(l))return;const u=performance.now();(n==null?void 0:n.path)===o&&u-n.at<$me||(n={path:o,at:u},t(o))},i={provideLinks(o,l){const u=Cj(e,o);if(u.length===0){l(void 0);return}const d=u.reduce((h,p)=>{for(const y of _j(p))y.start.y!==o||y.end.y!==o||h.push({text:p.path,range:y,decorations:{underline:!1,pointerCursor:!0},hover:()=>{Wme(e,p)},leave:()=>{Og(e)},dispose:()=>{Og(e)},activate:v=>{r(p.path,v)}});return h},[]);l(d.length>0?d:void 0)}},s=e.registerLinkProvider(i);return{dispose:()=>{Og(e),s.dispose()},provider:i}}function Wme(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;Og(e),qme(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,h=s.top-i.top,p=e.buffer.active.viewportY;for(const y of t.segments){const v=y.lineNumber-p;if(v<1||v>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=`${h+(v-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 Og(e){var t;(t=e.element)==null||t.querySelectorAll('[data-slot="pty-file-link-hover-overlay"]').forEach(n=>n.remove())}function qme(e){window.getComputedStyle(e).position==="static"&&(e.style.position="relative")}function qa(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 Vme(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 Yme(e){const t=new MouseEvent("mouseup",{bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY});return Object.defineProperty(t,"pointerType",{configurable:!0,value:"touch"}),t}function kj(e,t,n){if(t.length===0)return qa("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 qa("skip",{reason:"missing-elements",hasScreen:!!i,hasMetricHost:!!s,point:n}),null;const o=fE(s,e);if(!o||o.cellW<=0||o.cellH<=0)return qa("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 qa("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 h=e.buffer.active.viewportY+d,p={x:u,y:h};qa("probe",{point:n,viewportX:u,viewportY:d,bufferLineNumber:h,providers:t.length,metrics:o});for(const y of t){let v=null;if(y.provideLinks(h,_=>{qa("links",{bufferLineNumber:h,position:p,count:(_==null?void 0:_.length)??0,links:_==null?void 0:_.map(x=>({text:x.text,range:x.range}))});const w=_==null?void 0:_.find(x=>Vme(x,p,e.cols));w&&(v=w)}),v)return v}return qa("miss",{position:p,point:n,bufferLineNumber:h}),null}function Kme(e,t,n){return kj(e,t,n)!==null}function Gme(e,t,n){const r=kj(e,t,n);return r?(r.activate(Yme(n),r.text),qa("activate",{text:r.text,range:r.range,point:n}),!0):!1}const Xme=2*1024*1024,Zme=2560,U2=.82,Qme=.9,Jme=new Set(["image/jpeg","image/png","image/webp"]),Tj=new Map([["image/jpeg","jpg"],["image/png","png"],["image/webp","webp"]]);function Rj(e){return e.size>Xme&&Jme.has(e.type)}function ege(e,t,n=Zme){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 tge(e,t){const n=Tj.get(t);return n?`${e.replace(/\.(?:jpe?g|png|webp)$/iu,"")||"image"}.${n}`:e}function nge(){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 Aj(e,t=nge()){var r;if(!Rj(e)||!t)return e;let n=null;try{n=await t.decode(e);const i=ege(n.width,n.height);let s=await t.encode(n,i.width,i.height,"image/webp",U2);return(s==null?void 0:s.type)!=="image/webp"&&e.type==="image/jpeg"&&(s=await t.encode(n,i.width,i.height,"image/jpeg",U2)),!s||!Tj.has(s.type)||s.size>=e.size*Qme?e:new File([s],tge(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 kf(e){const t=Rj(e.file),n=nt.loading(t?`正在压缩并上传 ${e.file.name} ...`:`上传 ${e.file.name} ...`);try{const r=await Aj(e.file),i=await e.relay.uploadFile(e.sessionId,r);return!i.success||!i.path?(nt.error(i.error??"上传失败",{id:n}),null):(e.successLabel===null?nt.dismiss(n):nt.success(e.successLabel??`已上传 ${i.path}`,{id:n}),i.path)}catch(r){return nt.error(r instanceof Error?r.message:String(r),{id:n}),null}}function W2(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 q2="--dev-visual-viewport-height",rge=.3;function Nj({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=V2(l,e),h=i?V2(u,r):0;return Math.max(d,h)}function ige({layoutViewportHeight:e,visualViewportHeight:t,visualViewportOffsetTop:n,baselineViewportHeight:r=e,allowBaselineFallback:i=!1,softKeyboardOpen:s=!1}){return s?Math.max(e-t-n,0):Nj({layoutViewportHeight:e,visualViewportHeight:t,visualViewportOffsetTop:n,baselineViewportHeight:r,allowBaselineFallback:i})}function V2(e,t){const n=Math.max(e,0);return n<=0?0:n/Math.max(t,1)>=rge?n:0}function sge(){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(q2,`${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(q2)}},[])}function Y2(){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 oge(){b.useEffect(()=>{const e=window.visualViewport;let t=0;const n=()=>{Y2(),cancelAnimationFrame(t),t=requestAnimationFrame(()=>{t=0,Y2()})};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 age(){return vE().bottomOffset}function vE(){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=lge();let o=0;const l=()=>{const h=i.height,p=i.offsetTop,y=i.width,v=Math.max(window.innerHeight,h+p);!n.current||Math.abs(y-r.current)>1?(n.current=v,r.current=y):n.current=Math.max(n.current,v);const _=window.innerHeight,w=cge(),x=!s||w,E=s&&w,k=Nj({layoutViewportHeight:_,visualViewportHeight:h,visualViewportOffsetTop:p,baselineViewportHeight:n.current,allowBaselineFallback:x,subtractVisualViewportOffsetTop:s}),R={bottomOffset:k,layoutBottomInset:ige({layoutViewportHeight:_,visualViewportHeight:h,visualViewportOffsetTop:p,baselineViewportHeight:n.current,allowBaselineFallback:E,softKeyboardOpen:k>0})};t(A=>A.bottomOffset===R.bottomOffset&&A.layoutBottomInset===R.layoutBottomInset?A:R)},u=()=>{cancelAnimationFrame(o),o=requestAnimationFrame(()=>{o=0,l()})};u(),window.addEventListener("resize",u),i.addEventListener("resize",u),i.addEventListener("scroll",u);const d=()=>{setTimeout(u,300)};return window.addEventListener("focusout",d),()=>{cancelAnimationFrame(o),window.removeEventListener("resize",u),i.removeEventListener("resize",u),i.removeEventListener("scroll",u),window.removeEventListener("focusout",d)}},[]),e}function lge(){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 cge(){const e=document.activeElement;return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}const uge=new Set(["\x1B[A","\x1B[B","\x1B[C","\x1B[D"]);function Vh(e,t){return!(t!=null&&t.applicationCursorKeysMode)||!uge.has(e)?e:`\x1BO${e.at(-1)}`}function dge(e){window.__devAnywherePtyTerminal=e}function hge(){window.__devAnywherePtyTerminal&&delete window.__devAnywherePtyTerminal}function fge(e){window.__devAnywherePtyDebug=e}function pge(){window.__devAnywherePtyDebug&&delete window.__devAnywherePtyDebug}function mge(e,t){const n=e(),{container:r,spacer:i,host:s,term:o}=t,{cellH:l,cellW:u,paddingTop:d,paddingBottom:h,canvasLastY:p}=n,y=Math.max(0,r.clientHeight-d-h),v=o.buffer.active;let _=0;if(l>0&&u>0){const B=fj({bufferLength:v.length,rows:o.rows,cols:o.cols,viewportY:v.viewportY,cursorY:v.cursorY,cellH:l,cellW:u,visibleContentHeight:y},p);_=(B==null?void 0:B.spacerHeight)??0}const w=Ws(i.style.height),x=Ws(s.style.top),E=Ws(s.style.height),k=Ws(s.style.width),R=Ws(s.style.paddingTop),A=Ws(i.style.width);let I=0;if(l>0){const B=o.rows*l,L=B>0&&B<y?y-B:0;I=Math.max(0,v.viewportY*l+L)}const T=x-I,H=r.scrollTop,D=H+r.clientHeight,W=x+E,U=Math.max(0,Math.min(D,W)-Math.max(H,x)),F=r.clientHeight>0?U/r.clientHeight:0,O=v.baseY+v.cursorY,M=hE({rows:o.rows,cellH:l,bufferLength:v.length,cursorBufferRow:O,visibleContentHeight:y,paddingTop:d,paddingBottom:h,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:h},spacer:{height:w,width:A},host:{top:x,height:E,width:k,paddingTop:R,expectedTop:I,topDrift:T},term:{rows:o.rows,cols:o.cols,bufferLength:v.length,viewportY:v.viewportY,baseY:v.baseY,cursorX:v.cursorX,cursorY:v.cursorY},cell:{h:l,w:u},visibleContentHeight:y,anchor:{atBottom:M.isAtBottom,cursorInViewport:M.cursorInViewport,cursorBufferRow:O,bottomScrollTop:M.bottomScrollTop,scrollTopDeltaToBottom:r.scrollTop-M.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:F,pendingContainerSyncRetry:n.pendingContainerSyncRetry}}const ay={enabled:!1,phase:"idle",error:null,lastSpokenText:"",approvalRequestId:null,activityLevel:0,waveform:[],resumeRequestSeq:0};function gge(e){return Number.isFinite(e)?Math.max(0,Math.min(1,e)):0}function Fs(e,t,n){const r=e.bySessionId[t]??ay;return{bySessionId:{...e.bySessionId,[t]:n(r)}}}const cn=td()(nd(e=>({bySessionId:{},enable:t=>e(n=>Fs(n,t,r=>({...r,enabled:!0,phase:"starting",error:null,waveform:[]}))),disable:t=>e(n=>Fs(n,t,r=>({...r,enabled:!1,phase:"idle",error:null,approvalRequestId:null,activityLevel:0,waveform:[]}))),requestResume:t=>e(n=>Fs(n,t,r=>({...r,resumeRequestSeq:r.resumeRequestSeq+1}))),setPhase:(t,n)=>e(r=>Fs(r,t,i=>({...i,phase:n,error:n==="error"?i.error:null}))),setError:(t,n)=>e(r=>Fs(r,t,i=>({...i,phase:"error",error:n,activityLevel:0,waveform:[]}))),clearError:t=>e(n=>Fs(n,t,r=>({...r,error:null,phase:r.enabled&&r.phase==="error"?"starting":r.phase}))),setLastSpokenText:(t,n)=>e(r=>Fs(r,t,i=>({...i,lastSpokenText:n}))),setApproval:(t,n)=>e(r=>Fs(r,t,i=>({...i,approvalRequestId:n}))),setActivityLevel:(t,n)=>e(r=>Fs(r,t,i=>({...i,activityLevel:gge(n)}))),appendWaveform:(t,n)=>{n.length!==0&&e(r=>Fs(r,t,i=>({...i,waveform:[...i.waveform,...n].slice(-q0)})))},clearWaveform:t=>e(n=>Fs(n,t,r=>({...r,waveform:[]}))),resetAll:()=>e({bySessionId:{}})}),{name:"voice-pilot-store"}));function vge(){const[e,t]=b.useState(!1),[n,r]=b.useState(!1),[i,s]=b.useState(!1);b.useEffect(()=>{if(e){r(!1);return}const p=setTimeout(()=>r(!0),300);return()=>clearTimeout(p)},[e]);const o=b.useCallback(()=>{t(!0),s(!1)},[]),l=b.useCallback(()=>{t(!1),s(!1)},[]),u=b.useCallback(()=>{s(!0)},[]),d=b.useMemo(()=>({connecting:n,subscribeDelayed:i}),[n,i]),h=b.useMemo(()=>({onReady:o,onSubscribeStarted:l,onSubscribeDelayed:u}),[o,u,l]);return{ready:e,overlay:d,transport:h}}const yge=900;function bge(){var t;const e=navigator.virtualKeyboard;(t=e==null?void 0:e.show)==null||t.call(e)}function _ge(e){const{containerEl:t,xtermHostRef:n,terminalRef:r}=e,[i,s]=b.useState(!1),o=b.useRef(0),l=b.useCallback(()=>{const v=document.activeElement;!t||!(v instanceof HTMLElement)||!t.contains(v)||v.blur()},[t]),u=b.useCallback(()=>{const v=n.current,_=document.activeElement,w=!!(v&&_ instanceof HTMLElement&&v.contains(_));s(w),w&&bge()},[n]),d=b.useCallback((v={})=>{o.current=performance.now()+yge,(v.blur??!0)&&(l(),s(!1))},[l]),h=b.useCallback(v=>{if(performance.now()<=o.current){v.target instanceof HTMLElement&&v.target.blur(),window.setTimeout(u,0);return}u()},[u]),p=b.useCallback(()=>{window.setTimeout(u,0)},[u]),y=b.useCallback(()=>{var v;o.current=0,(v=r.current)==null||v.focus(),window.setTimeout(u,0)},[u,r]);return{ptyInputFocused:i,suppressPtyFocus:d,focusPtyInput:y,handleFocusCapture:h,handleBlurCapture:p}}function wge(){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}}async function Mj(e,{allowLegacyFallback:t=!1}={}){var r,i;const n=(i=(r=navigator.clipboard)==null?void 0:r.writeText)==null?void 0:i.bind(navigator.clipboard);if(n&&window.isSecureContext!==!1)try{return await n(e),"clipboard"}catch{}return t&&Sge(e)?"legacy":"failed"}function Sge(e){if(!document.body||typeof document.execCommand!="function")return!1;const t=document.createElement("textarea");t.value=e,t.readOnly=!0,t.setAttribute("aria-hidden","true"),t.style.position="fixed",t.style.left="-9999px",t.style.top="0",t.style.opacity="0",t.style.fontSize="16px",document.body.appendChild(t);try{return t.select(),t.setSelectionRange(0,e.length),document.execCommand("copy")}catch{return!1}finally{t.remove()}}const xge=new Intl.Segmenter("zh-CN",{granularity:"word"}),Ege=/^[./:@_+~=-]+$/u,Cge=/[a-z0-9]/iu;function Oj({terminal:e,host:t,cellWidth:n,cellHeight:r}){return n&&r?{cellW:n,cellH:r}:fE(t,e)}function kge(e,t){const n=Math.min(e.length,t),r=[];let i="";for(let s=0;s<n;s+=1){const o=e.getCell(s),l=(o==null?void 0:o.getWidth())??1;if(l===0)continue;const u=(o==null?void 0:o.getChars())||" ",d=i.length;i+=u,r.push({textStart:d,textEnd:i.length,cellStart:s,cellEnd:Math.min(n-1,s+Math.max(1,l)-1)})}return{text:i.trimEnd(),spans:r}}function K2(e){return Ege.test(e.segment)}function KS(e){return e.isWordLike===!0&&Cge.test(e.segment)}function Tge(e,t){let n=t,r=t;for(;n>0;){let o=n-1;for(;o>=0&&K2(e[o]);)o-=1;if(o===n-1)break;if(o>=0&&KS(e[o])){n=o;continue}n=o+1;break}for(;r+1<e.length;){let o=r+1;for(;o<e.length&&K2(e[o]);)o+=1;if(o===r+1||o>=e.length||!KS(e[o]))break;r=o}const i=e[n].index,s=e[r];return{start:i,end:s.index+s.segment.length}}function Rge(e){const t=Array.from(xge.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(KS(o)?Tge(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 Age(e,t){const{text:n,spans:r}=kge(e,t);return Rge(n).flatMap(i=>{const s=r.filter(u=>u.textStart<i.end&&u.textEnd>i.start),o=s[0],l=s.at(-1);return o&&l?[{start:o.cellStart,end:l.cellEnd}]:[]})}function Nge(e,t){if(e.length===0)return null;let n=0,r=Number.POSITIVE_INFINITY;for(let i=0;i<e.length;i+=1){const s=e[i],o=t<s.start?s.start-t:t>s.end?t-s.end:0;o<r&&(r=o,n=i)}return n}function Mge(e,t){return e.row<t.row||e.row===t.row&&e.column<=t.column?{start:e,end:t}:{start:t,end:e}}function Oge(e,t,n){const r=[];for(let i=t.row;i<=n.row;i+=1){const s=e.buffer.active.getLine(i);if(!s){r.push("");continue}const o=i===t.row?t.column:0,l=i===n.row?n.column+1:e.cols;r.push(s.translateToString(!0,o,l))}return r.join(`
643
- `).replace(/\s+$/,"")}function Yh({terminal:e,host:t,clientX:n,clientY:r,cellWidth:i,cellHeight:s}){const o=t.querySelector(".xterm-screen");if(!o)return null;const l=Oj({terminal:e,host:t,cellWidth:i,cellHeight:s});if(!(l!=null&&l.cellW)||!l.cellH)return null;const u=o.getBoundingClientRect(),d=Math.floor((r-u.top)/l.cellH),h=Math.floor((n-u.left)/l.cellW);return d<0||d>=e.rows||h<0||h>=e.cols?null:{row:e.buffer.active.viewportY+d,column:h}}function G2({terminal:e,host:t,point:n,affinity:r="before",cellWidth:i,cellHeight:s}){const o=t.querySelector(".xterm-screen");if(!o)return null;const l=Oj({terminal:e,host:t,cellWidth:i,cellHeight:s});if(!(l!=null&&l.cellW)||!l.cellH)return null;const u=n.row-e.buffer.active.viewportY;if(u<0||u>=e.rows||n.column<0||n.column>=e.cols)return null;const d=o.getBoundingClientRect(),h=r==="after"?n.column+1:n.column;return{left:d.left+h*l.cellW,top:d.top+(u+1)*l.cellH}}function lv({terminal:e,anchor:t,focus:n}){var u;const{start:r,end:i}=Mge(t,n),o=Math.max(0,i.row-r.row)*e.cols+(i.column-r.column)+1;if(o<=0)return null;e.select(r.column,r.row,o);const l=((u=e.getSelection)==null?void 0:u.call(e))||Oge(e,r,i);return l.trim()?{anchor:t,focus:n,text:l}:null}function X2({terminal:e,host:t,clientX:n,clientY:r,cellWidth:i,cellHeight:s}){const o=Yh({terminal:e,host:t,clientX:n,clientY:r,cellWidth:i,cellHeight:s});return o?GS({terminal:e,point:o}):null}function GS({terminal:e,point:t}){const n=e.buffer.active.getLine(t.row);if(!n)return null;const r=Age(n,e.cols),i=Nge(r,t.column);if(i===null)return null;const s=r[i];return s?lv({terminal:e,anchor:{row:t.row,column:s.start},focus:{row:t.row,column:s.end}}):null}function Z2({terminal:e,point:t}){const n=t.row+1,r=t.column+1,i=[...wj(e,n).map(o=>({match:o,pathAction:{kind:"image-preview",path:o.path}})),...Cj(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=lv({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}function Q2(e,t,n){return t>n?(t+n)/2:Math.min(Math.max(e,t),n)}const Dge=64;function Dj({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-Dge;return{left:Q2(e,o,l),top:Q2(t-48,u,d)}}function Pge(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 Lge({terminal:e,host:t,anchor:n,focus:r}){const i=e.buffer.active.viewportY,s=i+e.rows-1,o=d=>({...d,row:Math.min(s,Math.max(i,d.row))}),l=G2({terminal:e,host:t,point:o(n),affinity:"before"}),u=G2({terminal:e,host:t,point:o(r),affinity:"after"});return!l||!u?null:{anchor:l,focus:u}}function Ige({handles:e,viewportWidth:t,viewportHeight:n,viewportOffsetLeft:r=0,viewportOffsetTop:i=0}){return Dj({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 zge=/\.(?:png|jpe?g|webp|gif)$/i,Pj=/\.[\p{L}\p{N}]{1,16}$/u;function Bge(e){return e.trim().replace(/^@/,"").replace(/^[([{]+/,"").replace(/[)\].,;:!?,。;:!?、]+$/u,"")}function jge(e){const t=e.trim();if(!t||t.includes(`
644
- `))return null;const n=Bge(t);return!n||/^[a-z][a-z0-9+.-]*:\/\//i.test(n)||pE(n)||n.split("/").includes("...")?null:n}function Fge(e){return e.includes("/")?!1:gE(e)}function $ge(e){const t=e.split("/").pop()??e;if(/^\d+(?:\.\d+)+$/.test(t))return!1;if(e.includes("/"))return!0;const n=e.replace(Pj,""),r=n.split("/").pop()??n;return/[A-Za-z_-]/.test(r)}function Hge(e){const t=jge(e);return!t||Fge(t)||!$ge(t)?null:zge.test(t)?{kind:"image-preview",path:t}:Pj.test(t)?{kind:"file-download",path:t}:null}const Uge=16,Wge=24,xh=6,qge=425,Kh=-1;function eg(e,t){return e.pointerId===t||t===Kh}function gu(e){return Math.hypot(e.lastX-e.startX,e.lastY-e.startY)}function Ri(e,t={}){const n=window.__ccTestPtyTouchGestureEvents;n&&(n.push({event:e,t:performance.now(),...t}),n.length>200&&n.splice(0,n.length-200))}function Vge({terminalRef:e,suppressPtyFocus:t,focusTerminal:n,onLongPressCandidateStart:r,onTap:i,isTapCandidate:s,onLongPressStart:o,onLongPressMove:l,onLongPressEnd:u}){const d=b.useRef(null),h=b.useCallback(F=>{F.longPressTimer!==null&&(window.clearTimeout(F.longPressTimer),F.longPressTimer=null)},[]),p=b.useCallback(F=>{F.longPressed||F.moved||(F.longPressed=!0,F.longPressArmed=!1,h(F),t(),o==null||o({clientX:F.startX,clientY:F.startY}))},[h,o,t]),y=b.useCallback(F=>{if(!(F.longPressed||F.longPressArmed||F.moved)){if(gu(F)>xh){h(F),Ri("longpress:cancel-drift",{distance:gu(F),threshold:xh});return}if(s!=null&&s({clientX:F.startX,clientY:F.startY})){F.longPressArmed=!0,h(F),Ri("longpress:arm-link",{clientX:F.startX,clientY:F.startY});return}p(F)}},[h,s,p]),v=b.useCallback(F=>{if(F.longPressDelivered||!F.longPressed||F.moved)return;F.longPressDelivered=!0;const O={clientX:F.lastX,clientY:F.lastY};window.setTimeout(()=>u==null?void 0:u(O),0)},[u]),_=b.useCallback((F,O,M,B=!1)=>{const L={pointerId:F,startX:O,startY:M,lastX:O,lastY:M,moved:!1,longPressArmed:!1,longPressed:!1,longPressDelivered:!1,touchEventStream:B,longPressTimer:null};L.longPressTimer=window.setTimeout(()=>{d.current===L&&y(L)},qge),d.current=L,Ri("start",{pointerId:F,clientX:O,clientY:M,touchEventStream:B}),r==null||r({clientX:O,clientY:M})},[y,r]),w=b.useCallback((F,O,M)=>{const B=d.current;if(!B||!eg(B,F))return!1;B.lastX=O,B.lastY=M;const L=gu(B);if(B.longPressArmed&&L>xh&&(B.longPressArmed=!1,Ri("longpress:cancel-armed-drift",{pointerId:F,clientX:O,clientY:M,distance:L,threshold:xh})),B.longPressed)return Ri("move",{pointerId:F,clientX:O,clientY:M,distance:L,moved:B.moved,longPressed:!0}),l==null||l({clientX:O,clientY:M}),!0;const N=O-B.startX,V=M-B.startY;return!B.moved&&L>=Uge&&(B.moved=!0,h(B)),Ri("move",{pointerId:F,clientX:O,clientY:M,dx:N,dy:V,distance:L,moved:B.moved,longPressed:!1}),B.moved},[h,l]),x=b.useCallback((F,O)=>{var N;const M=d.current;if(!M||!eg(M,F))return null;O&&(M.lastX=O.clientX,M.lastY=O.clientY),d.current=null,h(M);const B=gu(M);let L;if(M.longPressArmed){if(B<=xh)return p(M),v(M),L="longpress",Ri("finish",{pointerId:F,result:L,point:O,moved:M.moved,distance:B,longPressed:!0,longPressArmed:!0}),L;M.longPressArmed=!1}return M.longPressed?(v(M),L="longpress",Ri("finish",{pointerId:F,result:L,point:O,moved:M.moved,longPressArmed:M.longPressArmed,distance:B,longPressed:!0}),L):M.moved?O&&gu(M)<=Wge&&(i!=null&&i(O))?(t(),L="link",Ri("finish",{pointerId:F,result:L,point:O,moved:!0,distance:B,longPressed:!1}),L):(t(),L="scroll",Ri("finish",{pointerId:F,result:L,point:O,moved:!0,distance:B,longPressed:!1}),L):O&&(i!=null&&i(O))?(t(),L="link",Ri("finish",{pointerId:F,result:L,point:O,moved:!1,distance:B,longPressed:!1}),L):(n?n():(N=e.current)==null||N.focus(),L="tap",Ri("finish",{pointerId:F,result:L,point:O,moved:!1,distance:B,longPressed:!1}),L)},[h,v,n,i,p,t,e]),E=b.useCallback(F=>{const O=d.current;return!O||!eg(O,F)?null:(h(O),d.current=null,O.longPressed?(v(O),Ri("cancel",{pointerId:F,result:"longpress"}),"longpress"):(O.longPressArmed&&Ri("cancel",{pointerId:F,result:"armed"}),t(),Ri("cancel",{pointerId:F,result:"scroll",moved:O.moved,distance:gu(O)}),"scroll"))},[h,v,t]),k=b.useCallback(F=>{if(F.pointerType!=="touch")return;const O=F.target;!(O instanceof Element)||!O.closest(".xterm")||(_(F.pointerId,F.clientX,F.clientY),F.stopPropagation())},[_]),R=b.useCallback(F=>{if(F.pointerType!=="touch")return;const O=w(F.pointerId,F.clientX,F.clientY),M=d.current;M&&O&&(F.stopPropagation(),M.longPressed&&F.preventDefault())},[w]),A=b.useCallback(F=>{const O=x(F.pointerId,{clientX:F.clientX,clientY:F.clientY});O&&(F.stopPropagation(),O==="link"&&F.cancelable&&F.preventDefault())},[x]),I=b.useCallback(F=>{const O=d.current;if(F.pointerType==="touch"&&O&&eg(O,F.pointerId)&&O.touchEventStream&&!O.longPressed){F.stopPropagation();return}E(F.pointerId)&&F.stopPropagation()},[E]),T=b.useCallback(F=>{const O=F.target;if(!(O instanceof Element)||!O.closest(".xterm"))return;if(d.current){d.current.touchEventStream=!0;return}const M=F.touches[0]??F.changedTouches[0];M&&_(Kh,M.clientX,M.clientY,!0)},[_]),H=b.useCallback(F=>{const O=F.touches[0]??F.changedTouches[0];if(!O)return;const M=w(Kh,O.clientX,O.clientY),B=d.current;B&&M&&B.longPressed&&(F.stopPropagation(),F.preventDefault())},[w]),D=b.useCallback(F=>{const O=F.changedTouches[0],M=d.current,B=O?{clientX:O.clientX,clientY:O.clientY}:M?{clientX:M.lastX,clientY:M.lastY}:void 0,L=x(Kh,B);(L==="longpress"||L==="link")&&(F.stopPropagation(),F.cancelable&&F.preventDefault())},[x]),W=b.useCallback(F=>{E(Kh)==="longpress"&&F.stopPropagation()},[E]),U=b.useCallback(F=>{const O=d.current;O&&(F.preventDefault(),F.stopPropagation(),y(O))},[y]);return{onPointerDownCapture:k,onPointerMoveCapture:R,onPointerUpCapture:A,onPointerCancelCapture:I,onTouchStartCapture:T,onTouchMoveCapture:H,onTouchEndCapture:D,onTouchCancelCapture:W,onContextMenuCapture:U}}function Yge({terminalRef:e,containerEl:t,suppressPtyFocus:n,focusPtyInput:r,isSelectionActive:i,onTap:s,isTapCandidate:o,onLongPressCandidateStart:l,onLongPressStart:u,onLongPressMove:d,onLongPressEnd:h,onHorizontalScrollIntent:p,onSelectionAutoscroll:y,onHandleDragStart:v,onHandleDragMove:_,onHandleDragEnd:w,onHandleDragCancel:x}){const E=b.useRef(null),k=b.useRef(null),R=b.useRef(null),A=b.useRef(!1),I=b.useRef(null),T=b.useCallback(()=>{var L;(L=I.current)==null||L.call(I),I.current=null,k.current=null,R.current=null,A.current=!1,E.current!==null&&(cancelAnimationFrame(E.current),E.current=null)},[]),H=b.useCallback(()=>{var $;E.current=null;const L=k.current;if(!L||!t||!i())return;const N=t.getBoundingClientRect(),{dx:V,dy:Y}=cj({pointerX:L.clientX,pointerY:L.clientY,rect:N,scrollLeft:t.scrollLeft,scrollTop:t.scrollTop,scrollWidth:t.scrollWidth,scrollHeight:t.scrollHeight,clientWidth:t.clientWidth,clientHeight:t.clientHeight,edgePx:44,maxSpeedPx:18});V!==0&&(p==null||p(`selectionGestureAutoscroll dx=${Math.round(V)}`),t.scrollLeft+=V),Y!==0&&(t.scrollTop+=Y),(V!==0||Y!==0)&&(y==null||y({scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}),($=R.current)==null||$.call(R,L)),E.current=requestAnimationFrame(H)},[t,i,p,y]),D=b.useCallback((L,N)=>{k.current=L,R.current=N,E.current===null&&(E.current=requestAnimationFrame(H))},[H]);b.useEffect(()=>T,[T]),b.useEffect(()=>{if(!t)return;const L=N=>{A.current&&N.preventDefault()};return t.addEventListener("touchmove",L,{capture:!0,passive:!1}),document.addEventListener("touchmove",L,{capture:!0,passive:!1}),()=>{t.removeEventListener("touchmove",L,{capture:!0}),document.removeEventListener("touchmove",L,{capture:!0})}},[t]);const W=b.useCallback(L=>{T(),A.current=!0,u(L)},[u,T]),U=b.useCallback(L=>{d(L),D(L,d)},[d,D]),F=b.useCallback(L=>{T(),h(L)},[h,T]),O=Vge({terminalRef:e,suppressPtyFocus:n,focusTerminal:r,onTap:s,isTapCandidate:o,onLongPressCandidateStart:l,onLongPressStart:W,onLongPressMove:U,onLongPressEnd:F}),M=b.useCallback((L,N)=>{N.preventDefault(),N.stopPropagation(),T(),A.current=!0,v(L);let V=()=>{};const Y=q=>{q.cancelable&&q.preventDefault();const K={clientX:q.clientX,clientY:q.clientY};_(L,K),D(K,z=>_(L,z))},$=q=>{const K={clientX:q.clientX,clientY:q.clientY};V(),I.current=null,T(),w(L,K)},P=()=>{V(),I.current=null,T(),x(L)};V=()=>{window.removeEventListener("pointermove",Y),window.removeEventListener("pointerup",$),window.removeEventListener("pointercancel",P)},I.current=V,window.addEventListener("pointermove",Y,{passive:!1}),window.addEventListener("pointerup",$,{once:!0}),window.addEventListener("pointercancel",P,{once:!0})},[x,w,_,v,T,D]),B=b.useCallback((L,N)=>{if(I.current||!(N.touches[0]??N.changedTouches[0]))return;N.preventDefault(),N.stopPropagation(),A.current=!0,v(L);let Y=()=>{};const $=K=>{const z=K.touches[0]??K.changedTouches[0];if(!z)return;K.cancelable&&K.preventDefault();const X={clientX:z.clientX,clientY:z.clientY};_(L,X),D(X,ee=>_(L,ee))},P=K=>{const z=K.changedTouches[0],X=z?{clientX:z.clientX,clientY:z.clientY}:k.current;Y(),I.current=null,T(),w(L,X)},q=()=>{Y(),I.current=null,T(),x(L)};Y=()=>{window.removeEventListener("touchmove",$),window.removeEventListener("touchend",P),window.removeEventListener("touchcancel",q)},I.current=Y,window.addEventListener("touchmove",$,{passive:!1}),window.addEventListener("touchend",P,{once:!0}),window.addEventListener("touchcancel",q,{once:!0})},[x,w,_,v,T,D]);return{pointerHandlers:O,stopPtySelectionGesture:T,handlePtySelectionHandlePointerDown:M,handlePtySelectionHandleTouchStart:B}}const Kge=8;function Gge(e){const{sessionId:t,terminalRef:n,xtermHostRef:r,scrollControllerRef:i,containerEl:s,scrollState:o,keyboardOffset:l,ptyFontSize:u,suppressPtyFocus:d,focusPtyInput:h,onTap:p,isTapCandidate:y,onDownloadPath:v,onPreviewPath:_}=e,w=b.useRef(null),x=b.useRef(null),E=b.useRef(null),k=b.useRef(null),R=b.useRef(!1),A=b.useRef(null),I=b.useRef(null),T=b.useRef(""),H=b.useRef(null),[D,W]=b.useState(null),[U,F]=b.useState(null),[O,M]=b.useState(null),B=b.useMemo(()=>Pge(u),[u]),L=b.useCallback((ye,He)=>{const Ge=window.visualViewport;return Dj({clientX:ye,clientY:He,viewportWidth:(Ge==null?void 0:Ge.width)??window.innerWidth,viewportHeight:(Ge==null?void 0:Ge.height)??window.innerHeight,viewportOffsetLeft:(Ge==null?void 0:Ge.offsetLeft)??0,viewportOffsetTop:(Ge==null?void 0:Ge.offsetTop)??0})},[]),N=b.useCallback((ye,He)=>{const Ge=n.current,be=r.current;return!Ge||!be?null:Lge({terminal:Ge,host:be,anchor:ye,focus:He})},[n,r]),V=b.useCallback((ye,He)=>{const Ge=He??Hge(ye);return I.current=Ge,M(Ge),Ge},[]),Y=b.useCallback(ye=>{const He=window.visualViewport;return Ige({handles:ye,viewportWidth:(He==null?void 0:He.width)??window.innerWidth,viewportHeight:(He==null?void 0:He.height)??window.innerHeight,viewportOffsetLeft:(He==null?void 0:He.offsetLeft)??0,viewportOffsetTop:(He==null?void 0:He.offsetTop)??0})},[]),$=b.useCallback(()=>{const ye=w.current,He=x.current;if(!ye||!He){F(null);return}const Ge=N(ye,He);if(F(Ge),!Ge){W(null);return}W(be=>be&&Y(Ge))},[N,Y]),P=b.useCallback(()=>{var ye,He;(ye=H.current)==null||ye.call(H),E.current=null,k.current=null,w.current=null,x.current=null,R.current=!1,A.current=null,I.current=null,T.current="",(He=n.current)==null||He.clearSelection(),W(null),F(null),M(null)},[n]),q=b.useCallback((ye="")=>{w.current=null,x.current=null,R.current=!1,I.current=null,T.current=ye,W(null),F(null),M(null)},[]),K=b.useCallback(({clientX:ye,clientY:He})=>{const Ge=n.current,be=r.current;d({blur:!1}),k.current={clientX:ye,clientY:He},E.current=Ge&&be?Yh({terminal:Ge,host:be,clientX:ye,clientY:He}):null},[d,n,r]),z=b.useCallback(({clientX:ye,clientY:He,draggedHandle:Ge="focus"})=>{const be=n.current,Xe=r.current,rt=w.current,pt=x.current;if(!be||!Xe||!rt)return null;const le=Yh({terminal:be,host:Xe,clientX:ye,clientY:He});if(!le)return null;const Ae=Ge==="anchor"?le:rt,Ze=Ge==="focus"?le:pt??rt;w.current=Ae,x.current=Ze,R.current=!0;const tt=lv({terminal:be,anchor:Ae,focus:Ze});return T.current=(tt==null?void 0:tt.text)??"",V((tt==null?void 0:tt.text)??""),F(tt?N(Ae,Ze):null),tt},[N,V,n,r]),X=b.useCallback(({point:ye,clientX:He,clientY:Ge,showToolbar:be=!0})=>{const Xe=n.current,rt=r.current;if(!Xe||!rt)return!1;A.current=null;const pt=ye?Z2({terminal:Xe,point:ye}):null,le=pt??(ye?GS({terminal:Xe,point:ye}):X2({terminal:Xe,host:rt,clientX:He,clientY:Ge}));if(!(le!=null&&le.text))return!1;w.current=le.anchor,x.current=le.focus,T.current=le.text,V(le.text,pt==null?void 0:pt.pathAction);const Ae=N(le.anchor,le.focus);return F(Ae),be&&W(Ae?Y(Ae):L(He,Ge)),!0},[N,L,Y,V,n,r]),ee=b.useCallback(()=>{const ye=w.current,He=x.current;if(!ye||!He){W(null);return}const Ge=N(ye,He);F(Ge),W(Ge?Y(Ge):null)},[N,Y]),te=b.useCallback(ye=>{var be,Xe;const He=((Xe=(be=n.current)==null?void 0:be.getSelection)==null?void 0:Xe.call(be))??"",Ge=V(He);T.current=He,w.current=null,x.current=null,R.current=!1,F(null),W(Ge?L(ye.clientX,ye.clientY):null)},[L,V,n]);b.useEffect(()=>{const ye=r.current;if(!ye)return;let He=!1;const Ge=rt=>{var le,Ae;if(rt.pointerType!=="mouse"||rt.button!==0)return;const pt=rt.target;!(pt instanceof Element)||!pt.closest(".xterm")||(He=!0,q(((Ae=(le=n.current)==null?void 0:le.getSelection)==null?void 0:Ae.call(le))??""))},be=rt=>{if(rt.pointerType!=="mouse"||!He)return;He=!1;const pt={clientX:rt.clientX,clientY:rt.clientY};window.setTimeout(()=>te(pt),0)},Xe=()=>{He=!1};return ye.addEventListener("pointerdown",Ge,!0),window.addEventListener("pointerup",be,!0),window.addEventListener("pointercancel",Xe,!0),()=>{ye.removeEventListener("pointerdown",Ge,!0),window.removeEventListener("pointerup",be,!0),window.removeEventListener("pointercancel",Xe,!0)}},[q,te,n,r]),b.useLayoutEffect(()=>{if(!D&&!U)return;const ye=He=>{const Ge=He.target;Ge instanceof Element&&Ge.closest('[data-slot="pty-selection-toolbar"], [data-slot="pty-selection-handle"]')||P()};return document.addEventListener("pointerdown",ye,!0),document.addEventListener("touchstart",ye,!0),()=>{document.removeEventListener("pointerdown",ye,!0),document.removeEventListener("touchstart",ye,!0)}},[P,U,D]),b.useEffect(()=>{if(!s||!D)return;const ye=()=>{const He=A.current;He&&s.scrollLeft===He.scrollLeft&&s.scrollTop===He.scrollTop||P()};return s.addEventListener("scroll",ye,{passive:!0}),()=>s.removeEventListener("scroll",ye)},[P,s,D]);const Q=U!==null;b.useLayoutEffect(()=>{var ye;Q&&((ye=i.current)==null||ye.relayout(),$())},[Q,l,$,i]),b.useEffect(()=>{Q&&$()},[Q,$,o.scrollLeft,o.scrollTop]),b.useEffect(()=>{if(!Q)return;const ye=window.visualViewport;let He=0,Ge=0;const be=()=>{cancelAnimationFrame(He),window.clearTimeout(Ge),He=requestAnimationFrame(()=>{$(),Ge=window.setTimeout(()=>{He=requestAnimationFrame(()=>$())},160)})};return be(),window.addEventListener("resize",be),ye==null||ye.addEventListener("resize",be),ye==null||ye.addEventListener("scroll",be),()=>{cancelAnimationFrame(He),window.clearTimeout(Ge),window.removeEventListener("resize",be),ye==null||ye.removeEventListener("resize",be),ye==null||ye.removeEventListener("scroll",be)}},[Q,$]);const me=b.useCallback(({clientX:ye,clientY:He})=>{const Ge=n.current,be=r.current;if(!Ge||!be)return;const Xe=Yh({terminal:Ge,host:be,clientX:ye,clientY:He})??E.current;if(Ge.clearSelection(),!Xe){w.current=null,x.current=null,I.current=null,T.current="",W(null),F(null),M(null);return}w.current=Xe,x.current=Xe,R.current=!1,I.current=null,T.current="",W(null),F(null),M(null),X({point:Xe,clientX:ye,clientY:He,showToolbar:!1})},[X,n,r]),ve=b.useCallback(({clientX:ye,clientY:He})=>{z({clientX:ye,clientY:He}),W(null)},[z]),Ce=b.useCallback(({clientX:ye,clientY:He})=>{const Ge=n.current,be=r.current;if(!Ge||!be)return;const Xe=w.current,rt=Yh({terminal:Ge,host:be,clientX:ye,clientY:He}),pt=rt??x.current,le=E.current,Ae=k.current,Ze=Ae?Math.hypot(ye-Ae.clientX,He-Ae.clientY)>=Kge:!1,tt=le??rt;if(!R.current&&!Ze&&T.current){ee(),E.current=null,k.current=null;return}const dt=!R.current&&!Ze&&tt?Z2({terminal:Ge,point:tt}):null,Dt=Ze?rt??pt:pt,Wt=(R.current||Ze)&&Xe&&Dt?lv({terminal:Ge,anchor:Xe,focus:Dt}):dt??X2({terminal:Ge,host:be,clientX:ye,clientY:He})??(le?GS({terminal:Ge,point:le}):null);if(E.current=null,k.current=null,!(Wt!=null&&Wt.text)){P();return}w.current=Wt.anchor,x.current=Wt.focus,T.current=Wt.text,V(Wt.text,dt==null?void 0:dt.pathAction);const tn=N(Wt.anchor,Wt.focus);F(tn),W(tn?Y(tn):L(ye,He))},[P,N,L,Y,V,ee,n,r]),Me=b.useCallback(()=>{var Ge;const ye=n.current,He=((Ge=ye==null?void 0:ye.getSelection)==null?void 0:Ge.call(ye))||T.current;He&&Mj(He,{allowLegacyFallback:!0}).then(be=>{P(),be==="failed"?nt.error("复制失败"):nt.success("已复制")})},[P,n]),Ve=b.useCallback(()=>{const ye=I.current;ye&&(ye.kind==="image-preview"?_(ye.path):v(ye.path),P())},[P,v,_]),Qe=b.useCallback(()=>w.current!==null,[]),ct=b.useCallback(()=>{W(null)},[]),Ot=b.useCallback((ye,{clientX:He,clientY:Ge})=>{z({clientX:He,clientY:Ge,draggedHandle:ye}),W(null)},[z]),he=b.useCallback((ye,He)=>{He&&z({...He,draggedHandle:ye}),T.current&&ee()},[z,ee]),Ke=b.useCallback(()=>{W(null)},[]);b.useEffect(()=>{},[P,N,Y,t,V,n]);const Rt=Yge({terminalRef:n,containerEl:s,suppressPtyFocus:d,focusPtyInput:h,isSelectionActive:Qe,onTap:p,isTapCandidate:y,onLongPressCandidateStart:K,onLongPressStart:me,onLongPressMove:ve,onLongPressEnd:Ce,onHorizontalScrollIntent:ye=>{var He;return(He=i.current)==null?void 0:He.markHorizontalScrollIntent(ye)},onSelectionAutoscroll:ye=>{A.current=ye},onHandleDragStart:ct,onHandleDragMove:Ot,onHandleDragEnd:he,onHandleDragCancel:Ke});return H.current=Rt.stopPtySelectionGesture,{pointerHandlers:Rt.pointerHandlers,ptySelectionToolbar:D,ptySelectionHandles:U,ptySelectionPathAction:O,ptySelectionHandleMetrics:B,copyPtySelection:Me,openPtySelectionPathAction:Ve,handlePtySelectionHandlePointerDown:Rt.handlePtySelectionHandlePointerDown,handlePtySelectionHandleTouchStart:Rt.handlePtySelectionHandleTouchStart}}function Xge(){return Ne(e=>e.ptyScrollTraceEnabled)}const Zge=new Set(["image/png","image/jpeg","image/webp","image/gif"]);function J2(e){return Zge.has(e)}function yE(e){if(!e)return null;const t=Array.from(e.items??[]);for(const r of t){if(r.kind!=="file"||!J2(r.type))continue;const i=r.getAsFile();if(i)return i}return Array.from(e.files??[]).find(r=>J2(r.type))??null}function Qge(e){return`${e.startsWith("@")?e:`@${e}`} `}async function Lj(e){const t=yE(e.clipboardData);if(!t)return null;if(!e.relay)throw new Error("请先连接开发机");const n=await Aj(t),r=await e.relay.uploadClipboardImage(e.sessionId,n);if(!r.success||!r.path)throw new Error(r.error??"剪贴板图片上传失败");return{path:r.path,pathMention:Qge(r.path)}}function Jge(e){if(!(e!=null&&e.files)||e.files.length===0)return null;for(const t of e.files)if(!t.type.startsWith("image/"))return t;return null}function eve({sessionId:e,terminalRef:t,onAfterPaste:n}){return b.useCallback(async r=>{var u;const i=r.clipboardData,s=!!yE(i),o=s?null:Jge(i);if(!s&&!o)return;r.preventDefault(),r.stopPropagation();const l=Pt;if(!l){nt.error("请先连接开发机");return}if(s){const d=nt.loading("图片上传中...");try{const h=await Lj({clipboardData:i,relay:l,sessionId:e});if(nt.dismiss(d),!h)return;Ys(e,h.pathMention)}catch(h){nt.error(h instanceof Error?h.message:String(h),{id:d});return}}else if(o){const d=await kf({relay:l,sessionId:e,file:o});if(!d)return;Ys(e,`@${d} `)}n==null||n(),(u=t.current)==null||u.focus()},[e,t,n])}const tve=new Set(["Enter","Backspace","Tab","Escape","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Delete","Home","End"]),eO={caseSensitive:!1,regex:!1,wholeWord:!1,decorations:Kfe};function nve({softKeyboardEditingSurface:e,ptyInputFocused:t,keyboardOpen:n}){return e&&t&&n}function rve({controlsVisible:e,keyboardOpen:t,previous:n}){return e?!n.controlsVisible||t&&!n.keyboardOpen:!1}function ive({touchEditingSurface:e,inputModePreference:t,detectedPhysicalKeyboard:n,softKeyboardDetected:r}){return!e||t==="hardware"?!0:t==="touch"?!1:n&&!r}function sve({active:e,touchEditingSurface:t,key:n,code:r,altKey:i=!1,ctrlKey:s=!1,metaKey:o=!1,isComposing:l=!1,targetAcceptsPtyInput:u=!0}){return!e||!t||!u||l||i||s||o||!r||r==="Unidentified"?!1:n.length===1?!0:n==="Unidentified"||n==="Process"||n==="Dead"?!1:tve.has(n)}const tO=8,ove=32;function ave({showMobilePtyControls:e,horizontalScrollable:t,mobileControlsHeight:n}){return e?Math.ceil(Math.max(0,n))+tO:t?ove:tO}function lve(e,t){return e.isComposing||e.altKey||e.ctrlKey||e.metaKey?null:e.key.length===1?e.key:e.key==="Enter"?"\r":e.key==="Backspace"?"":e.key==="Tab"?e.shiftKey?"\x1B[Z":" ":e.key==="Escape"?"\x1B":e.key==="ArrowUp"?Vh("\x1B[A",t):e.key==="ArrowDown"?Vh("\x1B[B",t):e.key==="ArrowRight"?Vh("\x1B[C",t):e.key==="ArrowLeft"?Vh("\x1B[D",t):e.key==="Delete"?"\x1B[3~":e.key==="Home"?"\x1B[H":e.key==="End"?"\x1B[F":null}function cve(e){const{sessionId:t,active:n=!0,containerEl:r,spacerRef:i,xtermHostRef:s,mobileControlsHeight:o}=e,l=vge(),u=wge(),d=Xge(),{openImagePreview:h}=N3(),p=b.useRef(null),y=b.useRef(null),v=b.useRef([]),_=b.useRef(null),w=b.useRef(null),x=b.useRef(n),E=b.useRef(n),k=b.useRef(!1),R=b.useRef(!1),A=b.useRef(!1),I=b.useRef(null),T=b.useRef(null),H=b.useRef(null),D=b.useRef(null),W=b.useRef({keyboardOpen:!1,controlsVisible:!1}),U=b.useRef(!1),F=b.useRef(!1),O=b.useRef(!1),M=b.useRef(null),B=b.useRef({keyboardOffset:0,hasSeenSoftKeyboard:!1,showMobilePtyControls:!1,touchEditingSurface:!1,ptyInputFocused:!1,containerPaddingBottom:0,mobileControlsBottomInset:0}),[L,N]=b.useState({scrollTop:0,scrollLeft:0,scrollHeight:0,scrollWidth:0,clientHeight:0,clientWidth:0,scrollable:!1,horizontalScrollable:!1}),[V,Y]=b.useState(!1),[$,P]=b.useState(!1),[q,K]=b.useState({resultIndex:-1,resultCount:0}),z=Ne(ue=>ue.connected),X=Ne(ue=>ue.proxyOnline),ee=Ne(ue=>ue.ptyFontSize),te=Ne(ue=>ue.inputModePreference),Q=Ne(ue=>ue.adaptiveInputModality),me=Ne(ue=>ue.setAdaptiveInputModality),ve=Q==="hardware",Ce=ul("(pointer: coarse), (hover: none)"),{bottomOffset:Me,layoutBottomInset:Ve}=vE(),Qe=te==="hardware",ct=ive({touchEditingSurface:Ce,inputModePreference:te,detectedPhysicalKeyboard:ve,softKeyboardDetected:Me>0}),Ot=Ce&&!ct,he=ct?0:Me,Ke=he>0,Rt=ct?0:Ve;U.current=ct,b.useEffect(()=>{x.current=n},[n]),b.useEffect(()=>{k.current=l.ready},[l.ready]);const ye=b.useCallback(()=>x.current&&k.current,[]);b.useEffect(()=>{he>0&&Y(!0)},[he]);const He=_ge({containerEl:r,xtermHostRef:s,terminalRef:p}),{ptyInputFocused:Ge,suppressPtyFocus:be,focusPtyInput:Xe,handleFocusCapture:rt,handleBlurCapture:pt}=He,le=nve({softKeyboardEditingSurface:Ot,ptyInputFocused:Ge,keyboardOpen:Ke});B.current={keyboardOffset:he,hasSeenSoftKeyboard:V,showMobilePtyControls:le,touchEditingSurface:Ce,ptyInputFocused:Ge,containerPaddingBottom:B.current.containerPaddingBottom,mobileControlsBottomInset:Rt};const Ae=u.clearNewFramesWhileAway;T.current||(T.current=W2(()=>{var ue;(ue=w.current)==null||ue.relayout()})),H.current||(H.current=W2(()=>{var xe,ke;const ue=D.current??{reason:"rawInput",force:!1};D.current=null,(xe=w.current)==null||xe.traceRawInputFollowFire(),(ke=w.current)==null||ke.scrollToBottom(ue.reason,ue.force?{force:!0}:void 0),Ae()}));const Ze=b.useCallback(()=>{M.current!==null&&(cancelAnimationFrame(M.current),M.current=null)},[]),tt=b.useCallback(()=>{O.current=!0,Ze()},[Ze]),dt=b.useCallback(()=>{var ue;!O.current||document.visibilityState==="hidden"||((ue=w.current)==null||ue.preparePageResumeRestore(),Ze(),M.current=requestAnimationFrame(()=>{M.current=requestAnimationFrame(()=>{M.current=null;const xe=w.current;xe&&(xe.restorePageResume(),Ae(),O.current=!1)})}))},[Ze,Ae]);b.useEffect(()=>()=>{var ue,xe;(ue=T.current)==null||ue.dispose(),(xe=H.current)==null||xe.dispose(),Ze(),T.current=null,H.current=null},[Ze]),b.useEffect(()=>{const ue=()=>{tt()},xe=()=>{if(document.visibilityState==="hidden"){ue();return}dt()};return document.addEventListener("visibilitychange",xe),window.addEventListener("pagehide",ue),window.addEventListener("pageshow",dt),window.addEventListener("focus",dt),()=>{document.removeEventListener("visibilitychange",xe),window.removeEventListener("pagehide",ue),window.removeEventListener("pageshow",dt),window.removeEventListener("focus",dt),Ze()}},[Ze,tt,dt]),b.useEffect(()=>{const ue=E.current;if(E.current=n,ue!==n){if(!n){tt();return}dt()}},[n,tt,dt]);const Dt=b.useCallback((ue="rawInput",xe)=>{var se,fe;const ke=D.current,De=(ke==null?void 0:ke.force)===!0||(xe==null?void 0:xe.force)===!0;D.current={reason:(xe==null?void 0:xe.force)===!0||!ke?ue:ke.reason,force:De},(se=w.current)==null||se.traceRawInputFollowScheduled(ue),(fe=H.current)==null||fe.schedule()},[]),Wt=b.useCallback((ue,xe)=>{var ke;!ue.includes("\r")&&!ue.includes(`
645
- `)||(ke=w.current)==null||ke.resetHorizontalScroll(xe,{holdUntilCursorVisible:!0})},[]),tn=b.useCallback(()=>U.current?"submit":"linefeed",[]),vn=b.useCallback(()=>U.current,[]);b.useEffect(()=>{if(!n||te!=="auto"||!Ce)return;const ue=ke=>{const De=s.current,se=r;return ke instanceof Node?De!=null&&De.contains(ke)||ke===document.body||ke===document.documentElement?!0:se!=null&&se.contains(ke)?ke instanceof HTMLElement?ke.closest('a,button,input,textarea,select,[contenteditable="true"],[role="button"],[role="textbox"]')===null:!0:!1:ke===window},xe=ke=>{var fe,Oe;if(!sve({active:x.current,touchEditingSurface:Ce,key:ke.key,code:ke.code,altKey:ke.altKey,ctrlKey:ke.ctrlKey,metaKey:ke.metaKey,isComposing:ke.isComposing,targetAcceptsPtyInput:ue(ke.target)}))return;me("hardware"),U.current=!0,(fe=p.current)==null||fe.focus();const De=s.current;if(ke.target instanceof Node&&(De!=null&&De.contains(ke.target)))return;const se=lve(ke,(Oe=p.current)==null?void 0:Oe.modes);!se||!ye()||(ke.preventDefault(),ke.stopPropagation(),Ys(t,se),Dt("physicalKeyboard"),Wt(se,"physicalKeyboardEnter"))};return window.addEventListener("keydown",xe,!0),()=>window.removeEventListener("keydown",xe,!0)},[n,ye,r,te,Wt,Dt,t,me,Ce,s]);const un=b.useCallback(ue=>{const xe=Pt;if(!xe){nt.error("请先连接开发机");return}const ke=nt.loading(`下载 ${ue} ...`);Y1({relay:xe,sessionId:t,path:ue}).then(De=>{De.ok?nt.success(`已开始下载 ${ue}`,{id:ke}):nt.error(De.error,{id:ke})}).catch(De=>{nt.error(De instanceof Error?De.message:String(De),{id:ke})})},[t]),Zt=b.useCallback(ue=>{const xe=p.current;return xe?Gme(xe,v.current,ue):!1},[]),Xn=b.useCallback(ue=>{const xe=p.current;return xe?Kme(xe,v.current,ue):!1},[]),Kt=Gge({sessionId:t,terminalRef:p,xtermHostRef:s,scrollControllerRef:w,containerEl:r,scrollState:L,keyboardOffset:he,ptyFontSize:ee,suppressPtyFocus:be,focusPtyInput:Xe,onTap:Zt,isTapCandidate:Xn,onDownloadPath:un,onPreviewPath:h});F.current=Kt.ptySelectionHandles!==null;const Zn=eve({sessionId:t,terminalRef:p,onAfterPaste:()=>Dt("paste")}),ze=b.useCallback(ue=>{if(!ye()){ue.preventDefault();return}Zn(ue)},[ye,Zn]),[et,Et]=b.useState(!1),Bt=b.useCallback(ue=>{ue.dataTransfer.types.includes("Files")&&(ue.preventDefault(),Et(xe=>xe||!0))},[]),J=b.useCallback(ue=>{ue.currentTarget.contains(ue.relatedTarget)||Et(!1)},[]),_e=b.useCallback(async ue=>{var se;const xe=(se=ue.dataTransfer.files)==null?void 0:se[0];if(!xe||(ue.preventDefault(),Et(!1),!ye()))return;const ke=Pt;if(!ke){nt.error("请先连接开发机");return}const De=await kf({relay:ke,sessionId:t,file:xe});De&&(Ys(t,`@${De} `),Dt("dropUpload"))},[ye,Dt,t]),Be=b.useCallback(ue=>{var ke;if(!ye()){ue.preventDefault();return}const xe=ue.target;xe instanceof Element&&xe.closest(".xterm")||(ue.preventDefault(),(ke=p.current)==null||ke.focus())},[ye]);b.useEffect(()=>{if(!z||!X)return;const ue=s.current,xe=ec,ke=Pt,De=r,se=i.current;if(!ue||!xe||!ke||!De||!se)return;let fe=null,Oe=null,Ue=null,ft=null,gt=null,kt=null,Tt=null;const rr=rme({host:ue,sessionId:t,ws:xe,relay:ke,scheduleAutoFocus:Ot?()=>{}:void 0,createTerminal:async fn=>{const $e=await sj(fn,{fontSize:Ne.getState().ptyFontSize});return Tt=$e.serializeAddon,$e},attachRawInput:(fn,$e,vt)=>bpe(fn,$e,{...vt,getPlainEnterBehavior:tn,isPhysicalKeyboardMode:vn,physicalKeyboardMode:Qe}),isInputEnabled:ye,canFocus:ye,onTerminalReady:fn=>{const $e=fn;p.current=$e;const vt=new xce({highlightLimit:1e3});$e.loadAddon(vt),y.current=vt,kt=vt.onDidChangeResults(Gt=>{K(Gt)}),P(!0);const Vt=Tme($e,h);fe=Vt.dispose;const bn=Ume($e,un);Oe=bn.dispose,v.current=[Vt.provider,bn.provider],dge(()=>p.current);const Bn=rpe(ue,{serializeRangeAsHtml:(Gt,nn)=>(Tt==null?void 0:Tt.serializeAsHTML({range:{startLine:Gt,endLine:Math.min(nn,Math.max(0,$e.buffer.active.length-1)),startCol:0},includeGlobalBackground:!0,onlySelection:!1,scrollback:0}))??""});ft=Bn.dispose;const zt=O.current;zt&&(A.current=!1);const Tn=Gpe({container:De,spacer:se,host:ue,term:$e,hasNewFrame:()=>R.current,consumeNewFrame:()=>{R.current=!1},hasNewFramesWhileAway:()=>u.hasNewFramesWhileAwayRef.current,setNewFramesWhileAway:u.setHasNewFramesWhileAway,onAtBottomChange:u.handleAtBottomChange,onScrollStateChange:N,initialUserHasVerticalScrollIntent:zt?!1:A.current,onUserVerticalScrollIntentChange:Gt=>{A.current=Gt},onTouchReviewStart:be,onTouchBoundaryPrevent:be,onReviewSnapshotCapture:Bn.captureRange,onReviewSnapshotClear:Bn.clear});w.current=Tn,Ue=Tn.dispose,zt&&(Tn.restorePageResume(),Ae(),O.current=!1),fge(()=>{var Ac;const Gt=ai=>{if(!ai)return null;const hs=ai.getBoundingClientRect();return{top:hs.top,bottom:hs.bottom,height:hs.height,left:hs.left,right:hs.right,width:hs.width}},nn=document.querySelector('[data-slot="pty-mobile-controls"]'),Bi=document.querySelector("[data-keyboard-offset]"),zr=window.visualViewport,Is=Gt(nn),ua=(zr==null?void 0:zr.height)??window.innerHeight;return{...mge(Tn.getDebugProbe,{container:De,spacer:se,host:ue,term:$e}),mobileLayout:{...B.current,window:{innerHeight:window.innerHeight,outerHeight:window.outerHeight,documentClientHeight:document.documentElement.clientHeight},visualViewport:zr?{height:zr.height,width:zr.width,offsetTop:zr.offsetTop,pageTop:zr.pageTop,scale:zr.scale}:null,chatRoot:{dataKeyboardOffset:(Bi==null?void 0:Bi.getAttribute("data-keyboard-offset"))??null,rect:Gt(Bi)},ptyViewRect:Gt(De.parentElement),containerRect:Gt(De),controlsRect:Is,controlsOverflowBelowVisualViewport:Is===null?null:Is.bottom-ua,activeElement:document.activeElement instanceof HTMLElement?{tag:document.activeElement.tagName,ariaLabel:document.activeElement.getAttribute("aria-label"),slot:(Ac=document.activeElement.closest("[data-slot]"))==null?void 0:Ac.getAttribute("data-slot")}:null},frame:{lastWriteAt:I.current,pendingNewFrame:R.current}}}),gt=ope({container:De,host:ue,onHorizontalScrollIntent:Gt=>{var nn;return(nn=w.current)==null?void 0:nn.markHorizontalScrollIntent(Gt)}}).dispose},onFramePending:()=>{R.current=!0,A.current&&!u.hasNewFramesWhileAwayRef.current&&u.setHasNewFramesWhileAway(!0)},onFrameWritten:()=>{var fn;I.current=performance.now(),(fn=T.current)==null||fn.schedule()},onRawInput:fn=>{Dt("rawInput",{force:!0}),Wt(fn,"rawInputEnter")},onError:fn=>{const $e=fn instanceof Error?fn.message:String(fn);nt.error(`终端初始化失败:${$e}`)},...l.transport});return _.current=rr,()=>{gt==null||gt(),Ue==null||Ue(),ft==null||ft(),kt==null||kt.dispose(),pge(),fe==null||fe(),Oe==null||Oe(),v.current=[],hge(),y.current=null,P(!1),K({resultIndex:-1,resultCount:0}),rr.dispose(),p.current=null,w.current=null,_.current=null}},[t,z,X,r,i,s,l.transport,u.handleAtBottomChange,u.hasNewFramesWhileAwayRef,u.setHasNewFramesWhileAway,ye,Qe,tn,vn,un,h,be,Dt,Wt]),b.useEffect(()=>{const ue=p.current,xe=w.current;!ue||!xe||Zfe(ue,ee,xe.relayout)},[ee]),b.useEffect(()=>{if(!n||!l.ready||Ot)return;const ue=requestAnimationFrame(()=>{var xe;return(xe=p.current)==null?void 0:xe.focus()});return()=>cancelAnimationFrame(ue)},[n,l.ready,Ot]);const ht=b.useCallback((ue="viewExternal",xe)=>{var ke;(ke=w.current)==null||ke.scrollToBottom(ue,xe)},[]),jt=b.useCallback(()=>{var ue;(ue=w.current)==null||ue.refreshReviewSnapshot()},[]),re=b.useCallback(ue=>{var xe;(xe=w.current)==null||xe.scrollToRatio(ue)},[]),ie=b.useCallback(ue=>{var xe;(xe=w.current)==null||xe.scrollToXRatio(ue)},[]),de=b.useCallback(ue=>{var Oe;const xe=p.current,ke=xe==null?void 0:xe.getSelectionPosition();if(!xe||!ke)return;const De=ke.start.y;if(De>=ue&&De<ue+xe.rows)return;const se=Math.max(0,xe.buffer.active.length-xe.rows);if(se===0)return;const fe=Math.max(0,Math.min(se,De-Math.floor(xe.rows/2)));(Oe=w.current)==null||Oe.scrollToRatio(fe/se)},[]),pe=b.useCallback((ue,xe=!1)=>{const ke=p.current,De=y.current;if(!ke||!De||!ue)return ue||(De==null||De.clearDecorations(),ke==null||ke.clearSelection(),K({resultIndex:-1,resultCount:0})),!1;const se=ke.buffer.active.viewportY,fe=De.findNext(ue,{...eO,incremental:xe});return fe&&de(se),fe},[de]),Z=b.useCallback(ue=>{const xe=p.current,ke=y.current;if(!xe||!ke||!ue)return!1;const De=xe.buffer.active.viewportY,se=ke.findPrevious(ue,eO);return se&&de(De),se},[de]),ne=b.useCallback(()=>{var ue,xe;(ue=y.current)==null||ue.clearDecorations(),(xe=p.current)==null||xe.clearSelection(),K({resultIndex:-1,resultCount:0})},[]),ae=b.useCallback(ue=>{var ke,De;if(!ye())return;const xe=Vh(ue,(ke=p.current)==null?void 0:ke.modes);Ys(t,xe),Dt("mobileControl",{force:!0}),Wt(ue,"mobileControlEnter"),(De=p.current)==null||De.focus()},[ye,Wt,Dt,t]),Te=b.useCallback(()=>{var xe,ke,De;if(!ye())return;const ue=(ke=(xe=navigator.clipboard)==null?void 0:xe.readText)==null?void 0:ke.bind(navigator.clipboard);if(!window.isSecureContext||!ue){nt.error("无法读取剪贴板"),(De=p.current)==null||De.focus();return}ue().then(se=>{if(!se)return;const fe=p.current;if(fe){fe.paste(se);return}Ys(t,se),Dt("paste"),Wt(se,"pasteEnter")}).catch(se=>{const fe=se instanceof Error&&se.message?se.message:"无法读取剪贴板";nt.error(fe)}).finally(()=>{var se;return(se=p.current)==null?void 0:se.focus()})},[ye,Wt,Dt,t]),je=ave({showMobilePtyControls:le,horizontalScrollable:L.horizontalScrollable,mobileControlsHeight:o});B.current.containerPaddingBottom=je,b.useEffect(()=>{var ke,De;F.current?(ke=w.current)==null||ke.relayout():(De=T.current)==null||De.schedule();const ue=W.current,xe=rve({controlsVisible:le,keyboardOpen:Ke,previous:ue});W.current={keyboardOpen:Ke,controlsVisible:le},le&&(F.current?Ae():xe?Dt("keyboardOffset",{force:!0}):Ke||Dt("keyboardOffset"))},[he,Ke,le,je,Ae,Dt]);const st=b.useMemo(()=>({onFocusCapture:rt,onBlurCapture:pt}),[rt,pt]);return{scrollState:L,isAtBottom:u.isAtBottom,hasNewFramesWhileAway:u.hasNewFramesWhileAway,ptyInputFocused:Ge,showMobilePtyControls:le,touchEditingSurface:Ce,keyboardOffset:he,physicalKeyboardMode:ct,softKeyboardEditingSurface:Ot,mobileControlsBottomInset:Rt,connectionReady:l.ready,connectionOverlay:l.overlay,containerPaddingBottom:je,traceEnabled:d,findReady:$,findResultIndex:q.resultIndex,findResultCount:q.resultCount,findNext:pe,findPrevious:Z,clearFind:ne,refreshReviewSnapshot:jt,scrollToBottom:ht,scrollToRatio:re,scrollToXRatio:ie,clearNewFramesWhileAway:Ae,sendMobileInput:ae,pasteMobileClipboard:Te,handleTerminalContainerMouseDown:Be,handlePasteCapture:ze,pointerHandlers:Kt.pointerHandlers,focusHandlers:st,ptySelectionToolbar:Kt.ptySelectionToolbar,ptySelectionHandles:Kt.ptySelectionHandles,ptySelectionPathAction:Kt.ptySelectionPathAction,ptySelectionHandleMetrics:Kt.ptySelectionHandleMetrics,copyPtySelection:Kt.copyPtySelection,openPtySelectionPathAction:Kt.openPtySelectionPathAction,handlePtySelectionHandlePointerDown:Kt.handlePtySelectionHandlePointerDown,handlePtySelectionHandleTouchStart:Kt.handlePtySelectionHandleTouchStart,isPtyDragOver:et,handlePtyDragOver:Bt,handlePtyDragLeave:J,handlePtyDrop:_e}}function uve({sessionId:e,sessionKind:t,provider:n,active:r=!0,findRequest:i}){const[s,o]=b.useState(null),[l,u]=b.useState(0),[d,h]=b.useState(!1),[p,y]=b.useState(""),v=b.useRef(null),_=b.useRef(null),w=cve({sessionId:e,active:r,containerEl:s,spacerRef:v,xtermHostRef:_,mobileControlsHeight:l}),x=w.ptySelectionHandleMetrics,{clearFind:E,findNext:k,findPrevious:R,findReady:A,findResultCount:I,findResultIndex:T}=w,H=b.useCallback(()=>{R(p)},[R,p]),D=b.useCallback(()=>{k(p)},[k,p]),W=b.useCallback(()=>h(!0),[]),U=b.useCallback(()=>{h(!1),E()},[E]),F=L3({enabled:r,open:d,openRequest:i,onOpen:W,onClose:U,onPrevious:H,onNext:D});return b.useEffect(()=>{!d||!A||(p?k(p,!0):E())},[E,k,d,p,A]),g.jsxs("div",{className:"flex flex-col h-full relative","data-slot":"chat-pty-view","data-connection-ready":w.connectionReady?"true":"false","aria-busy":!w.connectionReady,children:[d?g.jsx(X0,{query:p,resultIndex:T,resultCount:I,focusRequest:F.focusRequest,loading:!!p&&!A,onQueryChange:y,onPrevious:H,onNext:D,onClose:F.closeFind}):null,g.jsx("div",{ref:o,className:"flex-1 min-h-0 overflow-auto overscroll-contain bg-background px-3 pt-2",style:{paddingBottom:`calc(env(safe-area-inset-bottom) + ${w.containerPaddingBottom}px)`,touchAction:"pan-x pan-y",overflowAnchor:"none"},onMouseDownCapture:w.handleTerminalContainerMouseDown,onPointerDownCapture:O=>{w.refreshReviewSnapshot(),w.pointerHandlers.onPointerDownCapture(O)},onPointerMoveCapture:w.pointerHandlers.onPointerMoveCapture,onPointerUpCapture:w.pointerHandlers.onPointerUpCapture,onPointerCancelCapture:w.pointerHandlers.onPointerCancelCapture,onTouchStartCapture:w.pointerHandlers.onTouchStartCapture,onTouchMoveCapture:w.pointerHandlers.onTouchMoveCapture,onTouchEndCapture:w.pointerHandlers.onTouchEndCapture,onTouchCancelCapture:w.pointerHandlers.onTouchCancelCapture,onContextMenuCapture:w.pointerHandlers.onContextMenuCapture,onPasteCapture:w.handlePasteCapture,onDragOver:w.handlePtyDragOver,onDragLeave:w.handlePtyDragLeave,onDrop:w.handlePtyDrop,onFocusCapture:w.focusHandlers.onFocusCapture,onBlurCapture:w.focusHandlers.onBlurCapture,"data-slot":"pty-terminal","data-drag-over":w.isPtyDragOver?"true":void 0,children:g.jsx("div",{ref:v,style:{position:"relative",overflowAnchor:"none"},"data-slot":"pty-spacer",children:g.jsx("div",{ref:_,style:{position:"absolute",left:0,top:0,overflow:"hidden",overflowAnchor:"none",boxSizing:"border-box"},"data-slot":"pty-host"})})}),g.jsx(O3,{visible:!w.isAtBottom,hasNewMessages:w.hasNewFramesWhileAway,className:d?"top-14":"top-10",onClick:()=>{w.scrollToBottom("backToBottomBtn",{force:!0}),w.clearNewFramesWhileAway()}}),w.showMobilePtyControls?g.jsx(Lle,{sessionKind:t,provider:n,bottomInset:w.mobileControlsBottomInset,onInput:w.sendMobileInput,onPaste:w.pasteMobileClipboard,onHeightChange:u}):null,w.ptySelectionHandles?g.jsxs(g.Fragment,{children:[g.jsx(nO,{kind:"anchor",position:w.ptySelectionHandles.anchor,metrics:x,"aria-label":"调整选区起点",onPointerDown:O=>w.handlePtySelectionHandlePointerDown("anchor",O),onTouchStart:O=>w.handlePtySelectionHandleTouchStart("anchor",O)}),g.jsx(nO,{kind:"focus",position:w.ptySelectionHandles.focus,metrics:x,"aria-label":"调整选区终点",onPointerDown:O=>w.handlePtySelectionHandlePointerDown("focus",O),onTouchStart:O=>w.handlePtySelectionHandleTouchStart("focus",O)})]}):null,w.ptySelectionToolbar?g.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:w.ptySelectionToolbar.left,top:w.ptySelectionToolbar.top},"data-slot":"pty-selection-toolbar",children:[g.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:O=>O.preventDefault(),onClick:w.copyPtySelection,"aria-label":"复制终端选区",children:"复制"}),w.ptySelectionPathAction?g.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:O=>O.preventDefault(),onClick:w.openPtySelectionPathAction,"aria-label":w.ptySelectionPathAction.kind==="image-preview"?"预览终端选区图片":"下载终端选区文件",children:w.ptySelectionPathAction.kind==="image-preview"?"预览":"下载"}):null]}):null,g.jsx(Ule,{state:w.scrollState,onScrollRatio:w.scrollToRatio}),g.jsx(Wle,{state:w.scrollState,onScrollRatio:w.scrollToXRatio}),g.jsx(Sle,{...w.connectionOverlay}),g.jsx(Ele,{ptyInputFocused:w.ptyInputFocused,touchEditingSurface:w.touchEditingSurface,softKeyboardEditingSurface:w.softKeyboardEditingSurface,physicalKeyboardMode:w.physicalKeyboardMode,keyboardOffset:w.keyboardOffset,showMobilePtyControls:w.showMobilePtyControls,mobileControlsBottomInset:w.mobileControlsBottomInset}),w.traceEnabled?g.jsx(dve,{}):null]})}function nO({kind:e,position:t,metrics:n,"aria-label":r,onPointerDown:i,onTouchStart:s}){const o=n.touchSize/2,l=2,u=n.visualSize,d=Math.max(n.stemSize+2,u+1),h=o-l/2,p=o,y=e==="anchor"?h-u+l:h,v=p+d-u+l,_=e==="anchor"?{borderTopLeftRadius:u,borderBottomLeftRadius:u,borderTopRightRadius:2,borderBottomRightRadius:u}:{borderTopLeftRadius:2,borderBottomLeftRadius:u,borderTopRightRadius:u,borderBottomRightRadius:u};return g.jsxs("button",{type:"button",className:"fixed z-50 touch-none rounded-full bg-transparent p-0 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring",style:{left:t.left,top:t.top,width:n.touchSize,height:n.touchSize,transform:"translate(-50%, -50%)"},"data-slot":"pty-selection-handle","data-kind":e,"aria-label":r,onPointerDown:i,onTouchStart:s,children:[g.jsx("span",{className:"pointer-events-none absolute rounded-full bg-primary",style:{left:h,top:p,width:l,height:d},"data-slot":"pty-selection-handle-stem"}),g.jsx("span",{className:"pointer-events-none absolute border-2 border-primary bg-background shadow-sm shadow-black/30",style:{left:y,top:v,width:u,height:u,..._},"data-slot":"pty-selection-handle-dot"})]})}function dve(){const[e,t]=b.useState(!1);async function n(){const r=_le();try{await navigator.clipboard.writeText(r),t(!0),window.setTimeout(()=>t(!1),1200)}catch{window.prompt("Copy PTY scroll trace",r)}}return g.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 hve=3,fve=1024,pve=720,tg=.5,Ij=b.createContext(null);function mve({children:e}){const[t,n]=b.useState([]),[r,i]=b.useState(null),[s,o]=b.useState(null),l=Ne(k=>k.selectedProxyId),u=$t(k=>k.sessions),d=$t(k=>k.sessionListLoaded),h=b.useRef(l),p=b.useRef(null),y=b.useMemo(()=>u.filter(k=>k.mode==="pty").map(k=>k.sessionId).sort().join(`
641
+ `))}},lfe=class extends Error{constructor(t,n){super(t),this.name="ListenerLeakError",this.stack=n}},cfe=class extends Error{constructor(t,n){super(t),this.name="ListenerRefusalError",this.stack=n}},ufe=0,Mw=class{constructor(t){this.value=t,this.id=ufe++}},dfe=2,hfe,Wa=class{constructor(e){var t,n,r,i;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new ofe((e==null?void 0:e.onListenerError)??Nw,((n=this._options)==null?void 0:n.leakWarningThreshold)??sfe):void 0,this._perfMon=(r=this._options)!=null&&r._profName?new ife(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,h;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let p=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(p);let y=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],v=new cfe(`${p}. HINT: Stack shows most frequent listener (${y[1]}-times)`,y[0]);return(((o=this._options)==null?void 0:o.onListenerError)||Nw)(v),ov.None}if(this._disposed)return ov.None;t&&(e=e.bind(t));let r=new Mw(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=afe.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Mw?(this._deliveryQueue??(this._deliveryQueue=new ffe),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,(h=(d=this._options)==null?void 0:d.onDidAddFirstListener)==null||h.call(d,this)),this._size++;let s=$5(()=>{i==null||i(),this._removeListener(r)});return n instanceof aE?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*dfe<=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)||Nw;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 Mw)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}},ffe=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}},Fu=class Ag{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Wa,this.onChange=this._onChange.event;let t=new Yhe;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=Ag.extractWidth(l);Ag.extractShouldJoin(l)&&(u-=Ag.extractWidth(r)),n+=u,r=l}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},lE=0,K5=-3,Cf=class{constructor(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}},pfe=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 Cf,this.dtree=new Cf}},G5=new Cf,X5=new Cf,cE=new Uint8Array(30),uE=new Uint16Array(30),Z5=new Uint8Array(30),Q5=new Uint16Array(30),mfe=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),A2=new Cf,lo=new Uint8Array(320);function J5(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 gfe(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 N2=new Uint16Array(16);function Ow(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)N2[i]=s,s+=e.table[i];for(i=0;i<r;++i)t[n+i]&&(e.trans[N2[t[n+i]]++]=i)}function vfe(e){e.bitcount--||(e.tag=e.source[e.sourceIndex++],e.bitcount=7);var t=e.tag&1;return e.tag>>>=1,t}function vo(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 HS(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 yfe(e,t,n){var r,i,s,o,l,u;for(r=vo(e,5,257),i=vo(e,5,1),s=vo(e,4,4),o=0;o<19;++o)lo[o]=0;for(o=0;o<s;++o){var d=vo(e,3,0);lo[mfe[o]]=d}for(Ow(A2,lo,0,19),l=0;l<r+i;){var h=HS(e,A2);switch(h){case 16:var p=lo[l-1];for(u=vo(e,2,3);u;--u)lo[l++]=p;break;case 17:for(u=vo(e,3,3);u;--u)lo[l++]=0;break;case 18:for(u=vo(e,7,11);u;--u)lo[l++]=0;break;default:lo[l++]=h;break}}Ow(t,lo,0,r),Ow(n,lo,r,i)}function M2(e,t,n){for(;;){var r=HS(e,t);if(r===256)return lE;if(r<256)e.dest[e.destLen++]=r;else{var i,s,o,l;for(r-=257,i=vo(e,cE[r],uE[r]),s=HS(e,n),o=e.destLen-vo(e,Z5[s],Q5[s]),l=o;l<o+i;++l)e.dest[e.destLen++]=e.dest[l]}}}function bfe(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 K5;for(e.sourceIndex+=4,r=t;r;--r)e.dest[e.destLen++]=e.source[e.sourceIndex++];return e.bitcount=0,lE}function _fe(e,t){var n=new pfe(e,t),r,i,s;do{switch(r=vfe(n),i=vo(n,2,0),i){case 0:s=bfe(n);break;case 1:s=M2(n,G5,X5);break;case 2:yfe(n,n.ltree,n.dtree),s=M2(n,n.ltree,n.dtree);break;default:s=K5}if(s!==lE)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}gfe(G5,X5);J5(cE,uE,4,3);J5(Z5,Q5,2,1);cE[28]=0;uE[28]=258;var O2=_fe,dE=11,ic=5,wfe=dE-ic,Sfe=65536>>dE,xfe=1<<wfe,Efe=xfe-1,Ng=2,Cfe=1<<ic,Dw=Cfe-1,e4=65536>>ic,kfe=1024>>ic,Tfe=e4+kfe,Rfe=Tfe,Afe=32,Nfe=Rfe+Afe,Mfe=1<<Ng,Ofe=new Uint8Array(new Uint32Array([305419896]).buffer)[0]===18,Dfe=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=O2(e,new Uint8Array(n)),e=O2(e,new Uint8Array(n)),Ofe){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>>ic]<<Ng)+(e&Dw),this.data[t]):e<=65535?(t=(this.data[e4+(e-55296>>ic)]<<Ng)+(e&Dw),this.data[t]):e<this.highStart?(t=this.data[Nfe-Sfe+(e>>dE)],t=this.data[t+(e>>ic&Efe)],t=(t<<Ng)+(e&Dw),this.data[t]):this.data[this.data.length-Mfe]}},Pfe=Dfe,Lfe="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 Ife(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 zfe=new Pfe(Ife(Lfe)),US=15,WS=0,Bfe=48,jfe=4,Ffe=0,t4=1,n4=2,qS=3,$fe=4,Pw=5,Lw=6,Iw=7,D2=8,zw=9,P2=10,Hfe=11,Ufe=32;function L2(e){return(e&Bfe)>>jfe}function Wfe(e,t){let n=(e&US)>>WS,r=(t&US)>>WS;return qfe(n,r)?r===qS?Ufe:r+16:r-16}function qfe(e,t){return e>=Pw&&e<=zw&&(e==Pw&&(t==Pw||t==Lw||t==D2||t==zw)||(e==D2||e==Lw)&&(t==Lw||t==Iw)||(e==zw||e==Iw)&&t==Iw)||t==n4||t==P2||e==t4||t==$fe||e==P2&&t==Hfe||t==qS&&e==qS}function I2(e){return zfe.get(e)}var r4=class i4{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 i4._plainNarrowProperties;let r=I2(t),i=L2(r),s=!1;if(i>=2?i=i===3||this.ambiguousCharsAreWide||t===65039?2:1:i=1,n!==0){let o=Fu.extractWidth(n);this.handleGraphemes?r=Wfe(Fu.extractCharKind(n),r):r=i===0?1:0,s=r>0,s&&(o>i?i=o:r===32&&(i=2))}return Fu.createPropertyValue(r,i,s)}wcwidth(t){let n=I2(t),r=L2(n),i=(n&US)>>WS;return i===n4||i===t4?0:r>=2&&(r===3||this.ambiguousCharsAreWide)?2:1}};r4._plainNarrowProperties=Fu.createPropertyValue(Ffe,1,!1);var z2=r4,Vfe=class{constructor(){this._oldVersion=""}activate(e){this._provider15||(this._provider15=new z2(!1)),this._provider15Graphemes||(this._provider15Graphemes=new z2(!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 Yfe={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"},Kfe={matchBackground:"#264F78",matchBorder:"#3B8EEA",matchOverviewRuler:"#3B8EEA",activeMatchBackground:"#7A4E00",activeMatchBorder:"#F5F543",activeMatchColorOverviewRuler:"#F5F543"},Gfe="─│╭╮╰╯";function Xfe(e={}){return{scrollback:5e3,fontFamily:iL,fontSize:e.fontSize??Hu,cursorBlink:!0,cursorStyle:"block",cursorInactiveStyle:"none",disableStdin:!1,theme:Yfe,allowProposedApi:!0}}async function s4(e,t={}){await document.fonts.ready;const n=t.fontSize??Hu;try{await document.fonts.load(`${n}px "Sarasa Fixed SC"`,Gfe)}catch{}const r=new Ohe(Xfe(t)),i=new zhe,s=new Whe,o=new Vfe;r.loadAddon(i),r.loadAddon(s),r.loadAddon(o),e.replaceChildren(),r.open(e);const l=()=>{r.refresh(0,r.rows-1)},u=()=>{document.visibilityState==="visible"&&r.refresh(0,r.rows-1)},d=()=>{r.refresh(0,r.rows-1)},h=()=>{r.refresh(0,r.rows-1)};return document.fonts.addEventListener("loadingdone",l),document.addEventListener("visibilitychange",u),window.addEventListener("pageshow",d),window.addEventListener("focus",h),{terminal:r,serializeAddon:i,dispose:()=>{document.fonts.removeEventListener("loadingdone",l),document.removeEventListener("visibilitychange",u),window.removeEventListener("pageshow",d),window.removeEventListener("focus",h),r.dispose()}}}function Zfe(e,t,n){return e.options.fontSize===t?!1:(e.options.fontSize=t,requestAnimationFrame(()=>n==null?void 0:n()),!0)}const o4="pty-review-snapshot";function Qfe(e){return Array.from(e.children).find(t=>t instanceof HTMLElement&&t.classList.contains("xterm-rows")&&t.dataset.slot!==o4)??null}function Jfe(e,t){const n=document.createElement("div");return n.dataset.slot=o4,n.setAttribute("aria-hidden","true"),Object.assign(n.style,{position:"absolute",top:"0",right:"0",left:"0",height:t.style.height||"100%",overflow:"hidden",pointerEvents:"none",backgroundColor:getComputedStyle(e).backgroundColor}),n.append(t),n}function epe(e){for(const t of e.querySelectorAll("span[style]")){const n=t.style.opacity;if(!n||n==="1")continue;t.style.removeProperty("opacity");const r=document.createElement("span");r.style.opacity=n,r.append(...Array.from(t.childNodes)),t.append(r)}}function tpe(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 npe(e,t,n){const i=new DOMParser().parseFromString(e,"text/html").querySelector("pre > div");if(!i)return null;const s=document.importNode(i,!0);s.className=t.className,s.removeAttribute("id"),tpe(s),epe(s);const o=getComputedStyle(t),l=n>0?t.clientHeight/n:0,u=s.childElementCount;Object.assign(s.style,{position:"absolute",top:"0",left:"0",width:"100%",height:`${u*l}px`,fontFamily:o.fontFamily,fontSize:o.fontSize,fontWeight:o.fontWeight,fontVariantLigatures:o.fontVariantLigatures,letterSpacing:o.letterSpacing,whiteSpace:"pre"});for(const d of Array.from(s.children))d instanceof HTMLElement&&Object.assign(d.style,{height:`${l}px`,lineHeight:`${l}px`,overflow:"hidden",whiteSpace:"pre"});return s}function rpe(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(h=>h instanceof HTMLElement&&h.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{captureRange:(l,u)=>{const d=e.querySelector(".xterm-screen"),h=d?Qfe(d):null;if(!d||!h||!t.serializeRangeAsHtml||u<=0)return!1;const p=t.serializeRangeAsHtml(l,l+u),y=npe(p,h,u);if(!y)return!1;const v=Jfe(d,y);return i(v),!0},clear:s,dispose:s}}const a4=28,l4=14;function Jm(e,t,n){const r=Math.min(1,Math.max(0,1-e/t));return Math.ceil(n*r)}function c4({pointerX:e,pointerY:t,rect:n,scrollLeft:r,scrollTop:i,scrollWidth:s,scrollHeight:o,clientWidth:l,clientHeight:u,edgePx:d=a4,maxSpeedPx:h=l4}){let p=0;const y=e-n.left,v=n.right-e;if(y<d&&r>0)p=-Jm(y,d,h);else if(v<d){const E=Math.max(0,s-l);r<E&&(p=Jm(v,d,h))}let _=0;const w=t-n.top,x=n.bottom-t;if(w<d&&i>0)_=-Jm(w,d,h);else if(x<d){const E=Math.max(0,o-u);i<E&&(_=Jm(x,d,h))}return{dx:p,dy:_}}const ipe=a4,spe=l4;function ope(e){var T,H,D,W;const{container:t,host:n,edgePx:r=ipe,maxSpeedPx:i=spe,onHorizontalScrollIntent:s,requestFrame:o=U=>requestAnimationFrame(U),cancelFrame:l=U=>cancelAnimationFrame(U)}=e;let u=!1,d=0,h=0,p=null,y=0,v="unknown",_=null,w=null,x=null;const E=()=>{if(x&&x.isConnected)return x;const U=n.querySelector(".xterm-screen");return x=U??n,v=U?"xterm-screen":"host",x},k=()=>{u=!1,p!==null&&(l(p),p=null)},R=()=>{if(p=null,!u)return;const U=t.getBoundingClientRect(),{dx:F,dy:O}=c4({pointerX:d,pointerY:h,rect:U,scrollLeft:t.scrollLeft,scrollTop:t.scrollTop,scrollWidth:t.scrollWidth,scrollHeight:t.scrollHeight,clientWidth:t.clientWidth,clientHeight:t.clientHeight,edgePx:r,maxSpeedPx:i});F!==0&&(s==null||s(`dragSelectAutoscroll dx=${Math.round(F)}`),t.scrollLeft+=F),O!==0&&(t.scrollTop+=O),(F!==0||O!==0)&&(E().dispatchEvent(new MouseEvent("mousemove",{clientX:d,clientY:h,bubbles:!0,cancelable:!0})),y+=1,_={dx:F,dy:O},w=Date.now()),p=o(R)},A=U=>{U.pointerType==="mouse"&&U.button===0&&(u=!0,d=U.clientX,h=U.clientY,p===null&&(p=o(R)))},I=U=>{u&&(d=U.clientX,h=U.clientY)};return t.addEventListener("pointerdown",A),(T=globalThis.addEventListener)==null||T.call(globalThis,"pointermove",I),(H=globalThis.addEventListener)==null||H.call(globalThis,"pointerup",k),(D=globalThis.addEventListener)==null||D.call(globalThis,"pointercancel",k),(W=globalThis.addEventListener)==null||W.call(globalThis,"blur",k),{dispose(){var U,F,O,M;k(),t.removeEventListener("pointerdown",A),(U=globalThis.removeEventListener)==null||U.call(globalThis,"pointermove",I),(F=globalThis.removeEventListener)==null||F.call(globalThis,"pointerup",k),(O=globalThis.removeEventListener)==null||O.call(globalThis,"pointercancel",k),(M=globalThis.removeEventListener)==null||M.call(globalThis,"blur",k)},getDebugSnapshot(){return{dragging:u,pointerX:d,pointerY:h,dispatchCount:y,dispatchTargetTag:v,lastScrollDelta:_,lastDispatchedAt:w}}}}const ape=16,lpe=16,cpe=16;function u4(e){const t=Array.from(e);return t.length!==1?!1:/^[\p{P}\p{S}]$/u.test(t[0])}function upe(e){if(e.length!==1)return!1;const t=e.charCodeAt(0);return t>=48&&t<=57}function dpe(e){for(const t of e){const n=t.codePointAt(0);if(n!==void 0&&n>127)return!0}return!1}function hpe(e,t){return t.physicalKeyboardMode!==!0||e.length===0?!1:e===" "||dpe(e)?!0:Array.from(e).every(u4)}function fpe(e,t={}){return e.type!=="keydown"||e.ctrlKey||e.metaKey||e.altKey||e.isComposing||t.imeComposing?!1:u4(e.key)||t.physicalKeyboardMode===!0&&(e.key===" "||upe(e.key))}function ppe(e){return e.type!=="keydown"||!e.ctrlKey||e.metaKey||e.altKey||e.shiftKey?!1:e.key===" "||e.key==="Spacebar"||e.code==="Space"}function mpe(e){return e.type!=="keydown"?!1:e.metaKey}function d4(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 h4(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 gpe(){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 vpe(e){const t=d4(e),n=gpe();return e.setAttribute("autocapitalize","off"),e.setAttribute("autocomplete","off"),e.setAttribute("autocorrect","off"),e.spellcheck=!1,n&&(e.style.colorScheme=n),()=>h4(e,t)}function ype(e){const t=d4(e);return e.setAttribute("enterkeyhint","send"),()=>{h4(e,t)}}function bpe(e,t,n={}){var L,N,V,Y;let r,i,s,o=!1,l;const u=()=>{var $;return(($=n.isPhysicalKeyboardMode)==null?void 0:$.call(n))??n.physicalKeyboardMode===!0},d=()=>{var $;return(($=n.getPlainEnterBehavior)==null?void 0:$.call(n))??n.plainEnterBehavior??"submit"},h=e.textarea?vpe(e.textarea):void 0,p=u()&&e.textarea?ype(e.textarea):void 0,y=()=>{const $=e.textarea;!$||l||(l=setTimeout(()=>{l=void 0,o||($.value="")},0))},v=$=>{var P;if(n.isInputEnabled&&!n.isInputEnabled()){y();return}Ys(t,$),(P=n.onRawInput)==null||P.call(n,$),y()},_=$=>{v($)},w=()=>{i&&(clearTimeout(i.timer),i=void 0)},x=()=>{s&&(clearTimeout(s.timer),s=void 0)},E=$=>{if(x(),!$)return;const P={data:$,timer:setTimeout(()=>{s===P&&(s=void 0)},cpe)};s=P},k=$=>{E(`${(s==null?void 0:s.data)??""}${$}`)},R=$=>!s||!$||!s.data.startsWith($)?!1:(E(s.data.slice($.length)),!0),A=($,P)=>{w();const q={data:$,keydownText:P,timer:setTimeout(()=>{i===q&&(i=void 0)},lpe)};i=q},I=($,P)=>{const q=$.startsWith(P.data)?P.data:$.startsWith(P.keydownText)?P.keydownText:"";return q?$.slice(q.length):$},T=($,P,q)=>I($,{data:q,keydownText:P.keydownText}),H=($,P)=>{let q=!1;for(const K of $.bufferedXtermData){let z=K;if(!q){const X=T(K,$,P);X!==K&&(z=X,q=!0)}z&&_(z)}},D=$=>{const P=r;P&&(r=void 0,clearTimeout(P.timer),v($),A($,P.keydownText),H(P,$))},W=$=>{r&&D(r.keydownText),w();const P={bufferedXtermData:[],keydownText:$,timer:setTimeout(()=>{r===P&&D($)},ape)};r=P},U=$=>hpe($,{physicalKeyboardMode:u()})?R($)?(y(),!0):(v($),A($,$),!0):!1,F=$=>{const P=$,q=P.data??"";if(!P.isComposing&&r&&q){D(q);return}P.isComposing||P.inputType!=="insertText"&&P.inputType!=="insertCompositionText"||U(q)},O=()=>{o=!0,l&&(clearTimeout(l),l=void 0);const $=e.textarea;$&&($.value="")},M=$=>{o=!1,r&&$.data&&D($.data)},B=e.onData($=>{if(r){r.bufferedXtermData.push($);return}if(i){const P=I($,i);w(),P&&_(P);return}_($),k($)});return(L=e.textarea)==null||L.addEventListener("input",F),(N=e.textarea)==null||N.addEventListener("compositionstart",O,!0),(V=e.textarea)==null||V.addEventListener("compositionend",M),(Y=e.attachCustomKeyEventHandler)==null||Y.call(e,$=>u()&&(ppe($)||mpe($))?!1:fpe($,{physicalKeyboardMode:u(),imeComposing:o})?(W($.key),!1):$.type!=="keydown"||$.key!=="Enter"?!0:d()==="linefeed"!==$.shiftKey?(v(`
642
+ `),$.preventDefault(),!1):!0),{dispose:()=>{var $,P,q;B.dispose(),($=e.textarea)==null||$.removeEventListener("input",F),(P=e.textarea)==null||P.removeEventListener("compositionstart",O,!0),(q=e.textarea)==null||q.removeEventListener("compositionend",M),r&&(clearTimeout(r.timer),r=void 0),l&&(clearTimeout(l),l=void 0),p==null||p(),h==null||h(),w(),x()}}}function f4(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=t<0?1:Math.max(1,t+1),l=r?Math.max(0,s-o*e.cellH):0,u=Math.max(0,e.bufferLength-e.rows),d=u*e.cellH+i;if(i>0&&n>i&&e.cursorY!==void 0){const p=Math.max(0,Math.min(e.rows-1,e.cursorY)),y=u*e.cellH,v=y+n-i,_=y+p*e.cellH-(i-e.cellH)/2;return{spacerHeight:Math.max(y,Math.min(v,_))+i,spacerWidth:e.cols*e.cellW,hostWidth:e.cols*e.cellW,hostHeight:n,hostPaddingTop:l}}return{spacerHeight:Math.max(e.bufferLength*e.cellH,d),spacerWidth:e.cols*e.cellW,hostWidth:e.cols*e.cellW,hostHeight:n,hostPaddingTop:l}}function hE(e){const t=e.paddingTop+e.cursorBufferRow*e.cellH,n=e.containerScrollTop+e.paddingTop,r=e.containerScrollTop+e.containerClientHeight-e.paddingBottom,i=Math.max(1,e.atBottomThreshold),s=e.cellH>0&&t>=n-i&&t+e.cellH<=r+i,o=Math.max(0,e.containerScrollHeight-e.containerClientHeight),l=e.rows*e.cellH,u=e.cellH>0&&l>e.visibleContentHeight;let d,h;if(u){d=s;const p=t-e.paddingTop-(e.visibleContentHeight-e.cellH)/2,v=Math.max(0,e.bufferLength-e.rows)*e.cellH;h=Math.max(v,Math.min(o,p))}else d=e.containerScrollTop+e.containerClientHeight>=e.containerScrollHeight-e.atBottomThreshold,h=o;return{isAtBottom:d,bottomScrollTop:h,cursorInViewport:s}}function p4(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 B2(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 _pe(e,t){return t<=0?0:Math.max(0,e)*t}function wpe(){return{intent:!1,lastUserInputAt:null,unmarkedOriginLeft:null,lastSeenLeft:0,pendingFollowLeft:null}}function Spe(e,t){return{...e,intent:t,unmarkedOriginLeft:t?e.unmarkedOriginLeft:null}}function Mg(e,t){return{state:{...Spe(e,!1),lastUserInputAt:null,pendingFollowLeft:null,...t.scrollLeft!==void 0?{lastSeenLeft:t.scrollLeft}:{}},trace:e.intent?{kind:"clear",details:t.details}:null}}function xpe(e,t){return{state:{...e,intent:!0,lastUserInputAt:t.now,unmarkedOriginLeft:null},trace:e.intent?null:{kind:"set",details:t.details}}}function Epe(e,t){return{...e,pendingFollowLeft:t}}function Cpe(e,t){if(!t.hasOverflow)return{...Mg(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,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,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 kpe({syncingExternal:e,effectiveScrollTop:t,pendingFollowTop:n,pendingProgrammaticTop:r,atBottom:i,canPassiveFollow:s,tolerancePx:o=1}){if(e)return{action:"external-sync",nextPendingFollowTop:n,nextPendingProgrammaticTop:r};if(n!==null&&Math.abs(t-n)<=o)return{action:"programmatic-follow",nextPendingFollowTop:null,nextPendingProgrammaticTop:null};const u=r!==null&&Math.abs(t-r)<=o&&s;return!i&&u?{action:"programmatic-drift",nextPendingFollowTop:null,nextPendingProgrammaticTop:null}:{action:"continue",nextPendingFollowTop:null,nextPendingProgrammaticTop:null}}function Tpe(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 Rpe(e){return!(e.bottomScrollTop<e.domMaxScrollTop-1)||e.rawScrollTop<=e.bottomScrollTop+1?{action:"keep",scrollTop:e.rawScrollTop}:{action:"clamp",scrollTop:e.bottomScrollTop}}function Ape({container:e,term:t,onWheel:n,onTouchStart:r,onTouchMove:i,onTouchEnd:s,onTouchCancel:o,onContainerScroll:l,onTermScroll:u,onRender:d,onRelayout:h,onWriteParsed:p}){var x;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),v=t.onRender(d),_=p?(x=t.onWriteParsed)==null?void 0:x.call(t,p):void 0,w=new ResizeObserver(h);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(),v.dispose(),_==null||_.dispose(),w.disconnect()}}}function Npe({container:e,host:t,term:n,atBottomThreshold:r,getDims:i,getVerticalInsets:s,getPrevCursorBufferRow:o,getPendingProgrammaticScrollTop:l,getPendingFollowCursorScrollTop:u,getPendingFollowCursorScrollLeft:d,getPendingContainerSyncRetry:h,getHorizontalIntent:p,getVerticalIntent:y,getUserHasVerticalScrollIntent:v}){var T,H;let _=null,w=null;const x=()=>{var B;const D=document.activeElement;if(!D)return null;const W=D.getAttribute("aria-label")??"",U=D.tagName,F=typeof D.closest=="function"?((B=D.closest("[data-slot]"))==null?void 0:B.getAttribute("data-slot"))??"":"",O=D.id?`#${D.id}`:"",M=typeof D.className=="string"&&D.className?"."+D.className.split(/\s+/).filter(Boolean).slice(0,2).join("."):"";return W?`${W}|${U}${O}${M}{${F}}`:`${U}${O}${M}{${F}}`},E=(D,W={})=>{if(!dw())return;const U=e.getBoundingClientRect(),F=t.getBoundingClientRect(),O=window.visualViewport,{cellH:M,cellW:B}=i(),{paddingTop:L,paddingBottom:N}=s(),V=Math.max(0,e.clientHeight-L-N),Y=n.buffer.active,$=Y.baseY+Y.cursorY,P=hE({rows:n.rows,cellH:M,bufferLength:Y.length,cursorBufferRow:$,visibleContentHeight:V,paddingTop:L,paddingBottom:N,containerScrollTop:e.scrollTop,containerScrollHeight:e.scrollHeight,containerClientHeight:e.clientHeight,atBottomThreshold:r}),q=o(),K=q===null?null:$-q,z=W.cursorDeltaRows!==void 0?W.cursorDeltaRows:K,X=W.scrollDeltaToAnchor!==void 0?W.scrollDeltaToAnchor:e.scrollTop-P.bottomScrollTop,ee=Ws(t.style.top),te=M>0?p4({ydisp:Y.viewportY,rows:n.rows,cellH:M,visibleContentHeight:V}):0,Q=Ws(t.style.height),me=e.scrollTop,ve=me+e.clientHeight,Ce=ee+Q,Me=Math.max(0,Math.min(ve,Ce)-Math.max(me,ee)),Ve=y();yle({t:performance.now(),event:D,scope:W.scope,action:W.action,reason:W.reason,scrollTop:e.scrollTop,scrollLeft:e.scrollLeft,scrollHeight:e.scrollHeight,scrollWidth:e.scrollWidth,clientHeight:e.clientHeight,clientWidth:e.clientWidth,innerHeight:window.innerHeight,visualViewportHeight:O==null?void 0:O.height,visualViewportOffsetTop:O==null?void 0:O.offsetTop,containerTop:U.top,containerBottom:U.bottom,hostRectTop:F.top,hostRectBottom:F.bottom,viewportY:Y.viewportY,bufferLength:Y.length,hostTop:t.style.top,cellH:M,cellW:B,cursorX:Y.cursorX,cursorY:Y.cursorY,cursorBufferRow:$,cursorDeltaRows:z,cursorInViewport:P.cursorInViewport,anchorBottomScrollTop:P.bottomScrollTop,scrollDeltaToAnchor:X,pendingProgrammaticScrollTop:l(),pendingFollowCursorScrollTop:u(),pendingFollowCursorScrollLeft:d(),pendingContainerSyncRetry:h(),horizontalIntent:p(),intentMode:Ve.mode,intentSource:Ve.source,intentTransition:Ve.lastTransitionId,prevCursorBufferRow:q,hostTopDrift:ee-te,viewportHostCoverage:e.clientHeight>0?Me/e.clientHeight:0,focus:x(),atBottom:P.isAtBottom,touchActive:Ve.touchActive,userIntent:v(),...W})},k=D=>{if(!dw())return;const W=window.visualViewport;if(!W)return;const U=_===null?0:W.height-_,F=w===null?0:W.offsetTop-w;_=W.height,w=W.offsetTop,E(D,{vvHeightDelta:U,vvOffsetDelta:F})},R=()=>k("vv:resize"),A=()=>k("vv:scroll"),I=D=>{var B;if(!dw())return;const W=D.target,U=W===e||W instanceof Node&&e.contains(W),F=W&&typeof W.closest=="function"?((B=W.closest("[data-slot]"))==null?void 0:B.getAttribute("data-slot"))??"":"",O=(W==null?void 0:W.tagName)??"",M=W&&typeof W.className=="string"&&W.className?"."+W.className.split(/\s+/).filter(Boolean).slice(0,2).join("."):"";E(`wheel:window deltaY=${Math.round(D.deltaY)} reachesContainer=${U?1:0} prevented=${D.defaultPrevented?1:0} target=${O}${M}{${F}}`)};return(T=window.visualViewport)==null||T.addEventListener("resize",R),(H=window.visualViewport)==null||H.addEventListener("scroll",A),window.addEventListener("wheel",I,{passive:!0,capture:!0}),{trace:E,dispose:()=>{var D,W;(D=window.visualViewport)==null||D.removeEventListener("resize",R),(W=window.visualViewport)==null||W.removeEventListener("scroll",A),window.removeEventListener("wheel",I,{capture:!0})}}}function m4(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 Bw=e=>e.mode==="reviewing",wh=e=>e.mode==="following"&&!e.touchActive;function Mpe(e,t){return e==="following"&&t==="reviewing"?"set":e==="reviewing"&&t==="following"?"clear":"keep"}function Kr(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:Mpe(e.mode,t.mode),reason:n}}}function Sh(e,t,n,r){return{...e,mode:"reviewing",source:t,lastScrollTop:n,lastTransitionId:r}}function jw(e,t,n,r){return{...e,mode:"following",source:t,lastScrollTop:n,lastTransitionId:r}}function Ope(e){throw new Error(`Unhandled PTY vertical intent event: ${JSON.stringify(e)}`)}function Dpe(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)?Kr(e,{...o,mode:"following",source:"none",lastTransitionId:`${r}.bottom-down`},`scrollTop=${t.scrollTop} atBottom=true`):Kr(e,{...o,lastTransitionId:`${r}.not-bottom`},`scrollTop=${t.scrollTop} atBottom=${t.atCursorAwareBottom}`)}function Ppe(e,t,n={}){const r=n.atBottomThreshold??8;switch(t.type){case"attach":{const i=m4({initialIntent:t.initialIntent,scrollTop:t.scrollTop});return Kr(e,i,`initialIntent=${t.initialIntent}`)}case"scroll-to-bottom":return t.force?Kr(e,jw({...e,touchActive:!1,touchStartY:null,touchStartScrollTop:null,touchReviewNotified:!1},"programmatic-bottom",e.lastScrollTop,"bottom.force"),`reason=${t.reason} force=true`):Kr(e,{...e,lastTransitionId:`bottom.passive.${e.mode}`},`reason=${t.reason} force=false`);case"scroll-to-ratio":return Kr(e,Sh(e,"ratio-scroll",t.scrollTop,"ratio.reviewing"),`ratio=${t.ratio}`);case"wheel":return t.nextScrollTop===t.previousScrollTop?Kr(e,{...e,lastTransitionId:"wheel.clamped",lastScrollTop:t.nextScrollTop},`delta=${t.deltaY}`):t.deltaY<0?Kr(e,Sh(e,"wheel",t.nextScrollTop,"wheel.up"),`delta=${t.deltaY}`):t.deltaY>0&&t.reachedCursorAwareBottom?Kr(e,jw(e,"none",t.nextScrollTop,"wheel.down.bottom"),`delta=${t.deltaY}`):Kr(e,Sh(e,"wheel",t.nextScrollTop,"wheel.down.not-bottom"),`delta=${t.deltaY}`);case"container-scroll":return t.source!=="user"?Kr(e,{...e,lastScrollTop:t.scrollTop,lastTransitionId:`container.${t.source}`},`source=${t.source} scrollTop=${t.scrollTop}`):t.atCursorAwareBottom?t.verticalDelta>r&&e.mode==="reviewing"&&!e.touchActive?Kr(e,jw(e,"none",t.scrollTop,"container.user.bottom-down"),`delta=${t.verticalDelta} threshold=${r}`):Kr(e,{...e,lastScrollTop:t.scrollTop,lastTransitionId:"container.user.bottom-small-delta"},`delta=${t.verticalDelta} threshold=${r}`):Kr(e,Sh(e,"native-scroll",t.scrollTop,"container.user.away"),`scrollTop=${t.scrollTop} atBottom=false`);case"touch-start":return Kr(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?Kr(e,{...Sh(e,"touch",e.lastScrollTop,"touch.move.review"),touchReviewNotified:!0},`movement=${i} threshold=${t.reviewThresholdPx}`,!0):i>=t.reviewThresholdPx?Kr(e,{...e,lastTransitionId:"touch.move.reviewing"},`movement=${i} threshold=${t.reviewThresholdPx}`):Kr(e,{...e,lastTransitionId:"touch.move.below-threshold"},`movement=${i} threshold=${t.reviewThresholdPx}`)}case"touch-end":case"touch-cancel":return Dpe(e,t,r);default:return Ope(t)}}const Gr={bottom:{defaultThresholdPx:8},horizontal:{nativeIntentThresholdPx:48,cursorFollowRightMarginColumns:8},rawInput:{recentLayoutDriftMs:1e3},touch:{scrollJumpMinThresholdPx:512,hostTopJumpMinThresholdPx:64,gestureSlopPx:16,horizontalGestureSlopPx:6,horizontalLockRatio:1,verticalLockRatio:1.25,nativeScrollRecentMs:500}};function Lpe({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 Ipe({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 zpe({touchActive:e,touchStartScrollTop:t,touchStartY:n,currentY:r,touchStartedAtCursorAwareBottom:i,bottomScrollTop:s,domMaxScrollTop:o}){if(!e||t===null||n===null||r===null)return!1;const l=Math.min(o,s),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 Bpe({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 jpe({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 Fpe(){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 $pe(){return{startedAtCursorAwareBottom:!1,startClientX:null,startScrollLeft:null,lastClientY:null,lastGestureAt:null,lastHorizontalGestureAt:null,gestureMode:null}}function Hpe(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"}}function Upe(e,t){return{...e,lastGestureAt:t}}function j2(e,t){return{...e,lastHorizontalGestureAt:t}}function Wpe(e,t){return{...e,lastClientY:t.currentY,lastGestureAt:t.now}}function qpe(e,t){return!t.touchActive||e.gestureMode!==null||t.currentY===null?e:{...e,gestureMode:"pending"}}function F2(e,t){return e.gestureMode===t?e:{...e,gestureMode:t}}function Vpe(e){return{...e,startedAtCursorAwareBottom:!1,startClientX:null,startScrollLeft:null,lastClientY:null,gestureMode:null}}function Ype({container:e,atBottomThreshold:t,trace:n,getPageResumePending:r,getVerticalIntent:i,dispatchVerticalIntent:s,getCurrentAnchor:o,getLastSeenScrollTop:l,hasHorizontalOverflow:u,clearHorizontalIntentIfUnscrollable:d,markHorizontalUserInput:h,onTouchBoundaryPrevent:p,notifyAtBottom:y,flushPendingTouchScrollNotify:v}){let _=$pe();const w=D=>{const W=D??_.lastClientY,U=o(),F=Math.max(0,e.scrollHeight-e.clientHeight),O=i();return zpe({touchActive:O.touchActive,touchStartScrollTop:O.touchStartScrollTop,touchStartY:O.touchStartY,currentY:W,touchStartedAtCursorAwareBottom:_.startedAtCursorAwareBottom,bottomScrollTop:U.bottomScrollTop,domMaxScrollTop:F})},x=(D,W)=>Ipe({startX:_.startClientX,startY:i().touchStartY,currentX:D,currentY:W}),E=D=>{const W=Math.max(0,e.scrollWidth-e.clientWidth);return Bpe({touchActive:i().touchActive,touchStartClientX:_.startClientX,touchStartScrollLeft:_.startScrollLeft,currentX:D,maxScrollLeft:W})},k=(D,W,U,F,O)=>D?[`raw=${Math.round(W)}`,`effective=${Math.round(U)}`,`prev=${Math.round(F)}`,`delta=${Math.round(O)}`,`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)}`,`max=${Math.round(D.cursorAwareMaxScrollTop)}`].join(" "):null,R=D=>{var M;if(r()){n("touchstart:page-resume-pending");return}const W=((M=D.touches)==null?void 0:M[0])??null,U=(W==null?void 0:W.clientX)??null,F=(W==null?void 0:W.clientY)??null;d("touchstart");const O=o();_=Hpe(_,{startedAtCursorAwareBottom:O.isAtBottom,startClientX:U,startClientY:F,startScrollLeft:e.scrollLeft,now:performance.now()}),s({type:"touch-start",clientY:F,scrollTop:e.scrollTop}),n("touchstart",{details:[`startX=${U??"null"}`,`startY=${F??"null"}`,`startScroll=${Math.round(e.scrollTop)}`,`bottom=${Math.round(O.bottomScrollTop)}`,`atBottom=${O.isAtBottom?1:0}`].join(" ")})},A=D=>{var Y;if(r()){n("touchmove:page-resume-pending");return}const W=((Y=D.touches)==null?void 0:Y[0])??null,U=(W==null?void 0:W.clientX)??null,F=(W==null?void 0:W.clientY)??null,O=performance.now();_=Wpe(_,{currentY:F,now:O});const M=x(U,F);n("touchmove",{details:F===null?"currentY=null":k(w(F),e.scrollTop,e.scrollTop,l(),e.scrollTop-l())??[`mode=${_.gestureMode??"none"}`,`currentY=${Math.round(F)}`,M?`dx=${Math.round(M.dx)} dy=${Math.round(M.dy)} distance=${Math.round(M.distance)}`:null].filter(Boolean).join(" ")});const B=u();if(B||d("touchmove"),_=qpe(_,{touchActive:i().touchActive,currentY:F}),_.gestureMode==="pending"&&M){const $=B&&M.absDx>=Gr.touch.horizontalGestureSlopPx&&M.absDx>M.absDy*Gr.touch.horizontalLockRatio,P=M.absDy>=Gr.touch.gestureSlopPx&&(!B||M.absDy>M.absDx*Gr.touch.verticalLockRatio);if($)_=F2(_,"horizontal"),_=j2(_,O),n("touchmove:horizontal-lock",{details:`dx=${Math.round(M.dx)} dy=${Math.round(M.dy)} distance=${Math.round(M.distance)}`});else if(P)_=F2(_,"vertical"),n("touchmove:vertical-lock",{details:`dx=${Math.round(M.dx)} dy=${Math.round(M.dy)} distance=${Math.round(M.distance)} threshold=${Gr.touch.gestureSlopPx}`});else{n("touchmove:pending",{details:[`dx=${Math.round(M.dx)}`,`dy=${Math.round(M.dy)}`,`distance=${Math.round(M.distance)}`,`hThreshold=${Gr.touch.horizontalGestureSlopPx}`,`vThreshold=${Gr.touch.gestureSlopPx}`].join(" ")}),M.absDy<Gr.touch.gestureSlopPx&&s({type:"touch-move",clientY:F,reviewThresholdPx:Gr.touch.gestureSlopPx});return}}if(_.gestureMode==="horizontal"){const $=E(U);if(!B||!$){d("touchmove-horizontal"),n("touchmove:horizontal-native",{details:M?`blocked dx=${Math.round(M.dx)} dy=${Math.round(M.dy)} distance=${Math.round(M.distance)}`:"blocked movement=null"});return}M&&(_=j2(_,O),h(`site=touchmove-horizontal dx=${Math.round(M.absDx)} dy=${Math.round(M.absDy)}`)),n("touchmove:horizontal-native",{details:[`scrollLeft=${Math.round(e.scrollLeft)}`,`expected=${Math.round($.expectedScrollLeft)}`,`startScrollLeft=${Math.round($.touchStartScrollLeft)}`,`startX=${Math.round($.touchStartX)}`,`currentX=${Math.round($.currentX)}`,`touchDeltaX=${Math.round($.touchDeltaX)}`,`max=${Math.round($.maxScrollLeft)}`].join(" ")});return}if(_.gestureMode!=="vertical")return;const L=w(F);if(L&&n("touchmove:vertical-native",{details:[`scrollTop=${Math.round(e.scrollTop)}`,`expected=${Math.round(L.expectedScrollTop)}`,`startScroll=${Math.round(L.touchStartScrollTop)}`,`base=${Math.round(L.gestureBaseScrollTop)}`,`startY=${Math.round(L.touchStartY)}`,`currentY=${Math.round(L.currentY)}`,`touchDeltaY=${Math.round(L.touchDeltaY)}`].join(" ")}),L&&_.startedAtCursorAwareBottom&&L.expectedScrollTop>=L.cursorAwareMaxScrollTop-t&&F!==null&&F<=L.touchStartY){n("touchmove:bottom-boundary-follow");return}s({type:"touch-move",clientY:F,reviewThresholdPx:Gr.touch.gestureSlopPx}).notifyTouchReviewStart&&(p==null||p(),n("touchmove:review"))},I=D=>{const W=e.scrollTop,U=o(),F=jpe({touchStartScrollTop:i().touchStartScrollTop,liveScrollTop:W,atBottomThreshold:t,touchStartedAtCursorAwareBottom:_.startedAtCursorAwareBottom,anchorIsAtBottom:U.isAtBottom,reviewedDuringTouch:i().touchReviewNotified});_=Vpe(_),s({type:D,scrollTop:W,atCursorAwareBottom:F.atCursorAwareBottomForIntent,releaseOnSemanticBottom:F.releaseOnSemanticBottom}),_=Upe(_,performance.now()),v(),y()};return{onTouchStart:R,onTouchMove:A,onTouchEnd:()=>{if(r()){n("touchend:page-resume-pending");return}I("touch-end"),n("touchend")},onTouchCancel:()=>{if(r()){n("touchcancel:page-resume-pending");return}I("touch-cancel"),n("touchcancel")},isRecentNativeScroll:()=>i().touchActive||_.lastGestureAt!==null&&performance.now()-_.lastGestureAt<=Gr.touch.nativeScrollRecentMs,isRecentHorizontalGesture:()=>_.lastHorizontalGestureAt!==null&&performance.now()-_.lastHorizontalGestureAt<=Gr.touch.nativeScrollRecentMs,getScrollExpectation:w,describeScrollExpectation:k,getState:()=>_}}function fE(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 Kpe(e,t){for(let n=t-1;n>=0;n--){const r=e.viewportY+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}function Gpe(e){const{container:t,spacer:n,host:r,term:i,hasNewFrame:s,consumeNewFrame:o,hasNewFramesWhileAway:l,setNewFramesWhileAway:u,onAtBottomChange:d,onScrollStateChange:h,initialUserHasVerticalScrollIntent:p=!1,onUserVerticalScrollIntentChange:y,onTouchReviewStart:v,onTouchBoundaryPrevent:_,onReviewSnapshotCapture:w,onReviewSnapshotClear:x,atBottomThreshold:E=Gr.bottom.defaultThresholdPx}=e,k=()=>fE(r,i)??{cellH:0,cellW:0},R=()=>{const se=getComputedStyle(t);return{paddingTop:Ws(se.paddingTop),paddingBottom:Ws(se.paddingBottom)}},A=Fpe(),I=(se,fe,Oe)=>{A.set(se,fe,Oe)},T={external:!1,internal:!1};let H=null,D="",W=m4({initialIntent:p,scrollTop:t.scrollTop}),U=null,F=null,O=!1,M=null,B=wpe(),L=0,N=!1,V=null,Y=null,$=null,P=null,q=p,K=!1,z=null;const X=()=>Bw(W),ee=()=>X()&&K,te=Npe({container:t,host:r,term:i,atBottomThreshold:E,getDims:k,getVerticalInsets:R,getPrevCursorBufferRow:()=>V,getPendingProgrammaticScrollTop:()=>U,getPendingFollowCursorScrollTop:()=>M,getPendingFollowCursorScrollLeft:()=>B.pendingFollowLeft,getPendingContainerSyncRetry:()=>O,getHorizontalIntent:()=>B.intent,getVerticalIntent:()=>W,getUserHasVerticalScrollIntent:()=>X()}),Q=te.trace,me=se=>{if(se){if(se.kind==="ignore"){Q("horizontal-intent:ignore",{details:se.details});return}Q(`horizontal-intent:${se.kind}`,{details:se.details})}},ve=()=>t.scrollWidth>t.clientWidth+E,Ce=se=>{if(ve())return!1;const fe=Mg(B,{details:`site=${se} reason=not-scrollable scrollWidth=${t.scrollWidth} clientWidth=${t.clientWidth}`,scrollLeft:t.scrollLeft});return B=fe.state,me(fe.trace),t.scrollLeft!==0&&(t.scrollLeft=0,B={...B,lastSeenLeft:0}),!0},Me=se=>{if(!ve()){Ce("markHorizontalUserInput");return}const fe=xpe(B,{now:performance.now(),details:se});B=fe.state,me(fe.trace)},Ve=()=>({scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,scrollHeight:t.scrollHeight,scrollWidth:t.scrollWidth,clientHeight:t.clientHeight,clientWidth:t.clientWidth,scrollable:t.scrollHeight>t.clientHeight+E,horizontalScrollable:ve()}),Qe=()=>{if(!h)return;const se=Ve(),fe=[se.scrollTop,se.scrollLeft,se.scrollHeight,se.scrollWidth,se.clientHeight,se.clientWidth,se.scrollable,se.horizontalScrollable].join(":");fe!==D&&(D=fe,h(se))},ct=()=>{const{cellH:se}=k(),{paddingTop:fe,paddingBottom:Oe}=R(),Ue=i.buffer.active;return hE({rows:i.rows,cellH:se,bufferLength:Ue.length,cursorBufferRow:Ue.baseY+Ue.cursorY,visibleContentHeight:Math.max(0,t.clientHeight-fe-Oe),paddingTop:fe,paddingBottom:Oe,containerScrollTop:t.scrollTop,containerScrollHeight:t.scrollHeight,containerClientHeight:t.clientHeight,atBottomThreshold:E})},Ot=()=>{const se=ct().isAtBottom;H!==se&&(H=se,d==null||d(se))},he=()=>{Ot(),Qe()},Ke=()=>W.touchActive,Rt=()=>{$!==null&&(P==null||P($),$=null,P=null)},ye=()=>{if($!==null)return;const se=()=>{$=null,P=null,he()};if(typeof window.requestAnimationFrame=="function"){$=window.requestAnimationFrame(se),P=typeof window.cancelAnimationFrame=="function"?fe=>window.cancelAnimationFrame(fe):null;return}$=window.setTimeout(se,16),P=fe=>window.clearTimeout(fe)},He=()=>{$!==null&&(Rt(),he())},Ge=(se="rawInput")=>{Y=performance.now(),Q(`rawInputFollow:scheduled[${se}]`)},be=()=>{Y=performance.now(),Q("rawInputFollow:fire")},Xe=se=>{const fe=(w==null?void 0:w(se,i.rows))===!0;return fe&&(K=!0),fe},rt=()=>{if(!X()||!q)return;const{cellH:se}=k();if(!(se<=0)){if(!z){const fe=Bt(t.scrollTop,se);z={scrollTop:t.scrollTop,ydisp:fe,cellH:se};const Oe=Xe(fe);q=!Oe,Oe||(z=null);return}q=!Xe(_e(t.scrollTop,se))}},pt=()=>{q=!0,rt()},le=se=>{const fe=Bw(W),Oe=Ppe(W,se,{atBottomThreshold:E});W=Oe.state,Oe.trace&&Q(`intent:${Oe.trace.action}`,{details:`id=${Oe.trace.id} reason=${Oe.trace.reason}`});const Ue=Bw(W);if(fe!==Ue)if(y==null||y(Ue),Ue){q=!0;const{cellH:ft}=k();if(ft>0){const gt=Bt(t.scrollTop,ft);z={scrollTop:t.scrollTop,ydisp:gt,cellH:ft};const kt=Xe(gt);q=!kt,kt||(z=null)}}else q=!1,K=!1,z=null,x==null||x();return Oe.notifyTouchReviewStart&&(v==null||v()),Oe},Ae=(se,fe,Oe)=>{if(fe<=0)return;const Ue=Oe??(()=>{const{paddingTop:Tt,paddingBottom:Ht}=R();return Math.max(0,t.clientHeight-Tt-Ht)})(),ft=p4({ydisp:se,rows:i.rows,cellH:fe,visibleContentHeight:Ue}),gt=r.style.top,kt=`${ft}px`;I(r,"position","absolute"),I(r,"left","0px"),I(r,"top",kt),gt!==kt&&Q("host-position",{ydisp:se,details:`${gt||"0px"}->${kt}`})},Ze=(se="internal",fe={})=>{const Oe=Math.max(0,i.buffer.active.length-i.rows),Ue=ct(),ft=Tpe({force:fe.force??!1,reviewing:X()||W.touchActive,viewportY:i.buffer.active.viewportY,expectedYdisp:Oe,scrollTop:t.scrollTop,bottomScrollTop:Ue.bottomScrollTop,atBottom:Ue.isAtBottom}).action;if(ft==="blocked-by-review")return;if(ft==="noop"){O=!1;return}Q(`scroll-to-bottom:start[${se}]`),le({type:"scroll-to-bottom",force:fe.force??!1,reason:se});const gt=Math.max(0,i.buffer.active.length-i.rows);T.internal=!0;try{i.scrollToLine(gt)}finally{T.internal=!1}const{cellH:kt}=k();kt!==0&&Ae(gt,kt);const Tt=ct().bottomScrollTop;t.scrollTop=Tt,U=Tt,V=i.buffer.active.baseY+i.buffer.active.cursorY,he(),O=!1,Q("scroll-to-bottom:end",{ydisp:gt})},tt=()=>{N=!0,Q("page-resume:prepare-follow"),X()&&le({type:"scroll-to-bottom",force:!0,reason:"pageResumePrepare"})},dt=()=>{tt(),ze(),Ze("pageResume",{force:!0}),vn("pageResume"),N=!1},Dt=se=>{Q("scroll-to-ratio:start");const fe=Math.max(0,t.scrollHeight-t.clientHeight),Oe=Math.max(0,Math.min(1,se)),Ue=fe*Oe;le({type:"scroll-to-ratio",ratio:Oe,scrollTop:Ue}),q=!0,t.scrollTop=Ue,Be()},Wt=se=>{if(se===0)return;Q("wheel");const fe=Math.max(0,t.scrollHeight-t.clientHeight),Oe=Math.min(fe,ct().bottomScrollTop);if(Oe<=0){Q("wheel:max-zero");return}const Ue=t.scrollTop,ft=Math.max(0,Math.min(Oe,Ue+se));if(ft===Ue){Q("wheel:clamped"),he();return}q=!0,t.scrollTop=ft,L=ft,Be(),le({type:"wheel",deltaY:se,previousScrollTop:Ue,nextScrollTop:ft,reachedCursorAwareBottom:ft>Ue&&ft>=Oe-E&&ct().isAtBottom})},tn=se=>{if(!ve()){Ce("scrollToXRatio"),he();return}const fe=Math.max(0,t.scrollWidth-t.clientWidth),Oe=Math.max(0,Math.min(1,se));t.scrollLeft=fe*Oe,Me(`site=scrollToXRatio ratio=${Oe}`),B={...B,lastSeenLeft:t.scrollLeft},he()},vn=(se="external",fe={})=>{const Oe=t.scrollLeft,Ue=Mg(B,{details:`site=resetHorizontalScroll reason=${se}`,scrollLeft:0});B=Ue.state,me(Ue.trace),Oe!==0&&(t.scrollLeft=0),fe.holdUntilCursorVisible&&Me(`site=resetHorizontalScroll-hold reason=${se}`),Q(`horizontal-scroll-reset[${se}]`,{details:`scrollLeft=${Oe}->${t.scrollLeft}`}),he()},un=(se="external")=>{Me(`site=${se}`)};let Zt=0,Xn=null,Kt=-1;const Zn=()=>{const se=i.buffer.active,fe=`${Zt}:${se.viewportY}:${se.length}:${i.rows}`;return fe===Xn||(Kt=Kpe(se,i.rows),Xn=fe),Kt},ze=()=>{const{cellH:se,cellW:fe}=k();if(se===0||fe===0)return;const{paddingTop:Oe,paddingBottom:Ue}=R(),ft=Math.max(0,t.clientHeight-Oe-Ue),gt=i.buffer.active,kt=Zn(),Tt=f4({bufferLength:gt.length,rows:i.rows,cols:i.cols,viewportY:gt.viewportY,cursorY:gt.cursorY,cellH:se,cellW:fe,visibleContentHeight:ft},kt);Tt&&(I(n,"overflow","hidden"),I(n,"height",`${Tt.spacerHeight}px`),I(n,"width",`${Tt.spacerWidth}px`),I(r,"width",`${Tt.hostWidth}px`),I(r,"height",`${Tt.hostHeight}px`),I(r,"paddingTop",`${Tt.hostPaddingTop}px`),F=performance.now(),ee()||Ae(gt.viewportY,se,ft))},et=(se,fe,Oe={})=>{if(se===i.buffer.active.viewportY){Oe.deferHostUntilRender||Ae(se,fe);return}T.internal=!0;try{if(Oe.deferHostUntilRender){i.scrollToLine(se);return}Ae(se,fe),i.scrollToLine(se)}finally{T.internal=!1}},Et=()=>s()?W.touchActive&&!X()?"deferred":(o(),wh(W)?(Ze("pendingFrame"),"followed"):(l()||u(!0),"marked")):"none";function Bt(se,fe){const Oe=i.buffer.active;return B2(se,{bufferLength:Oe.length,rows:i.rows,cols:i.cols,viewportY:Oe.viewportY,cellH:fe}).ydisp}function J(se){!X()||!z||z.cellH!==se&&(z={scrollTop:t.scrollTop,ydisp:z.ydisp,cellH:se})}function _e(se,fe){if(J(fe),!z)return Bt(se,fe);const Oe=Math.max(0,i.buffer.active.length-i.rows),Ue=Math.floor((se-z.scrollTop)/fe);return Math.max(0,Math.min(Oe,z.ydisp+Ue))}const Be=(se={})=>{Rt(),Q("container-sync:start");const{cellH:fe}=k();if(fe===0){O=!0;return}O=!1;const Oe=_e(t.scrollTop,fe),Ue=X();Ue&&(q||!K)&&Xe(Oe)&&(q=!1),et(Oe,fe,{deferHostUntilRender:(se.deferHostUntilRender??Ke())&&!(Ue&&K)}),he(),Q("container-sync:end",{ydisp:Oe})},ht=()=>W.touchActive||ie.isRecentNativeScroll(),jt=se=>{if(!ht())return!1;const{cellH:fe}=k();if(fe===0)return!1;const Oe=_e(se,fe);return Oe!==i.buffer.active.viewportY?!1:(ye(),Q("container-sync:skip[same-row-touch]",{ydisp:Oe,details:`scrollTop=${Math.round(se)} viewportY=${i.buffer.active.viewportY}`}),!0)},re=se=>{const fe=Math.max(0,t.scrollHeight-t.clientHeight),Oe=ct(),Ue=Rpe({rawScrollTop:se,bottomScrollTop:Oe.bottomScrollTop,domMaxScrollTop:fe});return Ue.action==="keep"||(Q("container-scroll:clamp-cursor-bottom",{details:`prev=${se} next=${Ue.scrollTop} domMax=${fe}`}),t.scrollTop=Ue.scrollTop,U=null,M=null),Ue.scrollTop},ie=Ype({container:t,atBottomThreshold:E,trace:Q,getPageResumePending:()=>N,getVerticalIntent:()=>W,dispatchVerticalIntent:le,getCurrentAnchor:ct,getLastSeenScrollTop:()=>L,hasHorizontalOverflow:ve,clearHorizontalIntentIfUnscrollable:Ce,markHorizontalUserInput:Me,onTouchBoundaryPrevent:_,notifyAtBottom:Ot,flushPendingTouchScrollNotify:He}),de=()=>B.intent?ie.getState().gestureMode==="horizontal"||ie.isRecentHorizontalGesture():!1,pe=se=>{const fe=ie.getScrollExpectation();if(!fe)return!1;const{touchStartScrollTop:Oe,touchStartY:Ue,currentY:ft,gestureBaseScrollTop:gt,expectedScrollTop:kt}=fe,Tt=Math.abs(ft-Ue)>.5,Ht=se<=E&&gt>t.clientHeight,yn=parseFloat(r.style.top||"0"),oi=ct(),fn=ie.getState().startedAtCursorAwareBottom&&Number.isFinite(yn)&&Math.abs(se-yn)<=E&&Math.abs(oi.bottomScrollTop-yn)<=t.clientHeight+E&&Math.abs(kt-se)>Gr.touch.hostTopJumpMinThresholdPx;if(!Tt&&!Ht&&!fn)return!1;const $e=Math.max(Gr.touch.scrollJumpMinThresholdPx,t.clientHeight*1.25);return!fn&&Math.abs(se-kt)<=$e?!1:(Q("container-scroll:restore-touch-impossible-jump",{details:[`scrollTop=${Math.round(se)}`,`expected=${Math.round(kt)}`,`diff=${Math.round(se-kt)}`,`threshold=${Math.round($e)}`,`touchStart=${Math.round(Oe)}`,fn?"hostTop=1":null,`startY=${Math.round(Ue)}`,`currentY=${Math.round(ft)}`].filter(Boolean).join(" ")}),t.scrollTop=kt,L=kt,Be({deferHostUntilRender:!0}),!0)},Z=(se,fe,Oe)=>{if(fe||W.touchActive||!wh(W)||!(Y!==null&&performance.now()-Y<=Gr.rawInput.recentLayoutDriftMs))return!1;const ft=ct();return Q("container-scroll:restore-raw-input-layout-bottom",{details:`scrollTop=${se} bottom=${ft.bottomScrollTop}`}),le({type:"container-scroll",source:"programmatic-bottom",scrollTop:se,atCursorAwareBottom:fe,verticalDelta:Oe}),Ze("rawInputLayoutDrift"),!0},ne=()=>{Q("container-scroll");const se=Cpe(B,{hasOverflow:ve(),scrollLeft:t.scrollLeft,now:performance.now(),nativeIntentThresholdPx:Gr.horizontal.nativeIntentThresholdPx});B=se.state,me(se.trace),se.resetScrollLeft&&(t.scrollLeft=0);const fe=t.scrollTop,Oe=L,Ue=fe-L,ft=re(fe);if(W.touchActive){const Tt=ie.getScrollExpectation();Q("container-scroll:touch-active",{details:ie.describeScrollExpectation(Tt,fe,ft,Oe,Ue)??`raw=${Math.round(fe)} effective=${Math.round(ft)}`})}L=ft;const gt=kpe({syncingExternal:T.external,effectiveScrollTop:ft,pendingFollowTop:M,pendingProgrammaticTop:U,atBottom:ct().isAtBottom,canPassiveFollow:wh(W)});if(M=gt.nextPendingFollowTop,U=gt.nextPendingProgrammaticTop,gt.action==="external-sync"){le({type:"container-scroll",source:"external-sync",scrollTop:ft,atCursorAwareBottom:ct().isAtBottom,verticalDelta:Ue}),he();return}if(gt.action==="programmatic-follow"){le({type:"container-scroll",source:"programmatic-follow",scrollTop:ft,atCursorAwareBottom:ct().isAtBottom,verticalDelta:Ue}),he();return}const kt=ct().isAtBottom;if(gt.action==="programmatic-drift"){le({type:"container-scroll",source:"programmatic-bottom",scrollTop:ft,atCursorAwareBottom:kt,verticalDelta:Ue}),Ze("programmaticDrift");return}if(!pe(ft)&&!Z(ft,kt,Ue)){if(N){Q("container-scroll:page-resume-pending",{details:`scrollTop=${ft} bottom=${ct().bottomScrollTop}`}),le({type:"container-scroll",source:"programmatic-bottom",scrollTop:ft,atCursorAwareBottom:kt,verticalDelta:Ue}),Be();return}le({type:"container-scroll",source:"user",scrollTop:ft,atCursorAwareBottom:kt,verticalDelta:Ue}),X()&&Ue!==0&&(q=!0),!jt(ft)&&Be()}},ae=()=>{if(Q("term-scroll"),!T.internal){T.external=!0;try{ze();const se=Et();if(se==="followed")return;if(se==="none"&&wh(W)){Ze("termScroll");return}if(ee()){se==="marked"&&ct().cursorInViewport&&(q=!0),he();return}const{cellH:fe}=k();if(fe!==0){const Oe=i.buffer.active,{ydisp:Ue}=B2(t.scrollTop,{bufferLength:Oe.length,rows:i.rows,cols:i.cols,viewportY:Oe.viewportY,cellH:fe,cellW:1});et(Ue,fe)}he()}finally{T.external=!1}}},Te=()=>{ze();const se=Et();if(se==="followed")return;if(se==="none"&&wh(W)){Ze("relayout");return}if(ee()){he();return}const{cellH:fe}=k();if(fe!==0)if(O)Q("pending-sync-retry-fire"),Be();else{const Oe=_e(t.scrollTop,fe),Ue=_pe(i.buffer.active.viewportY,fe);Oe!==i.buffer.active.viewportY?t.scrollTop=Ue:Math.abs(t.scrollTop-Ue)>1&&Q("relayout:preserve-host-offset",{details:`scrollTop=${Math.round(t.scrollTop)} viewportTop=${Math.round(Ue)} ydisp=${Oe}`}),Ae(i.buffer.active.viewportY,fe)}he()},je=()=>{const{cellH:se}=k(),{paddingTop:fe,paddingBottom:Oe}=R(),Ue=Math.max(0,t.clientHeight-fe-Oe),ft=i.buffer.active,gt=ft.baseY+ft.cursorY,kt=V,Tt=ct(),Ht=Lpe({reviewing:X()||W.touchActive,cellH:se,rows:i.rows,visibleContentHeight:Ue,cursorBufferRow:gt,prevCursorBufferRow:V,cursorInViewport:Tt.cursorInViewport,targetScrollTop:Tt.bottomScrollTop,currentScrollTop:t.scrollTop});if(Ht.reason==="intent"){V=Ht.nextPrevCursorBufferRow,Q("followCursorY:skip",{details:Ht.reason});return}if(Ht.reason==="cellH=0"){Q("followCursorY:skip",{details:Ht.reason});return}if(Ht.reason==="shortHost"){V=Ht.nextPrevCursorBufferRow,Q("followCursorY:skip",{details:Ht.reason});return}if(Ht.reason==="same-row"){Q("followCursorY:skip[same-row]",{cursorDeltaRows:Ht.cursorDeltaRows,details:`cursorRow=${gt} same-row`});return}if(V=Ht.nextPrevCursorBufferRow,Ht.reason==="inViewport"){Q("followCursorY:skip",{cursorDeltaRows:Ht.cursorDeltaRows,details:`cursorRow=${kt??"null"}->${gt} inViewport`});return}if(Ht.reason==="aligned"){Q("followCursorY:skip",{cursorDeltaRows:Ht.cursorDeltaRows,details:`cursorRow=${kt??"null"}->${gt} aligned`});return}if(Ht.action!=="follow")return;M=Ht.targetScrollTop;const yn=t.scrollTop;t.scrollTop=Ht.targetScrollTop,Q("followCursorY:hit",{cursorDeltaRows:Ht.cursorDeltaRows,scrollDeltaToAnchor:yn-Ht.targetScrollTop,details:`cursorRow=${kt??"null"}->${gt} scrollTop=${Math.round(yn)}->${Math.round(Ht.targetScrollTop)}`})},st=()=>{if(!ve()){Ce("followCursorX");return}const{cellW:se}=k();if(se<=0)return;const fe=i.buffer.active.cursorX*se,Oe=t.scrollLeft,Ue=Oe+t.clientWidth;if(fe>=Oe&&fe<=Ue){if(de()){Q("followCursorX:skip",{details:`horizontalTouchIntent cursorPx=${fe} viewport=${Oe}..${Ue}`});return}const rr=Mg(B,{details:`site=followCursorX cursorPx=${fe} viewport=${Oe}..${Ue}`,scrollLeft:t.scrollLeft});if(B=rr.state,me(rr.trace),rr.trace){Q("followCursorX:skip",{details:"cursorInViewport"});return}}if(B.intent){Q("followCursorX:skip",{details:`horizontalIntent cursorPx=${fe} viewport=${Oe}..${Ue}`});return}const gt=Math.min(t.clientWidth/2,Gr.horizontal.cursorFollowRightMarginColumns*se),kt=Ue-gt;if(!(fe<Oe||fe>=kt)){Q("followCursorX:skip",{details:`cursorSafe cursorPx=${fe} viewport=${Oe}..${Ue} rightBoundary=${kt}`});return}const Ht=Math.max(0,fe-t.clientWidth/2),yn=Math.max(0,t.scrollWidth-t.clientWidth),oi=Math.min(yn,Ht);B=Epe(B,oi),t.scrollLeft=oi,Q("followCursorX:hit",{details:`cursorPx=${fe} viewport=${Oe}..${Ue} rightBoundary=${kt} target=${oi}`})},ue=()=>{Q("render"),ze(),O&&(Q("pending-sync-retry-fire"),Be());const se=Et();st(),je(),X()&&(se==="marked"&&ct().cursorInViewport&&(q=!0),rt()),he()};ze(),X()?he():Ze("init");const ke=Ape({container:t,term:i,onWheel:se=>{ve()&&Math.abs(se.deltaX)>0&&Math.abs(se.deltaX)>=Math.abs(se.deltaY)&&Me(`site=wheel deltaX=${se.deltaX}`),se.deltaY!==0&&(Q("wheel:enter"),se.preventDefault(),se.stopPropagation(),Wt(se.deltaY))},onTouchStart:ie.onTouchStart,onTouchMove:ie.onTouchMove,onTouchEnd:()=>{ie.onTouchEnd(),Te()},onTouchCancel:()=>{ie.onTouchCancel(),Te()},onContainerScroll:ne,onTermScroll:ae,onRender:ue,onRelayout:Te,onWriteParsed:()=>{Zt+=1}});return{dispose:()=>{ke.dispose(),te.dispose(),Rt(),x==null||x()},relayout:Te,scrollToBottom:Ze,preparePageResumeRestore:tt,restorePageResume:dt,scrollToRatio:Dt,scrollToXRatio:tn,resetHorizontalScroll:vn,markHorizontalScrollIntent:un,traceRawInputFollowScheduled:Ge,traceRawInputFollowFire:be,refreshReviewSnapshot:pt,getDebugProbe:()=>{const{cellH:se,cellW:fe}=k(),{paddingTop:Oe,paddingBottom:Ue}=R();return{cellH:se,cellW:fe,paddingTop:Oe,paddingBottom:Ue,canvasLastY:se>0&&fe>0?Zn():-1,userHasVerticalScrollIntent:X(),verticalIntentMode:W.mode,verticalIntentSource:W.source,verticalIntentTransitionId:W.lastTransitionId,userHasHorizontalScrollIntent:B.intent,pendingProgrammaticScrollTop:U,pendingFollowCursorScrollTop:M,pendingFollowCursorScrollLeft:B.pendingFollowLeft,prevCursorBufferRow:V,lastSeenScrollTop:L,lastSeenScrollLeft:B.lastSeenLeft,touchScrollActive:W.touchActive,touchScrollGestureMode:ie.getState().gestureMode,syncingInternal:T.internal,syncingExternal:T.external,atBottomThreshold:E,lastSpacerUpdateAt:F,pendingContainerSyncRetry:O}}}}function Xpe(e,t={}){const{onFramePending:n,onFrameWritten:r,schedule:i=v=>requestAnimationFrame(v),cancel:s=v=>cancelAnimationFrame(v)}=t;let o=null,l=!1,u=[],d=[];const h=()=>{u=[],d=[],o!==null&&(s(o),o=null)},p=()=>{if(o=null,l||u.length===0)return;const v=u,_=d;u=[],d=[];const w=v.reduce((k,R)=>k+R.byteLength,0),x=new Uint8Array(w);let E=0;for(const k of v)x.set(k,E),E+=k.byteLength;e.write(x,()=>{for(const k of _)k();r==null||r()})},y=()=>{l||o!==null||u.length===0||(o=i(p))};return{target:{reset:()=>{h(),e.reset()},resize:(v,_)=>e.resize(v,_),write:(v,_)=>{if(typeof v=="string"){e.write(v,_);return}const w=u.length===0;u.push(v),_&&d.push(_),w&&(n==null||n()),y()}},clear:h,dispose:()=>{l=!0,h()}}}const $2=5e3,Zpe=1e3;function Qpe(){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 Jpe=Qpe();let eme=0;function tme(e={}){let t=0;const n=`${Jpe}-${++eme}`,r=e.requestIdFactory??(()=>`pty-snapshot-${n}-${++t}`);let i=null,s=!1,o=[];const l=new Map;let u=0,d=0;const h=p=>{let y=0,v=u+1;for(;l.has(v);){const _=l.get(v);l.delete(v),u=v,p.write(_),y+=1,v+=1}return y};return{startSnapshotRequest(){const p=r();return i=p,s=!1,o=[],l.clear(),d+=1,p},hasAppliedSnapshot(){return s},hasPendingGap(){return s&&l.size>0},handleBinaryFrame(p,y){if(!s)return o.push(p),o.length>$2&&o.splice(0,o.length-$2),{written:!1,hasGap:!1};if(p.outputSeq<=u)return{written:!1,hasGap:!1};if(l.set(p.outputSeq,p.data),l.size>Zpe){const _=l.keys().next().value;_!==void 0&&l.delete(_)}return{written:h(y)>0,hasGap:l.size>0}},applySnapshot(p,y,v){if(!i)return{applied:!1,reason:"no_active_request"};if(p.requestId!==i)return{applied:!1,reason:"stale_snapshot"};const _=o;o=[],l.clear(),i=null,s=!0,u=p.outputSeq,d+=1;const w=d,x=_.filter(E=>E.outputSeq>p.outputSeq).sort((E,k)=>E.outputSeq-k.outputSeq);return y.reset(),y.resize(p.cols,p.rows),y.write(p.data,()=>{if(w===d){for(const E of x)l.set(E.outputSeq,E.data);h(y),v==null||v(l.size>0)}}),{applied:!0,replayedFrames:x.length}}}}function nme(e){const{sessionId:t,ws:n,relay:r,target:i,retryDelayMs:s=3e4,slowNoticeDelayMs:o=1e4,gapRecoveryDelayMs:l=2e3,scheduleReady:u=$=>requestAnimationFrame($),scheduleFrameFlush:d,cancelFrameFlush:h,onFramePending:p,onFrameWritten:y,onReady:v,onSubscribeDelayed:_,onSubscribeStarted:w,onGapRecovery:x}=e,E=tme(),R=Xpe({reset:()=>i.reset(),resize:($,P)=>i.resize($,P),write:($,P)=>{i.write($,()=>{$ instanceof Uint8Array&&Moe(t,$.byteLength),P==null||P()})}},{onFramePending:p,onFrameWritten:y,schedule:d,cancel:h});let A=!1,I=null,T=null,H=null,D=!1;const W=()=>{I&&(clearTimeout(I),I=null)},U=()=>{T&&(clearTimeout(T),T=null)},F=()=>{H&&(clearTimeout(H),H=null)},O=()=>{H||(H=setTimeout(()=>{H=null,!(A||!E.hasPendingGap())&&(x==null||x(),N())},l))},M=()=>{const $=E.startSnapshotRequest();n.send(JSON.stringify({type:"session_subscribe",sessionId:t,requestId:$}))},B=()=>{I=setTimeout(()=>{I=null,!(A||E.hasAppliedSnapshot())&&(M(),B())},s)},L=()=>{T=setTimeout(()=>{T=null,!(A||E.hasAppliedSnapshot()||D)&&(D=!0,_==null||_())},o)},N=()=>{A||(W(),U(),F(),R.clear(),D=!1,w==null||w(),M(),B(),L())},V=n.subscribeBinary(t,($,P)=>{if(A)return;Noe(t,$,P),E.handleBinaryFrame({data:$,outputSeq:P},R.target).hasGap?O():F()}),Y=r.onMessage($=>{if(A||$.sessionId!==t)return;if($.type==="terminal_resize"){R.target.resize($.cols,$.rows),N();return}$.type!=="session_snapshot"||!E.applySnapshot({requestId:$.requestId,cols:$.cols,rows:$.rows,data:$.data,outputSeq:$.outputSeq},R.target,q=>{A||(q?O():F())}).applied||(W(),U(),u(()=>{A||v==null||v()}))});return N(),{dispose:()=>{A=!0,W(),U(),F(),R.dispose(),V(),Y()}}}function rme(e){const{host:t,sessionId:n,ws:r,relay:i,createTerminal:s,attachRawInput:o,attachTransport:l=nme,scheduleAutoFocus:u=D=>requestAnimationFrame(D),onTerminalReady:d,onFramePending:h,onFrameWritten:p,onRawInput:y,isInputEnabled:v,canFocus:_=()=>!0,onReady:w,onSubscribeStarted:x,onSubscribeDelayed:E,onError:k}=e;let R=!1,A=null,I=null,T=null,H=null;return(async()=>{try{const D=await s(t);if(R){D.dispose();return}A=D.dispose,I=o(D.terminal,n,{onRawInput:y,...v?{isInputEnabled:v}:{}}).dispose;const W=()=>{_()&&D.terminal.focus()};t.addEventListener("pointerdown",W,{passive:!0}),H=()=>t.removeEventListener("pointerdown",W),d==null||d(D.terminal),u(()=>{R||W()}),T=l({sessionId:n,ws:r,relay:i,target:D.terminal,onFramePending:h,onFrameWritten:p,onReady:w,onSubscribeStarted:x,onSubscribeDelayed:E})}catch(D){console.error("[pty-terminal-controller] initialization failed",D),k==null||k(D)}})(),{dispose:()=>{R=!0,T==null||T.dispose(),H==null||H(),I==null||I(),A==null||A()}}}function pE(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 ime=new RegExp("(?<![\\p{L}\\p{N}@:/.-])(?:~\\/|[^\\s`\"'<>,。;:!?、@])[^\\s`\"'<>,。;:!?、@]*?\\.(?:png|jpe?g|webp|gif)(?=$|[\\s`\"'<>),;:!?,。;:!?、]|\\.(?:$|[\\s`\"'<>),;:!?,。;:!?、]))","giu"),sme=new RegExp("(?<![A-Za-z0-9._+-])@(?:~\\/|[^\\s`\"'<>,。;:!?、@])[^\\s`\"'<>,。;:!?、@]*?\\.(?:png|jpe?g|webp|gif)(?=$|[\\s`\"'<>),;:!?,。;:!?、]|\\.(?:$|[\\s`\"'<>),;:!?,。;:!?、]))","giu"),ome=new RegExp("(?<![\\p{L}\\p{N}@:/.-])(?:~\\/|\\.{1,2}\\/|\\/|[^\\s`\"'<>,。;:!?、/@]+\\/)[^\\n\\r\\t`\"'<>,。;:!?、@]*?\\.(?:png|jpe?g|webp|gif)(?=$|[\\s`\"'<>),;:!?,。;:!?、])","giu"),ame=new RegExp("(?<![A-Za-z0-9._+-])@(?:~\\/|[^\\s`\"'<>,。;:!?、@])[^\\n\\r\\t`\"'<>,。;:!?、@]*?\\.(?:png|jpe?g|webp|gif)(?=$|[\\s`\"'<>),;:!?,。;:!?、])","giu"),lme=/\.(?:png|jpe?g|webp|gif)$/i;function g4(e){return e.replace(/^@/,"").replace(/^[([{]+/,"").replace(/[)\].,;:!?,。;:!?、]+$/u,"")}function cme(e){if(e.includes("/"))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 v4(e){const t=g4(e);return/^[a-z][a-z0-9+.-]*:\/\//i.test(t)||pE(t)||!lme.test(t)?!1:cme(t)}function y4(e){const t=[];for(const r of[ame,ome,sme,ime])for(const i of e.matchAll(r)){const s=i[0]??"",o=i.index??-1;if(o<0)continue;const l=g4(s);v4(l)&&t.push({path:l,start:o,end:o+s.length})}t.sort((r,i)=>r.start-i.start||i.end-r.end);const n=[];for(const r of t)n.some(i=>r.start<i.end&&r.end>i.start)||n.push(r);return n}function ume(e){const t=new Set,n=[];for(const{path:r}of y4(e))t.has(r)||(t.add(r),n.push(r));return n}const av=16,dme=8,hme=/(?:^|[\s([{@])@?(?:\/|\.\/|\.\.\/|~\/|[^\s`"'<>,。;:!?、/@]+\/)[^\n`"'<>,。;:!?、@]*$/u,fme=/^[^\n\r\t`"'<>,。;:!?、@]+$/u;function b4(e,t,n){const r=[mme(e,t),...gme(e,t)].filter(o=>o!==null),i=new Set,s=r.flatMap(o=>{const l=o.parts.map(u=>u.text).join("");return pme(l,n).map(u=>{const d=_me(o.parts,u.startIndex),h=wme(o.parts,u.endIndex);return!d||!h?null:{path:u.path,startLineNumber:d.lineNumber,startColumn:d.column,endLineNumber:h.lineNumber,endColumn:h.column,segments:Sme(o.parts,u.startIndex,u.endIndex)}}).filter(u=>u!==null).filter(u=>t>=u.startLineNumber&&t<=u.endLineNumber).filter(u=>{const d=`${u.path}:${u.startLineNumber}:${u.startColumn}:${u.endLineNumber}:${u.endColumn}`;return i.has(d)?!1:(i.add(d),!0)})});return s.filter(o=>!s.some(l=>l!==o&&H2(l.startLineNumber,l.startColumn,o.startLineNumber,o.startColumn)<=0&&H2(l.endLineNumber,l.endColumn,o.endLineNumber,o.endColumn)>=0&&(l.startLineNumber!==o.startLineNumber||l.startColumn!==o.startColumn||l.endLineNumber!==o.endLineNumber||l.endColumn!==o.endColumn)))}function H2(e,t,n,r){return e-n||t-r}function _4(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 pme(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 mme(e,t){const n=e.buffer.active;let r=t,i=t;for(let s=0;s<av;s+=1){const o=n.getLine(r-1);if(!(o!=null&&o.isWrapped)||r<=1)break;r-=1}for(let s=0;s<av;s+=1){const o=n.getLine(i);if(!(o!=null&&o.isWrapped))break;i+=1}return VS(e,r,i)}function VS(e,t,n){const r=e.buffer.active;let i=n??t;if(n===void 0)for(let o=0;o<av;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 gme(e,t){const n=e.buffer.active,r=[],i=Math.max(1,t-av);for(let s=i;s<=t;s+=1){const o=n.getLine(s-1);if(!o||o.isWrapped)continue;const l=vme(e,s);l&&t>=l.startLineNumber&&t<=l.endLineNumber&&r.push(l)}return r}function vme(e,t){const n=VS(e,t);if(!n)return null;const r=n.parts.map(l=>l.text).join("");if(!hme.test(r))return null;const i=[...n.parts];let s=n.endLineNumber,o=!1;for(let l=0;l<dme;l+=1){const u=s+1,d=VS(e,u);if(!d)break;const h=d.parts[0];if(!h)break;const p=yme(h.sourceText),y=h.sourceText.slice(p);if(!bme(p,y))break;i.push({...h,sourceStartIndex:p,text:y}),i.push(...d.parts.slice(1)),o=!0,s=d.endLineNumber}return o?{startLineNumber:t,endLineNumber:s,parts:i}:null}function yme(e){var t;return((t=e.match(/^\s*/))==null?void 0:t[0].length)??0}function bme(e,t){return e<2||!t||t.startsWith("-")||t.startsWith("•")||t.startsWith("›")||t.includes("://")?!1:fme.test(t)}function _me(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:YS(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:YS(s.sourceText,s.sourceStartIndex)}:null}n-=i.text.length}}return null}function wme(e,t){let n=t-1;for(const r of e){if(n<r.text.length)return{lineNumber:r.lineNumber,column:mE(r.sourceText.slice(0,r.sourceStartIndex+n+1))};n-=r.text.length}return null}function Sme(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,h=u-i;r.push({lineNumber:s.lineNumber,startColumn:YS(s.sourceText,s.sourceStartIndex+d),endColumn:mE(s.sourceText.slice(0,s.sourceStartIndex+h))})}i=o}return r}function YS(e,t){return mE(e.slice(0,t))+1}function mE(e){let t=0;for(const n of e)t+=xme(n.codePointAt(0)??0);return t}function xme(e){return e===0||e<32||e>=127&&e<160||Eme(e)?0:Cme(e)?2:1}function Eme(e){return e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071}function Cme(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 w4(e,t){return b4(e,t,ume)}function kme(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 Tme(e,t){const n={provideLinks(i,s){const o=w4(e,i);if(o.length===0){s(void 0);return}const l=o.reduce((u,d)=>{for(const h of _4(d))h.start.y!==i||h.end.y!==i||u.push({text:d.path,range:h,decorations:{underline:!0,pointerCursor:!0},activate:p=>{kme(p)&&t(d.path)}});return u},[]);s(l.length>0?l:void 0)}},r=e.registerLinkProvider(n);return{dispose:()=>r.dispose(),provider:n}}const Rme=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 gE(e){const n=(e.split(/[/?#]/,1)[0]??"").split(".");if(n.length<2)return!1;const r=(n.at(-1)??"").toLowerCase();return Rme.has(r)?n.every(i=>/^[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?$/.test(i)):!1}const Ame=new RegExp("(?<![\\p{L}\\p{N}@:/.-])(?:~\\/|[^\\s`\"'<>,。;:!?、@])[^\\s`\"'<>,。;:!?、@]*\\.[\\p{L}\\p{N}]{1,16}(?=[\\s`\"'<>),.;:!?,。;:!?、]|$)","giu"),Nme=new RegExp("(?<![A-Za-z0-9._+-])@(?:~\\/|[^\\s`\"'<>,。;:!?、@])[^\\s`\"'<>,。;:!?、@]*\\.[\\p{L}\\p{N}]{1,16}(?=[\\s`\"'<>),.;:!?,。;:!?、]|$)","giu"),Mme=new RegExp("(?<![\\p{L}\\p{N}@:/.-])(?:~\\/|\\.{1,2}\\/|\\/|[^\\s`\"'<>,。;:!?、/@]+\\/)[^\\n\\r\\t`\"'<>,。;:!?、@]*?\\.[\\p{L}\\p{N}]{1,16}(?=$|[\\s`\"'<>),;:!?,。;:!?、])","giu"),Ome=new RegExp("(?<![A-Za-z0-9._+-])@(?:~\\/|[^\\s`\"'<>,。;:!?、@])[^\\n\\r\\t`\"'<>,。;:!?、@]*?\\.[\\p{L}\\p{N}]{1,16}(?=$|[\\s`\"'<>),;:!?,。;:!?、])","giu"),Dme=/\.(?:png|jpe?g|webp|gif)$/i,Pme=/\.[\p{L}\p{N}]{1,16}$/u,Lme=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 S4(e){return e.replace(/^@/,"").replace(/^[([{]+/,"").replace(/[)\].,;:!?,。;:!?、]+$/u,"")}function Ime(e){const t=e.split("/").pop()??e;if(/^\d+(?:\.\d+)+$/.test(t))return!1;if(e.includes("/"))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 zme(e){return e.includes("/")?!1:gE(e)}function Bme(e){return e.includes("/")}function jme(e,t){return Bme(e)||t?!0:Lme.has(e.toLowerCase())}function x4(e,t={}){const n=S4(e);return/^[a-z][a-z0-9+.-]*:\/\//i.test(n)||pE(n)||!t.allowBare&&zme(n)||Dme.test(n)||!Pme.test(n)||!jme(n,t.allowBare===!0)||n.split("/").includes("...")?!1:Ime(n)}function E4(e){const t=[];for(const r of[Ome,Mme,Nme,Ame])for(const i of e.matchAll(r)){const s=i[0]??"",o=i.index??-1;if(o<0)continue;const l=S4(s);x4(l,{allowBare:s.startsWith("@")})&&t.push({path:l,start:o,end:o+s.length})}t.sort((r,i)=>r.start-i.start||i.end-r.end);const n=[];for(const r of t)n.some(i=>r.start<i.end&&r.end>i.start)||n.push(r);return n}function Fme(e){const t=new Set,n=[];for(const{path:r}of E4(e))t.has(r)||(t.add(r),n.push(r));return n}const $me=750;function C4(e,t){return b4(e,t,Fme)}function Hme(e){return e.metaKey||e.ctrlKey}function Ume(e,t){let n=null;const r=(o,l)=>{if(!Hme(l))return;const u=performance.now();(n==null?void 0:n.path)===o&&u-n.at<$me||(n={path:o,at:u},t(o))},i={provideLinks(o,l){const u=C4(e,o);if(u.length===0){l(void 0);return}const d=u.reduce((h,p)=>{for(const y of _4(p))y.start.y!==o||y.end.y!==o||h.push({text:p.path,range:y,decorations:{underline:!1,pointerCursor:!0},hover:()=>{Wme(e,p)},leave:()=>{Og(e)},dispose:()=>{Og(e)},activate:v=>{r(p.path,v)}});return h},[]);l(d.length>0?d:void 0)}},s=e.registerLinkProvider(i);return{dispose:()=>{Og(e),s.dispose()},provider:i}}function Wme(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;Og(e),qme(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,h=s.top-i.top,p=e.buffer.active.viewportY;for(const y of t.segments){const v=y.lineNumber-p;if(v<1||v>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=`${h+(v-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 Og(e){var t;(t=e.element)==null||t.querySelectorAll('[data-slot="pty-file-link-hover-overlay"]').forEach(n=>n.remove())}function qme(e){window.getComputedStyle(e).position==="static"&&(e.style.position="relative")}function qa(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 Vme(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 Yme(e){const t=new MouseEvent("mouseup",{bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY});return Object.defineProperty(t,"pointerType",{configurable:!0,value:"touch"}),t}function k4(e,t,n){if(t.length===0)return qa("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 qa("skip",{reason:"missing-elements",hasScreen:!!i,hasMetricHost:!!s,point:n}),null;const o=fE(s,e);if(!o||o.cellW<=0||o.cellH<=0)return qa("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 qa("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 h=e.buffer.active.viewportY+d,p={x:u,y:h};qa("probe",{point:n,viewportX:u,viewportY:d,bufferLineNumber:h,providers:t.length,metrics:o});for(const y of t){let v=null;if(y.provideLinks(h,_=>{qa("links",{bufferLineNumber:h,position:p,count:(_==null?void 0:_.length)??0,links:_==null?void 0:_.map(x=>({text:x.text,range:x.range}))});const w=_==null?void 0:_.find(x=>Vme(x,p,e.cols));w&&(v=w)}),v)return v}return qa("miss",{position:p,point:n,bufferLineNumber:h}),null}function Kme(e,t,n){return k4(e,t,n)!==null}function Gme(e,t,n){const r=k4(e,t,n);return r?(r.activate(Yme(n),r.text),qa("activate",{text:r.text,range:r.range,point:n}),!0):!1}const Xme=2*1024*1024,Zme=2560,U2=.82,Qme=.9,Jme=new Set(["image/jpeg","image/png","image/webp"]),T4=new Map([["image/jpeg","jpg"],["image/png","png"],["image/webp","webp"]]);function R4(e){return e.size>Xme&&Jme.has(e.type)}function ege(e,t,n=Zme){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 tge(e,t){const n=T4.get(t);return n?`${e.replace(/\.(?:jpe?g|png|webp)$/iu,"")||"image"}.${n}`:e}function nge(){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 A4(e,t=nge()){var r;if(!R4(e)||!t)return e;let n=null;try{n=await t.decode(e);const i=ege(n.width,n.height);let s=await t.encode(n,i.width,i.height,"image/webp",U2);return(s==null?void 0:s.type)!=="image/webp"&&e.type==="image/jpeg"&&(s=await t.encode(n,i.width,i.height,"image/jpeg",U2)),!s||!T4.has(s.type)||s.size>=e.size*Qme?e:new File([s],tge(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 kf(e){const t=R4(e.file),n=nt.loading(t?`正在压缩并上传 ${e.file.name} ...`:`上传 ${e.file.name} ...`);try{const r=await A4(e.file),i=await e.relay.uploadFile(e.sessionId,r);return!i.success||!i.path?(nt.error(i.error??"上传失败",{id:n}),null):(e.successLabel===null?nt.dismiss(n):nt.success(e.successLabel??`已上传 ${i.path}`,{id:n}),i.path)}catch(r){return nt.error(r instanceof Error?r.message:String(r),{id:n}),null}}function W2(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 q2="--dev-visual-viewport-height",rge=.3;function N4({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=V2(l,e),h=i?V2(u,r):0;return Math.max(d,h)}function ige({layoutViewportHeight:e,visualViewportHeight:t,visualViewportOffsetTop:n,baselineViewportHeight:r=e,allowBaselineFallback:i=!1,softKeyboardOpen:s=!1}){return s?Math.max(e-t-n,0):N4({layoutViewportHeight:e,visualViewportHeight:t,visualViewportOffsetTop:n,baselineViewportHeight:r,allowBaselineFallback:i})}function V2(e,t){const n=Math.max(e,0);return n<=0?0:n/Math.max(t,1)>=rge?n:0}function sge(){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(q2,`${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(q2)}},[])}function Y2(){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 oge(){b.useEffect(()=>{const e=window.visualViewport;let t=0;const n=()=>{Y2(),cancelAnimationFrame(t),t=requestAnimationFrame(()=>{t=0,Y2()})};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 age(){return vE().bottomOffset}function vE(){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=lge();let o=0;const l=()=>{const h=i.height,p=i.offsetTop,y=i.width,v=Math.max(window.innerHeight,h+p);!n.current||Math.abs(y-r.current)>1?(n.current=v,r.current=y):n.current=Math.max(n.current,v);const _=window.innerHeight,w=cge(),x=!s||w,E=s&&w,k=N4({layoutViewportHeight:_,visualViewportHeight:h,visualViewportOffsetTop:p,baselineViewportHeight:n.current,allowBaselineFallback:x,subtractVisualViewportOffsetTop:s}),R={bottomOffset:k,layoutBottomInset:ige({layoutViewportHeight:_,visualViewportHeight:h,visualViewportOffsetTop:p,baselineViewportHeight:n.current,allowBaselineFallback:E,softKeyboardOpen:k>0})};t(A=>A.bottomOffset===R.bottomOffset&&A.layoutBottomInset===R.layoutBottomInset?A:R)},u=()=>{cancelAnimationFrame(o),o=requestAnimationFrame(()=>{o=0,l()})};u(),window.addEventListener("resize",u),i.addEventListener("resize",u),i.addEventListener("scroll",u);const d=()=>{setTimeout(u,300)};return window.addEventListener("focusout",d),()=>{cancelAnimationFrame(o),window.removeEventListener("resize",u),i.removeEventListener("resize",u),i.removeEventListener("scroll",u),window.removeEventListener("focusout",d)}},[]),e}function lge(){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 cge(){const e=document.activeElement;return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}const uge=new Set(["\x1B[A","\x1B[B","\x1B[C","\x1B[D"]);function Vh(e,t){return!(t!=null&&t.applicationCursorKeysMode)||!uge.has(e)?e:`\x1BO${e.at(-1)}`}function dge(e){window.__devAnywherePtyTerminal=e}function hge(){window.__devAnywherePtyTerminal&&delete window.__devAnywherePtyTerminal}function fge(e){window.__devAnywherePtyDebug=e}function pge(){window.__devAnywherePtyDebug&&delete window.__devAnywherePtyDebug}function mge(e,t){const n=e(),{container:r,spacer:i,host:s,term:o}=t,{cellH:l,cellW:u,paddingTop:d,paddingBottom:h,canvasLastY:p}=n,y=Math.max(0,r.clientHeight-d-h),v=o.buffer.active;let _=0;if(l>0&&u>0){const B=f4({bufferLength:v.length,rows:o.rows,cols:o.cols,viewportY:v.viewportY,cursorY:v.cursorY,cellH:l,cellW:u,visibleContentHeight:y},p);_=(B==null?void 0:B.spacerHeight)??0}const w=Ws(i.style.height),x=Ws(s.style.top),E=Ws(s.style.height),k=Ws(s.style.width),R=Ws(s.style.paddingTop),A=Ws(i.style.width);let I=0;if(l>0){const B=o.rows*l,L=B>0&&B<y?y-B:0;I=Math.max(0,v.viewportY*l+L)}const T=x-I,H=r.scrollTop,D=H+r.clientHeight,W=x+E,U=Math.max(0,Math.min(D,W)-Math.max(H,x)),F=r.clientHeight>0?U/r.clientHeight:0,O=v.baseY+v.cursorY,M=hE({rows:o.rows,cellH:l,bufferLength:v.length,cursorBufferRow:O,visibleContentHeight:y,paddingTop:d,paddingBottom:h,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:h},spacer:{height:w,width:A},host:{top:x,height:E,width:k,paddingTop:R,expectedTop:I,topDrift:T},term:{rows:o.rows,cols:o.cols,bufferLength:v.length,viewportY:v.viewportY,baseY:v.baseY,cursorX:v.cursorX,cursorY:v.cursorY},cell:{h:l,w:u},visibleContentHeight:y,anchor:{atBottom:M.isAtBottom,cursorInViewport:M.cursorInViewport,cursorBufferRow:O,bottomScrollTop:M.bottomScrollTop,scrollTopDeltaToBottom:r.scrollTop-M.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:F,pendingContainerSyncRetry:n.pendingContainerSyncRetry}}const ay={enabled:!1,phase:"idle",error:null,lastSpokenText:"",approvalRequestId:null,activityLevel:0,waveform:[],resumeRequestSeq:0};function gge(e){return Number.isFinite(e)?Math.max(0,Math.min(1,e)):0}function Fs(e,t,n){const r=e.bySessionId[t]??ay;return{bySessionId:{...e.bySessionId,[t]:n(r)}}}const cn=td()(nd(e=>({bySessionId:{},enable:t=>e(n=>Fs(n,t,r=>({...r,enabled:!0,phase:"starting",error:null,waveform:[]}))),disable:t=>e(n=>Fs(n,t,r=>({...r,enabled:!1,phase:"idle",error:null,approvalRequestId:null,activityLevel:0,waveform:[]}))),requestResume:t=>e(n=>Fs(n,t,r=>({...r,resumeRequestSeq:r.resumeRequestSeq+1}))),setPhase:(t,n)=>e(r=>Fs(r,t,i=>({...i,phase:n,error:n==="error"?i.error:null}))),setError:(t,n)=>e(r=>Fs(r,t,i=>({...i,phase:"error",error:n,activityLevel:0,waveform:[]}))),clearError:t=>e(n=>Fs(n,t,r=>({...r,error:null,phase:r.enabled&&r.phase==="error"?"starting":r.phase}))),setLastSpokenText:(t,n)=>e(r=>Fs(r,t,i=>({...i,lastSpokenText:n}))),setApproval:(t,n)=>e(r=>Fs(r,t,i=>({...i,approvalRequestId:n}))),setActivityLevel:(t,n)=>e(r=>Fs(r,t,i=>({...i,activityLevel:gge(n)}))),appendWaveform:(t,n)=>{n.length!==0&&e(r=>Fs(r,t,i=>({...i,waveform:[...i.waveform,...n].slice(-q0)})))},clearWaveform:t=>e(n=>Fs(n,t,r=>({...r,waveform:[]}))),resetAll:()=>e({bySessionId:{}})}),{name:"voice-pilot-store"}));function vge(){const[e,t]=b.useState(!1),[n,r]=b.useState(!1),[i,s]=b.useState(!1);b.useEffect(()=>{if(e){r(!1);return}const p=setTimeout(()=>r(!0),300);return()=>clearTimeout(p)},[e]);const o=b.useCallback(()=>{t(!0),s(!1)},[]),l=b.useCallback(()=>{t(!1),s(!1)},[]),u=b.useCallback(()=>{s(!0)},[]),d=b.useMemo(()=>({connecting:n,subscribeDelayed:i}),[n,i]),h=b.useMemo(()=>({onReady:o,onSubscribeStarted:l,onSubscribeDelayed:u}),[o,u,l]);return{ready:e,overlay:d,transport:h}}const yge=900;function bge(){var t;const e=navigator.virtualKeyboard;(t=e==null?void 0:e.show)==null||t.call(e)}function _ge(e){const{containerEl:t,xtermHostRef:n,terminalRef:r}=e,[i,s]=b.useState(!1),o=b.useRef(0),l=b.useCallback(()=>{const v=document.activeElement;!t||!(v instanceof HTMLElement)||!t.contains(v)||v.blur()},[t]),u=b.useCallback(()=>{const v=n.current,_=document.activeElement,w=!!(v&&_ instanceof HTMLElement&&v.contains(_));s(w),w&&bge()},[n]),d=b.useCallback((v={})=>{o.current=performance.now()+yge,(v.blur??!0)&&(l(),s(!1))},[l]),h=b.useCallback(v=>{if(performance.now()<=o.current){v.target instanceof HTMLElement&&v.target.blur(),window.setTimeout(u,0);return}u()},[u]),p=b.useCallback(()=>{window.setTimeout(u,0)},[u]),y=b.useCallback(()=>{var v;o.current=0,(v=r.current)==null||v.focus(),window.setTimeout(u,0)},[u,r]);return{ptyInputFocused:i,suppressPtyFocus:d,focusPtyInput:y,handleFocusCapture:h,handleBlurCapture:p}}function wge(){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}}async function M4(e,{allowLegacyFallback:t=!1}={}){var r,i;const n=(i=(r=navigator.clipboard)==null?void 0:r.writeText)==null?void 0:i.bind(navigator.clipboard);if(n&&window.isSecureContext!==!1)try{return await n(e),"clipboard"}catch{}return t&&Sge(e)?"legacy":"failed"}function Sge(e){if(!document.body||typeof document.execCommand!="function")return!1;const t=document.createElement("textarea");t.value=e,t.readOnly=!0,t.setAttribute("aria-hidden","true"),t.style.position="fixed",t.style.left="-9999px",t.style.top="0",t.style.opacity="0",t.style.fontSize="16px",document.body.appendChild(t);try{return t.select(),t.setSelectionRange(0,e.length),document.execCommand("copy")}catch{return!1}finally{t.remove()}}const xge=new Intl.Segmenter("zh-CN",{granularity:"word"}),Ege=/^[./:@_+~=-]+$/u,Cge=/[a-z0-9]/iu;function O4({terminal:e,host:t,cellWidth:n,cellHeight:r}){return n&&r?{cellW:n,cellH:r}:fE(t,e)}function kge(e,t){const n=Math.min(e.length,t),r=[];let i="";for(let s=0;s<n;s+=1){const o=e.getCell(s),l=(o==null?void 0:o.getWidth())??1;if(l===0)continue;const u=(o==null?void 0:o.getChars())||" ",d=i.length;i+=u,r.push({textStart:d,textEnd:i.length,cellStart:s,cellEnd:Math.min(n-1,s+Math.max(1,l)-1)})}return{text:i.trimEnd(),spans:r}}function K2(e){return Ege.test(e.segment)}function KS(e){return e.isWordLike===!0&&Cge.test(e.segment)}function Tge(e,t){let n=t,r=t;for(;n>0;){let o=n-1;for(;o>=0&&K2(e[o]);)o-=1;if(o===n-1)break;if(o>=0&&KS(e[o])){n=o;continue}n=o+1;break}for(;r+1<e.length;){let o=r+1;for(;o<e.length&&K2(e[o]);)o+=1;if(o===r+1||o>=e.length||!KS(e[o]))break;r=o}const i=e[n].index,s=e[r];return{start:i,end:s.index+s.segment.length}}function Rge(e){const t=Array.from(xge.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(KS(o)?Tge(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 Age(e,t){const{text:n,spans:r}=kge(e,t);return Rge(n).flatMap(i=>{const s=r.filter(u=>u.textStart<i.end&&u.textEnd>i.start),o=s[0],l=s.at(-1);return o&&l?[{start:o.cellStart,end:l.cellEnd}]:[]})}function Nge(e,t){if(e.length===0)return null;let n=0,r=Number.POSITIVE_INFINITY;for(let i=0;i<e.length;i+=1){const s=e[i],o=t<s.start?s.start-t:t>s.end?t-s.end:0;o<r&&(r=o,n=i)}return n}function Mge(e,t){return e.row<t.row||e.row===t.row&&e.column<=t.column?{start:e,end:t}:{start:t,end:e}}function Oge(e,t,n){const r=[];for(let i=t.row;i<=n.row;i+=1){const s=e.buffer.active.getLine(i);if(!s){r.push("");continue}const o=i===t.row?t.column:0,l=i===n.row?n.column+1:e.cols;r.push(s.translateToString(!0,o,l))}return r.join(`
643
+ `).replace(/\s+$/,"")}function Yh({terminal:e,host:t,clientX:n,clientY:r,cellWidth:i,cellHeight:s}){const o=t.querySelector(".xterm-screen");if(!o)return null;const l=O4({terminal:e,host:t,cellWidth:i,cellHeight:s});if(!(l!=null&&l.cellW)||!l.cellH)return null;const u=o.getBoundingClientRect(),d=Math.floor((r-u.top)/l.cellH),h=Math.floor((n-u.left)/l.cellW);return d<0||d>=e.rows||h<0||h>=e.cols?null:{row:e.buffer.active.viewportY+d,column:h}}function G2({terminal:e,host:t,point:n,affinity:r="before",cellWidth:i,cellHeight:s}){const o=t.querySelector(".xterm-screen");if(!o)return null;const l=O4({terminal:e,host:t,cellWidth:i,cellHeight:s});if(!(l!=null&&l.cellW)||!l.cellH)return null;const u=n.row-e.buffer.active.viewportY;if(u<0||u>=e.rows||n.column<0||n.column>=e.cols)return null;const d=o.getBoundingClientRect(),h=r==="after"?n.column+1:n.column;return{left:d.left+h*l.cellW,top:d.top+(u+1)*l.cellH}}function lv({terminal:e,anchor:t,focus:n}){var u;const{start:r,end:i}=Mge(t,n),o=Math.max(0,i.row-r.row)*e.cols+(i.column-r.column)+1;if(o<=0)return null;e.select(r.column,r.row,o);const l=((u=e.getSelection)==null?void 0:u.call(e))||Oge(e,r,i);return l.trim()?{anchor:t,focus:n,text:l}:null}function X2({terminal:e,host:t,clientX:n,clientY:r,cellWidth:i,cellHeight:s}){const o=Yh({terminal:e,host:t,clientX:n,clientY:r,cellWidth:i,cellHeight:s});return o?GS({terminal:e,point:o}):null}function GS({terminal:e,point:t}){const n=e.buffer.active.getLine(t.row);if(!n)return null;const r=Age(n,e.cols),i=Nge(r,t.column);if(i===null)return null;const s=r[i];return s?lv({terminal:e,anchor:{row:t.row,column:s.start},focus:{row:t.row,column:s.end}}):null}function Z2({terminal:e,point:t}){const n=t.row+1,r=t.column+1,i=[...w4(e,n).map(o=>({match:o,pathAction:{kind:"image-preview",path:o.path}})),...C4(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=lv({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}function Q2(e,t,n){return t>n?(t+n)/2:Math.min(Math.max(e,t),n)}const Dge=64;function D4({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-Dge;return{left:Q2(e,o,l),top:Q2(t-48,u,d)}}function Pge(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 Lge({terminal:e,host:t,anchor:n,focus:r}){const i=e.buffer.active.viewportY,s=i+e.rows-1,o=d=>({...d,row:Math.min(s,Math.max(i,d.row))}),l=G2({terminal:e,host:t,point:o(n),affinity:"before"}),u=G2({terminal:e,host:t,point:o(r),affinity:"after"});return!l||!u?null:{anchor:l,focus:u}}function Ige({handles:e,viewportWidth:t,viewportHeight:n,viewportOffsetLeft:r=0,viewportOffsetTop:i=0}){return D4({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 zge=/\.(?:png|jpe?g|webp|gif)$/i,P4=/\.[\p{L}\p{N}]{1,16}$/u;function Bge(e){return e.trim().replace(/^@/,"").replace(/^[([{]+/,"").replace(/[)\].,;:!?,。;:!?、]+$/u,"")}function jge(e){const t=e.trim();if(!t||t.includes(`
644
+ `))return null;const n=Bge(t);return!n||/^[a-z][a-z0-9+.-]*:\/\//i.test(n)||pE(n)||n.split("/").includes("...")?null:n}function Fge(e){return e.includes("/")?!1:gE(e)}function $ge(e){const t=e.split("/").pop()??e;if(/^\d+(?:\.\d+)+$/.test(t))return!1;if(e.includes("/"))return!0;const n=e.replace(P4,""),r=n.split("/").pop()??n;return/[A-Za-z_-]/.test(r)}function Hge(e){const t=jge(e);return!t||Fge(t)||!$ge(t)?null:zge.test(t)?{kind:"image-preview",path:t}:P4.test(t)?{kind:"file-download",path:t}:null}const Uge=16,Wge=24,xh=6,qge=425,Kh=-1;function eg(e,t){return e.pointerId===t||t===Kh}function gu(e){return Math.hypot(e.lastX-e.startX,e.lastY-e.startY)}function Ri(e,t={}){const n=window.__ccTestPtyTouchGestureEvents;n&&(n.push({event:e,t:performance.now(),...t}),n.length>200&&n.splice(0,n.length-200))}function Vge({terminalRef:e,suppressPtyFocus:t,focusTerminal:n,onLongPressCandidateStart:r,onTap:i,isTapCandidate:s,onLongPressStart:o,onLongPressMove:l,onLongPressEnd:u}){const d=b.useRef(null),h=b.useCallback(F=>{F.longPressTimer!==null&&(window.clearTimeout(F.longPressTimer),F.longPressTimer=null)},[]),p=b.useCallback(F=>{F.longPressed||F.moved||(F.longPressed=!0,F.longPressArmed=!1,h(F),t(),o==null||o({clientX:F.startX,clientY:F.startY}))},[h,o,t]),y=b.useCallback(F=>{if(!(F.longPressed||F.longPressArmed||F.moved)){if(gu(F)>xh){h(F),Ri("longpress:cancel-drift",{distance:gu(F),threshold:xh});return}if(s!=null&&s({clientX:F.startX,clientY:F.startY})){F.longPressArmed=!0,h(F),Ri("longpress:arm-link",{clientX:F.startX,clientY:F.startY});return}p(F)}},[h,s,p]),v=b.useCallback(F=>{if(F.longPressDelivered||!F.longPressed||F.moved)return;F.longPressDelivered=!0;const O={clientX:F.lastX,clientY:F.lastY};window.setTimeout(()=>u==null?void 0:u(O),0)},[u]),_=b.useCallback((F,O,M,B=!1)=>{const L={pointerId:F,startX:O,startY:M,lastX:O,lastY:M,moved:!1,longPressArmed:!1,longPressed:!1,longPressDelivered:!1,touchEventStream:B,longPressTimer:null};L.longPressTimer=window.setTimeout(()=>{d.current===L&&y(L)},qge),d.current=L,Ri("start",{pointerId:F,clientX:O,clientY:M,touchEventStream:B}),r==null||r({clientX:O,clientY:M})},[y,r]),w=b.useCallback((F,O,M)=>{const B=d.current;if(!B||!eg(B,F))return!1;B.lastX=O,B.lastY=M;const L=gu(B);if(B.longPressArmed&&L>xh&&(B.longPressArmed=!1,Ri("longpress:cancel-armed-drift",{pointerId:F,clientX:O,clientY:M,distance:L,threshold:xh})),B.longPressed)return Ri("move",{pointerId:F,clientX:O,clientY:M,distance:L,moved:B.moved,longPressed:!0}),l==null||l({clientX:O,clientY:M}),!0;const N=O-B.startX,V=M-B.startY;return!B.moved&&L>=Uge&&(B.moved=!0,h(B)),Ri("move",{pointerId:F,clientX:O,clientY:M,dx:N,dy:V,distance:L,moved:B.moved,longPressed:!1}),B.moved},[h,l]),x=b.useCallback((F,O)=>{var N;const M=d.current;if(!M||!eg(M,F))return null;O&&(M.lastX=O.clientX,M.lastY=O.clientY),d.current=null,h(M);const B=gu(M);let L;if(M.longPressArmed){if(B<=xh)return p(M),v(M),L="longpress",Ri("finish",{pointerId:F,result:L,point:O,moved:M.moved,distance:B,longPressed:!0,longPressArmed:!0}),L;M.longPressArmed=!1}return M.longPressed?(v(M),L="longpress",Ri("finish",{pointerId:F,result:L,point:O,moved:M.moved,longPressArmed:M.longPressArmed,distance:B,longPressed:!0}),L):M.moved?O&&gu(M)<=Wge&&(i!=null&&i(O))?(t(),L="link",Ri("finish",{pointerId:F,result:L,point:O,moved:!0,distance:B,longPressed:!1}),L):(t(),L="scroll",Ri("finish",{pointerId:F,result:L,point:O,moved:!0,distance:B,longPressed:!1}),L):O&&(i!=null&&i(O))?(t(),L="link",Ri("finish",{pointerId:F,result:L,point:O,moved:!1,distance:B,longPressed:!1}),L):(n?n():(N=e.current)==null||N.focus(),L="tap",Ri("finish",{pointerId:F,result:L,point:O,moved:!1,distance:B,longPressed:!1}),L)},[h,v,n,i,p,t,e]),E=b.useCallback(F=>{const O=d.current;return!O||!eg(O,F)?null:(h(O),d.current=null,O.longPressed?(v(O),Ri("cancel",{pointerId:F,result:"longpress"}),"longpress"):(O.longPressArmed&&Ri("cancel",{pointerId:F,result:"armed"}),t(),Ri("cancel",{pointerId:F,result:"scroll",moved:O.moved,distance:gu(O)}),"scroll"))},[h,v,t]),k=b.useCallback(F=>{if(F.pointerType!=="touch")return;const O=F.target;!(O instanceof Element)||!O.closest(".xterm")||(_(F.pointerId,F.clientX,F.clientY),F.stopPropagation())},[_]),R=b.useCallback(F=>{if(F.pointerType!=="touch")return;const O=w(F.pointerId,F.clientX,F.clientY),M=d.current;M&&O&&(F.stopPropagation(),M.longPressed&&F.preventDefault())},[w]),A=b.useCallback(F=>{const O=x(F.pointerId,{clientX:F.clientX,clientY:F.clientY});O&&(F.stopPropagation(),O==="link"&&F.cancelable&&F.preventDefault())},[x]),I=b.useCallback(F=>{const O=d.current;if(F.pointerType==="touch"&&O&&eg(O,F.pointerId)&&O.touchEventStream&&!O.longPressed){F.stopPropagation();return}E(F.pointerId)&&F.stopPropagation()},[E]),T=b.useCallback(F=>{const O=F.target;if(!(O instanceof Element)||!O.closest(".xterm"))return;if(d.current){d.current.touchEventStream=!0;return}const M=F.touches[0]??F.changedTouches[0];M&&_(Kh,M.clientX,M.clientY,!0)},[_]),H=b.useCallback(F=>{const O=F.touches[0]??F.changedTouches[0];if(!O)return;const M=w(Kh,O.clientX,O.clientY),B=d.current;B&&M&&B.longPressed&&(F.stopPropagation(),F.preventDefault())},[w]),D=b.useCallback(F=>{const O=F.changedTouches[0],M=d.current,B=O?{clientX:O.clientX,clientY:O.clientY}:M?{clientX:M.lastX,clientY:M.lastY}:void 0,L=x(Kh,B);(L==="longpress"||L==="link")&&(F.stopPropagation(),F.cancelable&&F.preventDefault())},[x]),W=b.useCallback(F=>{E(Kh)==="longpress"&&F.stopPropagation()},[E]),U=b.useCallback(F=>{const O=d.current;O&&(F.preventDefault(),F.stopPropagation(),y(O))},[y]);return{onPointerDownCapture:k,onPointerMoveCapture:R,onPointerUpCapture:A,onPointerCancelCapture:I,onTouchStartCapture:T,onTouchMoveCapture:H,onTouchEndCapture:D,onTouchCancelCapture:W,onContextMenuCapture:U}}function Yge({terminalRef:e,containerEl:t,suppressPtyFocus:n,focusPtyInput:r,isSelectionActive:i,onTap:s,isTapCandidate:o,onLongPressCandidateStart:l,onLongPressStart:u,onLongPressMove:d,onLongPressEnd:h,onHorizontalScrollIntent:p,onSelectionAutoscroll:y,onHandleDragStart:v,onHandleDragMove:_,onHandleDragEnd:w,onHandleDragCancel:x}){const E=b.useRef(null),k=b.useRef(null),R=b.useRef(null),A=b.useRef(!1),I=b.useRef(null),T=b.useCallback(()=>{var L;(L=I.current)==null||L.call(I),I.current=null,k.current=null,R.current=null,A.current=!1,E.current!==null&&(cancelAnimationFrame(E.current),E.current=null)},[]),H=b.useCallback(()=>{var $;E.current=null;const L=k.current;if(!L||!t||!i())return;const N=t.getBoundingClientRect(),{dx:V,dy:Y}=c4({pointerX:L.clientX,pointerY:L.clientY,rect:N,scrollLeft:t.scrollLeft,scrollTop:t.scrollTop,scrollWidth:t.scrollWidth,scrollHeight:t.scrollHeight,clientWidth:t.clientWidth,clientHeight:t.clientHeight,edgePx:44,maxSpeedPx:18});V!==0&&(p==null||p(`selectionGestureAutoscroll dx=${Math.round(V)}`),t.scrollLeft+=V),Y!==0&&(t.scrollTop+=Y),(V!==0||Y!==0)&&(y==null||y({scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}),($=R.current)==null||$.call(R,L)),E.current=requestAnimationFrame(H)},[t,i,p,y]),D=b.useCallback((L,N)=>{k.current=L,R.current=N,E.current===null&&(E.current=requestAnimationFrame(H))},[H]);b.useEffect(()=>T,[T]),b.useEffect(()=>{if(!t)return;const L=N=>{A.current&&N.preventDefault()};return t.addEventListener("touchmove",L,{capture:!0,passive:!1}),document.addEventListener("touchmove",L,{capture:!0,passive:!1}),()=>{t.removeEventListener("touchmove",L,{capture:!0}),document.removeEventListener("touchmove",L,{capture:!0})}},[t]);const W=b.useCallback(L=>{T(),A.current=!0,u(L)},[u,T]),U=b.useCallback(L=>{d(L),D(L,d)},[d,D]),F=b.useCallback(L=>{T(),h(L)},[h,T]),O=Vge({terminalRef:e,suppressPtyFocus:n,focusTerminal:r,onTap:s,isTapCandidate:o,onLongPressCandidateStart:l,onLongPressStart:W,onLongPressMove:U,onLongPressEnd:F}),M=b.useCallback((L,N)=>{N.preventDefault(),N.stopPropagation(),T(),A.current=!0,v(L);let V=()=>{};const Y=q=>{q.cancelable&&q.preventDefault();const K={clientX:q.clientX,clientY:q.clientY};_(L,K),D(K,z=>_(L,z))},$=q=>{const K={clientX:q.clientX,clientY:q.clientY};V(),I.current=null,T(),w(L,K)},P=()=>{V(),I.current=null,T(),x(L)};V=()=>{window.removeEventListener("pointermove",Y),window.removeEventListener("pointerup",$),window.removeEventListener("pointercancel",P)},I.current=V,window.addEventListener("pointermove",Y,{passive:!1}),window.addEventListener("pointerup",$,{once:!0}),window.addEventListener("pointercancel",P,{once:!0})},[x,w,_,v,T,D]),B=b.useCallback((L,N)=>{if(I.current||!(N.touches[0]??N.changedTouches[0]))return;N.preventDefault(),N.stopPropagation(),A.current=!0,v(L);let Y=()=>{};const $=K=>{const z=K.touches[0]??K.changedTouches[0];if(!z)return;K.cancelable&&K.preventDefault();const X={clientX:z.clientX,clientY:z.clientY};_(L,X),D(X,ee=>_(L,ee))},P=K=>{const z=K.changedTouches[0],X=z?{clientX:z.clientX,clientY:z.clientY}:k.current;Y(),I.current=null,T(),w(L,X)},q=()=>{Y(),I.current=null,T(),x(L)};Y=()=>{window.removeEventListener("touchmove",$),window.removeEventListener("touchend",P),window.removeEventListener("touchcancel",q)},I.current=Y,window.addEventListener("touchmove",$,{passive:!1}),window.addEventListener("touchend",P,{once:!0}),window.addEventListener("touchcancel",q,{once:!0})},[x,w,_,v,T,D]);return{pointerHandlers:O,stopPtySelectionGesture:T,handlePtySelectionHandlePointerDown:M,handlePtySelectionHandleTouchStart:B}}const Kge=8;function Gge(e){const{sessionId:t,terminalRef:n,xtermHostRef:r,scrollControllerRef:i,containerEl:s,scrollState:o,keyboardOffset:l,ptyFontSize:u,suppressPtyFocus:d,focusPtyInput:h,onTap:p,isTapCandidate:y,onDownloadPath:v,onPreviewPath:_}=e,w=b.useRef(null),x=b.useRef(null),E=b.useRef(null),k=b.useRef(null),R=b.useRef(!1),A=b.useRef(null),I=b.useRef(null),T=b.useRef(""),H=b.useRef(null),[D,W]=b.useState(null),[U,F]=b.useState(null),[O,M]=b.useState(null),B=b.useMemo(()=>Pge(u),[u]),L=b.useCallback((ye,He)=>{const Ge=window.visualViewport;return D4({clientX:ye,clientY:He,viewportWidth:(Ge==null?void 0:Ge.width)??window.innerWidth,viewportHeight:(Ge==null?void 0:Ge.height)??window.innerHeight,viewportOffsetLeft:(Ge==null?void 0:Ge.offsetLeft)??0,viewportOffsetTop:(Ge==null?void 0:Ge.offsetTop)??0})},[]),N=b.useCallback((ye,He)=>{const Ge=n.current,be=r.current;return!Ge||!be?null:Lge({terminal:Ge,host:be,anchor:ye,focus:He})},[n,r]),V=b.useCallback((ye,He)=>{const Ge=He??Hge(ye);return I.current=Ge,M(Ge),Ge},[]),Y=b.useCallback(ye=>{const He=window.visualViewport;return Ige({handles:ye,viewportWidth:(He==null?void 0:He.width)??window.innerWidth,viewportHeight:(He==null?void 0:He.height)??window.innerHeight,viewportOffsetLeft:(He==null?void 0:He.offsetLeft)??0,viewportOffsetTop:(He==null?void 0:He.offsetTop)??0})},[]),$=b.useCallback(()=>{const ye=w.current,He=x.current;if(!ye||!He){F(null);return}const Ge=N(ye,He);if(F(Ge),!Ge){W(null);return}W(be=>be&&Y(Ge))},[N,Y]),P=b.useCallback(()=>{var ye,He;(ye=H.current)==null||ye.call(H),E.current=null,k.current=null,w.current=null,x.current=null,R.current=!1,A.current=null,I.current=null,T.current="",(He=n.current)==null||He.clearSelection(),W(null),F(null),M(null)},[n]),q=b.useCallback((ye="")=>{w.current=null,x.current=null,R.current=!1,I.current=null,T.current=ye,W(null),F(null),M(null)},[]),K=b.useCallback(({clientX:ye,clientY:He})=>{const Ge=n.current,be=r.current;d({blur:!1}),k.current={clientX:ye,clientY:He},E.current=Ge&&be?Yh({terminal:Ge,host:be,clientX:ye,clientY:He}):null},[d,n,r]),z=b.useCallback(({clientX:ye,clientY:He,draggedHandle:Ge="focus"})=>{const be=n.current,Xe=r.current,rt=w.current,pt=x.current;if(!be||!Xe||!rt)return null;const le=Yh({terminal:be,host:Xe,clientX:ye,clientY:He});if(!le)return null;const Ae=Ge==="anchor"?le:rt,Ze=Ge==="focus"?le:pt??rt;w.current=Ae,x.current=Ze,R.current=!0;const tt=lv({terminal:be,anchor:Ae,focus:Ze});return T.current=(tt==null?void 0:tt.text)??"",V((tt==null?void 0:tt.text)??""),F(tt?N(Ae,Ze):null),tt},[N,V,n,r]),X=b.useCallback(({point:ye,clientX:He,clientY:Ge,showToolbar:be=!0})=>{const Xe=n.current,rt=r.current;if(!Xe||!rt)return!1;A.current=null;const pt=ye?Z2({terminal:Xe,point:ye}):null,le=pt??(ye?GS({terminal:Xe,point:ye}):X2({terminal:Xe,host:rt,clientX:He,clientY:Ge}));if(!(le!=null&&le.text))return!1;w.current=le.anchor,x.current=le.focus,T.current=le.text,V(le.text,pt==null?void 0:pt.pathAction);const Ae=N(le.anchor,le.focus);return F(Ae),be&&W(Ae?Y(Ae):L(He,Ge)),!0},[N,L,Y,V,n,r]),ee=b.useCallback(()=>{const ye=w.current,He=x.current;if(!ye||!He){W(null);return}const Ge=N(ye,He);F(Ge),W(Ge?Y(Ge):null)},[N,Y]),te=b.useCallback(ye=>{var be,Xe;const He=((Xe=(be=n.current)==null?void 0:be.getSelection)==null?void 0:Xe.call(be))??"",Ge=V(He);T.current=He,w.current=null,x.current=null,R.current=!1,F(null),W(Ge?L(ye.clientX,ye.clientY):null)},[L,V,n]);b.useEffect(()=>{const ye=r.current;if(!ye)return;let He=!1;const Ge=rt=>{var le,Ae;if(rt.pointerType!=="mouse"||rt.button!==0)return;const pt=rt.target;!(pt instanceof Element)||!pt.closest(".xterm")||(He=!0,q(((Ae=(le=n.current)==null?void 0:le.getSelection)==null?void 0:Ae.call(le))??""))},be=rt=>{if(rt.pointerType!=="mouse"||!He)return;He=!1;const pt={clientX:rt.clientX,clientY:rt.clientY};window.setTimeout(()=>te(pt),0)},Xe=()=>{He=!1};return ye.addEventListener("pointerdown",Ge,!0),window.addEventListener("pointerup",be,!0),window.addEventListener("pointercancel",Xe,!0),()=>{ye.removeEventListener("pointerdown",Ge,!0),window.removeEventListener("pointerup",be,!0),window.removeEventListener("pointercancel",Xe,!0)}},[q,te,n,r]),b.useLayoutEffect(()=>{if(!D&&!U)return;const ye=He=>{const Ge=He.target;Ge instanceof Element&&Ge.closest('[data-slot="pty-selection-toolbar"], [data-slot="pty-selection-handle"]')||P()};return document.addEventListener("pointerdown",ye,!0),document.addEventListener("touchstart",ye,!0),()=>{document.removeEventListener("pointerdown",ye,!0),document.removeEventListener("touchstart",ye,!0)}},[P,U,D]),b.useEffect(()=>{if(!s||!D)return;const ye=()=>{const He=A.current;He&&s.scrollLeft===He.scrollLeft&&s.scrollTop===He.scrollTop||P()};return s.addEventListener("scroll",ye,{passive:!0}),()=>s.removeEventListener("scroll",ye)},[P,s,D]);const Q=U!==null;b.useLayoutEffect(()=>{var ye;Q&&((ye=i.current)==null||ye.relayout(),$())},[Q,l,$,i]),b.useEffect(()=>{Q&&$()},[Q,$,o.scrollLeft,o.scrollTop]),b.useEffect(()=>{if(!Q)return;const ye=window.visualViewport;let He=0,Ge=0;const be=()=>{cancelAnimationFrame(He),window.clearTimeout(Ge),He=requestAnimationFrame(()=>{$(),Ge=window.setTimeout(()=>{He=requestAnimationFrame(()=>$())},160)})};return be(),window.addEventListener("resize",be),ye==null||ye.addEventListener("resize",be),ye==null||ye.addEventListener("scroll",be),()=>{cancelAnimationFrame(He),window.clearTimeout(Ge),window.removeEventListener("resize",be),ye==null||ye.removeEventListener("resize",be),ye==null||ye.removeEventListener("scroll",be)}},[Q,$]);const me=b.useCallback(({clientX:ye,clientY:He})=>{const Ge=n.current,be=r.current;if(!Ge||!be)return;const Xe=Yh({terminal:Ge,host:be,clientX:ye,clientY:He})??E.current;if(Ge.clearSelection(),!Xe){w.current=null,x.current=null,I.current=null,T.current="",W(null),F(null),M(null);return}w.current=Xe,x.current=Xe,R.current=!1,I.current=null,T.current="",W(null),F(null),M(null),X({point:Xe,clientX:ye,clientY:He,showToolbar:!1})},[X,n,r]),ve=b.useCallback(({clientX:ye,clientY:He})=>{z({clientX:ye,clientY:He}),W(null)},[z]),Ce=b.useCallback(({clientX:ye,clientY:He})=>{const Ge=n.current,be=r.current;if(!Ge||!be)return;const Xe=w.current,rt=Yh({terminal:Ge,host:be,clientX:ye,clientY:He}),pt=rt??x.current,le=E.current,Ae=k.current,Ze=Ae?Math.hypot(ye-Ae.clientX,He-Ae.clientY)>=Kge:!1,tt=le??rt;if(!R.current&&!Ze&&T.current){ee(),E.current=null,k.current=null;return}const dt=!R.current&&!Ze&&tt?Z2({terminal:Ge,point:tt}):null,Dt=Ze?rt??pt:pt,Wt=(R.current||Ze)&&Xe&&Dt?lv({terminal:Ge,anchor:Xe,focus:Dt}):dt??X2({terminal:Ge,host:be,clientX:ye,clientY:He})??(le?GS({terminal:Ge,point:le}):null);if(E.current=null,k.current=null,!(Wt!=null&&Wt.text)){P();return}w.current=Wt.anchor,x.current=Wt.focus,T.current=Wt.text,V(Wt.text,dt==null?void 0:dt.pathAction);const tn=N(Wt.anchor,Wt.focus);F(tn),W(tn?Y(tn):L(ye,He))},[P,N,L,Y,V,ee,n,r]),Me=b.useCallback(()=>{var Ge;const ye=n.current,He=((Ge=ye==null?void 0:ye.getSelection)==null?void 0:Ge.call(ye))||T.current;He&&M4(He,{allowLegacyFallback:!0}).then(be=>{P(),be==="failed"?nt.error("复制失败"):nt.success("已复制")})},[P,n]),Ve=b.useCallback(()=>{const ye=I.current;ye&&(ye.kind==="image-preview"?_(ye.path):v(ye.path),P())},[P,v,_]),Qe=b.useCallback(()=>w.current!==null,[]),ct=b.useCallback(()=>{W(null)},[]),Ot=b.useCallback((ye,{clientX:He,clientY:Ge})=>{z({clientX:He,clientY:Ge,draggedHandle:ye}),W(null)},[z]),he=b.useCallback((ye,He)=>{He&&z({...He,draggedHandle:ye}),T.current&&ee()},[z,ee]),Ke=b.useCallback(()=>{W(null)},[]);b.useEffect(()=>{},[P,N,Y,t,V,n]);const Rt=Yge({terminalRef:n,containerEl:s,suppressPtyFocus:d,focusPtyInput:h,isSelectionActive:Qe,onTap:p,isTapCandidate:y,onLongPressCandidateStart:K,onLongPressStart:me,onLongPressMove:ve,onLongPressEnd:Ce,onHorizontalScrollIntent:ye=>{var He;return(He=i.current)==null?void 0:He.markHorizontalScrollIntent(ye)},onSelectionAutoscroll:ye=>{A.current=ye},onHandleDragStart:ct,onHandleDragMove:Ot,onHandleDragEnd:he,onHandleDragCancel:Ke});return H.current=Rt.stopPtySelectionGesture,{pointerHandlers:Rt.pointerHandlers,ptySelectionToolbar:D,ptySelectionHandles:U,ptySelectionPathAction:O,ptySelectionHandleMetrics:B,copyPtySelection:Me,openPtySelectionPathAction:Ve,handlePtySelectionHandlePointerDown:Rt.handlePtySelectionHandlePointerDown,handlePtySelectionHandleTouchStart:Rt.handlePtySelectionHandleTouchStart}}function Xge(){return Ne(e=>e.ptyScrollTraceEnabled)}const Zge=new Set(["image/png","image/jpeg","image/webp","image/gif"]);function J2(e){return Zge.has(e)}function yE(e){if(!e)return null;const t=Array.from(e.items??[]);for(const r of t){if(r.kind!=="file"||!J2(r.type))continue;const i=r.getAsFile();if(i)return i}return Array.from(e.files??[]).find(r=>J2(r.type))??null}function Qge(e){return`${e.startsWith("@")?e:`@${e}`} `}async function L4(e){const t=yE(e.clipboardData);if(!t)return null;if(!e.relay)throw new Error("请先连接开发机");const n=await A4(t),r=await e.relay.uploadClipboardImage(e.sessionId,n);if(!r.success||!r.path)throw new Error(r.error??"剪贴板图片上传失败");return{path:r.path,pathMention:Qge(r.path)}}function Jge(e){if(!(e!=null&&e.files)||e.files.length===0)return null;for(const t of e.files)if(!t.type.startsWith("image/"))return t;return null}function eve({sessionId:e,terminalRef:t,onAfterPaste:n}){return b.useCallback(async r=>{var u;const i=r.clipboardData,s=!!yE(i),o=s?null:Jge(i);if(!s&&!o)return;r.preventDefault(),r.stopPropagation();const l=Pt;if(!l){nt.error("请先连接开发机");return}if(s){const d=nt.loading("图片上传中...");try{const h=await L4({clipboardData:i,relay:l,sessionId:e});if(nt.dismiss(d),!h)return;Ys(e,h.pathMention)}catch(h){nt.error(h instanceof Error?h.message:String(h),{id:d});return}}else if(o){const d=await kf({relay:l,sessionId:e,file:o});if(!d)return;Ys(e,`@${d} `)}n==null||n(),(u=t.current)==null||u.focus()},[e,t,n])}const tve=new Set(["Enter","Backspace","Tab","Escape","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Delete","Home","End"]),eO={caseSensitive:!1,regex:!1,wholeWord:!1,decorations:Kfe};function nve({softKeyboardEditingSurface:e,ptyInputFocused:t,keyboardOpen:n}){return e&&t&&n}function rve({controlsVisible:e,keyboardOpen:t,previous:n}){return e?!n.controlsVisible||t&&!n.keyboardOpen:!1}function ive({touchEditingSurface:e,inputModePreference:t,detectedPhysicalKeyboard:n,softKeyboardDetected:r}){return!e||t==="hardware"?!0:t==="touch"?!1:n&&!r}function sve({active:e,touchEditingSurface:t,key:n,code:r,altKey:i=!1,ctrlKey:s=!1,metaKey:o=!1,isComposing:l=!1,targetAcceptsPtyInput:u=!0}){return!e||!t||!u||l||i||s||o||!r||r==="Unidentified"?!1:n.length===1?!0:n==="Unidentified"||n==="Process"||n==="Dead"?!1:tve.has(n)}const tO=8,ove=32;function ave({showMobilePtyControls:e,horizontalScrollable:t,mobileControlsHeight:n}){return e?Math.ceil(Math.max(0,n))+tO:t?ove:tO}function lve(e,t){return e.isComposing||e.altKey||e.ctrlKey||e.metaKey?null:e.key.length===1?e.key:e.key==="Enter"?"\r":e.key==="Backspace"?"":e.key==="Tab"?e.shiftKey?"\x1B[Z":" ":e.key==="Escape"?"\x1B":e.key==="ArrowUp"?Vh("\x1B[A",t):e.key==="ArrowDown"?Vh("\x1B[B",t):e.key==="ArrowRight"?Vh("\x1B[C",t):e.key==="ArrowLeft"?Vh("\x1B[D",t):e.key==="Delete"?"\x1B[3~":e.key==="Home"?"\x1B[H":e.key==="End"?"\x1B[F":null}function cve(e){const{sessionId:t,active:n=!0,containerEl:r,spacerRef:i,xtermHostRef:s,mobileControlsHeight:o}=e,l=vge(),u=wge(),d=Xge(),{openImagePreview:h}=N3(),p=b.useRef(null),y=b.useRef(null),v=b.useRef([]),_=b.useRef(null),w=b.useRef(null),x=b.useRef(n),E=b.useRef(n),k=b.useRef(!1),R=b.useRef(!1),A=b.useRef(!1),I=b.useRef(null),T=b.useRef(null),H=b.useRef(null),D=b.useRef(null),W=b.useRef({keyboardOpen:!1,controlsVisible:!1}),U=b.useRef(!1),F=b.useRef(!1),O=b.useRef(!1),M=b.useRef(null),B=b.useRef({keyboardOffset:0,hasSeenSoftKeyboard:!1,showMobilePtyControls:!1,touchEditingSurface:!1,ptyInputFocused:!1,containerPaddingBottom:0,mobileControlsBottomInset:0}),[L,N]=b.useState({scrollTop:0,scrollLeft:0,scrollHeight:0,scrollWidth:0,clientHeight:0,clientWidth:0,scrollable:!1,horizontalScrollable:!1}),[V,Y]=b.useState(!1),[$,P]=b.useState(!1),[q,K]=b.useState({resultIndex:-1,resultCount:0}),z=Ne(ue=>ue.connected),X=Ne(ue=>ue.proxyOnline),ee=Ne(ue=>ue.ptyFontSize),te=Ne(ue=>ue.inputModePreference),Q=Ne(ue=>ue.adaptiveInputModality),me=Ne(ue=>ue.setAdaptiveInputModality),ve=Q==="hardware",Ce=ul("(pointer: coarse), (hover: none)"),{bottomOffset:Me,layoutBottomInset:Ve}=vE(),Qe=te==="hardware",ct=ive({touchEditingSurface:Ce,inputModePreference:te,detectedPhysicalKeyboard:ve,softKeyboardDetected:Me>0}),Ot=Ce&&!ct,he=ct?0:Me,Ke=he>0,Rt=ct?0:Ve;U.current=ct,b.useEffect(()=>{x.current=n},[n]),b.useEffect(()=>{k.current=l.ready},[l.ready]);const ye=b.useCallback(()=>x.current&&k.current,[]);b.useEffect(()=>{he>0&&Y(!0)},[he]);const He=_ge({containerEl:r,xtermHostRef:s,terminalRef:p}),{ptyInputFocused:Ge,suppressPtyFocus:be,focusPtyInput:Xe,handleFocusCapture:rt,handleBlurCapture:pt}=He,le=nve({softKeyboardEditingSurface:Ot,ptyInputFocused:Ge,keyboardOpen:Ke});B.current={keyboardOffset:he,hasSeenSoftKeyboard:V,showMobilePtyControls:le,touchEditingSurface:Ce,ptyInputFocused:Ge,containerPaddingBottom:B.current.containerPaddingBottom,mobileControlsBottomInset:Rt};const Ae=u.clearNewFramesWhileAway;T.current||(T.current=W2(()=>{var ue;(ue=w.current)==null||ue.relayout()})),H.current||(H.current=W2(()=>{var xe,ke;const ue=D.current??{reason:"rawInput",force:!1};D.current=null,(xe=w.current)==null||xe.traceRawInputFollowFire(),(ke=w.current)==null||ke.scrollToBottom(ue.reason,ue.force?{force:!0}:void 0),Ae()}));const Ze=b.useCallback(()=>{M.current!==null&&(cancelAnimationFrame(M.current),M.current=null)},[]),tt=b.useCallback(()=>{O.current=!0,Ze()},[Ze]),dt=b.useCallback(()=>{var ue;!O.current||document.visibilityState==="hidden"||((ue=w.current)==null||ue.preparePageResumeRestore(),Ze(),M.current=requestAnimationFrame(()=>{M.current=requestAnimationFrame(()=>{M.current=null;const xe=w.current;xe&&(xe.restorePageResume(),Ae(),O.current=!1)})}))},[Ze,Ae]);b.useEffect(()=>()=>{var ue,xe;(ue=T.current)==null||ue.dispose(),(xe=H.current)==null||xe.dispose(),Ze(),T.current=null,H.current=null},[Ze]),b.useEffect(()=>{const ue=()=>{tt()},xe=()=>{if(document.visibilityState==="hidden"){ue();return}dt()};return document.addEventListener("visibilitychange",xe),window.addEventListener("pagehide",ue),window.addEventListener("pageshow",dt),window.addEventListener("focus",dt),()=>{document.removeEventListener("visibilitychange",xe),window.removeEventListener("pagehide",ue),window.removeEventListener("pageshow",dt),window.removeEventListener("focus",dt),Ze()}},[Ze,tt,dt]),b.useEffect(()=>{const ue=E.current;if(E.current=n,ue!==n){if(!n){tt();return}dt()}},[n,tt,dt]);const Dt=b.useCallback((ue="rawInput",xe)=>{var se,fe;const ke=D.current,De=(ke==null?void 0:ke.force)===!0||(xe==null?void 0:xe.force)===!0;D.current={reason:(xe==null?void 0:xe.force)===!0||!ke?ue:ke.reason,force:De},(se=w.current)==null||se.traceRawInputFollowScheduled(ue),(fe=H.current)==null||fe.schedule()},[]),Wt=b.useCallback((ue,xe)=>{var ke;!ue.includes("\r")&&!ue.includes(`
645
+ `)||(ke=w.current)==null||ke.resetHorizontalScroll(xe,{holdUntilCursorVisible:!0})},[]),tn=b.useCallback(()=>U.current?"submit":"linefeed",[]),vn=b.useCallback(()=>U.current,[]);b.useEffect(()=>{if(!n||te!=="auto"||!Ce)return;const ue=ke=>{const De=s.current,se=r;return ke instanceof Node?De!=null&&De.contains(ke)||ke===document.body||ke===document.documentElement?!0:se!=null&&se.contains(ke)?ke instanceof HTMLElement?ke.closest('a,button,input,textarea,select,[contenteditable="true"],[role="button"],[role="textbox"]')===null:!0:!1:ke===window},xe=ke=>{var fe,Oe;if(!sve({active:x.current,touchEditingSurface:Ce,key:ke.key,code:ke.code,altKey:ke.altKey,ctrlKey:ke.ctrlKey,metaKey:ke.metaKey,isComposing:ke.isComposing,targetAcceptsPtyInput:ue(ke.target)}))return;me("hardware"),U.current=!0,(fe=p.current)==null||fe.focus();const De=s.current;if(ke.target instanceof Node&&(De!=null&&De.contains(ke.target)))return;const se=lve(ke,(Oe=p.current)==null?void 0:Oe.modes);!se||!ye()||(ke.preventDefault(),ke.stopPropagation(),Ys(t,se),Dt("physicalKeyboard"),Wt(se,"physicalKeyboardEnter"))};return window.addEventListener("keydown",xe,!0),()=>window.removeEventListener("keydown",xe,!0)},[n,ye,r,te,Wt,Dt,t,me,Ce,s]);const un=b.useCallback(ue=>{const xe=Pt;if(!xe){nt.error("请先连接开发机");return}const ke=nt.loading(`下载 ${ue} ...`);Y1({relay:xe,sessionId:t,path:ue}).then(De=>{De.ok?nt.success(`已开始下载 ${ue}`,{id:ke}):nt.error(De.error,{id:ke})}).catch(De=>{nt.error(De instanceof Error?De.message:String(De),{id:ke})})},[t]),Zt=b.useCallback(ue=>{const xe=p.current;return xe?Gme(xe,v.current,ue):!1},[]),Xn=b.useCallback(ue=>{const xe=p.current;return xe?Kme(xe,v.current,ue):!1},[]),Kt=Gge({sessionId:t,terminalRef:p,xtermHostRef:s,scrollControllerRef:w,containerEl:r,scrollState:L,keyboardOffset:he,ptyFontSize:ee,suppressPtyFocus:be,focusPtyInput:Xe,onTap:Zt,isTapCandidate:Xn,onDownloadPath:un,onPreviewPath:h});F.current=Kt.ptySelectionHandles!==null;const Zn=eve({sessionId:t,terminalRef:p,onAfterPaste:()=>Dt("paste")}),ze=b.useCallback(ue=>{if(!ye()){ue.preventDefault();return}Zn(ue)},[ye,Zn]),[et,Et]=b.useState(!1),Bt=b.useCallback(ue=>{ue.dataTransfer.types.includes("Files")&&(ue.preventDefault(),Et(xe=>xe||!0))},[]),J=b.useCallback(ue=>{ue.currentTarget.contains(ue.relatedTarget)||Et(!1)},[]),_e=b.useCallback(async ue=>{var se;const xe=(se=ue.dataTransfer.files)==null?void 0:se[0];if(!xe||(ue.preventDefault(),Et(!1),!ye()))return;const ke=Pt;if(!ke){nt.error("请先连接开发机");return}const De=await kf({relay:ke,sessionId:t,file:xe});De&&(Ys(t,`@${De} `),Dt("dropUpload"))},[ye,Dt,t]),Be=b.useCallback(ue=>{var ke;if(!ye()){ue.preventDefault();return}const xe=ue.target;xe instanceof Element&&xe.closest(".xterm")||(ue.preventDefault(),(ke=p.current)==null||ke.focus())},[ye]);b.useEffect(()=>{if(!z||!X)return;const ue=s.current,xe=ec,ke=Pt,De=r,se=i.current;if(!ue||!xe||!ke||!De||!se)return;let fe=null,Oe=null,Ue=null,ft=null,gt=null,kt=null,Tt=null;const rr=rme({host:ue,sessionId:t,ws:xe,relay:ke,scheduleAutoFocus:Ot?()=>{}:void 0,createTerminal:async fn=>{const $e=await s4(fn,{fontSize:Ne.getState().ptyFontSize});return Tt=$e.serializeAddon,$e},attachRawInput:(fn,$e,vt)=>bpe(fn,$e,{...vt,getPlainEnterBehavior:tn,isPhysicalKeyboardMode:vn,physicalKeyboardMode:Qe}),isInputEnabled:ye,canFocus:ye,onTerminalReady:fn=>{const $e=fn;p.current=$e;const vt=new xce({highlightLimit:1e3});$e.loadAddon(vt),y.current=vt,kt=vt.onDidChangeResults(Gt=>{K(Gt)}),P(!0);const Vt=Tme($e,h);fe=Vt.dispose;const bn=Ume($e,un);Oe=bn.dispose,v.current=[Vt.provider,bn.provider],dge(()=>p.current);const Bn=rpe(ue,{serializeRangeAsHtml:(Gt,nn)=>(Tt==null?void 0:Tt.serializeAsHTML({range:{startLine:Gt,endLine:Math.min(nn,Math.max(0,$e.buffer.active.length-1)),startCol:0},includeGlobalBackground:!0,onlySelection:!1,scrollback:0}))??""});ft=Bn.dispose;const zt=O.current;zt&&(A.current=!1);const Tn=Gpe({container:De,spacer:se,host:ue,term:$e,hasNewFrame:()=>R.current,consumeNewFrame:()=>{R.current=!1},hasNewFramesWhileAway:()=>u.hasNewFramesWhileAwayRef.current,setNewFramesWhileAway:u.setHasNewFramesWhileAway,onAtBottomChange:u.handleAtBottomChange,onScrollStateChange:N,initialUserHasVerticalScrollIntent:zt?!1:A.current,onUserVerticalScrollIntentChange:Gt=>{A.current=Gt},onTouchReviewStart:be,onTouchBoundaryPrevent:be,onReviewSnapshotCapture:Bn.captureRange,onReviewSnapshotClear:Bn.clear});w.current=Tn,Ue=Tn.dispose,zt&&(Tn.restorePageResume(),Ae(),O.current=!1),fge(()=>{var Ac;const Gt=ai=>{if(!ai)return null;const hs=ai.getBoundingClientRect();return{top:hs.top,bottom:hs.bottom,height:hs.height,left:hs.left,right:hs.right,width:hs.width}},nn=document.querySelector('[data-slot="pty-mobile-controls"]'),Bi=document.querySelector("[data-keyboard-offset]"),zr=window.visualViewport,Is=Gt(nn),ua=(zr==null?void 0:zr.height)??window.innerHeight;return{...mge(Tn.getDebugProbe,{container:De,spacer:se,host:ue,term:$e}),mobileLayout:{...B.current,window:{innerHeight:window.innerHeight,outerHeight:window.outerHeight,documentClientHeight:document.documentElement.clientHeight},visualViewport:zr?{height:zr.height,width:zr.width,offsetTop:zr.offsetTop,pageTop:zr.pageTop,scale:zr.scale}:null,chatRoot:{dataKeyboardOffset:(Bi==null?void 0:Bi.getAttribute("data-keyboard-offset"))??null,rect:Gt(Bi)},ptyViewRect:Gt(De.parentElement),containerRect:Gt(De),controlsRect:Is,controlsOverflowBelowVisualViewport:Is===null?null:Is.bottom-ua,activeElement:document.activeElement instanceof HTMLElement?{tag:document.activeElement.tagName,ariaLabel:document.activeElement.getAttribute("aria-label"),slot:(Ac=document.activeElement.closest("[data-slot]"))==null?void 0:Ac.getAttribute("data-slot")}:null},frame:{lastWriteAt:I.current,pendingNewFrame:R.current}}}),gt=ope({container:De,host:ue,onHorizontalScrollIntent:Gt=>{var nn;return(nn=w.current)==null?void 0:nn.markHorizontalScrollIntent(Gt)}}).dispose},onFramePending:()=>{R.current=!0,A.current&&!u.hasNewFramesWhileAwayRef.current&&u.setHasNewFramesWhileAway(!0)},onFrameWritten:()=>{var fn;I.current=performance.now(),(fn=T.current)==null||fn.schedule()},onRawInput:fn=>{Dt("rawInput",{force:!0}),Wt(fn,"rawInputEnter")},onError:fn=>{const $e=fn instanceof Error?fn.message:String(fn);nt.error(`终端初始化失败:${$e}`)},...l.transport});return _.current=rr,()=>{gt==null||gt(),Ue==null||Ue(),ft==null||ft(),kt==null||kt.dispose(),pge(),fe==null||fe(),Oe==null||Oe(),v.current=[],hge(),y.current=null,P(!1),K({resultIndex:-1,resultCount:0}),rr.dispose(),p.current=null,w.current=null,_.current=null}},[t,z,X,r,i,s,l.transport,u.handleAtBottomChange,u.hasNewFramesWhileAwayRef,u.setHasNewFramesWhileAway,ye,Qe,tn,vn,un,h,be,Dt,Wt]),b.useEffect(()=>{const ue=p.current,xe=w.current;!ue||!xe||Zfe(ue,ee,xe.relayout)},[ee]),b.useEffect(()=>{if(!n||!l.ready||Ot)return;const ue=requestAnimationFrame(()=>{var xe;return(xe=p.current)==null?void 0:xe.focus()});return()=>cancelAnimationFrame(ue)},[n,l.ready,Ot]);const ht=b.useCallback((ue="viewExternal",xe)=>{var ke;(ke=w.current)==null||ke.scrollToBottom(ue,xe)},[]),jt=b.useCallback(()=>{var ue;(ue=w.current)==null||ue.refreshReviewSnapshot()},[]),re=b.useCallback(ue=>{var xe;(xe=w.current)==null||xe.scrollToRatio(ue)},[]),ie=b.useCallback(ue=>{var xe;(xe=w.current)==null||xe.scrollToXRatio(ue)},[]),de=b.useCallback(ue=>{var Oe;const xe=p.current,ke=xe==null?void 0:xe.getSelectionPosition();if(!xe||!ke)return;const De=ke.start.y;if(De>=ue&&De<ue+xe.rows)return;const se=Math.max(0,xe.buffer.active.length-xe.rows);if(se===0)return;const fe=Math.max(0,Math.min(se,De-Math.floor(xe.rows/2)));(Oe=w.current)==null||Oe.scrollToRatio(fe/se)},[]),pe=b.useCallback((ue,xe=!1)=>{const ke=p.current,De=y.current;if(!ke||!De||!ue)return ue||(De==null||De.clearDecorations(),ke==null||ke.clearSelection(),K({resultIndex:-1,resultCount:0})),!1;const se=ke.buffer.active.viewportY,fe=De.findNext(ue,{...eO,incremental:xe});return fe&&de(se),fe},[de]),Z=b.useCallback(ue=>{const xe=p.current,ke=y.current;if(!xe||!ke||!ue)return!1;const De=xe.buffer.active.viewportY,se=ke.findPrevious(ue,eO);return se&&de(De),se},[de]),ne=b.useCallback(()=>{var ue,xe;(ue=y.current)==null||ue.clearDecorations(),(xe=p.current)==null||xe.clearSelection(),K({resultIndex:-1,resultCount:0})},[]),ae=b.useCallback(ue=>{var ke,De;if(!ye())return;const xe=Vh(ue,(ke=p.current)==null?void 0:ke.modes);Ys(t,xe),Dt("mobileControl",{force:!0}),Wt(ue,"mobileControlEnter"),(De=p.current)==null||De.focus()},[ye,Wt,Dt,t]),Te=b.useCallback(()=>{var xe,ke,De;if(!ye())return;const ue=(ke=(xe=navigator.clipboard)==null?void 0:xe.readText)==null?void 0:ke.bind(navigator.clipboard);if(!window.isSecureContext||!ue){nt.error("无法读取剪贴板"),(De=p.current)==null||De.focus();return}ue().then(se=>{if(!se)return;const fe=p.current;if(fe){fe.paste(se);return}Ys(t,se),Dt("paste"),Wt(se,"pasteEnter")}).catch(se=>{const fe=se instanceof Error&&se.message?se.message:"无法读取剪贴板";nt.error(fe)}).finally(()=>{var se;return(se=p.current)==null?void 0:se.focus()})},[ye,Wt,Dt,t]),je=ave({showMobilePtyControls:le,horizontalScrollable:L.horizontalScrollable,mobileControlsHeight:o});B.current.containerPaddingBottom=je,b.useEffect(()=>{var ke,De;F.current?(ke=w.current)==null||ke.relayout():(De=T.current)==null||De.schedule();const ue=W.current,xe=rve({controlsVisible:le,keyboardOpen:Ke,previous:ue});W.current={keyboardOpen:Ke,controlsVisible:le},le&&(F.current?Ae():xe?Dt("keyboardOffset",{force:!0}):Ke||Dt("keyboardOffset"))},[he,Ke,le,je,Ae,Dt]);const st=b.useMemo(()=>({onFocusCapture:rt,onBlurCapture:pt}),[rt,pt]);return{scrollState:L,isAtBottom:u.isAtBottom,hasNewFramesWhileAway:u.hasNewFramesWhileAway,ptyInputFocused:Ge,showMobilePtyControls:le,touchEditingSurface:Ce,keyboardOffset:he,physicalKeyboardMode:ct,softKeyboardEditingSurface:Ot,mobileControlsBottomInset:Rt,connectionReady:l.ready,connectionOverlay:l.overlay,containerPaddingBottom:je,traceEnabled:d,findReady:$,findResultIndex:q.resultIndex,findResultCount:q.resultCount,findNext:pe,findPrevious:Z,clearFind:ne,refreshReviewSnapshot:jt,scrollToBottom:ht,scrollToRatio:re,scrollToXRatio:ie,clearNewFramesWhileAway:Ae,sendMobileInput:ae,pasteMobileClipboard:Te,handleTerminalContainerMouseDown:Be,handlePasteCapture:ze,pointerHandlers:Kt.pointerHandlers,focusHandlers:st,ptySelectionToolbar:Kt.ptySelectionToolbar,ptySelectionHandles:Kt.ptySelectionHandles,ptySelectionPathAction:Kt.ptySelectionPathAction,ptySelectionHandleMetrics:Kt.ptySelectionHandleMetrics,copyPtySelection:Kt.copyPtySelection,openPtySelectionPathAction:Kt.openPtySelectionPathAction,handlePtySelectionHandlePointerDown:Kt.handlePtySelectionHandlePointerDown,handlePtySelectionHandleTouchStart:Kt.handlePtySelectionHandleTouchStart,isPtyDragOver:et,handlePtyDragOver:Bt,handlePtyDragLeave:J,handlePtyDrop:_e}}function uve({sessionId:e,sessionKind:t,provider:n,active:r=!0,findRequest:i}){const[s,o]=b.useState(null),[l,u]=b.useState(0),[d,h]=b.useState(!1),[p,y]=b.useState(""),v=b.useRef(null),_=b.useRef(null),w=cve({sessionId:e,active:r,containerEl:s,spacerRef:v,xtermHostRef:_,mobileControlsHeight:l}),x=w.ptySelectionHandleMetrics,{clearFind:E,findNext:k,findPrevious:R,findReady:A,findResultCount:I,findResultIndex:T}=w,H=b.useCallback(()=>{R(p)},[R,p]),D=b.useCallback(()=>{k(p)},[k,p]),W=b.useCallback(()=>h(!0),[]),U=b.useCallback(()=>{h(!1),E()},[E]),F=L3({enabled:r,open:d,openRequest:i,onOpen:W,onClose:U,onPrevious:H,onNext:D});return b.useEffect(()=>{!d||!A||(p?k(p,!0):E())},[E,k,d,p,A]),g.jsxs("div",{className:"flex flex-col h-full relative","data-slot":"chat-pty-view","data-connection-ready":w.connectionReady?"true":"false","aria-busy":!w.connectionReady,children:[d?g.jsx(X0,{query:p,resultIndex:T,resultCount:I,focusRequest:F.focusRequest,loading:!!p&&!A,onQueryChange:y,onPrevious:H,onNext:D,onClose:F.closeFind}):null,g.jsx("div",{ref:o,className:"flex-1 min-h-0 overflow-auto overscroll-contain bg-background px-3 pt-2",style:{paddingBottom:`calc(env(safe-area-inset-bottom) + ${w.containerPaddingBottom}px)`,touchAction:"pan-x pan-y",overflowAnchor:"none"},onMouseDownCapture:w.handleTerminalContainerMouseDown,onPointerDownCapture:O=>{w.refreshReviewSnapshot(),w.pointerHandlers.onPointerDownCapture(O)},onPointerMoveCapture:w.pointerHandlers.onPointerMoveCapture,onPointerUpCapture:w.pointerHandlers.onPointerUpCapture,onPointerCancelCapture:w.pointerHandlers.onPointerCancelCapture,onTouchStartCapture:w.pointerHandlers.onTouchStartCapture,onTouchMoveCapture:w.pointerHandlers.onTouchMoveCapture,onTouchEndCapture:w.pointerHandlers.onTouchEndCapture,onTouchCancelCapture:w.pointerHandlers.onTouchCancelCapture,onContextMenuCapture:w.pointerHandlers.onContextMenuCapture,onPasteCapture:w.handlePasteCapture,onDragOver:w.handlePtyDragOver,onDragLeave:w.handlePtyDragLeave,onDrop:w.handlePtyDrop,onFocusCapture:w.focusHandlers.onFocusCapture,onBlurCapture:w.focusHandlers.onBlurCapture,"data-slot":"pty-terminal","data-drag-over":w.isPtyDragOver?"true":void 0,children:g.jsx("div",{ref:v,style:{position:"relative",overflowAnchor:"none"},"data-slot":"pty-spacer",children:g.jsx("div",{ref:_,style:{position:"absolute",left:0,top:0,overflow:"hidden",overflowAnchor:"none",boxSizing:"border-box"},"data-slot":"pty-host"})})}),g.jsx(O3,{visible:!w.isAtBottom,hasNewMessages:w.hasNewFramesWhileAway,className:d?"top-14":"top-10",onClick:()=>{w.scrollToBottom("backToBottomBtn",{force:!0}),w.clearNewFramesWhileAway()}}),w.showMobilePtyControls?g.jsx(Lle,{sessionKind:t,provider:n,bottomInset:w.mobileControlsBottomInset,onInput:w.sendMobileInput,onPaste:w.pasteMobileClipboard,onHeightChange:u}):null,w.ptySelectionHandles?g.jsxs(g.Fragment,{children:[g.jsx(nO,{kind:"anchor",position:w.ptySelectionHandles.anchor,metrics:x,"aria-label":"调整选区起点",onPointerDown:O=>w.handlePtySelectionHandlePointerDown("anchor",O),onTouchStart:O=>w.handlePtySelectionHandleTouchStart("anchor",O)}),g.jsx(nO,{kind:"focus",position:w.ptySelectionHandles.focus,metrics:x,"aria-label":"调整选区终点",onPointerDown:O=>w.handlePtySelectionHandlePointerDown("focus",O),onTouchStart:O=>w.handlePtySelectionHandleTouchStart("focus",O)})]}):null,w.ptySelectionToolbar?g.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:w.ptySelectionToolbar.left,top:w.ptySelectionToolbar.top},"data-slot":"pty-selection-toolbar",children:[g.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:O=>O.preventDefault(),onClick:w.copyPtySelection,"aria-label":"复制终端选区",children:"复制"}),w.ptySelectionPathAction?g.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:O=>O.preventDefault(),onClick:w.openPtySelectionPathAction,"aria-label":w.ptySelectionPathAction.kind==="image-preview"?"预览终端选区图片":"下载终端选区文件",children:w.ptySelectionPathAction.kind==="image-preview"?"预览":"下载"}):null]}):null,g.jsx(Ule,{state:w.scrollState,onScrollRatio:w.scrollToRatio}),g.jsx(Wle,{state:w.scrollState,onScrollRatio:w.scrollToXRatio}),g.jsx(Sle,{...w.connectionOverlay}),g.jsx(Ele,{ptyInputFocused:w.ptyInputFocused,touchEditingSurface:w.touchEditingSurface,softKeyboardEditingSurface:w.softKeyboardEditingSurface,physicalKeyboardMode:w.physicalKeyboardMode,keyboardOffset:w.keyboardOffset,showMobilePtyControls:w.showMobilePtyControls,mobileControlsBottomInset:w.mobileControlsBottomInset}),w.traceEnabled?g.jsx(dve,{}):null]})}function nO({kind:e,position:t,metrics:n,"aria-label":r,onPointerDown:i,onTouchStart:s}){const o=n.touchSize/2,l=2,u=n.visualSize,d=Math.max(n.stemSize+2,u+1),h=o-l/2,p=o,y=e==="anchor"?h-u+l:h,v=p+d-u+l,_=e==="anchor"?{borderTopLeftRadius:u,borderBottomLeftRadius:u,borderTopRightRadius:2,borderBottomRightRadius:u}:{borderTopLeftRadius:2,borderBottomLeftRadius:u,borderTopRightRadius:u,borderBottomRightRadius:u};return g.jsxs("button",{type:"button",className:"fixed z-50 touch-none rounded-full bg-transparent p-0 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring",style:{left:t.left,top:t.top,width:n.touchSize,height:n.touchSize,transform:"translate(-50%, -50%)"},"data-slot":"pty-selection-handle","data-kind":e,"aria-label":r,onPointerDown:i,onTouchStart:s,children:[g.jsx("span",{className:"pointer-events-none absolute rounded-full bg-primary",style:{left:h,top:p,width:l,height:d},"data-slot":"pty-selection-handle-stem"}),g.jsx("span",{className:"pointer-events-none absolute border-2 border-primary bg-background shadow-sm shadow-black/30",style:{left:y,top:v,width:u,height:u,..._},"data-slot":"pty-selection-handle-dot"})]})}function dve(){const[e,t]=b.useState(!1);async function n(){const r=_le();try{await navigator.clipboard.writeText(r),t(!0),window.setTimeout(()=>t(!1),1200)}catch{window.prompt("Copy PTY scroll trace",r)}}return g.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 hve=3,fve=1024,pve=720,tg=.5,I4=b.createContext(null);function mve({children:e}){const[t,n]=b.useState([]),[r,i]=b.useState(null),[s,o]=b.useState(null),l=Ne(k=>k.selectedProxyId),u=$t(k=>k.sessions),d=$t(k=>k.sessionListLoaded),h=b.useRef(l),p=b.useRef(null),y=b.useMemo(()=>u.filter(k=>k.mode==="pty").map(k=>k.sessionId).sort().join(`
646
646
  `),[u]),v=b.useCallback(k=>{p.current=k.sessionId,i(k),n(R=>Woe(R,k.sessionId,{capacity:hve,now:Date.now(),activeSessionId:k.sessionId}).map(I=>I.sessionId===k.sessionId?{...I,sessionKind:k.sessionKind,provider:k.provider}:I))},[]),_=b.useCallback(k=>{p.current===k&&(p.current=null),i(R=>(R==null?void 0:R.sessionId)===k?null:R),o(R=>p.current===null?null:R)},[]),w=b.useCallback((k,R)=>{p.current===k&&o(A=>!R||A&&yve(A,R)?A:R)},[]),x=b.useCallback((k,R)=>{R!==void 0&&n(A=>A.map(I=>I.sessionId===k?{...I,findRequest:R}:I))},[]);b.useEffect(()=>{if(!d)return;const k=new Set(y?y.split(`
647
- `):[]);n(R=>R.filter(A=>k.has(A.sessionId))),i(R=>R&&k.has(R.sessionId)?R:null),p.current&&!k.has(p.current)&&(p.current=null,o(null))},[y,d]),b.useEffect(()=>{const k=h.current;h.current=l,!(!k||k===l)&&(p.current=null,n([]),i(null),o(null))},[l]);const E=b.useMemo(()=>({activate:v,deactivate:_,updateFindRequest:x,updateViewportRect:w}),[v,_,x,w]);return g.jsxs(Ij.Provider,{value:E,children:[e,g.jsx(vve,{entries:t,activeView:r,viewportRect:s})]})}function gve({sessionId:e,sessionKind:t,provider:n,findRequest:r}){const i=b.useContext(Ij),s=b.useRef(null);if(!i)throw new Error("PtyKeepAliveViewport must be used within PtyKeepAliveProvider");const{activate:o,deactivate:l,updateFindRequest:u,updateViewportRect:d}=i;return b.useLayoutEffect(()=>(o({sessionId:e,sessionKind:t,provider:n}),()=>l(e)),[o,l,e,t,n]),b.useLayoutEffect(()=>{u(e,r)},[r,e,u]),b.useLayoutEffect(()=>{const h=s.current;if(!h)return;const p=()=>{const v=h.getBoundingClientRect();d(e,{top:v.top,left:v.left,width:v.width,height:v.height})};p();const y=new ResizeObserver(p);return y.observe(h),window.addEventListener("resize",p),()=>{y.disconnect(),window.removeEventListener("resize",p)}},[e,d]),g.jsx("div",{ref:s,className:"h-full w-full bg-background","data-slot":"pty-keepalive-viewport","data-session-id":e})}function vve({entries:e,activeView:t,viewportRect:n}){return e.length===0?null:g.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)??fve,height:(n==null?void 0:n.height)??pve};return g.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:g.jsx(M3,{sessionId:r.sessionId,children:g.jsx(uve,{sessionId:r.sessionId,sessionKind:r.sessionKind,provider:r.provider,active:i,findRequest:r.findRequest})})},r.sessionId)})})}function yve(e,t){return Math.abs(e.top-t.top)<=tg&&Math.abs(e.left-t.left)<=tg&&Math.abs(e.width-t.width)<=tg&&Math.abs(e.height-t.height)<=tg}function bE({route:e,surface:t,proxiesLength:n,hasProxy:r,sessionCount:i,relayClientAuthIssue:s=null}){return s==="missing_client_token"?"Relay 服务器需要 client token。请在设置里填写。":s==="invalid_client_token"?"当前浏览器保存的 client token 无效或已过期。请在设置里更新。":n===0?"在开发机上启动 DEV Anywhere,本页会显示可连接的开发机。":t==="mobile"&&e==="proxy-select"||!r?"选择要连接的开发机。":i===0?"还没有会话。可以从本地终端接入,也可以新建会话。":t==="desktop"?"从左侧打开会话,或新建会话开始新的任务。":"打开会话,或新建会话开始新的任务。"}const _E="dev-anywhere:last-chat-route",zj="dev-anywhere:route-restored",XS="dev-anywhere:restored-target";function bve(e){return e.alreadyRestored||e.pathname!=="/"||!e.lastRoute||!e.lastRoute.startsWith("/chat/")?null:e.lastRoute}function _ve(){var e;try{return((e=globalThis.localStorage)==null?void 0:e.getItem(_E))??null}catch{return null}}function wve(e){var t;try{(t=globalThis.localStorage)==null||t.setItem(_E,e)}catch{}}function Bj(){var e;try{(e=globalThis.localStorage)==null||e.removeItem(_E)}catch{}}function Sve(){var e;try{return((e=globalThis.sessionStorage)==null?void 0:e.getItem(zj))==="1"}catch{return!1}}function xve(){var e;try{(e=globalThis.sessionStorage)==null||e.setItem(zj,"1")}catch{}}function Eve(e){var t;try{(t=globalThis.sessionStorage)==null||t.setItem(XS,e)}catch{}}function Cve(){var e,t;try{const n=((e=globalThis.sessionStorage)==null?void 0:e.getItem(XS))??null;return n!==null&&((t=globalThis.sessionStorage)==null||t.removeItem(XS)),n}catch{return null}}function kve(e){const t=WL(e);return t.osName!=="iPad"?{supported:!0}:e.standalone||t.browserName==="Safari"?{supported:!0}:{supported:!1,reason:"ipad-safari-required",browserName:t.browserName}}function Dg(){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 Tve(){return typeof navigator>"u"?{supported:!0}:kve({userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints,standalone:Dg()})}function Rve(){sge(),oge();const e=Pi(),t=Qs(),n=e.pathname.startsWith("/chat/"),r=e.pathname==="/"||e.pathname==="/sessions",[i,s]=b.useState(!1),[o,l]=b.useState(()=>Dg()),u=Ne(D=>D.proxies.length),d=Ne(D=>D.proxyListLoaded),h=Ne(D=>D.relayClientAuthIssue),p=Ne(D=>!!D.selectedProxyId),y=Ne(D=>D.selectedProxyId),v=Ne(D=>D.selectedProxyName),_=$t(D=>D.sessions.length),w=Ne(D=>D.pendingToast),x=Ne(D=>D.setPendingToast),E=e.pathname==="/"?"proxy-select":"sessions",k=bE({route:E,surface:"mobile",proxiesLength:u,hasProxy:p,sessionCount:_,relayClientAuthIssue:h}),R=v??y,I=e.pathname==="/sessions"&&d&&u>0?g.jsxs(_t,{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":R?`切换开发机,当前 ${R}`:"切换开发机",onClick:()=>t("/"),children:[g.jsx(DP,{className:"size-4 text-primary","aria-hidden":"true"}),g.jsxs("span",{className:"min-w-0 truncate",children:[g.jsx("span",{className:"text-foreground",children:"切换开发机"}),R?g.jsxs("span",{className:"ml-1 text-muted-foreground/75",children:["· ",R]}):null]})]}):null;b.useEffect(()=>{if(!w)return;({error:nt.error,info:nt.info,success:nt.success})[w.kind](w.message),x(null)},[w,x]),b.useEffect(()=>{if(typeof window.matchMedia!="function"){l(Dg());return}const D=window.matchMedia("(display-mode: standalone)"),W=window.matchMedia("(display-mode: fullscreen)"),U=()=>l(Dg());return U(),D.addEventListener("change",U),W.addEventListener("change",U),()=>{D.removeEventListener("change",U),W.removeEventListener("change",U)}},[]);const T=b.useRef(!1);b.useEffect(()=>{if(T.current)return;T.current=!0;const D=bve({pathname:e.pathname,alreadyRestored:Sve(),lastRoute:_ve()});xve(),D&&(Eve(D),t(D,{replace:!0}))},[]);const H=b.useRef(!1);return b.useEffect(()=>{n?(H.current=!0,wve(`${e.pathname}${e.search}`)):H.current&&(H.current=!1,Bj())},[n,e.pathname,e.search]),g.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":o?"true":void 0,children:[!n&&g.jsx(_t,{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:()=>s(!0),children:g.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:g.jsx(IP,{className:"size-4","aria-hidden":"true"})})}),!n&&g.jsx(Yse,{subtitle:k,action:I}),g.jsx(Uoe,{}),g.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[g.jsx(Wse,{className:"hidden md:flex"}),g.jsx("main",{className:"relative flex-1 overflow-hidden",role:"main",children:g.jsx(mve,{children:g.jsx("div",{className:Ye("h-full",!r&&"animate-in fade-in-0 duration-200 motion-reduce:animate-none"),children:g.jsx(YU,{})},r?"top-level":e.pathname)})})]}),g.jsx(Y0,{open:i,onOpenChange:s}),g.jsx(_oe,{}),g.jsx(noe,{}),g.jsx(bZ,{})]})}function jj({subtitle:e,action:t}){return g.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-6 px-6 text-center",children:[g.jsx(XB,{texts:ZB,className:"text-2xl md:text-3xl font-bold"}),g.jsx("p",{className:"max-w-md text-sm text-muted-foreground",children:e}),t&&g.jsx("div",{children:t})]})}function Ave(){const e=Ne(o=>o.proxies),t=Ne(o=>!!o.selectedProxyId),n=Ne(o=>o.relayClientAuthIssue),r=$t(o=>o.sessions.length),i=bE({route:"proxy-select",surface:"desktop",proxiesLength:e.length,hasProxy:t,sessionCount:r,relayClientAuthIssue:n}),s=n==="missing_client_token"?"client-token-missing":n==="invalid_client_token"?"client-token-invalid":null;return g.jsxs(g.Fragment,{children:[g.jsx("div",{className:"h-full md:hidden",children:g.jsx(PB,{layout:"page"})}),g.jsx("div",{className:"hidden md:block h-full",children:s?g.jsx(tc,{variant:s}):g.jsx(jj,{subtitle:i})})]})}function Nve(){const e=Ne(o=>o.proxies),t=Ne(o=>!!o.selectedProxyId),n=Ne(o=>o.relayClientAuthIssue),r=$t(o=>o.sessions.length),i=Ei("local",dn.proxyId)!==null;if(!t&&!i)return g.jsx(VU,{to:"/",replace:!0});const s=bE({route:"sessions",surface:"desktop",proxiesLength:e.length,hasProxy:t,sessionCount:r,relayClientAuthIssue:n});return g.jsxs(g.Fragment,{children:[g.jsx("div",{className:"h-full md:hidden",children:g.jsx(UB,{layout:"page"})}),g.jsx("div",{className:"hidden md:block h-full",children:g.jsx(jj,{subtitle:s})})]})}function Fj(){if(!(typeof navigator>"u"))return navigator.wakeLock}function Mve(e,t){return e===!1?"insecure-context":t?null:"unsupported"}function $j(){var t;const e=typeof window>"u"?void 0:window.isSecureContext;return Mve(e,typeof((t=Fj())==null?void 0:t.request)=="function")}function Ove(e){return e==="insecure-context"?"屏幕常亮需要 HTTPS":"当前浏览器不支持屏幕常亮"}function Dve(){const e=Fj();if(typeof(e==null?void 0:e.request)!="function")throw new Error(Ove($j()));return e.request("screen")}function Pve(e){return e instanceof Error&&e.message.trim()?e.message:"无法开启屏幕常亮"}class Lve{constructor(t={}){yt(this,"activeScopes",new Set);yt(this,"pendingScopes",new Set);yt(this,"listeners",new Map);yt(this,"sentinel",null);yt(this,"requestInFlight",null);yt(this,"requestWakeLock");yt(this,"documentRef");yt(this,"windowRef");yt(this,"unavailableReason");yt(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(()=>{})});yt(this,"handlePageHide",()=>{this.releaseSentinel().catch(()=>{})});var n,r;this.requestWakeLock=t.request??Dve,this.unavailableReason=typeof t.request=="function"?null:$j(),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(Pve(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 Ka=new Lve;function Hj(e){const[t,n]=b.useState(()=>Ka.getSnapshot(e));b.useEffect(()=>Ka.subscribe(e,n),[e]),b.useEffect(()=>()=>{Ka.disable(e).catch(()=>{})},[e]);const r=b.useCallback(()=>Ka.enable(e),[e]),i=b.useCallback(()=>Ka.disable(e),[e]),s=b.useCallback(()=>Ka.toggle(e),[e]);return{...t,enable:r,disable:i,toggle:s}}function Ive(){return new AudioContext}class zve{constructor(t=Ive){yt(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 Pg=new zve,rO=400,Pu=[];let Uj=1;function Bve(){return typeof performance>"u"?0:Math.round(performance.now()*10)/10}function Gh(e){const t={sequence:Uj++,timestamp:new Date().toISOString(),monotonicMs:Bve(),sessionId:e.sessionId,scope:e.scope,event:e.event,...e.attemptId?{attemptId:e.attemptId}:{},...e.requestId?{requestId:e.requestId}:{},...e.details?{details:{...e.details}}:{}};Pu.push(t),Pu.length>rO&&Pu.splice(0,Pu.length-rO)}function jve(){return Pu.map(e=>({...e,...e.details?{details:{...e.details}}:{}}))}function Fve(){Pu.length=0,Uj=1}typeof window<"u"&&(window.__devAnywhereVoicePilotDiagnostics={snapshot:jve,clear:Fve});function Wj(e){return`voice-pilot:${e}`}function $ve(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 Hve="modulepreload",Uve=function(e){return"/"+e},iO={},Wve=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){let o=function(d){return Promise.all(d.map(h=>Promise.resolve(h).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};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=Uve(d),d in iO)return;iO[d]=!0;const h=d.endsWith(".css"),p=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${p}`))return;const y=document.createElement("link");if(y.rel=h?"stylesheet":Hve,h||(y.as="script"),y.crossOrigin="",y.href=d,u&&y.setAttribute("nonce",u),document.head.appendChild(y),h)return new Promise((v,_)=>{y.addEventListener("load",v),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)})},qve="/assets/fvad-DYxbW2my.wasm",Ju=16e3,Vve=20,Ga=Ju*Vve/1e3,Fw=Ga*Int16Array.BYTES_PER_ELEMENT;let sO=null;async function Yve(){return sO??(sO=Wve(async()=>{const{default:e}=await import("./fvad-BpqijVEq.js");return{default:e}},[]).then(({default:e})=>e({locateFile:t=>t.endsWith(".wasm")?qve:t}))),sO}class wE{constructor(t,n,r){yt(this,"destroyed",!1);this.module=t,this.handle=n,this.framePointer=r}static async create(t=3){const n=await Yve(),r=n._fvad_new();if(!r)throw new Error("无法初始化浏览器语音活动检测器");const i=n._malloc(Fw);if(!i)throw n._fvad_free(r),new Error("无法分配浏览器语音活动检测缓冲区");if(n._fvad_set_sample_rate(r,Ju)!==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 wE(n,r,i)}process(t){if(this.destroyed)throw new Error("浏览器语音活动检测器已释放");if(t.byteLength!==Fw)throw new Error(`语音活动检测帧必须为 ${Fw} 字节`);this.module.HEAPU8.set(t,this.framePointer);const n=this.module._fvad_process(this.handle,this.framePointer,Ga);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 Kve{constructor(t={}){yt(this,"startSpeechFrames");yt(this,"endSilenceFrames");yt(this,"active",!1);yt(this,"speechFrames",0);yt(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 Gve{constructor(){yt(this,"pending",new Float32Array(Ga));yt(this,"pendingLength",0)}push(t,n){let r=0;if(this.pendingLength>0){const i=Ga-this.pendingLength,s=Math.min(i,t.length);this.pending.set(t.subarray(0,s),this.pendingLength),this.pendingLength+=s,r+=s,this.pendingLength===Ga&&(n(this.pending.slice()),this.pendingLength=0)}for(;r+Ga<=t.length;)n(t.slice(r,r+Ga)),r+=Ga;if(r<t.length){const i=t.subarray(r);this.pending.set(i,0),this.pendingLength=i.length}}reset(){this.pendingLength=0}}const Xve="/__dev_anywhere_debug/voice-fixture",Zve=Ju*qB/1e3;function Qve(){return wE.create(3)}const Jve={createVad:Qve,getUserMedia:e=>navigator.mediaDevices.getUserMedia(e),createAudioContext:e=>new AudioContext(e),fetch:e=>fetch(e)};function eye(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 tye(e){for(const t of e.getTracks())t.stop()}function qj(e){const t=e.createAudioContext({sampleRate:Ju});if(t.sampleRate!==Ju)throw t.close().catch(()=>{}),new Error("浏览器无法提供 Voice Pilot 所需的 16 kHz 音频输入");return t}async function nye(e){const t=qj(e);let n;try{n=await e.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0,sampleRate:Ju}})}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(),tye(n),t.state!=="closed"&&await t.close()}}}async function rye(e,t){const n=qj(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 Vj(e=window.location.search,t=!1){return t&&new URLSearchParams(e).get("voice-fixture")==="default"?{kind:"fixture",url:Xve}:{kind:"microphone"}}async function iye(e,t=Jve){const n=await t.createVad();let r;try{r=e.source.kind==="fixture"?await rye(e.source.url,t):await nye(t)}catch(h){throw n.destroy(),h}const i=new Kve,s=new Gve,o=r.context.createScriptProcessor(Zve,1,1);let l=!1,u=null,d=null;return o.onaudioprocess=h=>{l&&s.push(h.inputBuffer.getChannelData(0),p=>{const y=$ve(p),v=n.process(y);e.onFrame({pcm:y,speechProbability:v?1:0,activityLevel:eye(p)});const _=i.push(v);_==="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 Yj(e=kv().osName){return{mediaAccept:"image/*,video/*",fileAccept:e==="Android"?"application/*,text/*":void 0}}function sye(e){const[t,n,...r]=Array.from(e);return t&&n===" "&&r.length>0?{indicator:t,label:r.join("")}:{label:e}}function oye({title:e,isPtyTitle:t}){if(!t)return g.jsx(g.Fragment,{children:e});const{indicator:n,label:r}=sye(e);return g.jsxs("span",{className:"inline-flex items-center justify-center max-w-full min-w-0 font-mono font-normal",children:[n&&g.jsx("span",{className:"inline-block w-[1.25ch] shrink-0 text-center","aria-hidden":"true",children:n}),g.jsx("span",{className:"truncate",children:n?` ${r}`:r})]})}function aye(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 lye(){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(aye(n),{cause:n})}finally{e==null||e.getTracks().forEach(n=>n.stop())}}const vu="min-h-9 gap-2.5",ng="px-2 pb-1 pt-2 text-xs font-semibold text-muted-foreground";function fo({children:e,className:t}){return g.jsx("span",{"aria-hidden":"true","data-slot":"chat-menu-icon",className:Ye("inline-flex size-5 shrink-0 items-center justify-center text-muted-foreground [&_svg]:size-4",t),children:e})}function cye({label:e}){return g.jsxs(fo,{className:"relative",children:[g.jsx(OP,{className:"size-4","aria-hidden":"true"}),g.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 uye({sessionId:e,mode:t,onFind:n}){const r=Yj(),i=Qs(),s=$t(he=>he.sessions.find(Ke=>Ke.sessionId===e)),o=$t(he=>he.ptyTitles[e]),l=Ne(he=>he.ptyFontSize),u=Ne(he=>he.chatContentFontSize),d=Ne(he=>he.selectedProxyId),h=Ne(he=>he.adjustPtyFontSize),p=Ne(he=>he.adjustChatContentFontSize),y=Ne(he=>he.setChatContentFontSize),v=Ne(he=>he.resetPtyFontSize),_=Ne(he=>he.resetChatContentFontSize),w=Ne(he=>he.inputModePreference==="hardware"),x=$t(he=>he.renameSession),E=Bx(d,e),k=$t(he=>E?!!he.ptyAutoYesBySessionKey[E]:!1),R=$t(he=>he.setPtyAutoYes),I=ul("(pointer: coarse), (hover: none)")&&!w,T=t==="pty"||(s==null?void 0:s.mode)==="pty",H=(s==null?void 0:s.kind)==="terminal",D=Hj(e),W=cn(he=>he.bySessionId[e]??ay),U=cn(he=>he.enable),F=cn(he=>he.disable),O=!!(s!=null&&s.nameLocked&&(s!=null&&s.name)),M=Xx(s),B=O&&(s==null?void 0:s.name)||M||T&&o||(s==null?void 0:s.name)||e.slice(0,8),L=!!(T&&!H&&o&&!O),N=T?l:Ix(u,I),V=!T&&I?rL:tL,Y=T?v:_,[$,P]=b.useState(!1),[q,K]=b.useState(!1),z=W.enabled,X=D.active||z,ee=D.pending||!D.supported||z;function te(he){if(T){h(he);return}if(I){y(N+he);return}p(he)}function Q(){D.toggle().catch(he=>{nt.error(he instanceof Error?he.message:String(he))})}async function me(he){var Rt;if(T||H){nt.info("Voice Pilot 目前适用于聊天会话。");return}if(he!==!0){F(e);return}const Ke=Pt;if(!Ke){nt.error("请先连接开发机");return}try{if(!((Rt=(await Ke.requestVoiceConfig()).config)!=null&&Rt.configured)){nt.info("请先在设置里配置 Voice Pilot。");return}P(!0)}catch(ye){nt.error(ye instanceof Error?ye.message:String(ye))}}async function ve(){var ye;K(!0);let he=null,Ke=!1;const Rt=Wj(e);try{Gh({sessionId:e,scope:"runtime",event:"wake-lock-requested",details:{userActivationActive:((ye=navigator.userActivation)==null?void 0:ye.isActive)??!1,visibilityState:document.visibilityState,secureContext:window.isSecureContext}});const He=Ka.enable(Rt).then(()=>{Gh({sessionId:e,scope:"runtime",event:"wake-lock-acquired"})},rt=>{throw Gh({sessionId:e,scope:"runtime",event:"wake-lock-failed",details:{error:rt instanceof Error?rt.message:String(rt)}}),new Error("屏幕常亮请求被浏览器拒绝,Voice Pilot 未开启。",{cause:rt})});he=I1.acquire("capture");const Ge=Pg.prepare(),Xe=Vj().kind==="microphone"?lye():Promise.resolve();await Promise.all([He,Ge,Xe]),U(e),Ke=!0,P(!1)}catch(He){Gh({sessionId:e,scope:"runtime",event:"startup-failed",details:{error:He instanceof Error?He.message:String(He)}}),nt.error(He instanceof Error?He.message:String(He))}finally{he==null||he.release(),Ke||await Ka.disable(Rt).catch(()=>{}),K(!1)}}const Ce=b.useRef(null),Me=b.useRef(null),[Ve,Qe]=b.useState(!1);async function ct(he){var He;const Ke=(He=he.target.files)==null?void 0:He[0];if(he.target.value="",!Ke)return;const Rt=Pt;if(!Rt){nt.error("请先连接开发机");return}const ye=await kf({relay:Rt,sessionId:e,file:Ke});ye&&Ys(e,`@${ye} `)}async function Ot(he,Ke){const Rt=Pt;if(!Rt)throw new Error("请先连接开发机");const ye=await Rt.renameSession(he,Ke);if(!ye.success)throw new Error(ye.error??"重命名失败");x(he,ye.name??Ke),nt.success("已重命名会话")}return g.jsxs("div",{className:"border-b border-border bg-card pt-[env(safe-area-inset-top)] shrink-0","data-slot":"chat-header",children:[g.jsx("div",{className:"dev-chat-shell-rail-inset","data-slot":"chat-header-rail-inset",children:g.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:[g.jsx("div",{className:"flex justify-start",children:g.jsx(_t,{variant:"ghost",size:"icon-sm",className:"md:hidden",onClick:()=>i("/sessions"),"aria-label":"返回会话列表","data-slot":"chat-back-button",children:g.jsx(_v,{"aria-hidden":"true"})})}),g.jsx("span",{className:"text-sm font-semibold truncate text-center px-2","data-slot":"chat-session-title",children:g.jsx(oye,{title:B,isPtyTitle:L})}),g.jsxs(O1,{modal:!1,children:[g.jsx(D1,{asChild:!0,children:g.jsx(_t,{variant:"ghost",size:"icon-sm",className:"justify-self-end","aria-label":"会话操作","data-slot":"chat-overflow-trigger",children:g.jsx(g8,{"aria-hidden":"true"})})}),g.jsxs(P1,{align:"end",className:"w-max min-w-44 max-w-[calc(100vw-1rem)]","data-slot":"chat-overflow-menu",children:[g.jsx(jm,{className:ng,children:"会话"}),g.jsxs(yo,{className:vu,"data-slot":"chat-menu-find",onSelect:n,children:[g.jsx(fo,{children:g.jsx(zg,{"aria-hidden":"true"})}),"在会话中查找"]}),g.jsxs(yo,{className:vu,"data-slot":"chat-menu-rename",onSelect:()=>Qe(!0),children:[g.jsx(fo,{children:g.jsx(Z8,{"aria-hidden":"true"})}),"重命名"]}),g.jsxs(Z_,{checked:X,className:"min-h-9 justify-start gap-2.5 pl-2 pr-8 [&>span:first-child]:left-auto [&>span:first-child]:right-2",disabled:ee,"data-slot":"chat-menu-screen-wake-lock-item",onCheckedChange:Q,children:[g.jsx(fo,{children:g.jsx(O8,{"aria-hidden":"true"})}),g.jsx("span",{className:"min-w-0 flex-1",children:D.supported?z?"屏幕常亮(Voice Pilot 控制)":"屏幕常亮":D.unavailableReason==="insecure-context"?"屏幕常亮(需要 HTTPS)":"屏幕常亮(浏览器不支持)"})]}),T&&!H&&g.jsxs(Z_,{checked:k,className:"min-h-9 justify-start gap-2.5 pl-2 pr-8 [&>span:first-child]:left-auto [&>span:first-child]:right-2",disabled:!E,"data-slot":"chat-menu-pty-auto-yes-item",onCheckedChange:he=>{E&&R(E,he===!0)},children:[g.jsx(fo,{children:g.jsx(ta,{"aria-hidden":"true"})}),g.jsx("span",{className:"min-w-0 flex-1",children:"Always yes"})]}),!T&&!H&&g.jsxs(Z_,{checked:W.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:me,children:[g.jsx(fo,{children:g.jsx(B8,{"aria-hidden":"true"})}),g.jsx("span",{className:"min-w-0 flex-1",children:"Voice Pilot"})]}),g.jsx(Q_,{}),T&&!H?g.jsxs(g.Fragment,{children:[g.jsx(jm,{className:ng,children:"快捷键"}),g.jsxs(yo,{className:vu,"data-slot":"chat-menu-send-ctrl-o",onClick:()=>Ys(e,""),children:[g.jsx(cye,{label:"^O"}),"发送 Ctrl+O"]}),g.jsx(Q_,{}),g.jsx(jm,{className:ng,children:"文件"}),g.jsxs(yo,{className:vu,"data-slot":"chat-menu-upload-image",onClick:()=>{var he;return(he=Me.current)==null?void 0:he.click()},children:[g.jsx(fo,{children:g.jsx(Lf,{"aria-hidden":"true"})}),"上传照片或视频"]}),g.jsxs(yo,{className:vu,"data-slot":"chat-menu-upload-file",onClick:()=>{var he;return(he=Ce.current)==null?void 0:he.click()},children:[g.jsx(fo,{children:g.jsx(zP,{"aria-hidden":"true"})}),"上传文件"]}),g.jsx(Q_,{})]}):null,g.jsx(jm,{className:ng,children:"字号"}),g.jsx("div",{className:"px-2 pb-1","data-slot":"chat-menu-font-control",children:g.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:[g.jsx(fo,{children:g.jsx(S7,{"aria-hidden":"true"})}),g.jsxs("div",{className:"col-start-2 inline-flex w-fit shrink-0 items-center gap-2","data-slot":"chat-menu-font-stepper",children:[g.jsx(_t,{variant:"ghost",size:"icon-sm",className:"size-[22px] rounded-[5px] bg-muted/45 text-muted-foreground hover:bg-accent hover:text-accent-foreground",disabled:N<=V,"aria-label":"字号变小","data-slot":"chat-menu-font-smaller",onClick:he=>{he.stopPropagation(),te(-1)},children:g.jsx(F8,{"aria-hidden":"true"})}),g.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:[N,"px"]}),g.jsx(_t,{variant:"ghost",size:"icon-sm",className:"size-[22px] rounded-[5px] bg-muted/45 text-muted-foreground hover:bg-accent hover:text-accent-foreground",disabled:N>=nL,"aria-label":"字号变大","data-slot":"chat-menu-font-larger",onClick:he=>{he.stopPropagation(),te(1)},children:g.jsx(e7,{"aria-hidden":"true"})})]})]})}),g.jsxs(yo,{className:vu,"data-slot":"chat-menu-font-reset",onClick:Y,children:[g.jsx(fo,{children:g.jsx(r7,{"aria-hidden":"true"})}),g.jsx("span",{"data-slot":"chat-menu-font-reset-label",children:"恢复默认"})]})]})]})]})}),g.jsx(jh,{open:Ve,sessionId:e,initialName:s==null?void 0:s.name,onOpenChange:Qe,onRename:Ot}),g.jsx(Sc,{open:$&&!W.enabled,onOpenChange:he=>{q||P(he)},children:g.jsxs(xc,{className:"sm:max-w-md","data-slot":"voice-pilot-wake-lock-dialog",focusSurfaceOnOpen:!0,children:[g.jsxs(Ec,{children:[g.jsx(cl,{children:"开启 Voice Pilot?"}),g.jsx(uc,{children:"开启后会持续聆听并保持屏幕常亮,停止后自动恢复。"})]}),g.jsxs(Gu,{children:[g.jsx(_t,{type:"button",variant:"outline",disabled:q,onClick:()=>P(!1),children:"取消"}),g.jsx(_t,{type:"button","data-slot":"voice-pilot-confirm-start",disabled:q,onClick:()=>{ve()},children:q?"正在开启...":"开启 Voice Pilot"})]})]})}),T?g.jsxs(g.Fragment,{children:[g.jsx("input",{ref:Me,type:"file",accept:r.mediaAccept,className:"hidden","data-slot":"chat-menu-upload-image-input",onChange:he=>{ct(he)}}),g.jsx("input",{ref:Ce,type:"file",accept:r.fileAccept,className:"hidden","data-slot":"chat-menu-upload-file-input",onChange:he=>{ct(he)}})]}):null]})}function yu(e,t,n){let r=n.initialDeps??[],i,s=!0;function o(){var l,u,d;let h;n.key&&((l=n.debug)!=null&&l.call(n))&&(h=Date.now());const p=e();if(!(p.length!==r.length||p.some((_,w)=>r[w]!==_)))return i;r=p;let v;if(n.key&&((u=n.debug)!=null&&u.call(n))&&(v=Date.now()),i=t(...p),n.key&&((d=n.debug)!=null&&d.call(n))){const _=Math.round((Date.now()-h)*100)/100,w=Math.round((Date.now()-v)*100)/100,x=w/16,E=(k,R)=>{for(k=String(k);k.length<R;)k=" "+k;return k};console.info(`%c⏱ ${E(w,5)} /${E(_,5)} ms`,`
647
+ `):[]);n(R=>R.filter(A=>k.has(A.sessionId))),i(R=>R&&k.has(R.sessionId)?R:null),p.current&&!k.has(p.current)&&(p.current=null,o(null))},[y,d]),b.useEffect(()=>{const k=h.current;h.current=l,!(!k||k===l)&&(p.current=null,n([]),i(null),o(null))},[l]);const E=b.useMemo(()=>({activate:v,deactivate:_,updateFindRequest:x,updateViewportRect:w}),[v,_,x,w]);return g.jsxs(I4.Provider,{value:E,children:[e,g.jsx(vve,{entries:t,activeView:r,viewportRect:s})]})}function gve({sessionId:e,sessionKind:t,provider:n,findRequest:r}){const i=b.useContext(I4),s=b.useRef(null);if(!i)throw new Error("PtyKeepAliveViewport must be used within PtyKeepAliveProvider");const{activate:o,deactivate:l,updateFindRequest:u,updateViewportRect:d}=i;return b.useLayoutEffect(()=>(o({sessionId:e,sessionKind:t,provider:n}),()=>l(e)),[o,l,e,t,n]),b.useLayoutEffect(()=>{u(e,r)},[r,e,u]),b.useLayoutEffect(()=>{const h=s.current;if(!h)return;const p=()=>{const v=h.getBoundingClientRect();d(e,{top:v.top,left:v.left,width:v.width,height:v.height})};p();const y=new ResizeObserver(p);return y.observe(h),window.addEventListener("resize",p),()=>{y.disconnect(),window.removeEventListener("resize",p)}},[e,d]),g.jsx("div",{ref:s,className:"h-full w-full bg-background","data-slot":"pty-keepalive-viewport","data-session-id":e})}function vve({entries:e,activeView:t,viewportRect:n}){return e.length===0?null:g.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)??fve,height:(n==null?void 0:n.height)??pve};return g.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:g.jsx(M3,{sessionId:r.sessionId,children:g.jsx(uve,{sessionId:r.sessionId,sessionKind:r.sessionKind,provider:r.provider,active:i,findRequest:r.findRequest})})},r.sessionId)})})}function yve(e,t){return Math.abs(e.top-t.top)<=tg&&Math.abs(e.left-t.left)<=tg&&Math.abs(e.width-t.width)<=tg&&Math.abs(e.height-t.height)<=tg}function bE({route:e,surface:t,proxiesLength:n,hasProxy:r,sessionCount:i,relayClientAuthIssue:s=null}){return s==="missing_client_token"?"Relay 服务器需要 client token。请在设置里填写。":s==="invalid_client_token"?"当前浏览器保存的 client token 无效或已过期。请在设置里更新。":n===0?"在开发机上启动 DEV Anywhere,本页会显示可连接的开发机。":t==="mobile"&&e==="proxy-select"||!r?"选择要连接的开发机。":i===0?"还没有会话。可以从本地终端接入,也可以新建会话。":t==="desktop"?"从左侧打开会话,或新建会话开始新的任务。":"打开会话,或新建会话开始新的任务。"}const _E="dev-anywhere:last-chat-route",z4="dev-anywhere:route-restored",XS="dev-anywhere:restored-target";function bve(e){return e.alreadyRestored||e.pathname!=="/"||!e.lastRoute||!e.lastRoute.startsWith("/chat/")?null:e.lastRoute}function _ve(){var e;try{return((e=globalThis.localStorage)==null?void 0:e.getItem(_E))??null}catch{return null}}function wve(e){var t;try{(t=globalThis.localStorage)==null||t.setItem(_E,e)}catch{}}function B4(){var e;try{(e=globalThis.localStorage)==null||e.removeItem(_E)}catch{}}function Sve(){var e;try{return((e=globalThis.sessionStorage)==null?void 0:e.getItem(z4))==="1"}catch{return!1}}function xve(){var e;try{(e=globalThis.sessionStorage)==null||e.setItem(z4,"1")}catch{}}function Eve(e){var t;try{(t=globalThis.sessionStorage)==null||t.setItem(XS,e)}catch{}}function Cve(){var e,t;try{const n=((e=globalThis.sessionStorage)==null?void 0:e.getItem(XS))??null;return n!==null&&((t=globalThis.sessionStorage)==null||t.removeItem(XS)),n}catch{return null}}function kve(e){const t=WL(e);return t.osName!=="iPad"?{supported:!0}:e.standalone||t.browserName==="Safari"?{supported:!0}:{supported:!1,reason:"ipad-safari-required",browserName:t.browserName}}function Dg(){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 Tve(){return typeof navigator>"u"?{supported:!0}:kve({userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints,standalone:Dg()})}function Rve(){sge(),oge();const e=Pi(),t=Qs(),n=e.pathname.startsWith("/chat/"),r=e.pathname==="/"||e.pathname==="/sessions",[i,s]=b.useState(!1),[o,l]=b.useState(()=>Dg()),u=Ne(D=>D.proxies.length),d=Ne(D=>D.proxyListLoaded),h=Ne(D=>D.relayClientAuthIssue),p=Ne(D=>!!D.selectedProxyId),y=Ne(D=>D.selectedProxyId),v=Ne(D=>D.selectedProxyName),_=$t(D=>D.sessions.length),w=Ne(D=>D.pendingToast),x=Ne(D=>D.setPendingToast),E=e.pathname==="/"?"proxy-select":"sessions",k=bE({route:E,surface:"mobile",proxiesLength:u,hasProxy:p,sessionCount:_,relayClientAuthIssue:h}),R=v??y,I=e.pathname==="/sessions"&&d&&u>0?g.jsxs(_t,{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":R?`切换开发机,当前 ${R}`:"切换开发机",onClick:()=>t("/"),children:[g.jsx(DP,{className:"size-4 text-primary","aria-hidden":"true"}),g.jsxs("span",{className:"min-w-0 truncate",children:[g.jsx("span",{className:"text-foreground",children:"切换开发机"}),R?g.jsxs("span",{className:"ml-1 text-muted-foreground/75",children:["· ",R]}):null]})]}):null;b.useEffect(()=>{if(!w)return;({error:nt.error,info:nt.info,success:nt.success})[w.kind](w.message),x(null)},[w,x]),b.useEffect(()=>{if(typeof window.matchMedia!="function"){l(Dg());return}const D=window.matchMedia("(display-mode: standalone)"),W=window.matchMedia("(display-mode: fullscreen)"),U=()=>l(Dg());return U(),D.addEventListener("change",U),W.addEventListener("change",U),()=>{D.removeEventListener("change",U),W.removeEventListener("change",U)}},[]);const T=b.useRef(!1);b.useEffect(()=>{if(T.current)return;T.current=!0;const D=bve({pathname:e.pathname,alreadyRestored:Sve(),lastRoute:_ve()});xve(),D&&(Eve(D),t(D,{replace:!0}))},[]);const H=b.useRef(!1);return b.useEffect(()=>{n?(H.current=!0,wve(`${e.pathname}${e.search}`)):H.current&&(H.current=!1,B4())},[n,e.pathname,e.search]),g.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":o?"true":void 0,children:[!n&&g.jsx(_t,{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:()=>s(!0),children:g.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:g.jsx(IP,{className:"size-4","aria-hidden":"true"})})}),!n&&g.jsx(Yse,{subtitle:k,action:I}),g.jsx(Uoe,{}),g.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[g.jsx(Wse,{className:"hidden md:flex"}),g.jsx("main",{className:"relative flex-1 overflow-hidden",role:"main",children:g.jsx(mve,{children:g.jsx("div",{className:Ye("h-full",!r&&"animate-in fade-in-0 duration-200 motion-reduce:animate-none"),children:g.jsx(YU,{})},r?"top-level":e.pathname)})})]}),g.jsx(Y0,{open:i,onOpenChange:s}),g.jsx(_oe,{}),g.jsx(noe,{}),g.jsx(bZ,{})]})}function j4({subtitle:e,action:t}){return g.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-6 px-6 text-center",children:[g.jsx(XB,{texts:ZB,className:"text-2xl md:text-3xl font-bold"}),g.jsx("p",{className:"max-w-md text-sm text-muted-foreground",children:e}),t&&g.jsx("div",{children:t})]})}function Ave(){const e=Ne(o=>o.proxies),t=Ne(o=>!!o.selectedProxyId),n=Ne(o=>o.relayClientAuthIssue),r=$t(o=>o.sessions.length),i=bE({route:"proxy-select",surface:"desktop",proxiesLength:e.length,hasProxy:t,sessionCount:r,relayClientAuthIssue:n}),s=n==="missing_client_token"?"client-token-missing":n==="invalid_client_token"?"client-token-invalid":null;return g.jsxs(g.Fragment,{children:[g.jsx("div",{className:"h-full md:hidden",children:g.jsx(PB,{layout:"page"})}),g.jsx("div",{className:"hidden md:block h-full",children:s?g.jsx(tc,{variant:s}):g.jsx(j4,{subtitle:i})})]})}function Nve(){const e=Ne(o=>o.proxies),t=Ne(o=>!!o.selectedProxyId),n=Ne(o=>o.relayClientAuthIssue),r=$t(o=>o.sessions.length),i=Ei("local",dn.proxyId)!==null;if(!t&&!i)return g.jsx(VU,{to:"/",replace:!0});const s=bE({route:"sessions",surface:"desktop",proxiesLength:e.length,hasProxy:t,sessionCount:r,relayClientAuthIssue:n});return g.jsxs(g.Fragment,{children:[g.jsx("div",{className:"h-full md:hidden",children:g.jsx(UB,{layout:"page"})}),g.jsx("div",{className:"hidden md:block h-full",children:g.jsx(j4,{subtitle:s})})]})}function F4(){if(!(typeof navigator>"u"))return navigator.wakeLock}function Mve(e,t){return e===!1?"insecure-context":t?null:"unsupported"}function $4(){var t;const e=typeof window>"u"?void 0:window.isSecureContext;return Mve(e,typeof((t=F4())==null?void 0:t.request)=="function")}function Ove(e){return e==="insecure-context"?"屏幕常亮需要 HTTPS":"当前浏览器不支持屏幕常亮"}function Dve(){const e=F4();if(typeof(e==null?void 0:e.request)!="function")throw new Error(Ove($4()));return e.request("screen")}function Pve(e){return e instanceof Error&&e.message.trim()?e.message:"无法开启屏幕常亮"}class Lve{constructor(t={}){yt(this,"activeScopes",new Set);yt(this,"pendingScopes",new Set);yt(this,"listeners",new Map);yt(this,"sentinel",null);yt(this,"requestInFlight",null);yt(this,"requestWakeLock");yt(this,"documentRef");yt(this,"windowRef");yt(this,"unavailableReason");yt(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(()=>{})});yt(this,"handlePageHide",()=>{this.releaseSentinel().catch(()=>{})});var n,r;this.requestWakeLock=t.request??Dve,this.unavailableReason=typeof t.request=="function"?null:$4(),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(Pve(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 Ka=new Lve;function H4(e){const[t,n]=b.useState(()=>Ka.getSnapshot(e));b.useEffect(()=>Ka.subscribe(e,n),[e]),b.useEffect(()=>()=>{Ka.disable(e).catch(()=>{})},[e]);const r=b.useCallback(()=>Ka.enable(e),[e]),i=b.useCallback(()=>Ka.disable(e),[e]),s=b.useCallback(()=>Ka.toggle(e),[e]);return{...t,enable:r,disable:i,toggle:s}}function Ive(){return new AudioContext}class zve{constructor(t=Ive){yt(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 Pg=new zve,rO=400,Pu=[];let U4=1;function Bve(){return typeof performance>"u"?0:Math.round(performance.now()*10)/10}function Gh(e){const t={sequence:U4++,timestamp:new Date().toISOString(),monotonicMs:Bve(),sessionId:e.sessionId,scope:e.scope,event:e.event,...e.attemptId?{attemptId:e.attemptId}:{},...e.requestId?{requestId:e.requestId}:{},...e.details?{details:{...e.details}}:{}};Pu.push(t),Pu.length>rO&&Pu.splice(0,Pu.length-rO)}function jve(){return Pu.map(e=>({...e,...e.details?{details:{...e.details}}:{}}))}function Fve(){Pu.length=0,U4=1}typeof window<"u"&&(window.__devAnywhereVoicePilotDiagnostics={snapshot:jve,clear:Fve});function W4(e){return`voice-pilot:${e}`}function $ve(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 Hve="modulepreload",Uve=function(e){return"/"+e},iO={},Wve=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){let o=function(d){return Promise.all(d.map(h=>Promise.resolve(h).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};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=Uve(d),d in iO)return;iO[d]=!0;const h=d.endsWith(".css"),p=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${p}`))return;const y=document.createElement("link");if(y.rel=h?"stylesheet":Hve,h||(y.as="script"),y.crossOrigin="",y.href=d,u&&y.setAttribute("nonce",u),document.head.appendChild(y),h)return new Promise((v,_)=>{y.addEventListener("load",v),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)})},qve="/assets/fvad-DYxbW2my.wasm",Ju=16e3,Vve=20,Ga=Ju*Vve/1e3,Fw=Ga*Int16Array.BYTES_PER_ELEMENT;let sO=null;async function Yve(){return sO??(sO=Wve(async()=>{const{default:e}=await import("./fvad-DRqam2HY.js");return{default:e}},[]).then(({default:e})=>e({locateFile:t=>t.endsWith(".wasm")?qve:t}))),sO}class wE{constructor(t,n,r){yt(this,"destroyed",!1);this.module=t,this.handle=n,this.framePointer=r}static async create(t=3){const n=await Yve(),r=n._fvad_new();if(!r)throw new Error("无法初始化浏览器语音活动检测器");const i=n._malloc(Fw);if(!i)throw n._fvad_free(r),new Error("无法分配浏览器语音活动检测缓冲区");if(n._fvad_set_sample_rate(r,Ju)!==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 wE(n,r,i)}process(t){if(this.destroyed)throw new Error("浏览器语音活动检测器已释放");if(t.byteLength!==Fw)throw new Error(`语音活动检测帧必须为 ${Fw} 字节`);this.module.HEAPU8.set(t,this.framePointer);const n=this.module._fvad_process(this.handle,this.framePointer,Ga);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 Kve{constructor(t={}){yt(this,"startSpeechFrames");yt(this,"endSilenceFrames");yt(this,"active",!1);yt(this,"speechFrames",0);yt(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 Gve{constructor(){yt(this,"pending",new Float32Array(Ga));yt(this,"pendingLength",0)}push(t,n){let r=0;if(this.pendingLength>0){const i=Ga-this.pendingLength,s=Math.min(i,t.length);this.pending.set(t.subarray(0,s),this.pendingLength),this.pendingLength+=s,r+=s,this.pendingLength===Ga&&(n(this.pending.slice()),this.pendingLength=0)}for(;r+Ga<=t.length;)n(t.slice(r,r+Ga)),r+=Ga;if(r<t.length){const i=t.subarray(r);this.pending.set(i,0),this.pendingLength=i.length}}reset(){this.pendingLength=0}}const Xve="/__dev_anywhere_debug/voice-fixture",Zve=Ju*qB/1e3;function Qve(){return wE.create(3)}const Jve={createVad:Qve,getUserMedia:e=>navigator.mediaDevices.getUserMedia(e),createAudioContext:e=>new AudioContext(e),fetch:e=>fetch(e)};function eye(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 tye(e){for(const t of e.getTracks())t.stop()}function q4(e){const t=e.createAudioContext({sampleRate:Ju});if(t.sampleRate!==Ju)throw t.close().catch(()=>{}),new Error("浏览器无法提供 Voice Pilot 所需的 16 kHz 音频输入");return t}async function nye(e){const t=q4(e);let n;try{n=await e.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0,sampleRate:Ju}})}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(),tye(n),t.state!=="closed"&&await t.close()}}}async function rye(e,t){const n=q4(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 V4(e=window.location.search,t=!1){return t&&new URLSearchParams(e).get("voice-fixture")==="default"?{kind:"fixture",url:Xve}:{kind:"microphone"}}async function iye(e,t=Jve){const n=await t.createVad();let r;try{r=e.source.kind==="fixture"?await rye(e.source.url,t):await nye(t)}catch(h){throw n.destroy(),h}const i=new Kve,s=new Gve,o=r.context.createScriptProcessor(Zve,1,1);let l=!1,u=null,d=null;return o.onaudioprocess=h=>{l&&s.push(h.inputBuffer.getChannelData(0),p=>{const y=$ve(p),v=n.process(y);e.onFrame({pcm:y,speechProbability:v?1:0,activityLevel:eye(p)});const _=i.push(v);_==="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 Y4(e=kv().osName){return{mediaAccept:"image/*,video/*",fileAccept:e==="Android"?"application/*,text/*":void 0}}function sye(e){const[t,n,...r]=Array.from(e);return t&&n===" "&&r.length>0?{indicator:t,label:r.join("")}:{label:e}}function oye({title:e,isPtyTitle:t}){if(!t)return g.jsx(g.Fragment,{children:e});const{indicator:n,label:r}=sye(e);return g.jsxs("span",{className:"inline-flex items-center justify-center max-w-full min-w-0 font-mono font-normal",children:[n&&g.jsx("span",{className:"inline-block w-[1.25ch] shrink-0 text-center","aria-hidden":"true",children:n}),g.jsx("span",{className:"truncate",children:n?` ${r}`:r})]})}function aye(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 lye(){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(aye(n),{cause:n})}finally{e==null||e.getTracks().forEach(n=>n.stop())}}const vu="min-h-9 gap-2.5",ng="px-2 pb-1 pt-2 text-xs font-semibold text-muted-foreground";function fo({children:e,className:t}){return g.jsx("span",{"aria-hidden":"true","data-slot":"chat-menu-icon",className:Ye("inline-flex size-5 shrink-0 items-center justify-center text-muted-foreground [&_svg]:size-4",t),children:e})}function cye({label:e}){return g.jsxs(fo,{className:"relative",children:[g.jsx(OP,{className:"size-4","aria-hidden":"true"}),g.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 uye({sessionId:e,mode:t,onFind:n}){const r=Y4(),i=Qs(),s=$t(he=>he.sessions.find(Ke=>Ke.sessionId===e)),o=$t(he=>he.ptyTitles[e]),l=Ne(he=>he.ptyFontSize),u=Ne(he=>he.chatContentFontSize),d=Ne(he=>he.selectedProxyId),h=Ne(he=>he.adjustPtyFontSize),p=Ne(he=>he.adjustChatContentFontSize),y=Ne(he=>he.setChatContentFontSize),v=Ne(he=>he.resetPtyFontSize),_=Ne(he=>he.resetChatContentFontSize),w=Ne(he=>he.inputModePreference==="hardware"),x=$t(he=>he.renameSession),E=Bx(d,e),k=$t(he=>E?!!he.ptyAutoYesBySessionKey[E]:!1),R=$t(he=>he.setPtyAutoYes),I=ul("(pointer: coarse), (hover: none)")&&!w,T=t==="pty"||(s==null?void 0:s.mode)==="pty",H=(s==null?void 0:s.kind)==="terminal",D=H4(e),W=cn(he=>he.bySessionId[e]??ay),U=cn(he=>he.enable),F=cn(he=>he.disable),O=!!(s!=null&&s.nameLocked&&(s!=null&&s.name)),M=Xx(s),B=O&&(s==null?void 0:s.name)||M||T&&o||(s==null?void 0:s.name)||e.slice(0,8),L=!!(T&&!H&&o&&!O),N=T?l:Ix(u,I),V=!T&&I?rL:tL,Y=T?v:_,[$,P]=b.useState(!1),[q,K]=b.useState(!1),z=W.enabled,X=D.active||z,ee=D.pending||!D.supported||z;function te(he){if(T){h(he);return}if(I){y(N+he);return}p(he)}function Q(){D.toggle().catch(he=>{nt.error(he instanceof Error?he.message:String(he))})}async function me(he){var Rt;if(T||H){nt.info("Voice Pilot 目前适用于聊天会话。");return}if(he!==!0){F(e);return}const Ke=Pt;if(!Ke){nt.error("请先连接开发机");return}try{if(!((Rt=(await Ke.requestVoiceConfig()).config)!=null&&Rt.configured)){nt.info("请先在设置里配置 Voice Pilot。");return}P(!0)}catch(ye){nt.error(ye instanceof Error?ye.message:String(ye))}}async function ve(){var ye;K(!0);let he=null,Ke=!1;const Rt=W4(e);try{Gh({sessionId:e,scope:"runtime",event:"wake-lock-requested",details:{userActivationActive:((ye=navigator.userActivation)==null?void 0:ye.isActive)??!1,visibilityState:document.visibilityState,secureContext:window.isSecureContext}});const He=Ka.enable(Rt).then(()=>{Gh({sessionId:e,scope:"runtime",event:"wake-lock-acquired"})},rt=>{throw Gh({sessionId:e,scope:"runtime",event:"wake-lock-failed",details:{error:rt instanceof Error?rt.message:String(rt)}}),new Error("屏幕常亮请求被浏览器拒绝,Voice Pilot 未开启。",{cause:rt})});he=I1.acquire("capture");const Ge=Pg.prepare(),Xe=V4().kind==="microphone"?lye():Promise.resolve();await Promise.all([He,Ge,Xe]),U(e),Ke=!0,P(!1)}catch(He){Gh({sessionId:e,scope:"runtime",event:"startup-failed",details:{error:He instanceof Error?He.message:String(He)}}),nt.error(He instanceof Error?He.message:String(He))}finally{he==null||he.release(),Ke||await Ka.disable(Rt).catch(()=>{}),K(!1)}}const Ce=b.useRef(null),Me=b.useRef(null),[Ve,Qe]=b.useState(!1);async function ct(he){var He;const Ke=(He=he.target.files)==null?void 0:He[0];if(he.target.value="",!Ke)return;const Rt=Pt;if(!Rt){nt.error("请先连接开发机");return}const ye=await kf({relay:Rt,sessionId:e,file:Ke});ye&&Ys(e,`@${ye} `)}async function Ot(he,Ke){const Rt=Pt;if(!Rt)throw new Error("请先连接开发机");const ye=await Rt.renameSession(he,Ke);if(!ye.success)throw new Error(ye.error??"重命名失败");x(he,ye.name??Ke),nt.success("已重命名会话")}return g.jsxs("div",{className:"border-b border-border bg-card pt-[env(safe-area-inset-top)] shrink-0","data-slot":"chat-header",children:[g.jsx("div",{className:"dev-chat-shell-rail-inset","data-slot":"chat-header-rail-inset",children:g.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:[g.jsx("div",{className:"flex justify-start",children:g.jsx(_t,{variant:"ghost",size:"icon-sm",className:"md:hidden",onClick:()=>i("/sessions"),"aria-label":"返回会话列表","data-slot":"chat-back-button",children:g.jsx(_v,{"aria-hidden":"true"})})}),g.jsx("span",{className:"text-sm font-semibold truncate text-center px-2","data-slot":"chat-session-title",children:g.jsx(oye,{title:B,isPtyTitle:L})}),g.jsxs(O1,{modal:!1,children:[g.jsx(D1,{asChild:!0,children:g.jsx(_t,{variant:"ghost",size:"icon-sm",className:"justify-self-end","aria-label":"会话操作","data-slot":"chat-overflow-trigger",children:g.jsx(g8,{"aria-hidden":"true"})})}),g.jsxs(P1,{align:"end",className:"w-max min-w-44 max-w-[calc(100vw-1rem)]","data-slot":"chat-overflow-menu",children:[g.jsx(jm,{className:ng,children:"会话"}),g.jsxs(yo,{className:vu,"data-slot":"chat-menu-find",onSelect:n,children:[g.jsx(fo,{children:g.jsx(zg,{"aria-hidden":"true"})}),"在会话中查找"]}),g.jsxs(yo,{className:vu,"data-slot":"chat-menu-rename",onSelect:()=>Qe(!0),children:[g.jsx(fo,{children:g.jsx(Z8,{"aria-hidden":"true"})}),"重命名"]}),g.jsxs(Z_,{checked:X,className:"min-h-9 justify-start gap-2.5 pl-2 pr-8 [&>span:first-child]:left-auto [&>span:first-child]:right-2",disabled:ee,"data-slot":"chat-menu-screen-wake-lock-item",onCheckedChange:Q,children:[g.jsx(fo,{children:g.jsx(O8,{"aria-hidden":"true"})}),g.jsx("span",{className:"min-w-0 flex-1",children:D.supported?z?"屏幕常亮(Voice Pilot 控制)":"屏幕常亮":D.unavailableReason==="insecure-context"?"屏幕常亮(需要 HTTPS)":"屏幕常亮(浏览器不支持)"})]}),T&&!H&&g.jsxs(Z_,{checked:k,className:"min-h-9 justify-start gap-2.5 pl-2 pr-8 [&>span:first-child]:left-auto [&>span:first-child]:right-2",disabled:!E,"data-slot":"chat-menu-pty-auto-yes-item",onCheckedChange:he=>{E&&R(E,he===!0)},children:[g.jsx(fo,{children:g.jsx(ta,{"aria-hidden":"true"})}),g.jsx("span",{className:"min-w-0 flex-1",children:"Always yes"})]}),!T&&!H&&g.jsxs(Z_,{checked:W.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:me,children:[g.jsx(fo,{children:g.jsx(B8,{"aria-hidden":"true"})}),g.jsx("span",{className:"min-w-0 flex-1",children:"Voice Pilot"})]}),g.jsx(Q_,{}),T&&!H?g.jsxs(g.Fragment,{children:[g.jsx(jm,{className:ng,children:"快捷键"}),g.jsxs(yo,{className:vu,"data-slot":"chat-menu-send-ctrl-o",onClick:()=>Ys(e,""),children:[g.jsx(cye,{label:"^O"}),"发送 Ctrl+O"]}),g.jsx(Q_,{}),g.jsx(jm,{className:ng,children:"文件"}),g.jsxs(yo,{className:vu,"data-slot":"chat-menu-upload-image",onClick:()=>{var he;return(he=Me.current)==null?void 0:he.click()},children:[g.jsx(fo,{children:g.jsx(Lf,{"aria-hidden":"true"})}),"上传照片或视频"]}),g.jsxs(yo,{className:vu,"data-slot":"chat-menu-upload-file",onClick:()=>{var he;return(he=Ce.current)==null?void 0:he.click()},children:[g.jsx(fo,{children:g.jsx(zP,{"aria-hidden":"true"})}),"上传文件"]}),g.jsx(Q_,{})]}):null,g.jsx(jm,{className:ng,children:"字号"}),g.jsx("div",{className:"px-2 pb-1","data-slot":"chat-menu-font-control",children:g.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:[g.jsx(fo,{children:g.jsx(S7,{"aria-hidden":"true"})}),g.jsxs("div",{className:"col-start-2 inline-flex w-fit shrink-0 items-center gap-2","data-slot":"chat-menu-font-stepper",children:[g.jsx(_t,{variant:"ghost",size:"icon-sm",className:"size-[22px] rounded-[5px] bg-muted/45 text-muted-foreground hover:bg-accent hover:text-accent-foreground",disabled:N<=V,"aria-label":"字号变小","data-slot":"chat-menu-font-smaller",onClick:he=>{he.stopPropagation(),te(-1)},children:g.jsx(F8,{"aria-hidden":"true"})}),g.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:[N,"px"]}),g.jsx(_t,{variant:"ghost",size:"icon-sm",className:"size-[22px] rounded-[5px] bg-muted/45 text-muted-foreground hover:bg-accent hover:text-accent-foreground",disabled:N>=nL,"aria-label":"字号变大","data-slot":"chat-menu-font-larger",onClick:he=>{he.stopPropagation(),te(1)},children:g.jsx(e7,{"aria-hidden":"true"})})]})]})}),g.jsxs(yo,{className:vu,"data-slot":"chat-menu-font-reset",onClick:Y,children:[g.jsx(fo,{children:g.jsx(r7,{"aria-hidden":"true"})}),g.jsx("span",{"data-slot":"chat-menu-font-reset-label",children:"恢复默认"})]})]})]})]})}),g.jsx(jh,{open:Ve,sessionId:e,initialName:s==null?void 0:s.name,onOpenChange:Qe,onRename:Ot}),g.jsx(Sc,{open:$&&!W.enabled,onOpenChange:he=>{q||P(he)},children:g.jsxs(xc,{className:"sm:max-w-md","data-slot":"voice-pilot-wake-lock-dialog",focusSurfaceOnOpen:!0,children:[g.jsxs(Ec,{children:[g.jsx(cl,{children:"开启 Voice Pilot?"}),g.jsx(uc,{children:"开启后会持续聆听并保持屏幕常亮,停止后自动恢复。"})]}),g.jsxs(Gu,{children:[g.jsx(_t,{type:"button",variant:"outline",disabled:q,onClick:()=>P(!1),children:"取消"}),g.jsx(_t,{type:"button","data-slot":"voice-pilot-confirm-start",disabled:q,onClick:()=>{ve()},children:q?"正在开启...":"开启 Voice Pilot"})]})]})}),T?g.jsxs(g.Fragment,{children:[g.jsx("input",{ref:Me,type:"file",accept:r.mediaAccept,className:"hidden","data-slot":"chat-menu-upload-image-input",onChange:he=>{ct(he)}}),g.jsx("input",{ref:Ce,type:"file",accept:r.fileAccept,className:"hidden","data-slot":"chat-menu-upload-file-input",onChange:he=>{ct(he)}})]}):null]})}function yu(e,t,n){let r=n.initialDeps??[],i,s=!0;function o(){var l,u,d;let h;n.key&&((l=n.debug)!=null&&l.call(n))&&(h=Date.now());const p=e();if(!(p.length!==r.length||p.some((_,w)=>r[w]!==_)))return i;r=p;let v;if(n.key&&((u=n.debug)!=null&&u.call(n))&&(v=Date.now()),i=t(...p),n.key&&((d=n.debug)!=null&&d.call(n))){const _=Math.round((Date.now()-h)*100)/100,w=Math.round((Date.now()-v)*100)/100,x=w/16,E=(k,R)=>{for(k=String(k);k.length<R;)k=" "+k;return k};console.info(`%c⏱ ${E(w,5)} /${E(_,5)} ms`,`
648
648
  font-size: .6rem;
649
649
  font-weight: bold;
650
- color: hsl(${Math.max(0,Math.min(120-120*x,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 oO(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const dye=(e,t)=>Math.abs(e-t)<1.01,hye=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},aO=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},fye=e=>e,pye=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},mye=(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(aO(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(aO(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()});return s.observe(n,{box:"border-box"}),()=>{s.unobserve(n)}},lO={passive:!0},cO=typeof window>"u"?!0:"onscrollend"in window,gye=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;let i=0;const s=e.options.useScrollendEvent&&cO?()=>{}:hye(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=h=>()=>{const{horizontal:p,isRtl:y}=e.options;i=p?n.scrollLeft*(y&&-1||1):n.scrollTop,s(),t(i,h)},l=o(!0),u=o(!1);n.addEventListener("scroll",l,lO);const d=e.options.useScrollendEvent&&cO;return d&&n.addEventListener("scrollend",u,lO),()=>{n.removeEventListener("scroll",l),d&&n.removeEventListener("scrollend",u)}},vye=(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"]},yye=(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 bye{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:fye,rangeExtractor:pye,onChange:()=>{},measureElement:vye,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=yu(()=>(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=yu(()=>[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=yu(()=>[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 v of this.laneAssignments.keys())v>=n&&this.laneAssignments.delete(v);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(v=>{this.itemSizeCache.set(v.key,v.size)}));const h=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1);const p=this.measurementsCache.slice(0,h),y=new Array(l).fill(void 0);for(let v=0;v<h;v++){const _=p[v];_&&(y[_.lane]=v)}for(let v=h;v<n;v++){const _=s(v),w=this.laneAssignments.get(v);let x,E;const k=u==="estimate"||d.has(_);if(w!==void 0&&this.options.lanes>1){x=w;const T=y[x],H=T!==void 0?p[T]:void 0;E=H?H.end+this.options.gap:r+i}else{const T=this.options.lanes===1?p[v-1]:this.getFurthestMeasurement(p,v);E=T?T.end+this.options.gap:r+i,x=T?T.lane:v%this.options.lanes,this.options.lanes>1&&k&&this.laneAssignments.set(v,x)}const R=d.get(_),A=typeof R=="number"?R:this.options.estimateSize(v),I=E+A;p[v]={index:v,start:E,size:A,end:I,key:_,lane:x},y[x]=v}return this.measurementsCache=p,p},{key:!1,debug:()=>this.options.debug}),this.calculateRange=yu(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,r,i,s)=>this.range=n.length>0&&r>0?_ye({measurements:n,outerSize:r,scrollOffset:i,lanes:s}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=yu(()=>{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=yu(()=>[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 oO(r[Kj(0,r.length-1,i=>oO(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&&dye(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 Kj=(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 _ye({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=Kj(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(h=>h<n+t);){const h=e[l];u[h.lane]=h.end,l++}const d=Array(r).fill(n+t);for(;o>=0&&d.some(h=>h>=n);){const h=e[o];d[h.lane]=h.start,o--}o=Math.max(0,o-o%r),l=Math.min(i,l+(r-1-l%r))}return{startIndex:o,endIndex:l}}const uO=typeof document<"u"?b.useLayoutEffect:b.useEffect;function wye({useFlushSync:e=!0,...t}){const n=b.useReducer(()=>({}),{})[1],r={...t,onChange:(s,o)=>{var l;e&&o?id.flushSync(n):n(),(l=t.onChange)==null||l.call(t,s,o)}},[i]=b.useState(()=>new bye(r));return i.setOptions(r),uO(()=>i._didMount(),[]),uO(()=>i._willUpdate()),i}function Sye(e){return wye({observeElementRect:mye,observeElementOffset:gye,scrollToFn:yye,...e})}function xye(e){return e.kind==="diff"}const Eye=12e4;function dO(e){return e?e.replace(/\r\n?/gu,`
650
+ color: hsl(${Math.max(0,Math.min(120-120*x,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 oO(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const dye=(e,t)=>Math.abs(e-t)<1.01,hye=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},aO=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},fye=e=>e,pye=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},mye=(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(aO(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(aO(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()});return s.observe(n,{box:"border-box"}),()=>{s.unobserve(n)}},lO={passive:!0},cO=typeof window>"u"?!0:"onscrollend"in window,gye=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;let i=0;const s=e.options.useScrollendEvent&&cO?()=>{}:hye(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=h=>()=>{const{horizontal:p,isRtl:y}=e.options;i=p?n.scrollLeft*(y&&-1||1):n.scrollTop,s(),t(i,h)},l=o(!0),u=o(!1);n.addEventListener("scroll",l,lO);const d=e.options.useScrollendEvent&&cO;return d&&n.addEventListener("scrollend",u,lO),()=>{n.removeEventListener("scroll",l),d&&n.removeEventListener("scrollend",u)}},vye=(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"]},yye=(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 bye{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:fye,rangeExtractor:pye,onChange:()=>{},measureElement:vye,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=yu(()=>(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=yu(()=>[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=yu(()=>[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 v of this.laneAssignments.keys())v>=n&&this.laneAssignments.delete(v);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(v=>{this.itemSizeCache.set(v.key,v.size)}));const h=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1);const p=this.measurementsCache.slice(0,h),y=new Array(l).fill(void 0);for(let v=0;v<h;v++){const _=p[v];_&&(y[_.lane]=v)}for(let v=h;v<n;v++){const _=s(v),w=this.laneAssignments.get(v);let x,E;const k=u==="estimate"||d.has(_);if(w!==void 0&&this.options.lanes>1){x=w;const T=y[x],H=T!==void 0?p[T]:void 0;E=H?H.end+this.options.gap:r+i}else{const T=this.options.lanes===1?p[v-1]:this.getFurthestMeasurement(p,v);E=T?T.end+this.options.gap:r+i,x=T?T.lane:v%this.options.lanes,this.options.lanes>1&&k&&this.laneAssignments.set(v,x)}const R=d.get(_),A=typeof R=="number"?R:this.options.estimateSize(v),I=E+A;p[v]={index:v,start:E,size:A,end:I,key:_,lane:x},y[x]=v}return this.measurementsCache=p,p},{key:!1,debug:()=>this.options.debug}),this.calculateRange=yu(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,r,i,s)=>this.range=n.length>0&&r>0?_ye({measurements:n,outerSize:r,scrollOffset:i,lanes:s}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=yu(()=>{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=yu(()=>[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 oO(r[K4(0,r.length-1,i=>oO(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&&dye(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 K4=(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 _ye({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=K4(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(h=>h<n+t);){const h=e[l];u[h.lane]=h.end,l++}const d=Array(r).fill(n+t);for(;o>=0&&d.some(h=>h>=n);){const h=e[o];d[h.lane]=h.start,o--}o=Math.max(0,o-o%r),l=Math.min(i,l+(r-1-l%r))}return{startIndex:o,endIndex:l}}const uO=typeof document<"u"?b.useLayoutEffect:b.useEffect;function wye({useFlushSync:e=!0,...t}){const n=b.useReducer(()=>({}),{})[1],r={...t,onChange:(s,o)=>{var l;e&&o?id.flushSync(n):n(),(l=t.onChange)==null||l.call(t,s,o)}},[i]=b.useState(()=>new bye(r));return i.setOptions(r),uO(()=>i._didMount(),[]),uO(()=>i._willUpdate()),i}function Sye(e){return wye({observeElementRect:mye,observeElementOffset:gye,scrollToFn:yye,...e})}function xye(e){return e.kind==="diff"}const Eye=12e4;function dO(e){return e?e.replace(/\r\n?/gu,`
651
651
  `).split(`
652
- `):[]}function Cye(e,t,n){let r=n;for(const i of t)e.push({type:"remove",text:i,oldLineNumber:r,newLineNumber:null}),r+=1}function kye(e,t,n){let r=n;for(const i of t)e.push({type:"add",text:i,oldLineNumber:null,newLineNumber:r}),r+=1}function Tye(e,t){const n=dO(e),r=dO(t);if(n.length===0&&r.length===0)return[];if(n.length*r.length>Eye){const h=[];return Cye(h,n,1),kye(h,r,1),h}const i=Array.from({length:n.length+1},()=>Array(r.length+1).fill(0));for(let h=n.length-1;h>=0;h-=1)for(let p=r.length-1;p>=0;p-=1)i[h][p]=n[h]===r[p]?i[h+1][p+1]+1:Math.max(i[h+1][p],i[h][p+1]);const s=[];let o=0,l=0,u=1,d=1;for(;o<n.length||l<r.length;)o<n.length&&l<r.length&&n[o]===r[l]?(s.push({type:"context",text:n[o],oldLineNumber:u,newLineNumber:d}),o+=1,l+=1,u+=1,d+=1):l>=r.length||o<n.length&&i[o+1][l]>=i[o][l+1]?(s.push({type:"remove",text:n[o],oldLineNumber:u,newLineNumber:null}),o+=1,u+=1):(s.push({type:"add",text:r[l],oldLineNumber:null,newLineNumber:d}),l+=1,d+=1);return s}function hO(e){return e===null?"":String(e)}function Rye(e){return e==="add"?"+":e==="remove"?"-":" "}function Aye(e){return e==="add"?"border-l-[3px] border-l-emerald-500/60 bg-emerald-500/10 text-emerald-950 dark:text-emerald-100":e==="remove"?"border-l-[3px] border-l-red-500/60 bg-red-500/10 text-red-950 dark:text-red-100":"border-l-[3px] border-l-transparent text-foreground"}function Nye({detail:e}){const t=b.useMemo(()=>Tye(e.oldContent,e.newContent),[e.oldContent,e.newContent]),n=t.filter(i=>i.type==="remove").length,r=t.filter(i=>i.type==="add").length;return g.jsxs("section",{"data-slot":"activity-detail","data-kind":"diff",className:"min-w-0",children:[g.jsxs("div",{className:"mb-1 flex min-w-0 items-center gap-2 text-[11px] leading-none text-current/70",children:[g.jsx("span",{className:"min-w-0 truncate",children:e.title}),g.jsxs("span",{"data-slot":"activity-diff-stat",className:"shrink-0 font-mono text-[10px] text-red-600 dark:text-red-300/90",children:["-",n]}),g.jsxs("span",{"data-slot":"activity-diff-stat",className:"shrink-0 font-mono text-[10px] text-emerald-600 dark:text-emerald-300/90",children:["+",r]})]}),g.jsxs("div",{"data-slot":"activity-diff-content",className:"max-h-[min(58vh,560px)] min-w-0 overflow-auto rounded border border-current/10 bg-background/90 font-mono text-[11px] leading-relaxed text-foreground",children:[g.jsxs("div",{className:"sticky top-0 z-10 grid w-full grid-cols-[2.75rem_2.75rem_1.25rem_minmax(0,1fr)] border-b border-border bg-muted/80 px-0 text-[10px] text-muted-foreground backdrop-blur",children:[g.jsx("span",{className:"px-2 py-1 text-right",children:"旧"}),g.jsx("span",{className:"px-2 py-1 text-right",children:"新"}),g.jsx("span",{className:"px-1 py-1","aria-hidden":"true"}),g.jsx("span",{className:"px-2 py-1",children:"内容"})]}),t.length>0?t.map((i,s)=>g.jsxs("div",{"data-slot":"activity-diff-row","data-kind":i.type,className:Ye("grid w-full grid-cols-[2.75rem_2.75rem_1.25rem_minmax(0,1fr)]",Aye(i.type)),children:[g.jsx("span",{className:"select-none border-r border-current/10 px-2 text-right tabular-nums text-current/45",children:hO(i.oldLineNumber)}),g.jsx("span",{className:"select-none border-r border-current/10 px-2 text-right tabular-nums text-current/45",children:hO(i.newLineNumber)}),g.jsx("span",{"data-slot":"activity-diff-prefix",className:"select-none px-1 text-center text-current/70","aria-hidden":"true",children:Rye(i.type)}),g.jsx("code",{className:"min-w-0 whitespace-pre-wrap break-words px-2",children:i.text||" "})]},`${i.type}-${i.oldLineNumber??""}-${i.newLineNumber??""}-${s}`)):g.jsx("div",{className:"px-3 py-2 text-muted-foreground",children:"没有文本变更"})]})]})}function Gj({detail:e}){return xye(e)?g.jsx(Nye,{detail:e}):g.jsxs("section",{"data-slot":"activity-detail","data-kind":"text",className:"min-w-0",children:[g.jsx("div",{className:"mb-1 text-[11px] leading-none text-current/70",children:e.title}),g.jsx("pre",{"data-slot":"activity-detail-content",className:"max-h-[min(55vh,520px)] overflow-auto rounded border border-current/10 bg-background/80 p-2 font-mono text-[11px] leading-relaxed text-foreground whitespace-pre-wrap break-words",children:e.content})]})}function Mye(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Oye=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Dye=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Pye={};function fO(e,t){return(Pye.jsx?Dye:Oye).test(e)}const Lye=/[ \t\n\f\r]/g;function Iye(e){return typeof e=="object"?e.type==="text"?pO(e.value):!1:pO(e)}function pO(e){return e.replace(Lye,"")===""}class np{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}np.prototype.normal={};np.prototype.property={};np.prototype.space=void 0;function Xj(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new np(n,r,t)}function ZS(e){return e.toLowerCase()}class Xi{constructor(t,n){this.attribute=n,this.property=t}}Xi.prototype.attribute="";Xi.prototype.booleanish=!1;Xi.prototype.boolean=!1;Xi.prototype.commaOrSpaceSeparated=!1;Xi.prototype.commaSeparated=!1;Xi.prototype.defined=!1;Xi.prototype.mustUseProperty=!1;Xi.prototype.number=!1;Xi.prototype.overloadedBoolean=!1;Xi.prototype.property="";Xi.prototype.spaceSeparated=!1;Xi.prototype.space=void 0;let zye=0;const ln=Tc(),Dr=Tc(),QS=Tc(),it=Tc(),Qn=Tc(),$u=Tc(),os=Tc();function Tc(){return 2**++zye}const JS=Object.freeze(Object.defineProperty({__proto__:null,boolean:ln,booleanish:Dr,commaOrSpaceSeparated:os,commaSeparated:$u,number:it,overloadedBoolean:QS,spaceSeparated:Qn},Symbol.toStringTag,{value:"Module"})),$w=Object.keys(JS);class SE extends Xi{constructor(t,n,r,i){let s=-1;if(super(t,n),mO(this,"space",i),typeof r=="number")for(;++s<$w.length;){const o=$w[s];mO(this,$w[s],(r&JS[o])===JS[o])}}}SE.prototype.defined=!0;function mO(e,t,n){n&&(e[t]=n)}function fd(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new SE(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[ZS(r)]=r,n[ZS(s.attribute)]=r}return new np(t,n,e.space)}const Zj=fd({properties:{ariaActiveDescendant:null,ariaAtomic:Dr,ariaAutoComplete:null,ariaBusy:Dr,ariaChecked:Dr,ariaColCount:it,ariaColIndex:it,ariaColSpan:it,ariaControls:Qn,ariaCurrent:null,ariaDescribedBy:Qn,ariaDetails:null,ariaDisabled:Dr,ariaDropEffect:Qn,ariaErrorMessage:null,ariaExpanded:Dr,ariaFlowTo:Qn,ariaGrabbed:Dr,ariaHasPopup:null,ariaHidden:Dr,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Qn,ariaLevel:it,ariaLive:null,ariaModal:Dr,ariaMultiLine:Dr,ariaMultiSelectable:Dr,ariaOrientation:null,ariaOwns:Qn,ariaPlaceholder:null,ariaPosInSet:it,ariaPressed:Dr,ariaReadOnly:Dr,ariaRelevant:null,ariaRequired:Dr,ariaRoleDescription:Qn,ariaRowCount:it,ariaRowIndex:it,ariaRowSpan:it,ariaSelected:Dr,ariaSetSize:it,ariaSort:null,ariaValueMax:it,ariaValueMin:it,ariaValueNow:it,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Qj(e,t){return t in e?e[t]:t}function Jj(e,t){return Qj(e,t.toLowerCase())}const Bye=fd({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:$u,acceptCharset:Qn,accessKey:Qn,action:null,allow:null,allowFullScreen:ln,allowPaymentRequest:ln,allowUserMedia:ln,alt:null,as:null,async:ln,autoCapitalize:null,autoComplete:Qn,autoFocus:ln,autoPlay:ln,blocking:Qn,capture:null,charSet:null,checked:ln,cite:null,className:Qn,cols:it,colSpan:null,content:null,contentEditable:Dr,controls:ln,controlsList:Qn,coords:it|$u,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ln,defer:ln,dir:null,dirName:null,disabled:ln,download:QS,draggable:Dr,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ln,formTarget:null,headers:Qn,height:it,hidden:QS,high:it,href:null,hrefLang:null,htmlFor:Qn,httpEquiv:Qn,id:null,imageSizes:null,imageSrcSet:null,inert:ln,inputMode:null,integrity:null,is:null,isMap:ln,itemId:null,itemProp:Qn,itemRef:Qn,itemScope:ln,itemType:Qn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ln,low:it,manifest:null,max:null,maxLength:it,media:null,method:null,min:null,minLength:it,multiple:ln,muted:ln,name:null,nonce:null,noModule:ln,noValidate:ln,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:ln,optimum:it,pattern:null,ping:Qn,placeholder:null,playsInline:ln,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ln,referrerPolicy:null,rel:Qn,required:ln,reversed:ln,rows:it,rowSpan:it,sandbox:Qn,scope:null,scoped:ln,seamless:ln,selected:ln,shadowRootClonable:ln,shadowRootDelegatesFocus:ln,shadowRootMode:null,shape:null,size:it,sizes:null,slot:null,span:it,spellCheck:Dr,src:null,srcDoc:null,srcLang:null,srcSet:null,start:it,step:null,style:null,tabIndex:it,target:null,title:null,translate:null,type:null,typeMustMatch:ln,useMap:null,value:Dr,width:it,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Qn,axis:null,background:null,bgColor:null,border:it,borderColor:null,bottomMargin:it,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ln,declare:ln,event:null,face:null,frame:null,frameBorder:null,hSpace:it,leftMargin:it,link:null,longDesc:null,lowSrc:null,marginHeight:it,marginWidth:it,noResize:ln,noHref:ln,noShade:ln,noWrap:ln,object:null,profile:null,prompt:null,rev:null,rightMargin:it,rules:null,scheme:null,scrolling:Dr,standby:null,summary:null,text:null,topMargin:it,valueType:null,version:null,vAlign:null,vLink:null,vSpace:it,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:ln,disableRemotePlayback:ln,prefix:null,property:null,results:it,security:null,unselectable:null},space:"html",transform:Jj}),jye=fd({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:os,accentHeight:it,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:it,amplitude:it,arabicForm:null,ascent:it,attributeName:null,attributeType:null,azimuth:it,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:it,by:null,calcMode:null,capHeight:it,className:Qn,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:it,diffuseConstant:it,direction:null,display:null,dur:null,divisor:it,dominantBaseline:null,download:ln,dx:null,dy:null,edgeMode:null,editable:null,elevation:it,enableBackground:null,end:null,event:null,exponent:it,externalResourcesRequired:null,fill:null,fillOpacity:it,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:$u,g2:$u,glyphName:$u,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:it,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:it,horizOriginX:it,horizOriginY:it,id:null,ideographic:it,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:it,k:it,k1:it,k2:it,k3:it,k4:it,kernelMatrix:os,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:it,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:it,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:it,overlineThickness:it,paintOrder:null,panose1:null,path:null,pathLength:it,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Qn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:it,pointsAtY:it,pointsAtZ:it,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:os,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:os,rev:os,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:os,requiredFeatures:os,requiredFonts:os,requiredFormats:os,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:it,specularExponent:it,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:it,strikethroughThickness:it,string:null,stroke:null,strokeDashArray:os,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:it,strokeOpacity:it,strokeWidth:null,style:null,surfaceScale:it,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:os,tabIndex:it,tableValues:null,target:null,targetX:it,targetY:it,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:os,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:it,underlineThickness:it,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:it,values:null,vAlphabetic:it,vMathematical:it,vectorEffect:null,vHanging:it,vIdeographic:it,version:null,vertAdvY:it,vertOriginX:it,vertOriginY:it,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:it,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Qj}),e4=fd({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),t4=fd({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Jj}),n4=fd({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Fye={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},$ye=/[A-Z]/g,gO=/-[a-z]/g,Hye=/^data[-\w.:]+$/i;function Uye(e,t){const n=ZS(t);let r=t,i=Xi;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Hye.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(gO,qye);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!gO.test(s)){let o=s.replace($ye,Wye);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=SE}return new i(r,t)}function Wye(e){return"-"+e.toLowerCase()}function qye(e){return e.charAt(1).toUpperCase()}const Vye=Xj([Zj,Bye,e4,t4,n4],"html"),xE=Xj([Zj,jye,e4,t4,n4],"svg");function Yye(e){return e.join(" ").trim()}var bu={},Hw,vO;function Kye(){if(vO)return Hw;vO=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,l=/^\s+|\s+$/g,u=`
653
- `,d="/",h="*",p="",y="comment",v="declaration";function _(x,E){if(typeof x!="string")throw new TypeError("First argument must be a string");if(!x)return[];E=E||{};var k=1,R=1;function A(B){var L=B.match(t);L&&(k+=L.length);var N=B.lastIndexOf(u);R=~N?B.length-N:R+B.length}function I(){var B={line:k,column:R};return function(L){return L.position=new T(B),W(),L}}function T(B){this.start=B,this.end={line:k,column:R},this.source=E.source}T.prototype.content=x;function H(B){var L=new Error(E.source+":"+k+":"+R+": "+B);if(L.reason=B,L.filename=E.source,L.line=k,L.column=R,L.source=x,!E.silent)throw L}function D(B){var L=B.exec(x);if(L){var N=L[0];return A(N),x=x.slice(N.length),L}}function W(){D(n)}function U(B){var L;for(B=B||[];L=F();)L!==!1&&B.push(L);return B}function F(){var B=I();if(!(d!=x.charAt(0)||h!=x.charAt(1))){for(var L=2;p!=x.charAt(L)&&(h!=x.charAt(L)||d!=x.charAt(L+1));)++L;if(L+=2,p===x.charAt(L-1))return H("End of comment missing");var N=x.slice(2,L-2);return R+=2,A(N),x=x.slice(L),R+=2,B({type:y,comment:N})}}function O(){var B=I(),L=D(r);if(L){if(F(),!D(i))return H("property missing ':'");var N=D(s),V=B({type:v,property:w(L[0].replace(e,p)),value:N?w(N[0].replace(e,p)):p});return D(o),V}}function M(){var B=[];U(B);for(var L;L=O();)L!==!1&&(B.push(L),U(B));return B}return W(),M()}function w(x){return x?x.replace(l,p):p}return Hw=_,Hw}var yO;function Gye(){if(yO)return bu;yO=1;var e=bu&&bu.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(bu,"__esModule",{value:!0}),bu.default=n;const t=e(Kye());function n(r,i){let s=null;if(!r||typeof r!="string")return s;const o=(0,t.default)(r),l=typeof i=="function";return o.forEach(u=>{if(u.type!=="declaration")return;const{property:d,value:h}=u;l?i(d,h,u):h&&(s=s||{},s[d]=h)}),s}return bu}var Eh={},bO;function Xye(){if(bO)return Eh;bO=1,Object.defineProperty(Eh,"__esModule",{value:!0}),Eh.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,s=function(d){return!d||n.test(d)||e.test(d)},o=function(d,h){return h.toUpperCase()},l=function(d,h){return"".concat(h,"-")},u=function(d,h){return h===void 0&&(h={}),s(d)?d:(d=d.toLowerCase(),h.reactCompat?d=d.replace(i,l):d=d.replace(r,l),d.replace(t,o))};return Eh.camelCase=u,Eh}var Ch,_O;function Zye(){if(_O)return Ch;_O=1;var e=Ch&&Ch.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(Gye()),n=Xye();function r(i,s){var o={};return!i||typeof i!="string"||(0,t.default)(i,function(l,u){l&&u&&(o[(0,n.camelCase)(l,s)]=u)}),o}return r.default=r,Ch=r,Ch}var Qye=Zye();const Jye=Af(Qye),r4=i4("end"),EE=i4("start");function i4(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function ebe(e){const t=EE(e),n=r4(e);if(t&&n)return{start:t,end:n}}function tf(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?wO(e.position):"start"in e||"end"in e?wO(e):"line"in e||"column"in e?ex(e):""}function ex(e){return SO(e&&e.line)+":"+SO(e&&e.column)}function wO(e){return ex(e&&e.start)+"-"+ex(e&&e.end)}function SO(e){return e&&typeof e=="number"?e:1}class ki extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},o=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(o=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const u=r.indexOf(":");u===-1?s.ruleId=r:(s.source=r.slice(0,u),s.ruleId=r.slice(u+1))}if(!s.place&&s.ancestors&&s.ancestors){const u=s.ancestors[s.ancestors.length-1];u&&(s.place=u.position)}const l=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=l?l.line:void 0,this.name=tf(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}ki.prototype.file="";ki.prototype.name="";ki.prototype.reason="";ki.prototype.message="";ki.prototype.stack="";ki.prototype.column=void 0;ki.prototype.line=void 0;ki.prototype.ancestors=void 0;ki.prototype.cause=void 0;ki.prototype.fatal=void 0;ki.prototype.place=void 0;ki.prototype.ruleId=void 0;ki.prototype.source=void 0;const CE={}.hasOwnProperty,tbe=new Map,nbe=/[A-Z]/g,rbe=new Set(["table","tbody","thead","tfoot","tr"]),ibe=new Set(["td","th"]),s4="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function sbe(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=fbe(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=hbe(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?xE:Vye,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=o4(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function o4(e,t,n){if(t.type==="element")return obe(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return abe(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return cbe(e,t,n);if(t.type==="mdxjsEsm")return lbe(e,t);if(t.type==="root")return ube(e,t,n);if(t.type==="text")return dbe(e,t)}function obe(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=xE,e.schema=i),e.ancestors.push(t);const s=l4(e,t.tagName,!1),o=pbe(e,t);let l=TE(e,t);return rbe.has(t.tagName)&&(l=l.filter(function(u){return typeof u=="string"?!Iye(u):!0})),a4(e,o,s,t),kE(o,l),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function abe(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}Tf(e,t.position)}function lbe(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Tf(e,t.position)}function cbe(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=xE,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:l4(e,t.name,!0),o=mbe(e,t),l=TE(e,t);return a4(e,o,s,t),kE(o,l),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function ube(e,t,n){const r={};return kE(r,TE(e,t)),e.create(t,e.Fragment,r,n)}function dbe(e,t){return t.value}function a4(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function kE(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function hbe(e,t,n){return r;function r(i,s,o,l){const d=Array.isArray(o.children)?n:t;return l?d(s,o,l):d(s,o)}}function fbe(e,t){return n;function n(r,i,s,o){const l=Array.isArray(s.children),u=EE(r);return t(i,s,o,l,{columnNumber:u?u.column-1:void 0,fileName:e,lineNumber:u?u.line:void 0},void 0)}}function pbe(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&CE.call(t.properties,i)){const s=gbe(e,i,t.properties[i]);if(s){const[o,l]=s;e.tableCellAlignToStyle&&o==="align"&&typeof l=="string"&&ibe.has(t.tagName)?r=l:n[o]=l}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function mbe(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const o=s.expression;o.type;const l=o.properties[0];l.type,Object.assign(n,e.evaluater.evaluateExpression(l.argument))}else Tf(e,t.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const l=r.value.data.estree.body[0];l.type,s=e.evaluater.evaluateExpression(l.expression)}else Tf(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function TE(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:tbe;for(;++r<t.children.length;){const s=t.children[r];let o;if(e.passKeys){const u=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(u){const d=i.get(u)||0;o=u+"-"+d,i.set(u,d+1)}}const l=o4(e,s,o);l!==void 0&&n.push(l)}return n}function gbe(e,t,n){const r=Uye(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Mye(n):Yye(n)),r.property==="style"){let i=typeof n=="object"?n:vbe(e,String(n));return e.stylePropertyNameCase==="css"&&(i=ybe(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?Fye[r.property]||r.property:r.attribute,n]}}function vbe(e,t){try{return Jye(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new ki("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=s4+"#cannot-parse-style-attribute",i}}function l4(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,o;for(;++s<i.length;){const l=fO(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};o=o?{type:"MemberExpression",object:o,property:l,computed:!!(s&&l.type==="Literal"),optional:!1}:l}r=o}else r=fO(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return CE.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);Tf(e)}function Tf(e,t){const n=new ki("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=s4+"#cannot-handle-mdx-estrees-without-createevaluater",n}function ybe(e){const t={};let n;for(n in e)CE.call(e,n)&&(t[bbe(n)]=e[n]);return t}function bbe(e){let t=e.replace(nbe,_be);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function _be(e){return"-"+e.toLowerCase()}const Uw={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},wbe={};function RE(e,t){const n=wbe,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return c4(e,r,i)}function c4(e,t,n){if(Sbe(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return xO(e.children,t,n)}return Array.isArray(e)?xO(e,t,n):""}function xO(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=c4(e[i],t,n);return r.join("")}function Sbe(e){return!!(e&&typeof e=="object")}const EO=document.createElement("i");function AE(e){const t="&"+e+";";EO.innerHTML=t;const n=EO.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function us(e,t,n,r){const i=e.length;let s=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);s<r.length;)o=r.slice(s,s+1e4),o.unshift(t,0),e.splice(...o),s+=1e4,t+=1e4}function Ts(e,t){return e.length>0?(us(e,e.length,0,t),e):t}const CO={}.hasOwnProperty;function u4(e){const t={};let n=-1;for(;++n<e.length;)xbe(t,e[n]);return t}function xbe(e,t){let n;for(n in t){const i=(CO.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let o;if(s)for(o in s){CO.call(i,o)||(i[o]=[]);const l=s[o];Ebe(i[o],Array.isArray(l)?l:l?[l]:[])}}}function Ebe(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);us(e,0,0,r)}function d4(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Ks(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Di=xl(/[A-Za-z]/),xi=xl(/[\dA-Za-z]/),Cbe=xl(/[#-'*+\--9=?A-Z^-~]/);function cv(e){return e!==null&&(e<32||e===127)}const tx=xl(/\d/),kbe=xl(/[\dA-Fa-f]/),Tbe=xl(/[!-/:-@[-`{-~]/);function Ft(e){return e!==null&&e<-2}function Gn(e){return e!==null&&(e<0||e===32)}function Sn(e){return e===-2||e===-1||e===32}const ly=xl(new RegExp("\\p{P}|\\p{S}","u")),fc=xl(/\s/);function xl(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function pd(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let o="";if(s===37&&xi(e.charCodeAt(n+1))&&xi(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(o=String.fromCharCode(s));else if(s>55295&&s<57344){const l=e.charCodeAt(n+1);s<56320&&l>56319&&l<57344?(o=String.fromCharCode(s,l),i=1):o="�"}else o=String.fromCharCode(s);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function Mn(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(u){return Sn(u)?(e.enter(n),l(u)):t(u)}function l(u){return Sn(u)&&s++<i?(e.consume(u),l):(e.exit(n),t(u))}}const Rbe={tokenize:Abe};function Abe(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),Mn(e,t,"linePrefix")}function i(l){return e.enter("paragraph"),s(l)}function s(l){const u=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=u),n=u,o(l)}function o(l){if(l===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(l);return}return Ft(l)?(e.consume(l),e.exit("chunkText"),s):(e.consume(l),o)}}const Nbe={tokenize:Mbe},kO={tokenize:Obe};function Mbe(e){const t=this,n=[];let r=0,i,s,o;return l;function l(R){if(r<n.length){const A=n[r];return t.containerState=A[1],e.attempt(A[0].continuation,u,d)(R)}return d(R)}function u(R){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&k();const A=t.events.length;let I=A,T;for(;I--;)if(t.events[I][0]==="exit"&&t.events[I][1].type==="chunkFlow"){T=t.events[I][1].end;break}E(r);let H=A;for(;H<t.events.length;)t.events[H][1].end={...T},H++;return us(t.events,I+1,0,t.events.slice(A)),t.events.length=H,d(R)}return l(R)}function d(R){if(r===n.length){if(!i)return y(R);if(i.currentConstruct&&i.currentConstruct.concrete)return _(R);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(kO,h,p)(R)}function h(R){return i&&k(),E(r),y(R)}function p(R){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,_(R)}function y(R){return t.containerState={},e.attempt(kO,v,_)(R)}function v(R){return r++,n.push([t.currentConstruct,t.containerState]),y(R)}function _(R){if(R===null){i&&k(),E(0),e.consume(R);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),w(R)}function w(R){if(R===null){x(e.exit("chunkFlow"),!0),E(0),e.consume(R);return}return Ft(R)?(e.consume(R),x(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(R),w)}function x(R,A){const I=t.sliceStream(R);if(A&&I.push(null),R.previous=s,s&&(s.next=R),s=R,i.defineSkip(R.start),i.write(I),t.parser.lazy[R.start.line]){let T=i.events.length;for(;T--;)if(i.events[T][1].start.offset<o&&(!i.events[T][1].end||i.events[T][1].end.offset>o))return;const H=t.events.length;let D=H,W,U;for(;D--;)if(t.events[D][0]==="exit"&&t.events[D][1].type==="chunkFlow"){if(W){U=t.events[D][1].end;break}W=!0}for(E(r),T=H;T<t.events.length;)t.events[T][1].end={...U},T++;us(t.events,D+1,0,t.events.slice(H)),t.events.length=T}}function E(R){let A=n.length;for(;A-- >R;){const I=n[A];t.containerState=I[1],I[0].exit.call(t,e)}n.length=R}function k(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Obe(e,t,n){return Mn(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function ed(e){if(e===null||Gn(e)||fc(e))return 1;if(ly(e))return 2}function cy(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const s=e[i].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const nx={name:"attention",resolveAll:Dbe,tokenize:Pbe};function Dbe(e,t){let n=-1,r,i,s,o,l,u,d,h;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const p={...e[r][1].end},y={...e[n][1].start};TO(p,-u),TO(y,u),o={type:u>1?"strongSequence":"emphasisSequence",start:p,end:{...e[r][1].end}},l={type:u>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:y},s={type:u>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:u>1?"strong":"emphasis",start:{...o.start},end:{...l.end}},e[r][1].end={...o.start},e[n][1].start={...l.end},d=[],e[r][1].end.offset-e[r][1].start.offset&&(d=Ts(d,[["enter",e[r][1],t],["exit",e[r][1],t]])),d=Ts(d,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",s,t]]),d=Ts(d,cy(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),d=Ts(d,[["exit",s,t],["enter",l,t],["exit",l,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(h=2,d=Ts(d,[["enter",e[n][1],t],["exit",e[n][1],t]])):h=0,us(e,r-1,n-r+3,d),n=r+d.length-h-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function Pbe(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=ed(r);let s;return o;function o(u){return s=u,e.enter("attentionSequence"),l(u)}function l(u){if(u===s)return e.consume(u),l;const d=e.exit("attentionSequence"),h=ed(u),p=!h||h===2&&i||n.includes(u),y=!i||i===2&&h||n.includes(r);return d._open=!!(s===42?p:p&&(i||!y)),d._close=!!(s===42?y:y&&(h||!p)),t(u)}}function TO(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Lbe={name:"autolink",tokenize:Ibe};function Ibe(e,t,n){let r=0;return i;function i(v){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(v),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(v){return Di(v)?(e.consume(v),o):v===64?n(v):d(v)}function o(v){return v===43||v===45||v===46||xi(v)?(r=1,l(v)):d(v)}function l(v){return v===58?(e.consume(v),r=0,u):(v===43||v===45||v===46||xi(v))&&r++<32?(e.consume(v),l):(r=0,d(v))}function u(v){return v===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(v),e.exit("autolinkMarker"),e.exit("autolink"),t):v===null||v===32||v===60||cv(v)?n(v):(e.consume(v),u)}function d(v){return v===64?(e.consume(v),h):Cbe(v)?(e.consume(v),d):n(v)}function h(v){return xi(v)?p(v):n(v)}function p(v){return v===46?(e.consume(v),r=0,h):v===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(v),e.exit("autolinkMarker"),e.exit("autolink"),t):y(v)}function y(v){if((v===45||xi(v))&&r++<63){const _=v===45?y:p;return e.consume(v),_}return n(v)}}const rp={partial:!0,tokenize:zbe};function zbe(e,t,n){return r;function r(s){return Sn(s)?Mn(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||Ft(s)?t(s):n(s)}}const h4={continuation:{tokenize:jbe},exit:Fbe,name:"blockQuote",tokenize:Bbe};function Bbe(e,t,n){const r=this;return i;function i(o){if(o===62){const l=r.containerState;return l.open||(e.enter("blockQuote",{_container:!0}),l.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),s}return n(o)}function s(o){return Sn(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function jbe(e,t,n){const r=this;return i;function i(o){return Sn(o)?Mn(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt(h4,t,n)(o)}}function Fbe(e){e.exit("blockQuote")}const f4={name:"characterEscape",tokenize:$be};function $be(e,t,n){return r;function r(s){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(s),e.exit("escapeMarker"),i}function i(s){return Tbe(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const p4={name:"characterReference",tokenize:Hbe};function Hbe(e,t,n){const r=this;let i=0,s,o;return l;function l(p){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),u}function u(p){return p===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(p),e.exit("characterReferenceMarkerNumeric"),d):(e.enter("characterReferenceValue"),s=31,o=xi,h(p))}function d(p){return p===88||p===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(p),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,o=kbe,h):(e.enter("characterReferenceValue"),s=7,o=tx,h(p))}function h(p){if(p===59&&i){const y=e.exit("characterReferenceValue");return o===xi&&!AE(r.sliceSerialize(y))?n(p):(e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(p)&&i++<s?(e.consume(p),h):n(p)}}const RO={partial:!0,tokenize:Wbe},AO={concrete:!0,name:"codeFenced",tokenize:Ube};function Ube(e,t,n){const r=this,i={partial:!0,tokenize:I};let s=0,o=0,l;return u;function u(T){return d(T)}function d(T){const H=r.events[r.events.length-1];return s=H&&H[1].type==="linePrefix"?H[2].sliceSerialize(H[1],!0).length:0,l=T,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),h(T)}function h(T){return T===l?(o++,e.consume(T),h):o<3?n(T):(e.exit("codeFencedFenceSequence"),Sn(T)?Mn(e,p,"whitespace")(T):p(T))}function p(T){return T===null||Ft(T)?(e.exit("codeFencedFence"),r.interrupt?t(T):e.check(RO,w,A)(T)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),y(T))}function y(T){return T===null||Ft(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(T)):Sn(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Mn(e,v,"whitespace")(T)):T===96&&T===l?n(T):(e.consume(T),y)}function v(T){return T===null||Ft(T)?p(T):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),_(T))}function _(T){return T===null||Ft(T)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(T)):T===96&&T===l?n(T):(e.consume(T),_)}function w(T){return e.attempt(i,A,x)(T)}function x(T){return e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),E}function E(T){return s>0&&Sn(T)?Mn(e,k,"linePrefix",s+1)(T):k(T)}function k(T){return T===null||Ft(T)?e.check(RO,w,A)(T):(e.enter("codeFlowValue"),R(T))}function R(T){return T===null||Ft(T)?(e.exit("codeFlowValue"),k(T)):(e.consume(T),R)}function A(T){return e.exit("codeFenced"),t(T)}function I(T,H,D){let W=0;return U;function U(L){return T.enter("lineEnding"),T.consume(L),T.exit("lineEnding"),F}function F(L){return T.enter("codeFencedFence"),Sn(L)?Mn(T,O,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):O(L)}function O(L){return L===l?(T.enter("codeFencedFenceSequence"),M(L)):D(L)}function M(L){return L===l?(W++,T.consume(L),M):W>=o?(T.exit("codeFencedFenceSequence"),Sn(L)?Mn(T,B,"whitespace")(L):B(L)):D(L)}function B(L){return L===null||Ft(L)?(T.exit("codeFencedFence"),H(L)):D(L)}}}function Wbe(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const Ww={name:"codeIndented",tokenize:Vbe},qbe={partial:!0,tokenize:Ybe};function Vbe(e,t,n){const r=this;return i;function i(d){return e.enter("codeIndented"),Mn(e,s,"linePrefix",5)(d)}function s(d){const h=r.events[r.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?o(d):n(d)}function o(d){return d===null?u(d):Ft(d)?e.attempt(qbe,o,u)(d):(e.enter("codeFlowValue"),l(d))}function l(d){return d===null||Ft(d)?(e.exit("codeFlowValue"),o(d)):(e.consume(d),l)}function u(d){return e.exit("codeIndented"),t(d)}}function Ybe(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):Ft(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):Mn(e,s,"linePrefix",5)(o)}function s(o){const l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(o):Ft(o)?i(o):n(o)}}const Kbe={name:"codeText",previous:Xbe,resolve:Gbe,tokenize:Zbe};function Gbe(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Xbe(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Zbe(e,t,n){let r=0,i,s;return o;function o(p){return e.enter("codeText"),e.enter("codeTextSequence"),l(p)}function l(p){return p===96?(e.consume(p),r++,l):(e.exit("codeTextSequence"),u(p))}function u(p){return p===null?n(p):p===32?(e.enter("space"),e.consume(p),e.exit("space"),u):p===96?(s=e.enter("codeTextSequence"),i=0,h(p)):Ft(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),u):(e.enter("codeTextData"),d(p))}function d(p){return p===null||p===32||p===96||Ft(p)?(e.exit("codeTextData"),u(p)):(e.consume(p),d)}function h(p){return p===96?(e.consume(p),i++,h):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(p)):(s.type="codeTextData",d(p))}}class Qbe{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&kh(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),kh(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),kh(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);kh(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);kh(this.left,n.reverse())}}}function kh(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function m4(e){const t={};let n=-1,r,i,s,o,l,u,d;const h=new Qbe(e);for(;++n<h.length;){for(;n in t;)n=t[n];if(r=h.get(n),n&&r[1].type==="chunkFlow"&&h.get(n-1)[1].type==="listItemPrefix"&&(u=r[1]._tokenizer.events,s=0,s<u.length&&u[s][1].type==="lineEndingBlank"&&(s+=2),s<u.length&&u[s][1].type==="content"))for(;++s<u.length&&u[s][1].type!=="content";)u[s][1].type==="chunkText"&&(u[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,Jbe(h,n)),n=t[n],d=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(o=h.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(h.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...h.get(i)[1].start},l=h.slice(i,n),l.unshift(r),h.splice(i,n-i+1,l))}}return us(e,0,Number.POSITIVE_INFINITY,h.slice(0)),!d}function Jbe(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const l=o.events,u=[],d={};let h,p,y=-1,v=n,_=0,w=0;const x=[w];for(;v;){for(;e.get(++i)[1]!==v;);s.push(i),v._tokenizer||(h=r.sliceStream(v),v.next||h.push(null),p&&o.defineSkip(v.start),v._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(h),v._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),p=v,v=v.next}for(v=n;++y<l.length;)l[y][0]==="exit"&&l[y-1][0]==="enter"&&l[y][1].type===l[y-1][1].type&&l[y][1].start.line!==l[y][1].end.line&&(w=y+1,x.push(w),v._tokenizer=void 0,v.previous=void 0,v=v.next);for(o.events=[],v?(v._tokenizer=void 0,v.previous=void 0):x.pop(),y=x.length;y--;){const E=l.slice(x[y],x[y+1]),k=s.pop();u.push([k,k+E.length-1]),e.splice(k,2,E)}for(u.reverse(),y=-1;++y<u.length;)d[_+u[y][0]]=_+u[y][1],_+=u[y][1]-u[y][0]-1;return d}const e_e={resolve:n_e,tokenize:r_e},t_e={partial:!0,tokenize:i_e};function n_e(e){return m4(e),e}function r_e(e,t){let n;return r;function r(l){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(l)}function i(l){return l===null?s(l):Ft(l)?e.check(t_e,o,s)(l):(e.consume(l),i)}function s(l){return e.exit("chunkContent"),e.exit("content"),t(l)}function o(l){return e.consume(l),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function i_e(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),Mn(e,s,"linePrefix")}function s(o){if(o===null||Ft(o))return n(o);const l=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function g4(e,t,n,r,i,s,o,l,u){const d=u||Number.POSITIVE_INFINITY;let h=0;return p;function p(E){return E===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(E),e.exit(s),y):E===null||E===32||E===41||cv(E)?n(E):(e.enter(r),e.enter(o),e.enter(l),e.enter("chunkString",{contentType:"string"}),w(E))}function y(E){return E===62?(e.enter(s),e.consume(E),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),v(E))}function v(E){return E===62?(e.exit("chunkString"),e.exit(l),y(E)):E===null||E===60||Ft(E)?n(E):(e.consume(E),E===92?_:v)}function _(E){return E===60||E===62||E===92?(e.consume(E),v):v(E)}function w(E){return!h&&(E===null||E===41||Gn(E))?(e.exit("chunkString"),e.exit(l),e.exit(o),e.exit(r),t(E)):h<d&&E===40?(e.consume(E),h++,w):E===41?(e.consume(E),h--,w):E===null||E===32||E===40||cv(E)?n(E):(e.consume(E),E===92?x:w)}function x(E){return E===40||E===41||E===92?(e.consume(E),w):w(E)}}function v4(e,t,n,r,i,s){const o=this;let l=0,u;return d;function d(v){return e.enter(r),e.enter(i),e.consume(v),e.exit(i),e.enter(s),h}function h(v){return l>999||v===null||v===91||v===93&&!u||v===94&&!l&&"_hiddenFootnoteSupport"in o.parser.constructs?n(v):v===93?(e.exit(s),e.enter(i),e.consume(v),e.exit(i),e.exit(r),t):Ft(v)?(e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),h):(e.enter("chunkString",{contentType:"string"}),p(v))}function p(v){return v===null||v===91||v===93||Ft(v)||l++>999?(e.exit("chunkString"),h(v)):(e.consume(v),u||(u=!Sn(v)),v===92?y:p)}function y(v){return v===91||v===92||v===93?(e.consume(v),l++,p):p(v)}}function y4(e,t,n,r,i,s){let o;return l;function l(y){return y===34||y===39||y===40?(e.enter(r),e.enter(i),e.consume(y),e.exit(i),o=y===40?41:y,u):n(y)}function u(y){return y===o?(e.enter(i),e.consume(y),e.exit(i),e.exit(r),t):(e.enter(s),d(y))}function d(y){return y===o?(e.exit(s),u(o)):y===null?n(y):Ft(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),Mn(e,d,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),h(y))}function h(y){return y===o||y===null||Ft(y)?(e.exit("chunkString"),d(y)):(e.consume(y),y===92?p:h)}function p(y){return y===o||y===92?(e.consume(y),h):h(y)}}function nf(e,t){let n;return r;function r(i){return Ft(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):Sn(i)?Mn(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const s_e={name:"definition",tokenize:a_e},o_e={partial:!0,tokenize:l_e};function a_e(e,t,n){const r=this;let i;return s;function s(v){return e.enter("definition"),o(v)}function o(v){return v4.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(v)}function l(v){return i=Ks(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),v===58?(e.enter("definitionMarker"),e.consume(v),e.exit("definitionMarker"),u):n(v)}function u(v){return Gn(v)?nf(e,d)(v):d(v)}function d(v){return g4(e,h,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(v)}function h(v){return e.attempt(o_e,p,p)(v)}function p(v){return Sn(v)?Mn(e,y,"whitespace")(v):y(v)}function y(v){return v===null||Ft(v)?(e.exit("definition"),r.parser.defined.push(i),t(v)):n(v)}}function l_e(e,t,n){return r;function r(l){return Gn(l)?nf(e,i)(l):n(l)}function i(l){return y4(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function s(l){return Sn(l)?Mn(e,o,"whitespace")(l):o(l)}function o(l){return l===null||Ft(l)?t(l):n(l)}}const c_e={name:"hardBreakEscape",tokenize:u_e};function u_e(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return Ft(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const d_e={name:"headingAtx",resolve:h_e,tokenize:f_e};function h_e(e,t){let n=e.length-2,r=3,i,s;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},us(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function f_e(e,t,n){let r=0;return i;function i(h){return e.enter("atxHeading"),s(h)}function s(h){return e.enter("atxHeadingSequence"),o(h)}function o(h){return h===35&&r++<6?(e.consume(h),o):h===null||Gn(h)?(e.exit("atxHeadingSequence"),l(h)):n(h)}function l(h){return h===35?(e.enter("atxHeadingSequence"),u(h)):h===null||Ft(h)?(e.exit("atxHeading"),t(h)):Sn(h)?Mn(e,l,"whitespace")(h):(e.enter("atxHeadingText"),d(h))}function u(h){return h===35?(e.consume(h),u):(e.exit("atxHeadingSequence"),l(h))}function d(h){return h===null||h===35||Gn(h)?(e.exit("atxHeadingText"),l(h)):(e.consume(h),d)}}const p_e=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],NO=["pre","script","style","textarea"],m_e={concrete:!0,name:"htmlFlow",resolveTo:y_e,tokenize:b_e},g_e={partial:!0,tokenize:w_e},v_e={partial:!0,tokenize:__e};function y_e(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function b_e(e,t,n){const r=this;let i,s,o,l,u;return d;function d(z){return h(z)}function h(z){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(z),p}function p(z){return z===33?(e.consume(z),y):z===47?(e.consume(z),s=!0,w):z===63?(e.consume(z),i=3,r.interrupt?t:P):Di(z)?(e.consume(z),o=String.fromCharCode(z),x):n(z)}function y(z){return z===45?(e.consume(z),i=2,v):z===91?(e.consume(z),i=5,l=0,_):Di(z)?(e.consume(z),i=4,r.interrupt?t:P):n(z)}function v(z){return z===45?(e.consume(z),r.interrupt?t:P):n(z)}function _(z){const X="CDATA[";return z===X.charCodeAt(l++)?(e.consume(z),l===X.length?r.interrupt?t:O:_):n(z)}function w(z){return Di(z)?(e.consume(z),o=String.fromCharCode(z),x):n(z)}function x(z){if(z===null||z===47||z===62||Gn(z)){const X=z===47,ee=o.toLowerCase();return!X&&!s&&NO.includes(ee)?(i=1,r.interrupt?t(z):O(z)):p_e.includes(o.toLowerCase())?(i=6,X?(e.consume(z),E):r.interrupt?t(z):O(z)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(z):s?k(z):R(z))}return z===45||xi(z)?(e.consume(z),o+=String.fromCharCode(z),x):n(z)}function E(z){return z===62?(e.consume(z),r.interrupt?t:O):n(z)}function k(z){return Sn(z)?(e.consume(z),k):U(z)}function R(z){return z===47?(e.consume(z),U):z===58||z===95||Di(z)?(e.consume(z),A):Sn(z)?(e.consume(z),R):U(z)}function A(z){return z===45||z===46||z===58||z===95||xi(z)?(e.consume(z),A):I(z)}function I(z){return z===61?(e.consume(z),T):Sn(z)?(e.consume(z),I):R(z)}function T(z){return z===null||z===60||z===61||z===62||z===96?n(z):z===34||z===39?(e.consume(z),u=z,H):Sn(z)?(e.consume(z),T):D(z)}function H(z){return z===u?(e.consume(z),u=null,W):z===null||Ft(z)?n(z):(e.consume(z),H)}function D(z){return z===null||z===34||z===39||z===47||z===60||z===61||z===62||z===96||Gn(z)?I(z):(e.consume(z),D)}function W(z){return z===47||z===62||Sn(z)?R(z):n(z)}function U(z){return z===62?(e.consume(z),F):n(z)}function F(z){return z===null||Ft(z)?O(z):Sn(z)?(e.consume(z),F):n(z)}function O(z){return z===45&&i===2?(e.consume(z),N):z===60&&i===1?(e.consume(z),V):z===62&&i===4?(e.consume(z),q):z===63&&i===3?(e.consume(z),P):z===93&&i===5?(e.consume(z),$):Ft(z)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(g_e,K,M)(z)):z===null||Ft(z)?(e.exit("htmlFlowData"),M(z)):(e.consume(z),O)}function M(z){return e.check(v_e,B,K)(z)}function B(z){return e.enter("lineEnding"),e.consume(z),e.exit("lineEnding"),L}function L(z){return z===null||Ft(z)?M(z):(e.enter("htmlFlowData"),O(z))}function N(z){return z===45?(e.consume(z),P):O(z)}function V(z){return z===47?(e.consume(z),o="",Y):O(z)}function Y(z){if(z===62){const X=o.toLowerCase();return NO.includes(X)?(e.consume(z),q):O(z)}return Di(z)&&o.length<8?(e.consume(z),o+=String.fromCharCode(z),Y):O(z)}function $(z){return z===93?(e.consume(z),P):O(z)}function P(z){return z===62?(e.consume(z),q):z===45&&i===2?(e.consume(z),P):O(z)}function q(z){return z===null||Ft(z)?(e.exit("htmlFlowData"),K(z)):(e.consume(z),q)}function K(z){return e.exit("htmlFlow"),t(z)}}function __e(e,t,n){const r=this;return i;function i(o){return Ft(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s):n(o)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function w_e(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(rp,t,n)}}const S_e={name:"htmlText",tokenize:x_e};function x_e(e,t,n){const r=this;let i,s,o;return l;function l(P){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(P),u}function u(P){return P===33?(e.consume(P),d):P===47?(e.consume(P),I):P===63?(e.consume(P),R):Di(P)?(e.consume(P),D):n(P)}function d(P){return P===45?(e.consume(P),h):P===91?(e.consume(P),s=0,_):Di(P)?(e.consume(P),k):n(P)}function h(P){return P===45?(e.consume(P),v):n(P)}function p(P){return P===null?n(P):P===45?(e.consume(P),y):Ft(P)?(o=p,V(P)):(e.consume(P),p)}function y(P){return P===45?(e.consume(P),v):p(P)}function v(P){return P===62?N(P):P===45?y(P):p(P)}function _(P){const q="CDATA[";return P===q.charCodeAt(s++)?(e.consume(P),s===q.length?w:_):n(P)}function w(P){return P===null?n(P):P===93?(e.consume(P),x):Ft(P)?(o=w,V(P)):(e.consume(P),w)}function x(P){return P===93?(e.consume(P),E):w(P)}function E(P){return P===62?N(P):P===93?(e.consume(P),E):w(P)}function k(P){return P===null||P===62?N(P):Ft(P)?(o=k,V(P)):(e.consume(P),k)}function R(P){return P===null?n(P):P===63?(e.consume(P),A):Ft(P)?(o=R,V(P)):(e.consume(P),R)}function A(P){return P===62?N(P):R(P)}function I(P){return Di(P)?(e.consume(P),T):n(P)}function T(P){return P===45||xi(P)?(e.consume(P),T):H(P)}function H(P){return Ft(P)?(o=H,V(P)):Sn(P)?(e.consume(P),H):N(P)}function D(P){return P===45||xi(P)?(e.consume(P),D):P===47||P===62||Gn(P)?W(P):n(P)}function W(P){return P===47?(e.consume(P),N):P===58||P===95||Di(P)?(e.consume(P),U):Ft(P)?(o=W,V(P)):Sn(P)?(e.consume(P),W):N(P)}function U(P){return P===45||P===46||P===58||P===95||xi(P)?(e.consume(P),U):F(P)}function F(P){return P===61?(e.consume(P),O):Ft(P)?(o=F,V(P)):Sn(P)?(e.consume(P),F):W(P)}function O(P){return P===null||P===60||P===61||P===62||P===96?n(P):P===34||P===39?(e.consume(P),i=P,M):Ft(P)?(o=O,V(P)):Sn(P)?(e.consume(P),O):(e.consume(P),B)}function M(P){return P===i?(e.consume(P),i=void 0,L):P===null?n(P):Ft(P)?(o=M,V(P)):(e.consume(P),M)}function B(P){return P===null||P===34||P===39||P===60||P===61||P===96?n(P):P===47||P===62||Gn(P)?W(P):(e.consume(P),B)}function L(P){return P===47||P===62||Gn(P)?W(P):n(P)}function N(P){return P===62?(e.consume(P),e.exit("htmlTextData"),e.exit("htmlText"),t):n(P)}function V(P){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),Y}function Y(P){return Sn(P)?Mn(e,$,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):$(P)}function $(P){return e.enter("htmlTextData"),o(P)}}const NE={name:"labelEnd",resolveAll:T_e,resolveTo:R_e,tokenize:A_e},E_e={tokenize:N_e},C_e={tokenize:M_e},k_e={tokenize:O_e};function T_e(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&us(e,0,e.length,n),e}function R_e(e,t){let n=e.length,r=0,i,s,o,l;for(;n--;)if(i=e[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(o){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(o=n);const u={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},d={type:"label",start:{...e[s][1].start},end:{...e[o][1].end}},h={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[o-2][1].start}};return l=[["enter",u,t],["enter",d,t]],l=Ts(l,e.slice(s+1,s+r+3)),l=Ts(l,[["enter",h,t]]),l=Ts(l,cy(t.parser.constructs.insideSpan.null,e.slice(s+r+4,o-3),t)),l=Ts(l,[["exit",h,t],e[o-2],e[o-1],["exit",d,t]]),l=Ts(l,e.slice(o+1)),l=Ts(l,[["exit",u,t]]),us(e,s,e.length,l),e}function A_e(e,t,n){const r=this;let i=r.events.length,s,o;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return l;function l(y){return s?s._inactive?p(y):(o=r.parser.defined.includes(Ks(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(y),e.exit("labelMarker"),e.exit("labelEnd"),u):n(y)}function u(y){return y===40?e.attempt(E_e,h,o?h:p)(y):y===91?e.attempt(C_e,h,o?d:p)(y):o?h(y):p(y)}function d(y){return e.attempt(k_e,h,p)(y)}function h(y){return t(y)}function p(y){return s._balanced=!0,n(y)}}function N_e(e,t,n){return r;function r(p){return e.enter("resource"),e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),i}function i(p){return Gn(p)?nf(e,s)(p):s(p)}function s(p){return p===41?h(p):g4(e,o,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function o(p){return Gn(p)?nf(e,u)(p):h(p)}function l(p){return n(p)}function u(p){return p===34||p===39||p===40?y4(e,d,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):h(p)}function d(p){return Gn(p)?nf(e,h)(p):h(p)}function h(p){return p===41?(e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),e.exit("resource"),t):n(p)}}function M_e(e,t,n){const r=this;return i;function i(l){return v4.call(r,e,s,o,"reference","referenceMarker","referenceString")(l)}function s(l){return r.parser.defined.includes(Ks(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function o(l){return n(l)}}function O_e(e,t,n){return r;function r(s){return e.enter("reference"),e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),i}function i(s){return s===93?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),t):n(s)}}const D_e={name:"labelStartImage",resolveAll:NE.resolveAll,tokenize:P_e};function P_e(e,t,n){const r=this;return i;function i(l){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(l),e.exit("labelImageMarker"),s}function s(l){return l===91?(e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelImage"),o):n(l)}function o(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(l):t(l)}}const L_e={name:"labelStartLink",resolveAll:NE.resolveAll,tokenize:I_e};function I_e(e,t,n){const r=this;return i;function i(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),s}function s(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const qw={name:"lineEnding",tokenize:z_e};function z_e(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Mn(e,t,"linePrefix")}}const Lg={name:"thematicBreak",tokenize:B_e};function B_e(e,t,n){let r=0,i;return s;function s(d){return e.enter("thematicBreak"),o(d)}function o(d){return i=d,l(d)}function l(d){return d===i?(e.enter("thematicBreakSequence"),u(d)):r>=3&&(d===null||Ft(d))?(e.exit("thematicBreak"),t(d)):n(d)}function u(d){return d===i?(e.consume(d),r++,u):(e.exit("thematicBreakSequence"),Sn(d)?Mn(e,l,"whitespace")(d):l(d))}}const Vi={continuation:{tokenize:H_e},exit:W_e,name:"list",tokenize:$_e},j_e={partial:!0,tokenize:q_e},F_e={partial:!0,tokenize:U_e};function $_e(e,t,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return l;function l(v){const _=r.containerState.type||(v===42||v===43||v===45?"listUnordered":"listOrdered");if(_==="listUnordered"?!r.containerState.marker||v===r.containerState.marker:tx(v)){if(r.containerState.type||(r.containerState.type=_,e.enter(_,{_container:!0})),_==="listUnordered")return e.enter("listItemPrefix"),v===42||v===45?e.check(Lg,n,d)(v):d(v);if(!r.interrupt||v===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),u(v)}return n(v)}function u(v){return tx(v)&&++o<10?(e.consume(v),u):(!r.interrupt||o<2)&&(r.containerState.marker?v===r.containerState.marker:v===41||v===46)?(e.exit("listItemValue"),d(v)):n(v)}function d(v){return e.enter("listItemMarker"),e.consume(v),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||v,e.check(rp,r.interrupt?n:h,e.attempt(j_e,y,p))}function h(v){return r.containerState.initialBlankLine=!0,s++,y(v)}function p(v){return Sn(v)?(e.enter("listItemPrefixWhitespace"),e.consume(v),e.exit("listItemPrefixWhitespace"),y):n(v)}function y(v){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(v)}}function H_e(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(rp,i,s);function i(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Mn(e,t,"listItemIndent",r.containerState.size+1)(l)}function s(l){return r.containerState.furtherBlankLines||!Sn(l)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(l)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(F_e,t,o)(l))}function o(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,Mn(e,e.attempt(Vi,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function U_e(e,t,n){const r=this;return Mn(e,i,"listItemIndent",r.containerState.size+1);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(s):n(s)}}function W_e(e){e.exit(this.containerState.type)}function q_e(e,t,n){const r=this;return Mn(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const o=r.events[r.events.length-1];return!Sn(s)&&o&&o[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const MO={name:"setextUnderline",resolveTo:V_e,tokenize:Y_e};function V_e(e,t){let n=e.length,r,i,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",o,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function Y_e(e,t,n){const r=this;let i;return s;function s(d){let h=r.events.length,p;for(;h--;)if(r.events[h][1].type!=="lineEnding"&&r.events[h][1].type!=="linePrefix"&&r.events[h][1].type!=="content"){p=r.events[h][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||p)?(e.enter("setextHeadingLine"),i=d,o(d)):n(d)}function o(d){return e.enter("setextHeadingLineSequence"),l(d)}function l(d){return d===i?(e.consume(d),l):(e.exit("setextHeadingLineSequence"),Sn(d)?Mn(e,u,"lineSuffix")(d):u(d))}function u(d){return d===null||Ft(d)?(e.exit("setextHeadingLine"),t(d)):n(d)}}const K_e={tokenize:G_e};function G_e(e){const t=this,n=e.attempt(rp,r,e.attempt(this.parser.constructs.flowInitial,i,Mn(e,e.attempt(this.parser.constructs.flow,i,e.attempt(e_e,i)),"linePrefix")));return n;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const X_e={resolveAll:_4()},Z_e=b4("string"),Q_e=b4("text");function b4(e){return{resolveAll:_4(e==="text"?J_e:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,o,l);return o;function o(h){return d(h)?s(h):l(h)}function l(h){if(h===null){n.consume(h);return}return n.enter("data"),n.consume(h),u}function u(h){return d(h)?(n.exit("data"),s(h)):(n.consume(h),u)}function d(h){if(h===null)return!0;const p=i[h];let y=-1;if(p)for(;++y<p.length;){const v=p[y];if(!v.previous||v.previous.call(r,r.previous))return!0}return!1}}}function _4(e){return t;function t(n,r){let i=-1,s;for(;++i<=n.length;)s===void 0?n[i]&&n[i][1].type==="data"&&(s=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==s+2&&(n[s][1].end=n[i-1][1].end,n.splice(s+2,i-s-2),i=s+2),s=void 0);return e?e(n,r):n}}function J_e(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let s=i.length,o=-1,l=0,u;for(;s--;){const d=i[s];if(typeof d=="string"){for(o=d.length;d.charCodeAt(o-1)===32;)l++,o--;if(o)break;o=-1}else if(d===-2)u=!0,l++;else if(d!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const d={type:n===e.length||u||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?o:r.start._bufferIndex+o,_index:r.start._index+s,line:r.end.line,column:r.end.column-l,offset:r.end.offset-l},end:{...r.end}};r.end={...d.start},r.start.offset===r.end.offset?Object.assign(r,d):(e.splice(n,0,["enter",d,t],["exit",d,t]),n+=2)}n++}return e}const ewe={42:Vi,43:Vi,45:Vi,48:Vi,49:Vi,50:Vi,51:Vi,52:Vi,53:Vi,54:Vi,55:Vi,56:Vi,57:Vi,62:h4},twe={91:s_e},nwe={[-2]:Ww,[-1]:Ww,32:Ww},rwe={35:d_e,42:Lg,45:[MO,Lg],60:m_e,61:MO,95:Lg,96:AO,126:AO},iwe={38:p4,92:f4},swe={[-5]:qw,[-4]:qw,[-3]:qw,33:D_e,38:p4,42:nx,60:[Lbe,S_e],91:L_e,92:[c_e,f4],93:NE,95:nx,96:Kbe},owe={null:[nx,X_e]},awe={null:[42,95]},lwe={null:[]},cwe=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:awe,contentInitial:twe,disable:lwe,document:ewe,flow:rwe,flowInitial:nwe,insideSpan:owe,string:iwe,text:swe},Symbol.toStringTag,{value:"Module"}));function uwe(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let o=[],l=[];const u={attempt:H(I),check:H(T),consume:k,enter:R,exit:A,interrupt:H(T,{interrupt:!0})},d={code:null,containerState:{},defineSkip:w,events:[],now:_,parser:e,previous:null,sliceSerialize:y,sliceStream:v,write:p};let h=t.tokenize.call(d,u);return t.resolveAll&&s.push(t),d;function p(F){return o=Ts(o,F),x(),o[o.length-1]!==null?[]:(D(t,0),d.events=cy(s,d.events,d),d.events)}function y(F,O){return hwe(v(F),O)}function v(F){return dwe(o,F)}function _(){const{_bufferIndex:F,_index:O,line:M,column:B,offset:L}=r;return{_bufferIndex:F,_index:O,line:M,column:B,offset:L}}function w(F){i[F.line]=F.column,U()}function x(){let F;for(;r._index<o.length;){const O=o[r._index];if(typeof O=="string")for(F=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===F&&r._bufferIndex<O.length;)E(O.charCodeAt(r._bufferIndex));else E(O)}}function E(F){h=h(F)}function k(F){Ft(F)?(r.line++,r.column=1,r.offset+=F===-3?2:1,U()):F!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),d.previous=F}function R(F,O){const M=O||{};return M.type=F,M.start=_(),d.events.push(["enter",M,d]),l.push(M),M}function A(F){const O=l.pop();return O.end=_(),d.events.push(["exit",O,d]),O}function I(F,O){D(F,O.from)}function T(F,O){O.restore()}function H(F,O){return M;function M(B,L,N){let V,Y,$,P;return Array.isArray(B)?K(B):"tokenize"in B?K([B]):q(B);function q(te){return Q;function Q(me){const ve=me!==null&&te[me],Ce=me!==null&&te.null,Me=[...Array.isArray(ve)?ve:ve?[ve]:[],...Array.isArray(Ce)?Ce:Ce?[Ce]:[]];return K(Me)(me)}}function K(te){return V=te,Y=0,te.length===0?N:z(te[Y])}function z(te){return Q;function Q(me){return P=W(),$=te,te.partial||(d.currentConstruct=te),te.name&&d.parser.constructs.disable.null.includes(te.name)?ee():te.tokenize.call(O?Object.assign(Object.create(d),O):d,u,X,ee)(me)}}function X(te){return F($,P),L}function ee(te){return P.restore(),++Y<V.length?z(V[Y]):N}}}function D(F,O){F.resolveAll&&!s.includes(F)&&s.push(F),F.resolve&&us(d.events,O,d.events.length-O,F.resolve(d.events.slice(O),d)),F.resolveTo&&(d.events=F.resolveTo(d.events,d))}function W(){const F=_(),O=d.previous,M=d.currentConstruct,B=d.events.length,L=Array.from(l);return{from:B,restore:N};function N(){r=F,d.previous=O,d.currentConstruct=M,d.events.length=B,l=L,U()}}function U(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function dwe(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let o;if(n===i)o=[e[n].slice(r,s)];else{if(o=e.slice(n,i),r>-1){const l=o[0];typeof l=="string"?o[0]=l.slice(r):o.shift()}s>0&&o.push(e[i].slice(0,s))}return o}function hwe(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let o;if(typeof s=="string")o=s;else switch(s){case-5:{o="\r";break}case-4:{o=`
652
+ `):[]}function Cye(e,t,n){let r=n;for(const i of t)e.push({type:"remove",text:i,oldLineNumber:r,newLineNumber:null}),r+=1}function kye(e,t,n){let r=n;for(const i of t)e.push({type:"add",text:i,oldLineNumber:null,newLineNumber:r}),r+=1}function Tye(e,t){const n=dO(e),r=dO(t);if(n.length===0&&r.length===0)return[];if(n.length*r.length>Eye){const h=[];return Cye(h,n,1),kye(h,r,1),h}const i=Array.from({length:n.length+1},()=>Array(r.length+1).fill(0));for(let h=n.length-1;h>=0;h-=1)for(let p=r.length-1;p>=0;p-=1)i[h][p]=n[h]===r[p]?i[h+1][p+1]+1:Math.max(i[h+1][p],i[h][p+1]);const s=[];let o=0,l=0,u=1,d=1;for(;o<n.length||l<r.length;)o<n.length&&l<r.length&&n[o]===r[l]?(s.push({type:"context",text:n[o],oldLineNumber:u,newLineNumber:d}),o+=1,l+=1,u+=1,d+=1):l>=r.length||o<n.length&&i[o+1][l]>=i[o][l+1]?(s.push({type:"remove",text:n[o],oldLineNumber:u,newLineNumber:null}),o+=1,u+=1):(s.push({type:"add",text:r[l],oldLineNumber:null,newLineNumber:d}),l+=1,d+=1);return s}function hO(e){return e===null?"":String(e)}function Rye(e){return e==="add"?"+":e==="remove"?"-":" "}function Aye(e){return e==="add"?"border-l-[3px] border-l-emerald-500/60 bg-emerald-500/10 text-emerald-950 dark:text-emerald-100":e==="remove"?"border-l-[3px] border-l-red-500/60 bg-red-500/10 text-red-950 dark:text-red-100":"border-l-[3px] border-l-transparent text-foreground"}function Nye({detail:e}){const t=b.useMemo(()=>Tye(e.oldContent,e.newContent),[e.oldContent,e.newContent]),n=t.filter(i=>i.type==="remove").length,r=t.filter(i=>i.type==="add").length;return g.jsxs("section",{"data-slot":"activity-detail","data-kind":"diff",className:"min-w-0",children:[g.jsxs("div",{className:"mb-1 flex min-w-0 items-center gap-2 text-[11px] leading-none text-current/70",children:[g.jsx("span",{className:"min-w-0 truncate",children:e.title}),g.jsxs("span",{"data-slot":"activity-diff-stat",className:"shrink-0 font-mono text-[10px] text-red-600 dark:text-red-300/90",children:["-",n]}),g.jsxs("span",{"data-slot":"activity-diff-stat",className:"shrink-0 font-mono text-[10px] text-emerald-600 dark:text-emerald-300/90",children:["+",r]})]}),g.jsx("div",{"data-slot":"activity-diff-content",className:"max-h-[min(58vh,560px)] min-w-0 overflow-auto rounded border border-current/10 bg-background/90 font-mono text-[11px] leading-relaxed text-foreground",children:t.length>0?t.map((i,s)=>g.jsxs("div",{"data-slot":"activity-diff-row","data-kind":i.type,className:Ye("grid w-full grid-cols-[2.75rem_2.75rem_1.25rem_minmax(0,1fr)]",Aye(i.type)),children:[g.jsx("span",{className:"select-none border-r border-current/10 px-2 text-right tabular-nums text-current/45",children:hO(i.oldLineNumber)}),g.jsx("span",{className:"select-none border-r border-current/10 px-2 text-right tabular-nums text-current/45",children:hO(i.newLineNumber)}),g.jsx("span",{"data-slot":"activity-diff-prefix",className:"select-none px-1 text-center text-current/70","aria-hidden":"true",children:Rye(i.type)}),g.jsx("code",{className:"min-w-0 whitespace-pre-wrap break-words px-2",children:i.text||" "})]},`${i.type}-${i.oldLineNumber??""}-${i.newLineNumber??""}-${s}`)):g.jsx("div",{className:"px-3 py-2 text-muted-foreground",children:"没有文本变更"})})]})}function G4({detail:e}){return xye(e)?g.jsx(Nye,{detail:e}):g.jsxs("section",{"data-slot":"activity-detail","data-kind":"text",className:"min-w-0",children:[g.jsx("div",{className:"mb-1 text-[11px] leading-none text-current/70",children:e.title}),g.jsx("pre",{"data-slot":"activity-detail-content",className:"max-h-[min(55vh,520px)] overflow-auto rounded border border-current/10 bg-background/80 p-2 font-mono text-[11px] leading-relaxed text-foreground whitespace-pre-wrap break-words",children:e.content})]})}function Mye(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Oye=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Dye=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Pye={};function fO(e,t){return(Pye.jsx?Dye:Oye).test(e)}const Lye=/[ \t\n\f\r]/g;function Iye(e){return typeof e=="object"?e.type==="text"?pO(e.value):!1:pO(e)}function pO(e){return e.replace(Lye,"")===""}class np{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}np.prototype.normal={};np.prototype.property={};np.prototype.space=void 0;function X4(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new np(n,r,t)}function ZS(e){return e.toLowerCase()}class Xi{constructor(t,n){this.attribute=n,this.property=t}}Xi.prototype.attribute="";Xi.prototype.booleanish=!1;Xi.prototype.boolean=!1;Xi.prototype.commaOrSpaceSeparated=!1;Xi.prototype.commaSeparated=!1;Xi.prototype.defined=!1;Xi.prototype.mustUseProperty=!1;Xi.prototype.number=!1;Xi.prototype.overloadedBoolean=!1;Xi.prototype.property="";Xi.prototype.spaceSeparated=!1;Xi.prototype.space=void 0;let zye=0;const ln=Tc(),Dr=Tc(),QS=Tc(),it=Tc(),Qn=Tc(),$u=Tc(),os=Tc();function Tc(){return 2**++zye}const JS=Object.freeze(Object.defineProperty({__proto__:null,boolean:ln,booleanish:Dr,commaOrSpaceSeparated:os,commaSeparated:$u,number:it,overloadedBoolean:QS,spaceSeparated:Qn},Symbol.toStringTag,{value:"Module"})),$w=Object.keys(JS);class SE extends Xi{constructor(t,n,r,i){let s=-1;if(super(t,n),mO(this,"space",i),typeof r=="number")for(;++s<$w.length;){const o=$w[s];mO(this,$w[s],(r&JS[o])===JS[o])}}}SE.prototype.defined=!0;function mO(e,t,n){n&&(e[t]=n)}function fd(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new SE(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[ZS(r)]=r,n[ZS(s.attribute)]=r}return new np(t,n,e.space)}const Z4=fd({properties:{ariaActiveDescendant:null,ariaAtomic:Dr,ariaAutoComplete:null,ariaBusy:Dr,ariaChecked:Dr,ariaColCount:it,ariaColIndex:it,ariaColSpan:it,ariaControls:Qn,ariaCurrent:null,ariaDescribedBy:Qn,ariaDetails:null,ariaDisabled:Dr,ariaDropEffect:Qn,ariaErrorMessage:null,ariaExpanded:Dr,ariaFlowTo:Qn,ariaGrabbed:Dr,ariaHasPopup:null,ariaHidden:Dr,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Qn,ariaLevel:it,ariaLive:null,ariaModal:Dr,ariaMultiLine:Dr,ariaMultiSelectable:Dr,ariaOrientation:null,ariaOwns:Qn,ariaPlaceholder:null,ariaPosInSet:it,ariaPressed:Dr,ariaReadOnly:Dr,ariaRelevant:null,ariaRequired:Dr,ariaRoleDescription:Qn,ariaRowCount:it,ariaRowIndex:it,ariaRowSpan:it,ariaSelected:Dr,ariaSetSize:it,ariaSort:null,ariaValueMax:it,ariaValueMin:it,ariaValueNow:it,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Q4(e,t){return t in e?e[t]:t}function J4(e,t){return Q4(e,t.toLowerCase())}const Bye=fd({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:$u,acceptCharset:Qn,accessKey:Qn,action:null,allow:null,allowFullScreen:ln,allowPaymentRequest:ln,allowUserMedia:ln,alt:null,as:null,async:ln,autoCapitalize:null,autoComplete:Qn,autoFocus:ln,autoPlay:ln,blocking:Qn,capture:null,charSet:null,checked:ln,cite:null,className:Qn,cols:it,colSpan:null,content:null,contentEditable:Dr,controls:ln,controlsList:Qn,coords:it|$u,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ln,defer:ln,dir:null,dirName:null,disabled:ln,download:QS,draggable:Dr,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ln,formTarget:null,headers:Qn,height:it,hidden:QS,high:it,href:null,hrefLang:null,htmlFor:Qn,httpEquiv:Qn,id:null,imageSizes:null,imageSrcSet:null,inert:ln,inputMode:null,integrity:null,is:null,isMap:ln,itemId:null,itemProp:Qn,itemRef:Qn,itemScope:ln,itemType:Qn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ln,low:it,manifest:null,max:null,maxLength:it,media:null,method:null,min:null,minLength:it,multiple:ln,muted:ln,name:null,nonce:null,noModule:ln,noValidate:ln,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:ln,optimum:it,pattern:null,ping:Qn,placeholder:null,playsInline:ln,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ln,referrerPolicy:null,rel:Qn,required:ln,reversed:ln,rows:it,rowSpan:it,sandbox:Qn,scope:null,scoped:ln,seamless:ln,selected:ln,shadowRootClonable:ln,shadowRootDelegatesFocus:ln,shadowRootMode:null,shape:null,size:it,sizes:null,slot:null,span:it,spellCheck:Dr,src:null,srcDoc:null,srcLang:null,srcSet:null,start:it,step:null,style:null,tabIndex:it,target:null,title:null,translate:null,type:null,typeMustMatch:ln,useMap:null,value:Dr,width:it,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Qn,axis:null,background:null,bgColor:null,border:it,borderColor:null,bottomMargin:it,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ln,declare:ln,event:null,face:null,frame:null,frameBorder:null,hSpace:it,leftMargin:it,link:null,longDesc:null,lowSrc:null,marginHeight:it,marginWidth:it,noResize:ln,noHref:ln,noShade:ln,noWrap:ln,object:null,profile:null,prompt:null,rev:null,rightMargin:it,rules:null,scheme:null,scrolling:Dr,standby:null,summary:null,text:null,topMargin:it,valueType:null,version:null,vAlign:null,vLink:null,vSpace:it,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:ln,disableRemotePlayback:ln,prefix:null,property:null,results:it,security:null,unselectable:null},space:"html",transform:J4}),jye=fd({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:os,accentHeight:it,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:it,amplitude:it,arabicForm:null,ascent:it,attributeName:null,attributeType:null,azimuth:it,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:it,by:null,calcMode:null,capHeight:it,className:Qn,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:it,diffuseConstant:it,direction:null,display:null,dur:null,divisor:it,dominantBaseline:null,download:ln,dx:null,dy:null,edgeMode:null,editable:null,elevation:it,enableBackground:null,end:null,event:null,exponent:it,externalResourcesRequired:null,fill:null,fillOpacity:it,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:$u,g2:$u,glyphName:$u,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:it,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:it,horizOriginX:it,horizOriginY:it,id:null,ideographic:it,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:it,k:it,k1:it,k2:it,k3:it,k4:it,kernelMatrix:os,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:it,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:it,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:it,overlineThickness:it,paintOrder:null,panose1:null,path:null,pathLength:it,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Qn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:it,pointsAtY:it,pointsAtZ:it,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:os,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:os,rev:os,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:os,requiredFeatures:os,requiredFonts:os,requiredFormats:os,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:it,specularExponent:it,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:it,strikethroughThickness:it,string:null,stroke:null,strokeDashArray:os,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:it,strokeOpacity:it,strokeWidth:null,style:null,surfaceScale:it,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:os,tabIndex:it,tableValues:null,target:null,targetX:it,targetY:it,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:os,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:it,underlineThickness:it,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:it,values:null,vAlphabetic:it,vMathematical:it,vectorEffect:null,vHanging:it,vIdeographic:it,version:null,vertAdvY:it,vertOriginX:it,vertOriginY:it,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:it,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Q4}),ej=fd({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),tj=fd({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:J4}),nj=fd({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Fye={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},$ye=/[A-Z]/g,gO=/-[a-z]/g,Hye=/^data[-\w.:]+$/i;function Uye(e,t){const n=ZS(t);let r=t,i=Xi;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Hye.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(gO,qye);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!gO.test(s)){let o=s.replace($ye,Wye);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=SE}return new i(r,t)}function Wye(e){return"-"+e.toLowerCase()}function qye(e){return e.charAt(1).toUpperCase()}const Vye=X4([Z4,Bye,ej,tj,nj],"html"),xE=X4([Z4,jye,ej,tj,nj],"svg");function Yye(e){return e.join(" ").trim()}var bu={},Hw,vO;function Kye(){if(vO)return Hw;vO=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,l=/^\s+|\s+$/g,u=`
653
+ `,d="/",h="*",p="",y="comment",v="declaration";function _(x,E){if(typeof x!="string")throw new TypeError("First argument must be a string");if(!x)return[];E=E||{};var k=1,R=1;function A(B){var L=B.match(t);L&&(k+=L.length);var N=B.lastIndexOf(u);R=~N?B.length-N:R+B.length}function I(){var B={line:k,column:R};return function(L){return L.position=new T(B),W(),L}}function T(B){this.start=B,this.end={line:k,column:R},this.source=E.source}T.prototype.content=x;function H(B){var L=new Error(E.source+":"+k+":"+R+": "+B);if(L.reason=B,L.filename=E.source,L.line=k,L.column=R,L.source=x,!E.silent)throw L}function D(B){var L=B.exec(x);if(L){var N=L[0];return A(N),x=x.slice(N.length),L}}function W(){D(n)}function U(B){var L;for(B=B||[];L=F();)L!==!1&&B.push(L);return B}function F(){var B=I();if(!(d!=x.charAt(0)||h!=x.charAt(1))){for(var L=2;p!=x.charAt(L)&&(h!=x.charAt(L)||d!=x.charAt(L+1));)++L;if(L+=2,p===x.charAt(L-1))return H("End of comment missing");var N=x.slice(2,L-2);return R+=2,A(N),x=x.slice(L),R+=2,B({type:y,comment:N})}}function O(){var B=I(),L=D(r);if(L){if(F(),!D(i))return H("property missing ':'");var N=D(s),V=B({type:v,property:w(L[0].replace(e,p)),value:N?w(N[0].replace(e,p)):p});return D(o),V}}function M(){var B=[];U(B);for(var L;L=O();)L!==!1&&(B.push(L),U(B));return B}return W(),M()}function w(x){return x?x.replace(l,p):p}return Hw=_,Hw}var yO;function Gye(){if(yO)return bu;yO=1;var e=bu&&bu.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(bu,"__esModule",{value:!0}),bu.default=n;const t=e(Kye());function n(r,i){let s=null;if(!r||typeof r!="string")return s;const o=(0,t.default)(r),l=typeof i=="function";return o.forEach(u=>{if(u.type!=="declaration")return;const{property:d,value:h}=u;l?i(d,h,u):h&&(s=s||{},s[d]=h)}),s}return bu}var Eh={},bO;function Xye(){if(bO)return Eh;bO=1,Object.defineProperty(Eh,"__esModule",{value:!0}),Eh.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,s=function(d){return!d||n.test(d)||e.test(d)},o=function(d,h){return h.toUpperCase()},l=function(d,h){return"".concat(h,"-")},u=function(d,h){return h===void 0&&(h={}),s(d)?d:(d=d.toLowerCase(),h.reactCompat?d=d.replace(i,l):d=d.replace(r,l),d.replace(t,o))};return Eh.camelCase=u,Eh}var Ch,_O;function Zye(){if(_O)return Ch;_O=1;var e=Ch&&Ch.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(Gye()),n=Xye();function r(i,s){var o={};return!i||typeof i!="string"||(0,t.default)(i,function(l,u){l&&u&&(o[(0,n.camelCase)(l,s)]=u)}),o}return r.default=r,Ch=r,Ch}var Qye=Zye();const Jye=Af(Qye),rj=ij("end"),EE=ij("start");function ij(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function ebe(e){const t=EE(e),n=rj(e);if(t&&n)return{start:t,end:n}}function tf(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?wO(e.position):"start"in e||"end"in e?wO(e):"line"in e||"column"in e?ex(e):""}function ex(e){return SO(e&&e.line)+":"+SO(e&&e.column)}function wO(e){return ex(e&&e.start)+"-"+ex(e&&e.end)}function SO(e){return e&&typeof e=="number"?e:1}class ki extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},o=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(o=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const u=r.indexOf(":");u===-1?s.ruleId=r:(s.source=r.slice(0,u),s.ruleId=r.slice(u+1))}if(!s.place&&s.ancestors&&s.ancestors){const u=s.ancestors[s.ancestors.length-1];u&&(s.place=u.position)}const l=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=l?l.line:void 0,this.name=tf(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}ki.prototype.file="";ki.prototype.name="";ki.prototype.reason="";ki.prototype.message="";ki.prototype.stack="";ki.prototype.column=void 0;ki.prototype.line=void 0;ki.prototype.ancestors=void 0;ki.prototype.cause=void 0;ki.prototype.fatal=void 0;ki.prototype.place=void 0;ki.prototype.ruleId=void 0;ki.prototype.source=void 0;const CE={}.hasOwnProperty,tbe=new Map,nbe=/[A-Z]/g,rbe=new Set(["table","tbody","thead","tfoot","tr"]),ibe=new Set(["td","th"]),sj="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function sbe(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=fbe(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=hbe(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?xE:Vye,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=oj(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function oj(e,t,n){if(t.type==="element")return obe(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return abe(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return cbe(e,t,n);if(t.type==="mdxjsEsm")return lbe(e,t);if(t.type==="root")return ube(e,t,n);if(t.type==="text")return dbe(e,t)}function obe(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=xE,e.schema=i),e.ancestors.push(t);const s=lj(e,t.tagName,!1),o=pbe(e,t);let l=TE(e,t);return rbe.has(t.tagName)&&(l=l.filter(function(u){return typeof u=="string"?!Iye(u):!0})),aj(e,o,s,t),kE(o,l),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function abe(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}Tf(e,t.position)}function lbe(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Tf(e,t.position)}function cbe(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=xE,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:lj(e,t.name,!0),o=mbe(e,t),l=TE(e,t);return aj(e,o,s,t),kE(o,l),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function ube(e,t,n){const r={};return kE(r,TE(e,t)),e.create(t,e.Fragment,r,n)}function dbe(e,t){return t.value}function aj(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function kE(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function hbe(e,t,n){return r;function r(i,s,o,l){const d=Array.isArray(o.children)?n:t;return l?d(s,o,l):d(s,o)}}function fbe(e,t){return n;function n(r,i,s,o){const l=Array.isArray(s.children),u=EE(r);return t(i,s,o,l,{columnNumber:u?u.column-1:void 0,fileName:e,lineNumber:u?u.line:void 0},void 0)}}function pbe(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&CE.call(t.properties,i)){const s=gbe(e,i,t.properties[i]);if(s){const[o,l]=s;e.tableCellAlignToStyle&&o==="align"&&typeof l=="string"&&ibe.has(t.tagName)?r=l:n[o]=l}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function mbe(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const o=s.expression;o.type;const l=o.properties[0];l.type,Object.assign(n,e.evaluater.evaluateExpression(l.argument))}else Tf(e,t.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const l=r.value.data.estree.body[0];l.type,s=e.evaluater.evaluateExpression(l.expression)}else Tf(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function TE(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:tbe;for(;++r<t.children.length;){const s=t.children[r];let o;if(e.passKeys){const u=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(u){const d=i.get(u)||0;o=u+"-"+d,i.set(u,d+1)}}const l=oj(e,s,o);l!==void 0&&n.push(l)}return n}function gbe(e,t,n){const r=Uye(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Mye(n):Yye(n)),r.property==="style"){let i=typeof n=="object"?n:vbe(e,String(n));return e.stylePropertyNameCase==="css"&&(i=ybe(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?Fye[r.property]||r.property:r.attribute,n]}}function vbe(e,t){try{return Jye(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new ki("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=sj+"#cannot-parse-style-attribute",i}}function lj(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,o;for(;++s<i.length;){const l=fO(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};o=o?{type:"MemberExpression",object:o,property:l,computed:!!(s&&l.type==="Literal"),optional:!1}:l}r=o}else r=fO(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return CE.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);Tf(e)}function Tf(e,t){const n=new ki("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=sj+"#cannot-handle-mdx-estrees-without-createevaluater",n}function ybe(e){const t={};let n;for(n in e)CE.call(e,n)&&(t[bbe(n)]=e[n]);return t}function bbe(e){let t=e.replace(nbe,_be);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function _be(e){return"-"+e.toLowerCase()}const Uw={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},wbe={};function RE(e,t){const n=wbe,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return cj(e,r,i)}function cj(e,t,n){if(Sbe(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return xO(e.children,t,n)}return Array.isArray(e)?xO(e,t,n):""}function xO(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=cj(e[i],t,n);return r.join("")}function Sbe(e){return!!(e&&typeof e=="object")}const EO=document.createElement("i");function AE(e){const t="&"+e+";";EO.innerHTML=t;const n=EO.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function us(e,t,n,r){const i=e.length;let s=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);s<r.length;)o=r.slice(s,s+1e4),o.unshift(t,0),e.splice(...o),s+=1e4,t+=1e4}function Ts(e,t){return e.length>0?(us(e,e.length,0,t),e):t}const CO={}.hasOwnProperty;function uj(e){const t={};let n=-1;for(;++n<e.length;)xbe(t,e[n]);return t}function xbe(e,t){let n;for(n in t){const i=(CO.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let o;if(s)for(o in s){CO.call(i,o)||(i[o]=[]);const l=s[o];Ebe(i[o],Array.isArray(l)?l:l?[l]:[])}}}function Ebe(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);us(e,0,0,r)}function dj(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Ks(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Di=xl(/[A-Za-z]/),xi=xl(/[\dA-Za-z]/),Cbe=xl(/[#-'*+\--9=?A-Z^-~]/);function cv(e){return e!==null&&(e<32||e===127)}const tx=xl(/\d/),kbe=xl(/[\dA-Fa-f]/),Tbe=xl(/[!-/:-@[-`{-~]/);function Ft(e){return e!==null&&e<-2}function Gn(e){return e!==null&&(e<0||e===32)}function Sn(e){return e===-2||e===-1||e===32}const ly=xl(new RegExp("\\p{P}|\\p{S}","u")),fc=xl(/\s/);function xl(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function pd(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let o="";if(s===37&&xi(e.charCodeAt(n+1))&&xi(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(o=String.fromCharCode(s));else if(s>55295&&s<57344){const l=e.charCodeAt(n+1);s<56320&&l>56319&&l<57344?(o=String.fromCharCode(s,l),i=1):o="�"}else o=String.fromCharCode(s);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function Mn(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(u){return Sn(u)?(e.enter(n),l(u)):t(u)}function l(u){return Sn(u)&&s++<i?(e.consume(u),l):(e.exit(n),t(u))}}const Rbe={tokenize:Abe};function Abe(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),Mn(e,t,"linePrefix")}function i(l){return e.enter("paragraph"),s(l)}function s(l){const u=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=u),n=u,o(l)}function o(l){if(l===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(l);return}return Ft(l)?(e.consume(l),e.exit("chunkText"),s):(e.consume(l),o)}}const Nbe={tokenize:Mbe},kO={tokenize:Obe};function Mbe(e){const t=this,n=[];let r=0,i,s,o;return l;function l(R){if(r<n.length){const A=n[r];return t.containerState=A[1],e.attempt(A[0].continuation,u,d)(R)}return d(R)}function u(R){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&k();const A=t.events.length;let I=A,T;for(;I--;)if(t.events[I][0]==="exit"&&t.events[I][1].type==="chunkFlow"){T=t.events[I][1].end;break}E(r);let H=A;for(;H<t.events.length;)t.events[H][1].end={...T},H++;return us(t.events,I+1,0,t.events.slice(A)),t.events.length=H,d(R)}return l(R)}function d(R){if(r===n.length){if(!i)return y(R);if(i.currentConstruct&&i.currentConstruct.concrete)return _(R);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(kO,h,p)(R)}function h(R){return i&&k(),E(r),y(R)}function p(R){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,_(R)}function y(R){return t.containerState={},e.attempt(kO,v,_)(R)}function v(R){return r++,n.push([t.currentConstruct,t.containerState]),y(R)}function _(R){if(R===null){i&&k(),E(0),e.consume(R);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),w(R)}function w(R){if(R===null){x(e.exit("chunkFlow"),!0),E(0),e.consume(R);return}return Ft(R)?(e.consume(R),x(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(R),w)}function x(R,A){const I=t.sliceStream(R);if(A&&I.push(null),R.previous=s,s&&(s.next=R),s=R,i.defineSkip(R.start),i.write(I),t.parser.lazy[R.start.line]){let T=i.events.length;for(;T--;)if(i.events[T][1].start.offset<o&&(!i.events[T][1].end||i.events[T][1].end.offset>o))return;const H=t.events.length;let D=H,W,U;for(;D--;)if(t.events[D][0]==="exit"&&t.events[D][1].type==="chunkFlow"){if(W){U=t.events[D][1].end;break}W=!0}for(E(r),T=H;T<t.events.length;)t.events[T][1].end={...U},T++;us(t.events,D+1,0,t.events.slice(H)),t.events.length=T}}function E(R){let A=n.length;for(;A-- >R;){const I=n[A];t.containerState=I[1],I[0].exit.call(t,e)}n.length=R}function k(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Obe(e,t,n){return Mn(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function ed(e){if(e===null||Gn(e)||fc(e))return 1;if(ly(e))return 2}function cy(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const s=e[i].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const nx={name:"attention",resolveAll:Dbe,tokenize:Pbe};function Dbe(e,t){let n=-1,r,i,s,o,l,u,d,h;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const p={...e[r][1].end},y={...e[n][1].start};TO(p,-u),TO(y,u),o={type:u>1?"strongSequence":"emphasisSequence",start:p,end:{...e[r][1].end}},l={type:u>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:y},s={type:u>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:u>1?"strong":"emphasis",start:{...o.start},end:{...l.end}},e[r][1].end={...o.start},e[n][1].start={...l.end},d=[],e[r][1].end.offset-e[r][1].start.offset&&(d=Ts(d,[["enter",e[r][1],t],["exit",e[r][1],t]])),d=Ts(d,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",s,t]]),d=Ts(d,cy(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),d=Ts(d,[["exit",s,t],["enter",l,t],["exit",l,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(h=2,d=Ts(d,[["enter",e[n][1],t],["exit",e[n][1],t]])):h=0,us(e,r-1,n-r+3,d),n=r+d.length-h-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function Pbe(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=ed(r);let s;return o;function o(u){return s=u,e.enter("attentionSequence"),l(u)}function l(u){if(u===s)return e.consume(u),l;const d=e.exit("attentionSequence"),h=ed(u),p=!h||h===2&&i||n.includes(u),y=!i||i===2&&h||n.includes(r);return d._open=!!(s===42?p:p&&(i||!y)),d._close=!!(s===42?y:y&&(h||!p)),t(u)}}function TO(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Lbe={name:"autolink",tokenize:Ibe};function Ibe(e,t,n){let r=0;return i;function i(v){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(v),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(v){return Di(v)?(e.consume(v),o):v===64?n(v):d(v)}function o(v){return v===43||v===45||v===46||xi(v)?(r=1,l(v)):d(v)}function l(v){return v===58?(e.consume(v),r=0,u):(v===43||v===45||v===46||xi(v))&&r++<32?(e.consume(v),l):(r=0,d(v))}function u(v){return v===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(v),e.exit("autolinkMarker"),e.exit("autolink"),t):v===null||v===32||v===60||cv(v)?n(v):(e.consume(v),u)}function d(v){return v===64?(e.consume(v),h):Cbe(v)?(e.consume(v),d):n(v)}function h(v){return xi(v)?p(v):n(v)}function p(v){return v===46?(e.consume(v),r=0,h):v===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(v),e.exit("autolinkMarker"),e.exit("autolink"),t):y(v)}function y(v){if((v===45||xi(v))&&r++<63){const _=v===45?y:p;return e.consume(v),_}return n(v)}}const rp={partial:!0,tokenize:zbe};function zbe(e,t,n){return r;function r(s){return Sn(s)?Mn(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||Ft(s)?t(s):n(s)}}const hj={continuation:{tokenize:jbe},exit:Fbe,name:"blockQuote",tokenize:Bbe};function Bbe(e,t,n){const r=this;return i;function i(o){if(o===62){const l=r.containerState;return l.open||(e.enter("blockQuote",{_container:!0}),l.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),s}return n(o)}function s(o){return Sn(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function jbe(e,t,n){const r=this;return i;function i(o){return Sn(o)?Mn(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt(hj,t,n)(o)}}function Fbe(e){e.exit("blockQuote")}const fj={name:"characterEscape",tokenize:$be};function $be(e,t,n){return r;function r(s){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(s),e.exit("escapeMarker"),i}function i(s){return Tbe(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const pj={name:"characterReference",tokenize:Hbe};function Hbe(e,t,n){const r=this;let i=0,s,o;return l;function l(p){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),u}function u(p){return p===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(p),e.exit("characterReferenceMarkerNumeric"),d):(e.enter("characterReferenceValue"),s=31,o=xi,h(p))}function d(p){return p===88||p===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(p),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,o=kbe,h):(e.enter("characterReferenceValue"),s=7,o=tx,h(p))}function h(p){if(p===59&&i){const y=e.exit("characterReferenceValue");return o===xi&&!AE(r.sliceSerialize(y))?n(p):(e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(p)&&i++<s?(e.consume(p),h):n(p)}}const RO={partial:!0,tokenize:Wbe},AO={concrete:!0,name:"codeFenced",tokenize:Ube};function Ube(e,t,n){const r=this,i={partial:!0,tokenize:I};let s=0,o=0,l;return u;function u(T){return d(T)}function d(T){const H=r.events[r.events.length-1];return s=H&&H[1].type==="linePrefix"?H[2].sliceSerialize(H[1],!0).length:0,l=T,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),h(T)}function h(T){return T===l?(o++,e.consume(T),h):o<3?n(T):(e.exit("codeFencedFenceSequence"),Sn(T)?Mn(e,p,"whitespace")(T):p(T))}function p(T){return T===null||Ft(T)?(e.exit("codeFencedFence"),r.interrupt?t(T):e.check(RO,w,A)(T)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),y(T))}function y(T){return T===null||Ft(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(T)):Sn(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Mn(e,v,"whitespace")(T)):T===96&&T===l?n(T):(e.consume(T),y)}function v(T){return T===null||Ft(T)?p(T):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),_(T))}function _(T){return T===null||Ft(T)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(T)):T===96&&T===l?n(T):(e.consume(T),_)}function w(T){return e.attempt(i,A,x)(T)}function x(T){return e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),E}function E(T){return s>0&&Sn(T)?Mn(e,k,"linePrefix",s+1)(T):k(T)}function k(T){return T===null||Ft(T)?e.check(RO,w,A)(T):(e.enter("codeFlowValue"),R(T))}function R(T){return T===null||Ft(T)?(e.exit("codeFlowValue"),k(T)):(e.consume(T),R)}function A(T){return e.exit("codeFenced"),t(T)}function I(T,H,D){let W=0;return U;function U(L){return T.enter("lineEnding"),T.consume(L),T.exit("lineEnding"),F}function F(L){return T.enter("codeFencedFence"),Sn(L)?Mn(T,O,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):O(L)}function O(L){return L===l?(T.enter("codeFencedFenceSequence"),M(L)):D(L)}function M(L){return L===l?(W++,T.consume(L),M):W>=o?(T.exit("codeFencedFenceSequence"),Sn(L)?Mn(T,B,"whitespace")(L):B(L)):D(L)}function B(L){return L===null||Ft(L)?(T.exit("codeFencedFence"),H(L)):D(L)}}}function Wbe(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const Ww={name:"codeIndented",tokenize:Vbe},qbe={partial:!0,tokenize:Ybe};function Vbe(e,t,n){const r=this;return i;function i(d){return e.enter("codeIndented"),Mn(e,s,"linePrefix",5)(d)}function s(d){const h=r.events[r.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?o(d):n(d)}function o(d){return d===null?u(d):Ft(d)?e.attempt(qbe,o,u)(d):(e.enter("codeFlowValue"),l(d))}function l(d){return d===null||Ft(d)?(e.exit("codeFlowValue"),o(d)):(e.consume(d),l)}function u(d){return e.exit("codeIndented"),t(d)}}function Ybe(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):Ft(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):Mn(e,s,"linePrefix",5)(o)}function s(o){const l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(o):Ft(o)?i(o):n(o)}}const Kbe={name:"codeText",previous:Xbe,resolve:Gbe,tokenize:Zbe};function Gbe(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Xbe(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Zbe(e,t,n){let r=0,i,s;return o;function o(p){return e.enter("codeText"),e.enter("codeTextSequence"),l(p)}function l(p){return p===96?(e.consume(p),r++,l):(e.exit("codeTextSequence"),u(p))}function u(p){return p===null?n(p):p===32?(e.enter("space"),e.consume(p),e.exit("space"),u):p===96?(s=e.enter("codeTextSequence"),i=0,h(p)):Ft(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),u):(e.enter("codeTextData"),d(p))}function d(p){return p===null||p===32||p===96||Ft(p)?(e.exit("codeTextData"),u(p)):(e.consume(p),d)}function h(p){return p===96?(e.consume(p),i++,h):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(p)):(s.type="codeTextData",d(p))}}class Qbe{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&kh(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),kh(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),kh(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);kh(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);kh(this.left,n.reverse())}}}function kh(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function mj(e){const t={};let n=-1,r,i,s,o,l,u,d;const h=new Qbe(e);for(;++n<h.length;){for(;n in t;)n=t[n];if(r=h.get(n),n&&r[1].type==="chunkFlow"&&h.get(n-1)[1].type==="listItemPrefix"&&(u=r[1]._tokenizer.events,s=0,s<u.length&&u[s][1].type==="lineEndingBlank"&&(s+=2),s<u.length&&u[s][1].type==="content"))for(;++s<u.length&&u[s][1].type!=="content";)u[s][1].type==="chunkText"&&(u[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,Jbe(h,n)),n=t[n],d=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(o=h.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(h.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...h.get(i)[1].start},l=h.slice(i,n),l.unshift(r),h.splice(i,n-i+1,l))}}return us(e,0,Number.POSITIVE_INFINITY,h.slice(0)),!d}function Jbe(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const l=o.events,u=[],d={};let h,p,y=-1,v=n,_=0,w=0;const x=[w];for(;v;){for(;e.get(++i)[1]!==v;);s.push(i),v._tokenizer||(h=r.sliceStream(v),v.next||h.push(null),p&&o.defineSkip(v.start),v._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(h),v._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),p=v,v=v.next}for(v=n;++y<l.length;)l[y][0]==="exit"&&l[y-1][0]==="enter"&&l[y][1].type===l[y-1][1].type&&l[y][1].start.line!==l[y][1].end.line&&(w=y+1,x.push(w),v._tokenizer=void 0,v.previous=void 0,v=v.next);for(o.events=[],v?(v._tokenizer=void 0,v.previous=void 0):x.pop(),y=x.length;y--;){const E=l.slice(x[y],x[y+1]),k=s.pop();u.push([k,k+E.length-1]),e.splice(k,2,E)}for(u.reverse(),y=-1;++y<u.length;)d[_+u[y][0]]=_+u[y][1],_+=u[y][1]-u[y][0]-1;return d}const e_e={resolve:n_e,tokenize:r_e},t_e={partial:!0,tokenize:i_e};function n_e(e){return mj(e),e}function r_e(e,t){let n;return r;function r(l){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(l)}function i(l){return l===null?s(l):Ft(l)?e.check(t_e,o,s)(l):(e.consume(l),i)}function s(l){return e.exit("chunkContent"),e.exit("content"),t(l)}function o(l){return e.consume(l),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function i_e(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),Mn(e,s,"linePrefix")}function s(o){if(o===null||Ft(o))return n(o);const l=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function gj(e,t,n,r,i,s,o,l,u){const d=u||Number.POSITIVE_INFINITY;let h=0;return p;function p(E){return E===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(E),e.exit(s),y):E===null||E===32||E===41||cv(E)?n(E):(e.enter(r),e.enter(o),e.enter(l),e.enter("chunkString",{contentType:"string"}),w(E))}function y(E){return E===62?(e.enter(s),e.consume(E),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),v(E))}function v(E){return E===62?(e.exit("chunkString"),e.exit(l),y(E)):E===null||E===60||Ft(E)?n(E):(e.consume(E),E===92?_:v)}function _(E){return E===60||E===62||E===92?(e.consume(E),v):v(E)}function w(E){return!h&&(E===null||E===41||Gn(E))?(e.exit("chunkString"),e.exit(l),e.exit(o),e.exit(r),t(E)):h<d&&E===40?(e.consume(E),h++,w):E===41?(e.consume(E),h--,w):E===null||E===32||E===40||cv(E)?n(E):(e.consume(E),E===92?x:w)}function x(E){return E===40||E===41||E===92?(e.consume(E),w):w(E)}}function vj(e,t,n,r,i,s){const o=this;let l=0,u;return d;function d(v){return e.enter(r),e.enter(i),e.consume(v),e.exit(i),e.enter(s),h}function h(v){return l>999||v===null||v===91||v===93&&!u||v===94&&!l&&"_hiddenFootnoteSupport"in o.parser.constructs?n(v):v===93?(e.exit(s),e.enter(i),e.consume(v),e.exit(i),e.exit(r),t):Ft(v)?(e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),h):(e.enter("chunkString",{contentType:"string"}),p(v))}function p(v){return v===null||v===91||v===93||Ft(v)||l++>999?(e.exit("chunkString"),h(v)):(e.consume(v),u||(u=!Sn(v)),v===92?y:p)}function y(v){return v===91||v===92||v===93?(e.consume(v),l++,p):p(v)}}function yj(e,t,n,r,i,s){let o;return l;function l(y){return y===34||y===39||y===40?(e.enter(r),e.enter(i),e.consume(y),e.exit(i),o=y===40?41:y,u):n(y)}function u(y){return y===o?(e.enter(i),e.consume(y),e.exit(i),e.exit(r),t):(e.enter(s),d(y))}function d(y){return y===o?(e.exit(s),u(o)):y===null?n(y):Ft(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),Mn(e,d,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),h(y))}function h(y){return y===o||y===null||Ft(y)?(e.exit("chunkString"),d(y)):(e.consume(y),y===92?p:h)}function p(y){return y===o||y===92?(e.consume(y),h):h(y)}}function nf(e,t){let n;return r;function r(i){return Ft(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):Sn(i)?Mn(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const s_e={name:"definition",tokenize:a_e},o_e={partial:!0,tokenize:l_e};function a_e(e,t,n){const r=this;let i;return s;function s(v){return e.enter("definition"),o(v)}function o(v){return vj.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(v)}function l(v){return i=Ks(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),v===58?(e.enter("definitionMarker"),e.consume(v),e.exit("definitionMarker"),u):n(v)}function u(v){return Gn(v)?nf(e,d)(v):d(v)}function d(v){return gj(e,h,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(v)}function h(v){return e.attempt(o_e,p,p)(v)}function p(v){return Sn(v)?Mn(e,y,"whitespace")(v):y(v)}function y(v){return v===null||Ft(v)?(e.exit("definition"),r.parser.defined.push(i),t(v)):n(v)}}function l_e(e,t,n){return r;function r(l){return Gn(l)?nf(e,i)(l):n(l)}function i(l){return yj(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function s(l){return Sn(l)?Mn(e,o,"whitespace")(l):o(l)}function o(l){return l===null||Ft(l)?t(l):n(l)}}const c_e={name:"hardBreakEscape",tokenize:u_e};function u_e(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return Ft(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const d_e={name:"headingAtx",resolve:h_e,tokenize:f_e};function h_e(e,t){let n=e.length-2,r=3,i,s;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},us(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function f_e(e,t,n){let r=0;return i;function i(h){return e.enter("atxHeading"),s(h)}function s(h){return e.enter("atxHeadingSequence"),o(h)}function o(h){return h===35&&r++<6?(e.consume(h),o):h===null||Gn(h)?(e.exit("atxHeadingSequence"),l(h)):n(h)}function l(h){return h===35?(e.enter("atxHeadingSequence"),u(h)):h===null||Ft(h)?(e.exit("atxHeading"),t(h)):Sn(h)?Mn(e,l,"whitespace")(h):(e.enter("atxHeadingText"),d(h))}function u(h){return h===35?(e.consume(h),u):(e.exit("atxHeadingSequence"),l(h))}function d(h){return h===null||h===35||Gn(h)?(e.exit("atxHeadingText"),l(h)):(e.consume(h),d)}}const p_e=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],NO=["pre","script","style","textarea"],m_e={concrete:!0,name:"htmlFlow",resolveTo:y_e,tokenize:b_e},g_e={partial:!0,tokenize:w_e},v_e={partial:!0,tokenize:__e};function y_e(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function b_e(e,t,n){const r=this;let i,s,o,l,u;return d;function d(z){return h(z)}function h(z){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(z),p}function p(z){return z===33?(e.consume(z),y):z===47?(e.consume(z),s=!0,w):z===63?(e.consume(z),i=3,r.interrupt?t:P):Di(z)?(e.consume(z),o=String.fromCharCode(z),x):n(z)}function y(z){return z===45?(e.consume(z),i=2,v):z===91?(e.consume(z),i=5,l=0,_):Di(z)?(e.consume(z),i=4,r.interrupt?t:P):n(z)}function v(z){return z===45?(e.consume(z),r.interrupt?t:P):n(z)}function _(z){const X="CDATA[";return z===X.charCodeAt(l++)?(e.consume(z),l===X.length?r.interrupt?t:O:_):n(z)}function w(z){return Di(z)?(e.consume(z),o=String.fromCharCode(z),x):n(z)}function x(z){if(z===null||z===47||z===62||Gn(z)){const X=z===47,ee=o.toLowerCase();return!X&&!s&&NO.includes(ee)?(i=1,r.interrupt?t(z):O(z)):p_e.includes(o.toLowerCase())?(i=6,X?(e.consume(z),E):r.interrupt?t(z):O(z)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(z):s?k(z):R(z))}return z===45||xi(z)?(e.consume(z),o+=String.fromCharCode(z),x):n(z)}function E(z){return z===62?(e.consume(z),r.interrupt?t:O):n(z)}function k(z){return Sn(z)?(e.consume(z),k):U(z)}function R(z){return z===47?(e.consume(z),U):z===58||z===95||Di(z)?(e.consume(z),A):Sn(z)?(e.consume(z),R):U(z)}function A(z){return z===45||z===46||z===58||z===95||xi(z)?(e.consume(z),A):I(z)}function I(z){return z===61?(e.consume(z),T):Sn(z)?(e.consume(z),I):R(z)}function T(z){return z===null||z===60||z===61||z===62||z===96?n(z):z===34||z===39?(e.consume(z),u=z,H):Sn(z)?(e.consume(z),T):D(z)}function H(z){return z===u?(e.consume(z),u=null,W):z===null||Ft(z)?n(z):(e.consume(z),H)}function D(z){return z===null||z===34||z===39||z===47||z===60||z===61||z===62||z===96||Gn(z)?I(z):(e.consume(z),D)}function W(z){return z===47||z===62||Sn(z)?R(z):n(z)}function U(z){return z===62?(e.consume(z),F):n(z)}function F(z){return z===null||Ft(z)?O(z):Sn(z)?(e.consume(z),F):n(z)}function O(z){return z===45&&i===2?(e.consume(z),N):z===60&&i===1?(e.consume(z),V):z===62&&i===4?(e.consume(z),q):z===63&&i===3?(e.consume(z),P):z===93&&i===5?(e.consume(z),$):Ft(z)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(g_e,K,M)(z)):z===null||Ft(z)?(e.exit("htmlFlowData"),M(z)):(e.consume(z),O)}function M(z){return e.check(v_e,B,K)(z)}function B(z){return e.enter("lineEnding"),e.consume(z),e.exit("lineEnding"),L}function L(z){return z===null||Ft(z)?M(z):(e.enter("htmlFlowData"),O(z))}function N(z){return z===45?(e.consume(z),P):O(z)}function V(z){return z===47?(e.consume(z),o="",Y):O(z)}function Y(z){if(z===62){const X=o.toLowerCase();return NO.includes(X)?(e.consume(z),q):O(z)}return Di(z)&&o.length<8?(e.consume(z),o+=String.fromCharCode(z),Y):O(z)}function $(z){return z===93?(e.consume(z),P):O(z)}function P(z){return z===62?(e.consume(z),q):z===45&&i===2?(e.consume(z),P):O(z)}function q(z){return z===null||Ft(z)?(e.exit("htmlFlowData"),K(z)):(e.consume(z),q)}function K(z){return e.exit("htmlFlow"),t(z)}}function __e(e,t,n){const r=this;return i;function i(o){return Ft(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s):n(o)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function w_e(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(rp,t,n)}}const S_e={name:"htmlText",tokenize:x_e};function x_e(e,t,n){const r=this;let i,s,o;return l;function l(P){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(P),u}function u(P){return P===33?(e.consume(P),d):P===47?(e.consume(P),I):P===63?(e.consume(P),R):Di(P)?(e.consume(P),D):n(P)}function d(P){return P===45?(e.consume(P),h):P===91?(e.consume(P),s=0,_):Di(P)?(e.consume(P),k):n(P)}function h(P){return P===45?(e.consume(P),v):n(P)}function p(P){return P===null?n(P):P===45?(e.consume(P),y):Ft(P)?(o=p,V(P)):(e.consume(P),p)}function y(P){return P===45?(e.consume(P),v):p(P)}function v(P){return P===62?N(P):P===45?y(P):p(P)}function _(P){const q="CDATA[";return P===q.charCodeAt(s++)?(e.consume(P),s===q.length?w:_):n(P)}function w(P){return P===null?n(P):P===93?(e.consume(P),x):Ft(P)?(o=w,V(P)):(e.consume(P),w)}function x(P){return P===93?(e.consume(P),E):w(P)}function E(P){return P===62?N(P):P===93?(e.consume(P),E):w(P)}function k(P){return P===null||P===62?N(P):Ft(P)?(o=k,V(P)):(e.consume(P),k)}function R(P){return P===null?n(P):P===63?(e.consume(P),A):Ft(P)?(o=R,V(P)):(e.consume(P),R)}function A(P){return P===62?N(P):R(P)}function I(P){return Di(P)?(e.consume(P),T):n(P)}function T(P){return P===45||xi(P)?(e.consume(P),T):H(P)}function H(P){return Ft(P)?(o=H,V(P)):Sn(P)?(e.consume(P),H):N(P)}function D(P){return P===45||xi(P)?(e.consume(P),D):P===47||P===62||Gn(P)?W(P):n(P)}function W(P){return P===47?(e.consume(P),N):P===58||P===95||Di(P)?(e.consume(P),U):Ft(P)?(o=W,V(P)):Sn(P)?(e.consume(P),W):N(P)}function U(P){return P===45||P===46||P===58||P===95||xi(P)?(e.consume(P),U):F(P)}function F(P){return P===61?(e.consume(P),O):Ft(P)?(o=F,V(P)):Sn(P)?(e.consume(P),F):W(P)}function O(P){return P===null||P===60||P===61||P===62||P===96?n(P):P===34||P===39?(e.consume(P),i=P,M):Ft(P)?(o=O,V(P)):Sn(P)?(e.consume(P),O):(e.consume(P),B)}function M(P){return P===i?(e.consume(P),i=void 0,L):P===null?n(P):Ft(P)?(o=M,V(P)):(e.consume(P),M)}function B(P){return P===null||P===34||P===39||P===60||P===61||P===96?n(P):P===47||P===62||Gn(P)?W(P):(e.consume(P),B)}function L(P){return P===47||P===62||Gn(P)?W(P):n(P)}function N(P){return P===62?(e.consume(P),e.exit("htmlTextData"),e.exit("htmlText"),t):n(P)}function V(P){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),Y}function Y(P){return Sn(P)?Mn(e,$,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):$(P)}function $(P){return e.enter("htmlTextData"),o(P)}}const NE={name:"labelEnd",resolveAll:T_e,resolveTo:R_e,tokenize:A_e},E_e={tokenize:N_e},C_e={tokenize:M_e},k_e={tokenize:O_e};function T_e(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&us(e,0,e.length,n),e}function R_e(e,t){let n=e.length,r=0,i,s,o,l;for(;n--;)if(i=e[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(o){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(o=n);const u={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},d={type:"label",start:{...e[s][1].start},end:{...e[o][1].end}},h={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[o-2][1].start}};return l=[["enter",u,t],["enter",d,t]],l=Ts(l,e.slice(s+1,s+r+3)),l=Ts(l,[["enter",h,t]]),l=Ts(l,cy(t.parser.constructs.insideSpan.null,e.slice(s+r+4,o-3),t)),l=Ts(l,[["exit",h,t],e[o-2],e[o-1],["exit",d,t]]),l=Ts(l,e.slice(o+1)),l=Ts(l,[["exit",u,t]]),us(e,s,e.length,l),e}function A_e(e,t,n){const r=this;let i=r.events.length,s,o;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return l;function l(y){return s?s._inactive?p(y):(o=r.parser.defined.includes(Ks(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(y),e.exit("labelMarker"),e.exit("labelEnd"),u):n(y)}function u(y){return y===40?e.attempt(E_e,h,o?h:p)(y):y===91?e.attempt(C_e,h,o?d:p)(y):o?h(y):p(y)}function d(y){return e.attempt(k_e,h,p)(y)}function h(y){return t(y)}function p(y){return s._balanced=!0,n(y)}}function N_e(e,t,n){return r;function r(p){return e.enter("resource"),e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),i}function i(p){return Gn(p)?nf(e,s)(p):s(p)}function s(p){return p===41?h(p):gj(e,o,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function o(p){return Gn(p)?nf(e,u)(p):h(p)}function l(p){return n(p)}function u(p){return p===34||p===39||p===40?yj(e,d,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):h(p)}function d(p){return Gn(p)?nf(e,h)(p):h(p)}function h(p){return p===41?(e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),e.exit("resource"),t):n(p)}}function M_e(e,t,n){const r=this;return i;function i(l){return vj.call(r,e,s,o,"reference","referenceMarker","referenceString")(l)}function s(l){return r.parser.defined.includes(Ks(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function o(l){return n(l)}}function O_e(e,t,n){return r;function r(s){return e.enter("reference"),e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),i}function i(s){return s===93?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),t):n(s)}}const D_e={name:"labelStartImage",resolveAll:NE.resolveAll,tokenize:P_e};function P_e(e,t,n){const r=this;return i;function i(l){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(l),e.exit("labelImageMarker"),s}function s(l){return l===91?(e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelImage"),o):n(l)}function o(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(l):t(l)}}const L_e={name:"labelStartLink",resolveAll:NE.resolveAll,tokenize:I_e};function I_e(e,t,n){const r=this;return i;function i(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),s}function s(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const qw={name:"lineEnding",tokenize:z_e};function z_e(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Mn(e,t,"linePrefix")}}const Lg={name:"thematicBreak",tokenize:B_e};function B_e(e,t,n){let r=0,i;return s;function s(d){return e.enter("thematicBreak"),o(d)}function o(d){return i=d,l(d)}function l(d){return d===i?(e.enter("thematicBreakSequence"),u(d)):r>=3&&(d===null||Ft(d))?(e.exit("thematicBreak"),t(d)):n(d)}function u(d){return d===i?(e.consume(d),r++,u):(e.exit("thematicBreakSequence"),Sn(d)?Mn(e,l,"whitespace")(d):l(d))}}const Vi={continuation:{tokenize:H_e},exit:W_e,name:"list",tokenize:$_e},j_e={partial:!0,tokenize:q_e},F_e={partial:!0,tokenize:U_e};function $_e(e,t,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return l;function l(v){const _=r.containerState.type||(v===42||v===43||v===45?"listUnordered":"listOrdered");if(_==="listUnordered"?!r.containerState.marker||v===r.containerState.marker:tx(v)){if(r.containerState.type||(r.containerState.type=_,e.enter(_,{_container:!0})),_==="listUnordered")return e.enter("listItemPrefix"),v===42||v===45?e.check(Lg,n,d)(v):d(v);if(!r.interrupt||v===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),u(v)}return n(v)}function u(v){return tx(v)&&++o<10?(e.consume(v),u):(!r.interrupt||o<2)&&(r.containerState.marker?v===r.containerState.marker:v===41||v===46)?(e.exit("listItemValue"),d(v)):n(v)}function d(v){return e.enter("listItemMarker"),e.consume(v),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||v,e.check(rp,r.interrupt?n:h,e.attempt(j_e,y,p))}function h(v){return r.containerState.initialBlankLine=!0,s++,y(v)}function p(v){return Sn(v)?(e.enter("listItemPrefixWhitespace"),e.consume(v),e.exit("listItemPrefixWhitespace"),y):n(v)}function y(v){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(v)}}function H_e(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(rp,i,s);function i(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Mn(e,t,"listItemIndent",r.containerState.size+1)(l)}function s(l){return r.containerState.furtherBlankLines||!Sn(l)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(l)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(F_e,t,o)(l))}function o(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,Mn(e,e.attempt(Vi,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function U_e(e,t,n){const r=this;return Mn(e,i,"listItemIndent",r.containerState.size+1);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(s):n(s)}}function W_e(e){e.exit(this.containerState.type)}function q_e(e,t,n){const r=this;return Mn(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const o=r.events[r.events.length-1];return!Sn(s)&&o&&o[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const MO={name:"setextUnderline",resolveTo:V_e,tokenize:Y_e};function V_e(e,t){let n=e.length,r,i,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",o,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function Y_e(e,t,n){const r=this;let i;return s;function s(d){let h=r.events.length,p;for(;h--;)if(r.events[h][1].type!=="lineEnding"&&r.events[h][1].type!=="linePrefix"&&r.events[h][1].type!=="content"){p=r.events[h][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||p)?(e.enter("setextHeadingLine"),i=d,o(d)):n(d)}function o(d){return e.enter("setextHeadingLineSequence"),l(d)}function l(d){return d===i?(e.consume(d),l):(e.exit("setextHeadingLineSequence"),Sn(d)?Mn(e,u,"lineSuffix")(d):u(d))}function u(d){return d===null||Ft(d)?(e.exit("setextHeadingLine"),t(d)):n(d)}}const K_e={tokenize:G_e};function G_e(e){const t=this,n=e.attempt(rp,r,e.attempt(this.parser.constructs.flowInitial,i,Mn(e,e.attempt(this.parser.constructs.flow,i,e.attempt(e_e,i)),"linePrefix")));return n;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const X_e={resolveAll:_j()},Z_e=bj("string"),Q_e=bj("text");function bj(e){return{resolveAll:_j(e==="text"?J_e:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,o,l);return o;function o(h){return d(h)?s(h):l(h)}function l(h){if(h===null){n.consume(h);return}return n.enter("data"),n.consume(h),u}function u(h){return d(h)?(n.exit("data"),s(h)):(n.consume(h),u)}function d(h){if(h===null)return!0;const p=i[h];let y=-1;if(p)for(;++y<p.length;){const v=p[y];if(!v.previous||v.previous.call(r,r.previous))return!0}return!1}}}function _j(e){return t;function t(n,r){let i=-1,s;for(;++i<=n.length;)s===void 0?n[i]&&n[i][1].type==="data"&&(s=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==s+2&&(n[s][1].end=n[i-1][1].end,n.splice(s+2,i-s-2),i=s+2),s=void 0);return e?e(n,r):n}}function J_e(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let s=i.length,o=-1,l=0,u;for(;s--;){const d=i[s];if(typeof d=="string"){for(o=d.length;d.charCodeAt(o-1)===32;)l++,o--;if(o)break;o=-1}else if(d===-2)u=!0,l++;else if(d!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const d={type:n===e.length||u||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?o:r.start._bufferIndex+o,_index:r.start._index+s,line:r.end.line,column:r.end.column-l,offset:r.end.offset-l},end:{...r.end}};r.end={...d.start},r.start.offset===r.end.offset?Object.assign(r,d):(e.splice(n,0,["enter",d,t],["exit",d,t]),n+=2)}n++}return e}const ewe={42:Vi,43:Vi,45:Vi,48:Vi,49:Vi,50:Vi,51:Vi,52:Vi,53:Vi,54:Vi,55:Vi,56:Vi,57:Vi,62:hj},twe={91:s_e},nwe={[-2]:Ww,[-1]:Ww,32:Ww},rwe={35:d_e,42:Lg,45:[MO,Lg],60:m_e,61:MO,95:Lg,96:AO,126:AO},iwe={38:pj,92:fj},swe={[-5]:qw,[-4]:qw,[-3]:qw,33:D_e,38:pj,42:nx,60:[Lbe,S_e],91:L_e,92:[c_e,fj],93:NE,95:nx,96:Kbe},owe={null:[nx,X_e]},awe={null:[42,95]},lwe={null:[]},cwe=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:awe,contentInitial:twe,disable:lwe,document:ewe,flow:rwe,flowInitial:nwe,insideSpan:owe,string:iwe,text:swe},Symbol.toStringTag,{value:"Module"}));function uwe(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let o=[],l=[];const u={attempt:H(I),check:H(T),consume:k,enter:R,exit:A,interrupt:H(T,{interrupt:!0})},d={code:null,containerState:{},defineSkip:w,events:[],now:_,parser:e,previous:null,sliceSerialize:y,sliceStream:v,write:p};let h=t.tokenize.call(d,u);return t.resolveAll&&s.push(t),d;function p(F){return o=Ts(o,F),x(),o[o.length-1]!==null?[]:(D(t,0),d.events=cy(s,d.events,d),d.events)}function y(F,O){return hwe(v(F),O)}function v(F){return dwe(o,F)}function _(){const{_bufferIndex:F,_index:O,line:M,column:B,offset:L}=r;return{_bufferIndex:F,_index:O,line:M,column:B,offset:L}}function w(F){i[F.line]=F.column,U()}function x(){let F;for(;r._index<o.length;){const O=o[r._index];if(typeof O=="string")for(F=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===F&&r._bufferIndex<O.length;)E(O.charCodeAt(r._bufferIndex));else E(O)}}function E(F){h=h(F)}function k(F){Ft(F)?(r.line++,r.column=1,r.offset+=F===-3?2:1,U()):F!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),d.previous=F}function R(F,O){const M=O||{};return M.type=F,M.start=_(),d.events.push(["enter",M,d]),l.push(M),M}function A(F){const O=l.pop();return O.end=_(),d.events.push(["exit",O,d]),O}function I(F,O){D(F,O.from)}function T(F,O){O.restore()}function H(F,O){return M;function M(B,L,N){let V,Y,$,P;return Array.isArray(B)?K(B):"tokenize"in B?K([B]):q(B);function q(te){return Q;function Q(me){const ve=me!==null&&te[me],Ce=me!==null&&te.null,Me=[...Array.isArray(ve)?ve:ve?[ve]:[],...Array.isArray(Ce)?Ce:Ce?[Ce]:[]];return K(Me)(me)}}function K(te){return V=te,Y=0,te.length===0?N:z(te[Y])}function z(te){return Q;function Q(me){return P=W(),$=te,te.partial||(d.currentConstruct=te),te.name&&d.parser.constructs.disable.null.includes(te.name)?ee():te.tokenize.call(O?Object.assign(Object.create(d),O):d,u,X,ee)(me)}}function X(te){return F($,P),L}function ee(te){return P.restore(),++Y<V.length?z(V[Y]):N}}}function D(F,O){F.resolveAll&&!s.includes(F)&&s.push(F),F.resolve&&us(d.events,O,d.events.length-O,F.resolve(d.events.slice(O),d)),F.resolveTo&&(d.events=F.resolveTo(d.events,d))}function W(){const F=_(),O=d.previous,M=d.currentConstruct,B=d.events.length,L=Array.from(l);return{from:B,restore:N};function N(){r=F,d.previous=O,d.currentConstruct=M,d.events.length=B,l=L,U()}}function U(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function dwe(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let o;if(n===i)o=[e[n].slice(r,s)];else{if(o=e.slice(n,i),r>-1){const l=o[0];typeof l=="string"?o[0]=l.slice(r):o.shift()}s>0&&o.push(e[i].slice(0,s))}return o}function hwe(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let o;if(typeof s=="string")o=s;else switch(s){case-5:{o="\r";break}case-4:{o=`
654
654
  `;break}case-3:{o=`\r
655
- `;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&i)continue;o=" ";break}default:o=String.fromCharCode(s)}i=s===-2,r.push(o)}return r.join("")}function fwe(e){const r={constructs:u4([cwe,...(e||{}).extensions||[]]),content:i(Rbe),defined:[],document:i(Nbe),flow:i(K_e),lazy:{},string:i(Z_e),text:i(Q_e)};return r;function i(s){return o;function o(l){return uwe(r,s,l)}}}function pwe(e){for(;!m4(e););return e}const OO=/[\0\t\n\r]/g;function mwe(){let e=1,t="",n=!0,r;return i;function i(s,o,l){const u=[];let d,h,p,y,v;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s)),p=0,t="",n&&(s.charCodeAt(0)===65279&&p++,n=void 0);p<s.length;){if(OO.lastIndex=p,d=OO.exec(s),y=d&&d.index!==void 0?d.index:s.length,v=s.charCodeAt(y),!d){t=s.slice(p);break}if(v===10&&p===y&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),p<y&&(u.push(s.slice(p,y)),e+=y-p),v){case 0:{u.push(65533),e++;break}case 9:{for(h=Math.ceil(e/4)*4,u.push(-2);e++<h;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}p=y+1}return l&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}const gwe=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function vwe(e){return e.replace(gwe,ywe)}function ywe(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return d4(n.slice(s?2:1),s?16:10)}return AE(n)||e}const w4={}.hasOwnProperty;function bwe(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),_we(n)(pwe(fwe(n).document().write(mwe()(e,t,!0))))}function _we(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(ye),autolinkProtocol:W,autolinkEmail:W,atxHeading:s(Ot),blockQuote:s(Ce),characterEscape:W,characterReference:W,codeFenced:s(Me),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(Me,o),codeText:s(Ve,o),codeTextData:W,data:W,codeFlowValue:W,definition:s(Qe),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(ct),hardBreakEscape:s(he),hardBreakTrailing:s(he),htmlFlow:s(Ke,o),htmlFlowData:W,htmlText:s(Ke,o),htmlTextData:W,image:s(Rt),label:o,link:s(ye),listItem:s(Ge),listItemValue:y,listOrdered:s(He,p),listUnordered:s(He),paragraph:s(be),reference:z,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(Ot),strong:s(Xe),thematicBreak:s(pt)},exit:{atxHeading:u(),atxHeadingSequence:I,autolink:u(),autolinkEmail:ve,autolinkProtocol:me,blockQuote:u(),characterEscapeValue:U,characterReferenceMarkerHexadecimal:ee,characterReferenceMarkerNumeric:ee,characterReferenceValue:te,characterReference:Q,codeFenced:u(x),codeFencedFence:w,codeFencedFenceInfo:v,codeFencedFenceMeta:_,codeFlowValue:U,codeIndented:u(E),codeText:u(L),codeTextData:U,data:U,definition:u(),definitionDestinationString:A,definitionLabelString:k,definitionTitleString:R,emphasis:u(),hardBreakEscape:u(O),hardBreakTrailing:u(O),htmlFlow:u(M),htmlFlowData:U,htmlText:u(B),htmlTextData:U,image:u(V),label:$,labelText:Y,lineEnding:F,link:u(N),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:X,resourceDestinationString:P,resourceTitleString:q,resource:K,setextHeading:u(D),setextHeadingLineSequence:H,setextHeadingText:T,strong:u(),thematicBreak:u()}};S4(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(le){let Ae={type:"root",children:[]};const Ze={stack:[Ae],tokenStack:[],config:t,enter:l,exit:d,buffer:o,resume:h,data:n},tt=[];let dt=-1;for(;++dt<le.length;)if(le[dt][1].type==="listOrdered"||le[dt][1].type==="listUnordered")if(le[dt][0]==="enter")tt.push(dt);else{const Dt=tt.pop();dt=i(le,Dt,dt)}for(dt=-1;++dt<le.length;){const Dt=t[le[dt][0]];w4.call(Dt,le[dt][1].type)&&Dt[le[dt][1].type].call(Object.assign({sliceSerialize:le[dt][2].sliceSerialize},Ze),le[dt][1])}if(Ze.tokenStack.length>0){const Dt=Ze.tokenStack[Ze.tokenStack.length-1];(Dt[1]||DO).call(Ze,void 0,Dt[0])}for(Ae.position={start:Ha(le.length>0?le[0][1].start:{line:1,column:1,offset:0}),end:Ha(le.length>0?le[le.length-2][1].end:{line:1,column:1,offset:0})},dt=-1;++dt<t.transforms.length;)Ae=t.transforms[dt](Ae)||Ae;return Ae}function i(le,Ae,Ze){let tt=Ae-1,dt=-1,Dt=!1,Wt,tn,vn,un;for(;++tt<=Ze;){const Zt=le[tt];switch(Zt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Zt[0]==="enter"?dt++:dt--,un=void 0;break}case"lineEndingBlank":{Zt[0]==="enter"&&(Wt&&!un&&!dt&&!vn&&(vn=tt),un=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:un=void 0}if(!dt&&Zt[0]==="enter"&&Zt[1].type==="listItemPrefix"||dt===-1&&Zt[0]==="exit"&&(Zt[1].type==="listUnordered"||Zt[1].type==="listOrdered")){if(Wt){let Xn=tt;for(tn=void 0;Xn--;){const Kt=le[Xn];if(Kt[1].type==="lineEnding"||Kt[1].type==="lineEndingBlank"){if(Kt[0]==="exit")continue;tn&&(le[tn][1].type="lineEndingBlank",Dt=!0),Kt[1].type="lineEnding",tn=Xn}else if(!(Kt[1].type==="linePrefix"||Kt[1].type==="blockQuotePrefix"||Kt[1].type==="blockQuotePrefixWhitespace"||Kt[1].type==="blockQuoteMarker"||Kt[1].type==="listItemIndent"))break}vn&&(!tn||vn<tn)&&(Wt._spread=!0),Wt.end=Object.assign({},tn?le[tn][1].start:Zt[1].end),le.splice(tn||tt,0,["exit",Wt,Zt[2]]),tt++,Ze++}if(Zt[1].type==="listItemPrefix"){const Xn={type:"listItem",_spread:!1,start:Object.assign({},Zt[1].start),end:void 0};Wt=Xn,le.splice(tt,0,["enter",Xn,Zt[2]]),tt++,Ze++,vn=void 0,un=!0}}}return le[Ae][1]._spread=Dt,Ze}function s(le,Ae){return Ze;function Ze(tt){l.call(this,le(tt),tt),Ae&&Ae.call(this,tt)}}function o(){this.stack.push({type:"fragment",children:[]})}function l(le,Ae,Ze){this.stack[this.stack.length-1].children.push(le),this.stack.push(le),this.tokenStack.push([Ae,Ze||void 0]),le.position={start:Ha(Ae.start),end:void 0}}function u(le){return Ae;function Ae(Ze){le&&le.call(this,Ze),d.call(this,Ze)}}function d(le,Ae){const Ze=this.stack.pop(),tt=this.tokenStack.pop();if(tt)tt[0].type!==le.type&&(Ae?Ae.call(this,le,tt[0]):(tt[1]||DO).call(this,le,tt[0]));else throw new Error("Cannot close `"+le.type+"` ("+tf({start:le.start,end:le.end})+"): it’s not open");Ze.position.end=Ha(le.end)}function h(){return RE(this.stack.pop())}function p(){this.data.expectingFirstListItemValue=!0}function y(le){if(this.data.expectingFirstListItemValue){const Ae=this.stack[this.stack.length-2];Ae.start=Number.parseInt(this.sliceSerialize(le),10),this.data.expectingFirstListItemValue=void 0}}function v(){const le=this.resume(),Ae=this.stack[this.stack.length-1];Ae.lang=le}function _(){const le=this.resume(),Ae=this.stack[this.stack.length-1];Ae.meta=le}function w(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function x(){const le=this.resume(),Ae=this.stack[this.stack.length-1];Ae.value=le.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function E(){const le=this.resume(),Ae=this.stack[this.stack.length-1];Ae.value=le.replace(/(\r?\n|\r)$/g,"")}function k(le){const Ae=this.resume(),Ze=this.stack[this.stack.length-1];Ze.label=Ae,Ze.identifier=Ks(this.sliceSerialize(le)).toLowerCase()}function R(){const le=this.resume(),Ae=this.stack[this.stack.length-1];Ae.title=le}function A(){const le=this.resume(),Ae=this.stack[this.stack.length-1];Ae.url=le}function I(le){const Ae=this.stack[this.stack.length-1];if(!Ae.depth){const Ze=this.sliceSerialize(le).length;Ae.depth=Ze}}function T(){this.data.setextHeadingSlurpLineEnding=!0}function H(le){const Ae=this.stack[this.stack.length-1];Ae.depth=this.sliceSerialize(le).codePointAt(0)===61?1:2}function D(){this.data.setextHeadingSlurpLineEnding=void 0}function W(le){const Ze=this.stack[this.stack.length-1].children;let tt=Ze[Ze.length-1];(!tt||tt.type!=="text")&&(tt=rt(),tt.position={start:Ha(le.start),end:void 0},Ze.push(tt)),this.stack.push(tt)}function U(le){const Ae=this.stack.pop();Ae.value+=this.sliceSerialize(le),Ae.position.end=Ha(le.end)}function F(le){const Ae=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Ze=Ae.children[Ae.children.length-1];Ze.position.end=Ha(le.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Ae.type)&&(W.call(this,le),U.call(this,le))}function O(){this.data.atHardBreak=!0}function M(){const le=this.resume(),Ae=this.stack[this.stack.length-1];Ae.value=le}function B(){const le=this.resume(),Ae=this.stack[this.stack.length-1];Ae.value=le}function L(){const le=this.resume(),Ae=this.stack[this.stack.length-1];Ae.value=le}function N(){const le=this.stack[this.stack.length-1];if(this.data.inReference){const Ae=this.data.referenceType||"shortcut";le.type+="Reference",le.referenceType=Ae,delete le.url,delete le.title}else delete le.identifier,delete le.label;this.data.referenceType=void 0}function V(){const le=this.stack[this.stack.length-1];if(this.data.inReference){const Ae=this.data.referenceType||"shortcut";le.type+="Reference",le.referenceType=Ae,delete le.url,delete le.title}else delete le.identifier,delete le.label;this.data.referenceType=void 0}function Y(le){const Ae=this.sliceSerialize(le),Ze=this.stack[this.stack.length-2];Ze.label=vwe(Ae),Ze.identifier=Ks(Ae).toLowerCase()}function $(){const le=this.stack[this.stack.length-1],Ae=this.resume(),Ze=this.stack[this.stack.length-1];if(this.data.inReference=!0,Ze.type==="link"){const tt=le.children;Ze.children=tt}else Ze.alt=Ae}function P(){const le=this.resume(),Ae=this.stack[this.stack.length-1];Ae.url=le}function q(){const le=this.resume(),Ae=this.stack[this.stack.length-1];Ae.title=le}function K(){this.data.inReference=void 0}function z(){this.data.referenceType="collapsed"}function X(le){const Ae=this.resume(),Ze=this.stack[this.stack.length-1];Ze.label=Ae,Ze.identifier=Ks(this.sliceSerialize(le)).toLowerCase(),this.data.referenceType="full"}function ee(le){this.data.characterReferenceType=le.type}function te(le){const Ae=this.sliceSerialize(le),Ze=this.data.characterReferenceType;let tt;Ze?(tt=d4(Ae,Ze==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):tt=AE(Ae);const dt=this.stack[this.stack.length-1];dt.value+=tt}function Q(le){const Ae=this.stack.pop();Ae.position.end=Ha(le.end)}function me(le){U.call(this,le);const Ae=this.stack[this.stack.length-1];Ae.url=this.sliceSerialize(le)}function ve(le){U.call(this,le);const Ae=this.stack[this.stack.length-1];Ae.url="mailto:"+this.sliceSerialize(le)}function Ce(){return{type:"blockquote",children:[]}}function Me(){return{type:"code",lang:null,meta:null,value:""}}function Ve(){return{type:"inlineCode",value:""}}function Qe(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ct(){return{type:"emphasis",children:[]}}function Ot(){return{type:"heading",depth:0,children:[]}}function he(){return{type:"break"}}function Ke(){return{type:"html",value:""}}function Rt(){return{type:"image",title:null,url:"",alt:null}}function ye(){return{type:"link",title:null,url:"",children:[]}}function He(le){return{type:"list",ordered:le.type==="listOrdered",start:null,spread:le._spread,children:[]}}function Ge(le){return{type:"listItem",spread:le._spread,checked:null,children:[]}}function be(){return{type:"paragraph",children:[]}}function Xe(){return{type:"strong",children:[]}}function rt(){return{type:"text",value:""}}function pt(){return{type:"thematicBreak"}}}function Ha(e){return{line:e.line,column:e.column,offset:e.offset}}function S4(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?S4(e,r):wwe(e,r)}}function wwe(e,t){let n;for(n in t)if(w4.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function DO(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+tf({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+tf({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+tf({start:t.start,end:t.end})+") is still open")}function Swe(e){const t=this;t.parser=n;function n(r){return bwe(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function xwe(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function Ewe(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
655
+ `;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&i)continue;o=" ";break}default:o=String.fromCharCode(s)}i=s===-2,r.push(o)}return r.join("")}function fwe(e){const r={constructs:uj([cwe,...(e||{}).extensions||[]]),content:i(Rbe),defined:[],document:i(Nbe),flow:i(K_e),lazy:{},string:i(Z_e),text:i(Q_e)};return r;function i(s){return o;function o(l){return uwe(r,s,l)}}}function pwe(e){for(;!mj(e););return e}const OO=/[\0\t\n\r]/g;function mwe(){let e=1,t="",n=!0,r;return i;function i(s,o,l){const u=[];let d,h,p,y,v;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s)),p=0,t="",n&&(s.charCodeAt(0)===65279&&p++,n=void 0);p<s.length;){if(OO.lastIndex=p,d=OO.exec(s),y=d&&d.index!==void 0?d.index:s.length,v=s.charCodeAt(y),!d){t=s.slice(p);break}if(v===10&&p===y&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),p<y&&(u.push(s.slice(p,y)),e+=y-p),v){case 0:{u.push(65533),e++;break}case 9:{for(h=Math.ceil(e/4)*4,u.push(-2);e++<h;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}p=y+1}return l&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}const gwe=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function vwe(e){return e.replace(gwe,ywe)}function ywe(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return dj(n.slice(s?2:1),s?16:10)}return AE(n)||e}const wj={}.hasOwnProperty;function bwe(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),_we(n)(pwe(fwe(n).document().write(mwe()(e,t,!0))))}function _we(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(ye),autolinkProtocol:W,autolinkEmail:W,atxHeading:s(Ot),blockQuote:s(Ce),characterEscape:W,characterReference:W,codeFenced:s(Me),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(Me,o),codeText:s(Ve,o),codeTextData:W,data:W,codeFlowValue:W,definition:s(Qe),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(ct),hardBreakEscape:s(he),hardBreakTrailing:s(he),htmlFlow:s(Ke,o),htmlFlowData:W,htmlText:s(Ke,o),htmlTextData:W,image:s(Rt),label:o,link:s(ye),listItem:s(Ge),listItemValue:y,listOrdered:s(He,p),listUnordered:s(He),paragraph:s(be),reference:z,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(Ot),strong:s(Xe),thematicBreak:s(pt)},exit:{atxHeading:u(),atxHeadingSequence:I,autolink:u(),autolinkEmail:ve,autolinkProtocol:me,blockQuote:u(),characterEscapeValue:U,characterReferenceMarkerHexadecimal:ee,characterReferenceMarkerNumeric:ee,characterReferenceValue:te,characterReference:Q,codeFenced:u(x),codeFencedFence:w,codeFencedFenceInfo:v,codeFencedFenceMeta:_,codeFlowValue:U,codeIndented:u(E),codeText:u(L),codeTextData:U,data:U,definition:u(),definitionDestinationString:A,definitionLabelString:k,definitionTitleString:R,emphasis:u(),hardBreakEscape:u(O),hardBreakTrailing:u(O),htmlFlow:u(M),htmlFlowData:U,htmlText:u(B),htmlTextData:U,image:u(V),label:$,labelText:Y,lineEnding:F,link:u(N),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:X,resourceDestinationString:P,resourceTitleString:q,resource:K,setextHeading:u(D),setextHeadingLineSequence:H,setextHeadingText:T,strong:u(),thematicBreak:u()}};Sj(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(le){let Ae={type:"root",children:[]};const Ze={stack:[Ae],tokenStack:[],config:t,enter:l,exit:d,buffer:o,resume:h,data:n},tt=[];let dt=-1;for(;++dt<le.length;)if(le[dt][1].type==="listOrdered"||le[dt][1].type==="listUnordered")if(le[dt][0]==="enter")tt.push(dt);else{const Dt=tt.pop();dt=i(le,Dt,dt)}for(dt=-1;++dt<le.length;){const Dt=t[le[dt][0]];wj.call(Dt,le[dt][1].type)&&Dt[le[dt][1].type].call(Object.assign({sliceSerialize:le[dt][2].sliceSerialize},Ze),le[dt][1])}if(Ze.tokenStack.length>0){const Dt=Ze.tokenStack[Ze.tokenStack.length-1];(Dt[1]||DO).call(Ze,void 0,Dt[0])}for(Ae.position={start:Ha(le.length>0?le[0][1].start:{line:1,column:1,offset:0}),end:Ha(le.length>0?le[le.length-2][1].end:{line:1,column:1,offset:0})},dt=-1;++dt<t.transforms.length;)Ae=t.transforms[dt](Ae)||Ae;return Ae}function i(le,Ae,Ze){let tt=Ae-1,dt=-1,Dt=!1,Wt,tn,vn,un;for(;++tt<=Ze;){const Zt=le[tt];switch(Zt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Zt[0]==="enter"?dt++:dt--,un=void 0;break}case"lineEndingBlank":{Zt[0]==="enter"&&(Wt&&!un&&!dt&&!vn&&(vn=tt),un=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:un=void 0}if(!dt&&Zt[0]==="enter"&&Zt[1].type==="listItemPrefix"||dt===-1&&Zt[0]==="exit"&&(Zt[1].type==="listUnordered"||Zt[1].type==="listOrdered")){if(Wt){let Xn=tt;for(tn=void 0;Xn--;){const Kt=le[Xn];if(Kt[1].type==="lineEnding"||Kt[1].type==="lineEndingBlank"){if(Kt[0]==="exit")continue;tn&&(le[tn][1].type="lineEndingBlank",Dt=!0),Kt[1].type="lineEnding",tn=Xn}else if(!(Kt[1].type==="linePrefix"||Kt[1].type==="blockQuotePrefix"||Kt[1].type==="blockQuotePrefixWhitespace"||Kt[1].type==="blockQuoteMarker"||Kt[1].type==="listItemIndent"))break}vn&&(!tn||vn<tn)&&(Wt._spread=!0),Wt.end=Object.assign({},tn?le[tn][1].start:Zt[1].end),le.splice(tn||tt,0,["exit",Wt,Zt[2]]),tt++,Ze++}if(Zt[1].type==="listItemPrefix"){const Xn={type:"listItem",_spread:!1,start:Object.assign({},Zt[1].start),end:void 0};Wt=Xn,le.splice(tt,0,["enter",Xn,Zt[2]]),tt++,Ze++,vn=void 0,un=!0}}}return le[Ae][1]._spread=Dt,Ze}function s(le,Ae){return Ze;function Ze(tt){l.call(this,le(tt),tt),Ae&&Ae.call(this,tt)}}function o(){this.stack.push({type:"fragment",children:[]})}function l(le,Ae,Ze){this.stack[this.stack.length-1].children.push(le),this.stack.push(le),this.tokenStack.push([Ae,Ze||void 0]),le.position={start:Ha(Ae.start),end:void 0}}function u(le){return Ae;function Ae(Ze){le&&le.call(this,Ze),d.call(this,Ze)}}function d(le,Ae){const Ze=this.stack.pop(),tt=this.tokenStack.pop();if(tt)tt[0].type!==le.type&&(Ae?Ae.call(this,le,tt[0]):(tt[1]||DO).call(this,le,tt[0]));else throw new Error("Cannot close `"+le.type+"` ("+tf({start:le.start,end:le.end})+"): it’s not open");Ze.position.end=Ha(le.end)}function h(){return RE(this.stack.pop())}function p(){this.data.expectingFirstListItemValue=!0}function y(le){if(this.data.expectingFirstListItemValue){const Ae=this.stack[this.stack.length-2];Ae.start=Number.parseInt(this.sliceSerialize(le),10),this.data.expectingFirstListItemValue=void 0}}function v(){const le=this.resume(),Ae=this.stack[this.stack.length-1];Ae.lang=le}function _(){const le=this.resume(),Ae=this.stack[this.stack.length-1];Ae.meta=le}function w(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function x(){const le=this.resume(),Ae=this.stack[this.stack.length-1];Ae.value=le.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function E(){const le=this.resume(),Ae=this.stack[this.stack.length-1];Ae.value=le.replace(/(\r?\n|\r)$/g,"")}function k(le){const Ae=this.resume(),Ze=this.stack[this.stack.length-1];Ze.label=Ae,Ze.identifier=Ks(this.sliceSerialize(le)).toLowerCase()}function R(){const le=this.resume(),Ae=this.stack[this.stack.length-1];Ae.title=le}function A(){const le=this.resume(),Ae=this.stack[this.stack.length-1];Ae.url=le}function I(le){const Ae=this.stack[this.stack.length-1];if(!Ae.depth){const Ze=this.sliceSerialize(le).length;Ae.depth=Ze}}function T(){this.data.setextHeadingSlurpLineEnding=!0}function H(le){const Ae=this.stack[this.stack.length-1];Ae.depth=this.sliceSerialize(le).codePointAt(0)===61?1:2}function D(){this.data.setextHeadingSlurpLineEnding=void 0}function W(le){const Ze=this.stack[this.stack.length-1].children;let tt=Ze[Ze.length-1];(!tt||tt.type!=="text")&&(tt=rt(),tt.position={start:Ha(le.start),end:void 0},Ze.push(tt)),this.stack.push(tt)}function U(le){const Ae=this.stack.pop();Ae.value+=this.sliceSerialize(le),Ae.position.end=Ha(le.end)}function F(le){const Ae=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Ze=Ae.children[Ae.children.length-1];Ze.position.end=Ha(le.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Ae.type)&&(W.call(this,le),U.call(this,le))}function O(){this.data.atHardBreak=!0}function M(){const le=this.resume(),Ae=this.stack[this.stack.length-1];Ae.value=le}function B(){const le=this.resume(),Ae=this.stack[this.stack.length-1];Ae.value=le}function L(){const le=this.resume(),Ae=this.stack[this.stack.length-1];Ae.value=le}function N(){const le=this.stack[this.stack.length-1];if(this.data.inReference){const Ae=this.data.referenceType||"shortcut";le.type+="Reference",le.referenceType=Ae,delete le.url,delete le.title}else delete le.identifier,delete le.label;this.data.referenceType=void 0}function V(){const le=this.stack[this.stack.length-1];if(this.data.inReference){const Ae=this.data.referenceType||"shortcut";le.type+="Reference",le.referenceType=Ae,delete le.url,delete le.title}else delete le.identifier,delete le.label;this.data.referenceType=void 0}function Y(le){const Ae=this.sliceSerialize(le),Ze=this.stack[this.stack.length-2];Ze.label=vwe(Ae),Ze.identifier=Ks(Ae).toLowerCase()}function $(){const le=this.stack[this.stack.length-1],Ae=this.resume(),Ze=this.stack[this.stack.length-1];if(this.data.inReference=!0,Ze.type==="link"){const tt=le.children;Ze.children=tt}else Ze.alt=Ae}function P(){const le=this.resume(),Ae=this.stack[this.stack.length-1];Ae.url=le}function q(){const le=this.resume(),Ae=this.stack[this.stack.length-1];Ae.title=le}function K(){this.data.inReference=void 0}function z(){this.data.referenceType="collapsed"}function X(le){const Ae=this.resume(),Ze=this.stack[this.stack.length-1];Ze.label=Ae,Ze.identifier=Ks(this.sliceSerialize(le)).toLowerCase(),this.data.referenceType="full"}function ee(le){this.data.characterReferenceType=le.type}function te(le){const Ae=this.sliceSerialize(le),Ze=this.data.characterReferenceType;let tt;Ze?(tt=dj(Ae,Ze==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):tt=AE(Ae);const dt=this.stack[this.stack.length-1];dt.value+=tt}function Q(le){const Ae=this.stack.pop();Ae.position.end=Ha(le.end)}function me(le){U.call(this,le);const Ae=this.stack[this.stack.length-1];Ae.url=this.sliceSerialize(le)}function ve(le){U.call(this,le);const Ae=this.stack[this.stack.length-1];Ae.url="mailto:"+this.sliceSerialize(le)}function Ce(){return{type:"blockquote",children:[]}}function Me(){return{type:"code",lang:null,meta:null,value:""}}function Ve(){return{type:"inlineCode",value:""}}function Qe(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ct(){return{type:"emphasis",children:[]}}function Ot(){return{type:"heading",depth:0,children:[]}}function he(){return{type:"break"}}function Ke(){return{type:"html",value:""}}function Rt(){return{type:"image",title:null,url:"",alt:null}}function ye(){return{type:"link",title:null,url:"",children:[]}}function He(le){return{type:"list",ordered:le.type==="listOrdered",start:null,spread:le._spread,children:[]}}function Ge(le){return{type:"listItem",spread:le._spread,checked:null,children:[]}}function be(){return{type:"paragraph",children:[]}}function Xe(){return{type:"strong",children:[]}}function rt(){return{type:"text",value:""}}function pt(){return{type:"thematicBreak"}}}function Ha(e){return{line:e.line,column:e.column,offset:e.offset}}function Sj(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Sj(e,r):wwe(e,r)}}function wwe(e,t){let n;for(n in t)if(wj.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function DO(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+tf({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+tf({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+tf({start:t.start,end:t.end})+") is still open")}function Swe(e){const t=this;t.parser=n;function n(r){return bwe(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function xwe(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function Ewe(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
656
656
  `}]}function Cwe(e,t){const n=t.value?t.value+`
657
- `:"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let s={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(s.data={meta:t.meta}),e.patch(t,s),s=e.applyData(t,s),s={type:"element",tagName:"pre",properties:{},children:[s]},e.patch(t,s),s}function kwe(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Twe(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Rwe(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=pd(r.toLowerCase()),s=e.footnoteOrder.indexOf(r);let o,l=e.footnoteCounts.get(r);l===void 0?(l=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=s+1,l+=1,e.footnoteCounts.set(r,l);const u={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(o)}]};e.patch(t,u);const d={type:"element",tagName:"sup",properties:{},children:[u]};return e.patch(t,d),e.applyData(t,d)}function Awe(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Nwe(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function x4(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),s=i[0];s&&s.type==="text"?s.value="["+s.value:i.unshift({type:"text",value:"["});const o=i[i.length-1];return o&&o.type==="text"?o.value+=r:i.push({type:"text",value:r}),i}function Mwe(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return x4(e,t);const i={src:pd(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,s),e.applyData(t,s)}function Owe(e,t){const n={src:pd(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function Dwe(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function Pwe(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return x4(e,t);const i={href:pd(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function Lwe(e,t){const n={href:pd(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function Iwe(e,t,n){const r=e.all(t),i=n?zwe(n):E4(t),s={},o=[];if(typeof t.checked=="boolean"){const h=r[0];let p;h&&h.type==="element"&&h.tagName==="p"?p=h:(p={type:"element",tagName:"p",properties:{},children:[]},r.unshift(p)),p.children.length>0&&p.children.unshift({type:"text",value:" "}),p.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let l=-1;for(;++l<r.length;){const h=r[l];(i||l!==0||h.type!=="element"||h.tagName!=="p")&&o.push({type:"text",value:`
657
+ `:"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let s={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(s.data={meta:t.meta}),e.patch(t,s),s=e.applyData(t,s),s={type:"element",tagName:"pre",properties:{},children:[s]},e.patch(t,s),s}function kwe(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Twe(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Rwe(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=pd(r.toLowerCase()),s=e.footnoteOrder.indexOf(r);let o,l=e.footnoteCounts.get(r);l===void 0?(l=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=s+1,l+=1,e.footnoteCounts.set(r,l);const u={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(o)}]};e.patch(t,u);const d={type:"element",tagName:"sup",properties:{},children:[u]};return e.patch(t,d),e.applyData(t,d)}function Awe(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Nwe(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function xj(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),s=i[0];s&&s.type==="text"?s.value="["+s.value:i.unshift({type:"text",value:"["});const o=i[i.length-1];return o&&o.type==="text"?o.value+=r:i.push({type:"text",value:r}),i}function Mwe(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return xj(e,t);const i={src:pd(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,s),e.applyData(t,s)}function Owe(e,t){const n={src:pd(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function Dwe(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function Pwe(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return xj(e,t);const i={href:pd(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function Lwe(e,t){const n={href:pd(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function Iwe(e,t,n){const r=e.all(t),i=n?zwe(n):Ej(t),s={},o=[];if(typeof t.checked=="boolean"){const h=r[0];let p;h&&h.type==="element"&&h.tagName==="p"?p=h:(p={type:"element",tagName:"p",properties:{},children:[]},r.unshift(p)),p.children.length>0&&p.children.unshift({type:"text",value:" "}),p.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let l=-1;for(;++l<r.length;){const h=r[l];(i||l!==0||h.type!=="element"||h.tagName!=="p")&&o.push({type:"text",value:`
658
658
  `}),h.type==="element"&&h.tagName==="p"&&!i?o.push(...h.children):o.push(h)}const u=r[r.length-1];u&&(i||u.type!=="element"||u.tagName!=="p")&&o.push({type:"text",value:`
659
- `});const d={type:"element",tagName:"li",properties:s,children:o};return e.patch(t,d),e.applyData(t,d)}function zwe(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=E4(n[r])}return t}function E4(e){const t=e.spread;return t??e.children.length>1}function Bwe(e,t){const n={},r=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++i<r.length;){const o=r[i];if(o.type==="element"&&o.tagName==="li"&&o.properties&&Array.isArray(o.properties.className)&&o.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const s={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,s),e.applyData(t,s)}function jwe(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Fwe(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function $we(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Hwe(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const o={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],o),i.push(o)}if(n.length>0){const o={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},l=EE(t.children[1]),u=r4(t.children[t.children.length-1]);l&&u&&(o.position={start:l,end:u}),i.push(o)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,s),e.applyData(t,s)}function Uwe(e,t,n){const r=n?n.children:void 0,s=(r?r.indexOf(t):1)===0?"th":"td",o=n&&n.type==="table"?n.align:void 0,l=o?o.length:t.children.length;let u=-1;const d=[];for(;++u<l;){const p=t.children[u],y={},v=o?o[u]:void 0;v&&(y.align=v);let _={type:"element",tagName:s,properties:y,children:[]};p&&(_.children=e.all(p),e.patch(p,_),_=e.applyData(p,_)),d.push(_)}const h={type:"element",tagName:"tr",properties:{},children:e.wrap(d,!0)};return e.patch(t,h),e.applyData(t,h)}function Wwe(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const PO=9,LO=32;function qwe(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const s=[];for(;r;)s.push(IO(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return s.push(IO(t.slice(i),i>0,!1)),s.join("")}function IO(e,t,n){let r=0,i=e.length;if(t){let s=e.codePointAt(r);for(;s===PO||s===LO;)r++,s=e.codePointAt(r)}if(n){let s=e.codePointAt(i-1);for(;s===PO||s===LO;)i--,s=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function Vwe(e,t){const n={type:"text",value:qwe(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function Ywe(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const Kwe={blockquote:xwe,break:Ewe,code:Cwe,delete:kwe,emphasis:Twe,footnoteReference:Rwe,heading:Awe,html:Nwe,imageReference:Mwe,image:Owe,inlineCode:Dwe,linkReference:Pwe,link:Lwe,listItem:Iwe,list:Bwe,paragraph:jwe,root:Fwe,strong:$we,table:Hwe,tableCell:Wwe,tableRow:Uwe,text:Vwe,thematicBreak:Ywe,toml:rg,yaml:rg,definition:rg,footnoteDefinition:rg};function rg(){}const C4=-1,uy=0,rf=1,uv=2,ME=3,OE=4,DE=5,PE=6,k4=7,T4=8,zO=typeof self=="object"?self:globalThis,Gwe=(e,t)=>{const n=(i,s)=>(e.set(s,i),i),r=i=>{if(e.has(i))return e.get(i);const[s,o]=t[i];switch(s){case uy:case C4:return n(o,i);case rf:{const l=n([],i);for(const u of o)l.push(r(u));return l}case uv:{const l=n({},i);for(const[u,d]of o)l[r(u)]=r(d);return l}case ME:return n(new Date(o),i);case OE:{const{source:l,flags:u}=o;return n(new RegExp(l,u),i)}case DE:{const l=n(new Map,i);for(const[u,d]of o)l.set(r(u),r(d));return l}case PE:{const l=n(new Set,i);for(const u of o)l.add(r(u));return l}case k4:{const{name:l,message:u}=o;return n(new zO[l](u),i)}case T4:return n(BigInt(o),i);case"BigInt":return n(Object(BigInt(o)),i);case"ArrayBuffer":return n(new Uint8Array(o).buffer,o);case"DataView":{const{buffer:l}=new Uint8Array(o);return n(new DataView(l),o)}}return n(new zO[s](o),i)};return r},BO=e=>Gwe(new Map,e)(0),_u="",{toString:Xwe}={},{keys:Zwe}=Object,Th=e=>{const t=typeof e;if(t!=="object"||!e)return[uy,t];const n=Xwe.call(e).slice(8,-1);switch(n){case"Array":return[rf,_u];case"Object":return[uv,_u];case"Date":return[ME,_u];case"RegExp":return[OE,_u];case"Map":return[DE,_u];case"Set":return[PE,_u];case"DataView":return[rf,n]}return n.includes("Array")?[rf,n]:n.includes("Error")?[k4,n]:[uv,n]},ig=([e,t])=>e===uy&&(t==="function"||t==="symbol"),Qwe=(e,t,n,r)=>{const i=(o,l)=>{const u=r.push(o)-1;return n.set(l,u),u},s=o=>{if(n.has(o))return n.get(o);let[l,u]=Th(o);switch(l){case uy:{let h=o;switch(u){case"bigint":l=T4,h=o.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+u);h=null;break;case"undefined":return i([C4],o)}return i([l,h],o)}case rf:{if(u){let y=o;return u==="DataView"?y=new Uint8Array(o.buffer):u==="ArrayBuffer"&&(y=new Uint8Array(o)),i([u,[...y]],o)}const h=[],p=i([l,h],o);for(const y of o)h.push(s(y));return p}case uv:{if(u)switch(u){case"BigInt":return i([u,o.toString()],o);case"Boolean":case"Number":case"String":return i([u,o.valueOf()],o)}if(t&&"toJSON"in o)return s(o.toJSON());const h=[],p=i([l,h],o);for(const y of Zwe(o))(e||!ig(Th(o[y])))&&h.push([s(y),s(o[y])]);return p}case ME:return i([l,o.toISOString()],o);case OE:{const{source:h,flags:p}=o;return i([l,{source:h,flags:p}],o)}case DE:{const h=[],p=i([l,h],o);for(const[y,v]of o)(e||!(ig(Th(y))||ig(Th(v))))&&h.push([s(y),s(v)]);return p}case PE:{const h=[],p=i([l,h],o);for(const y of o)(e||!ig(Th(y)))&&h.push(s(y));return p}}const{message:d}=o;return i([l,{name:u,message:d}],o)};return s},jO=(e,{json:t,lossy:n}={})=>{const r=[];return Qwe(!(t||n),!!t,new Map,r)(e),r},dv=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?BO(jO(e,t)):structuredClone(e):(e,t)=>BO(jO(e,t));function Jwe(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function e0e(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function t0e(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||Jwe,r=e.options.footnoteBackLabel||e0e,i=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",o=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[];let u=-1;for(;++u<e.footnoteOrder.length;){const d=e.footnoteById.get(e.footnoteOrder[u]);if(!d)continue;const h=e.all(d),p=String(d.identifier).toUpperCase(),y=pd(p.toLowerCase());let v=0;const _=[],w=e.footnoteCounts.get(p);for(;w!==void 0&&++v<=w;){_.length>0&&_.push({type:"text",value:" "});let k=typeof n=="string"?n:n(u,v);typeof k=="string"&&(k={type:"text",value:k}),_.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+y+(v>1?"-"+v:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(u,v),className:["data-footnote-backref"]},children:Array.isArray(k)?k:[k]})}const x=h[h.length-1];if(x&&x.type==="element"&&x.tagName==="p"){const k=x.children[x.children.length-1];k&&k.type==="text"?k.value+=" ":x.children.push({type:"text",value:" "}),x.children.push(..._)}else h.push(..._);const E={type:"element",tagName:"li",properties:{id:t+"fn-"+y},children:e.wrap(h,!0)};e.patch(d,E),l.push(E)}if(l.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...dv(o),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
659
+ `});const d={type:"element",tagName:"li",properties:s,children:o};return e.patch(t,d),e.applyData(t,d)}function zwe(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=Ej(n[r])}return t}function Ej(e){const t=e.spread;return t??e.children.length>1}function Bwe(e,t){const n={},r=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++i<r.length;){const o=r[i];if(o.type==="element"&&o.tagName==="li"&&o.properties&&Array.isArray(o.properties.className)&&o.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const s={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,s),e.applyData(t,s)}function jwe(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Fwe(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function $we(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Hwe(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const o={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],o),i.push(o)}if(n.length>0){const o={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},l=EE(t.children[1]),u=rj(t.children[t.children.length-1]);l&&u&&(o.position={start:l,end:u}),i.push(o)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,s),e.applyData(t,s)}function Uwe(e,t,n){const r=n?n.children:void 0,s=(r?r.indexOf(t):1)===0?"th":"td",o=n&&n.type==="table"?n.align:void 0,l=o?o.length:t.children.length;let u=-1;const d=[];for(;++u<l;){const p=t.children[u],y={},v=o?o[u]:void 0;v&&(y.align=v);let _={type:"element",tagName:s,properties:y,children:[]};p&&(_.children=e.all(p),e.patch(p,_),_=e.applyData(p,_)),d.push(_)}const h={type:"element",tagName:"tr",properties:{},children:e.wrap(d,!0)};return e.patch(t,h),e.applyData(t,h)}function Wwe(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const PO=9,LO=32;function qwe(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const s=[];for(;r;)s.push(IO(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return s.push(IO(t.slice(i),i>0,!1)),s.join("")}function IO(e,t,n){let r=0,i=e.length;if(t){let s=e.codePointAt(r);for(;s===PO||s===LO;)r++,s=e.codePointAt(r)}if(n){let s=e.codePointAt(i-1);for(;s===PO||s===LO;)i--,s=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function Vwe(e,t){const n={type:"text",value:qwe(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function Ywe(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const Kwe={blockquote:xwe,break:Ewe,code:Cwe,delete:kwe,emphasis:Twe,footnoteReference:Rwe,heading:Awe,html:Nwe,imageReference:Mwe,image:Owe,inlineCode:Dwe,linkReference:Pwe,link:Lwe,listItem:Iwe,list:Bwe,paragraph:jwe,root:Fwe,strong:$we,table:Hwe,tableCell:Wwe,tableRow:Uwe,text:Vwe,thematicBreak:Ywe,toml:rg,yaml:rg,definition:rg,footnoteDefinition:rg};function rg(){}const Cj=-1,uy=0,rf=1,uv=2,ME=3,OE=4,DE=5,PE=6,kj=7,Tj=8,zO=typeof self=="object"?self:globalThis,Gwe=(e,t)=>{const n=(i,s)=>(e.set(s,i),i),r=i=>{if(e.has(i))return e.get(i);const[s,o]=t[i];switch(s){case uy:case Cj:return n(o,i);case rf:{const l=n([],i);for(const u of o)l.push(r(u));return l}case uv:{const l=n({},i);for(const[u,d]of o)l[r(u)]=r(d);return l}case ME:return n(new Date(o),i);case OE:{const{source:l,flags:u}=o;return n(new RegExp(l,u),i)}case DE:{const l=n(new Map,i);for(const[u,d]of o)l.set(r(u),r(d));return l}case PE:{const l=n(new Set,i);for(const u of o)l.add(r(u));return l}case kj:{const{name:l,message:u}=o;return n(new zO[l](u),i)}case Tj:return n(BigInt(o),i);case"BigInt":return n(Object(BigInt(o)),i);case"ArrayBuffer":return n(new Uint8Array(o).buffer,o);case"DataView":{const{buffer:l}=new Uint8Array(o);return n(new DataView(l),o)}}return n(new zO[s](o),i)};return r},BO=e=>Gwe(new Map,e)(0),_u="",{toString:Xwe}={},{keys:Zwe}=Object,Th=e=>{const t=typeof e;if(t!=="object"||!e)return[uy,t];const n=Xwe.call(e).slice(8,-1);switch(n){case"Array":return[rf,_u];case"Object":return[uv,_u];case"Date":return[ME,_u];case"RegExp":return[OE,_u];case"Map":return[DE,_u];case"Set":return[PE,_u];case"DataView":return[rf,n]}return n.includes("Array")?[rf,n]:n.includes("Error")?[kj,n]:[uv,n]},ig=([e,t])=>e===uy&&(t==="function"||t==="symbol"),Qwe=(e,t,n,r)=>{const i=(o,l)=>{const u=r.push(o)-1;return n.set(l,u),u},s=o=>{if(n.has(o))return n.get(o);let[l,u]=Th(o);switch(l){case uy:{let h=o;switch(u){case"bigint":l=Tj,h=o.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+u);h=null;break;case"undefined":return i([Cj],o)}return i([l,h],o)}case rf:{if(u){let y=o;return u==="DataView"?y=new Uint8Array(o.buffer):u==="ArrayBuffer"&&(y=new Uint8Array(o)),i([u,[...y]],o)}const h=[],p=i([l,h],o);for(const y of o)h.push(s(y));return p}case uv:{if(u)switch(u){case"BigInt":return i([u,o.toString()],o);case"Boolean":case"Number":case"String":return i([u,o.valueOf()],o)}if(t&&"toJSON"in o)return s(o.toJSON());const h=[],p=i([l,h],o);for(const y of Zwe(o))(e||!ig(Th(o[y])))&&h.push([s(y),s(o[y])]);return p}case ME:return i([l,o.toISOString()],o);case OE:{const{source:h,flags:p}=o;return i([l,{source:h,flags:p}],o)}case DE:{const h=[],p=i([l,h],o);for(const[y,v]of o)(e||!(ig(Th(y))||ig(Th(v))))&&h.push([s(y),s(v)]);return p}case PE:{const h=[],p=i([l,h],o);for(const y of o)(e||!ig(Th(y)))&&h.push(s(y));return p}}const{message:d}=o;return i([l,{name:u,message:d}],o)};return s},jO=(e,{json:t,lossy:n}={})=>{const r=[];return Qwe(!(t||n),!!t,new Map,r)(e),r},dv=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?BO(jO(e,t)):structuredClone(e):(e,t)=>BO(jO(e,t));function Jwe(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function e0e(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function t0e(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||Jwe,r=e.options.footnoteBackLabel||e0e,i=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",o=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[];let u=-1;for(;++u<e.footnoteOrder.length;){const d=e.footnoteById.get(e.footnoteOrder[u]);if(!d)continue;const h=e.all(d),p=String(d.identifier).toUpperCase(),y=pd(p.toLowerCase());let v=0;const _=[],w=e.footnoteCounts.get(p);for(;w!==void 0&&++v<=w;){_.length>0&&_.push({type:"text",value:" "});let k=typeof n=="string"?n:n(u,v);typeof k=="string"&&(k={type:"text",value:k}),_.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+y+(v>1?"-"+v:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(u,v),className:["data-footnote-backref"]},children:Array.isArray(k)?k:[k]})}const x=h[h.length-1];if(x&&x.type==="element"&&x.tagName==="p"){const k=x.children[x.children.length-1];k&&k.type==="text"?k.value+=" ":x.children.push({type:"text",value:" "}),x.children.push(..._)}else h.push(..._);const E={type:"element",tagName:"li",properties:{id:t+"fn-"+y},children:e.wrap(h,!0)};e.patch(d,E),l.push(E)}if(l.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...dv(o),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
660
660
  `},{type:"element",tagName:"ol",properties:{},children:e.wrap(l,!0)},{type:"text",value:`
661
- `}]}}const ip=(function(e){if(e==null)return s0e;if(typeof e=="function")return dy(e);if(typeof e=="object")return Array.isArray(e)?n0e(e):r0e(e);if(typeof e=="string")return i0e(e);throw new Error("Expected function, string, or object as test")});function n0e(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=ip(e[n]);return dy(r);function r(...i){let s=-1;for(;++s<t.length;)if(t[s].apply(this,i))return!0;return!1}}function r0e(e){const t=e;return dy(n);function n(r){const i=r;let s;for(s in e)if(i[s]!==t[s])return!1;return!0}}function i0e(e){return dy(t);function t(n){return n&&n.type===e}}function dy(e){return t;function t(n,r,i){return!!(o0e(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function s0e(){return!0}function o0e(e){return e!==null&&typeof e=="object"&&"type"in e}const R4=[],a0e=!0,rx=!1,l0e="skip";function A4(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const s=ip(i),o=r?-1:1;l(e,void 0,[])();function l(u,d,h){const p=u&&typeof u=="object"?u:{};if(typeof p.type=="string"){const v=typeof p.tagName=="string"?p.tagName:typeof p.name=="string"?p.name:void 0;Object.defineProperty(y,"name",{value:"node ("+(u.type+(v?"<"+v+">":""))+")"})}return y;function y(){let v=R4,_,w,x;if((!t||s(u,d,h[h.length-1]||void 0))&&(v=c0e(n(u,h)),v[0]===rx))return v;if("children"in u&&u.children){const E=u;if(E.children&&v[0]!==l0e)for(w=(r?E.children.length:-1)+o,x=h.concat(E);w>-1&&w<E.children.length;){const k=E.children[w];if(_=l(k,w,x)(),_[0]===rx)return _;w=typeof _[1]=="number"?_[1]:w+o}}return v}}}function c0e(e){return Array.isArray(e)?e:typeof e=="number"?[a0e,e]:e==null?R4:[e]}function hy(e,t,n,r){let i,s,o;typeof t=="function"&&typeof n!="function"?(s=void 0,o=t,i=n):(s=t,o=n,i=r),A4(e,s,l,i);function l(u,d){const h=d[d.length-1],p=h?h.children.indexOf(u):void 0;return o(u,p,h)}}const ix={}.hasOwnProperty,u0e={};function d0e(e,t){const n=t||u0e,r=new Map,i=new Map,s=new Map,o={...Kwe,...n.handlers},l={all:d,applyData:f0e,definitionById:r,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:o,one:u,options:n,patch:h0e,wrap:m0e};return hy(e,function(h){if(h.type==="definition"||h.type==="footnoteDefinition"){const p=h.type==="definition"?r:i,y=String(h.identifier).toUpperCase();p.has(y)||p.set(y,h)}}),l;function u(h,p){const y=h.type,v=l.handlers[y];if(ix.call(l.handlers,y)&&v)return v(l,h,p);if(l.options.passThrough&&l.options.passThrough.includes(y)){if("children"in h){const{children:w,...x}=h,E=dv(x);return E.children=l.all(h),E}return dv(h)}return(l.options.unknownHandler||p0e)(l,h,p)}function d(h){const p=[];if("children"in h){const y=h.children;let v=-1;for(;++v<y.length;){const _=l.one(y[v],h);if(_){if(v&&y[v-1].type==="break"&&(!Array.isArray(_)&&_.type==="text"&&(_.value=FO(_.value)),!Array.isArray(_)&&_.type==="element")){const w=_.children[0];w&&w.type==="text"&&(w.value=FO(w.value))}Array.isArray(_)?p.push(..._):p.push(_)}}}return p}}function h0e(e,t){e.position&&(t.position=ebe(e))}function f0e(e,t){let n=t;if(e&&e.data){const r=e.data.hName,i=e.data.hChildren,s=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const o="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:o}}n.type==="element"&&s&&Object.assign(n.properties,dv(s)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function p0e(e,t){const n=t.data||{},r="value"in t&&!(ix.call(n,"hProperties")||ix.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function m0e(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
661
+ `}]}}const ip=(function(e){if(e==null)return s0e;if(typeof e=="function")return dy(e);if(typeof e=="object")return Array.isArray(e)?n0e(e):r0e(e);if(typeof e=="string")return i0e(e);throw new Error("Expected function, string, or object as test")});function n0e(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=ip(e[n]);return dy(r);function r(...i){let s=-1;for(;++s<t.length;)if(t[s].apply(this,i))return!0;return!1}}function r0e(e){const t=e;return dy(n);function n(r){const i=r;let s;for(s in e)if(i[s]!==t[s])return!1;return!0}}function i0e(e){return dy(t);function t(n){return n&&n.type===e}}function dy(e){return t;function t(n,r,i){return!!(o0e(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function s0e(){return!0}function o0e(e){return e!==null&&typeof e=="object"&&"type"in e}const Rj=[],a0e=!0,rx=!1,l0e="skip";function Aj(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const s=ip(i),o=r?-1:1;l(e,void 0,[])();function l(u,d,h){const p=u&&typeof u=="object"?u:{};if(typeof p.type=="string"){const v=typeof p.tagName=="string"?p.tagName:typeof p.name=="string"?p.name:void 0;Object.defineProperty(y,"name",{value:"node ("+(u.type+(v?"<"+v+">":""))+")"})}return y;function y(){let v=Rj,_,w,x;if((!t||s(u,d,h[h.length-1]||void 0))&&(v=c0e(n(u,h)),v[0]===rx))return v;if("children"in u&&u.children){const E=u;if(E.children&&v[0]!==l0e)for(w=(r?E.children.length:-1)+o,x=h.concat(E);w>-1&&w<E.children.length;){const k=E.children[w];if(_=l(k,w,x)(),_[0]===rx)return _;w=typeof _[1]=="number"?_[1]:w+o}}return v}}}function c0e(e){return Array.isArray(e)?e:typeof e=="number"?[a0e,e]:e==null?Rj:[e]}function hy(e,t,n,r){let i,s,o;typeof t=="function"&&typeof n!="function"?(s=void 0,o=t,i=n):(s=t,o=n,i=r),Aj(e,s,l,i);function l(u,d){const h=d[d.length-1],p=h?h.children.indexOf(u):void 0;return o(u,p,h)}}const ix={}.hasOwnProperty,u0e={};function d0e(e,t){const n=t||u0e,r=new Map,i=new Map,s=new Map,o={...Kwe,...n.handlers},l={all:d,applyData:f0e,definitionById:r,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:o,one:u,options:n,patch:h0e,wrap:m0e};return hy(e,function(h){if(h.type==="definition"||h.type==="footnoteDefinition"){const p=h.type==="definition"?r:i,y=String(h.identifier).toUpperCase();p.has(y)||p.set(y,h)}}),l;function u(h,p){const y=h.type,v=l.handlers[y];if(ix.call(l.handlers,y)&&v)return v(l,h,p);if(l.options.passThrough&&l.options.passThrough.includes(y)){if("children"in h){const{children:w,...x}=h,E=dv(x);return E.children=l.all(h),E}return dv(h)}return(l.options.unknownHandler||p0e)(l,h,p)}function d(h){const p=[];if("children"in h){const y=h.children;let v=-1;for(;++v<y.length;){const _=l.one(y[v],h);if(_){if(v&&y[v-1].type==="break"&&(!Array.isArray(_)&&_.type==="text"&&(_.value=FO(_.value)),!Array.isArray(_)&&_.type==="element")){const w=_.children[0];w&&w.type==="text"&&(w.value=FO(w.value))}Array.isArray(_)?p.push(..._):p.push(_)}}}return p}}function h0e(e,t){e.position&&(t.position=ebe(e))}function f0e(e,t){let n=t;if(e&&e.data){const r=e.data.hName,i=e.data.hChildren,s=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const o="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:o}}n.type==="element"&&s&&Object.assign(n.properties,dv(s)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function p0e(e,t){const n=t.data||{},r="value"in t&&!(ix.call(n,"hProperties")||ix.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function m0e(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
662
662
  `});++r<e.length;)r&&n.push({type:"text",value:`
663
663
  `}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
664
664
  `}),n}function FO(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function $O(e,t){const n=d0e(e,t),r=n.one(e,void 0),i=t0e(n),s=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&s.children.push({type:"text",value:`
665
- `},i),s}function g0e(e,t){return e&&"run"in e?async function(n,r){const i=$O(n,{file:r,...t});await e.run(i,r)}:function(n,r){return $O(n,{file:r,...e||t})}}function HO(e){if(e)throw e}var Vw,UO;function v0e(){if(UO)return Vw;UO=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(d){return typeof Array.isArray=="function"?Array.isArray(d):t.call(d)==="[object Array]"},s=function(d){if(!d||t.call(d)!=="[object Object]")return!1;var h=e.call(d,"constructor"),p=d.constructor&&d.constructor.prototype&&e.call(d.constructor.prototype,"isPrototypeOf");if(d.constructor&&!h&&!p)return!1;var y;for(y in d);return typeof y>"u"||e.call(d,y)},o=function(d,h){n&&h.name==="__proto__"?n(d,h.name,{enumerable:!0,configurable:!0,value:h.newValue,writable:!0}):d[h.name]=h.newValue},l=function(d,h){if(h==="__proto__")if(e.call(d,h)){if(r)return r(d,h).value}else return;return d[h]};return Vw=function u(){var d,h,p,y,v,_,w=arguments[0],x=1,E=arguments.length,k=!1;for(typeof w=="boolean"&&(k=w,w=arguments[1]||{},x=2),(w==null||typeof w!="object"&&typeof w!="function")&&(w={});x<E;++x)if(d=arguments[x],d!=null)for(h in d)p=l(w,h),y=l(d,h),w!==y&&(k&&y&&(s(y)||(v=i(y)))?(v?(v=!1,_=p&&i(p)?p:[]):_=p&&s(p)?p:{},o(w,{name:h,newValue:u(k,_,y)})):typeof y<"u"&&o(w,{name:h,newValue:y}));return w},Vw}var y0e=v0e();const Yw=Af(y0e);function sx(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function b0e(){const e=[],t={run:n,use:r};return t;function n(...i){let s=-1;const o=i.pop();if(typeof o!="function")throw new TypeError("Expected function as last argument, not "+o);l(null,...i);function l(u,...d){const h=e[++s];let p=-1;if(u){o(u);return}for(;++p<i.length;)(d[p]===null||d[p]===void 0)&&(d[p]=i[p]);i=d,h?_0e(h,l)(...d):o(null,...d)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function _0e(e,t){let n;return r;function r(...o){const l=e.length>o.length;let u;l&&o.push(i);try{u=e.apply(this,o)}catch(d){const h=d;if(l&&n)throw h;return i(h)}l||(u&&u.then&&typeof u.then=="function"?u.then(s,i):u instanceof Error?i(u):s(u))}function i(o,...l){n||(n=!0,t(o,...l))}function s(o){i(null,o)}}const mo={basename:w0e,dirname:S0e,extname:x0e,join:E0e,sep:"/"};function w0e(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');sp(e);let n=0,r=-1,i=e.length,s;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else r<0&&(s=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let o=-1,l=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else o<0&&(s=!0,o=i+1),l>-1&&(e.codePointAt(i)===t.codePointAt(l--)?l<0&&(r=i):(l=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function S0e(e){if(sp(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function x0e(e){sp(e);let t=e.length,n=-1,r=0,i=-1,s=0,o;for(;t--;){const l=e.codePointAt(t);if(l===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),l===46?i<0?i=t:s!==1&&(s=1):i>-1&&(s=-1)}return i<0||n<0||s===0||s===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function E0e(...e){let t=-1,n;for(;++t<e.length;)sp(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":C0e(n)}function C0e(e){sp(e);const t=e.codePointAt(0)===47;let n=k0e(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function k0e(e,t){let n="",r=0,i=-1,s=0,o=-1,l,u;for(;++o<=e.length;){if(o<e.length)l=e.codePointAt(o);else{if(l===47)break;l=47}if(l===47){if(!(i===o-1||s===1))if(i!==o-1&&s===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(u=n.lastIndexOf("/"),u!==n.length-1){u<0?(n="",r=0):(n=n.slice(0,u),r=n.length-1-n.lastIndexOf("/")),i=o,s=0;continue}}else if(n.length>0){n="",r=0,i=o,s=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,s=0}else l===46&&s>-1?s++:s=-1}return n}function sp(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const T0e={cwd:R0e};function R0e(){return"/"}function ox(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function A0e(e){if(typeof e=="string")e=new URL(e);else if(!ox(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return N0e(e)}function N0e(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(t)}const Kw=["history","path","basename","stem","extname","dirname"];class N4{constructor(t){let n;t?ox(t)?n={path:t}:typeof t=="string"||M0e(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":T0e.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Kw.length;){const s=Kw[r];s in n&&n[s]!==void 0&&n[s]!==null&&(this[s]=s==="history"?[...n[s]]:n[s])}let i;for(i in n)Kw.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?mo.basename(this.path):void 0}set basename(t){Xw(t,"basename"),Gw(t,"basename"),this.path=mo.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?mo.dirname(this.path):void 0}set dirname(t){WO(this.basename,"dirname"),this.path=mo.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?mo.extname(this.path):void 0}set extname(t){if(Gw(t,"extname"),WO(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=mo.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){ox(t)&&(t=A0e(t)),Xw(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?mo.basename(this.path,this.extname):void 0}set stem(t){Xw(t,"stem"),Gw(t,"stem"),this.path=mo.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const i=this.message(t,n,r);throw i.fatal=!0,i}info(t,n,r){const i=this.message(t,n,r);return i.fatal=void 0,i}message(t,n,r){const i=new ki(t,n,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Gw(e,t){if(e&&e.includes(mo.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+mo.sep+"`")}function Xw(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function WO(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function M0e(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const O0e=(function(e){const r=this.constructor.prototype,i=r[e],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s}),D0e={}.hasOwnProperty;class LE extends O0e{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=b0e()}copy(){const t=new LE;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Yw(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Jw("data",this.frozen),this.namespace[t]=n,this):D0e.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Jw("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const i=n.call(t,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=sg(t),r=this.parser||this.Parser;return Zw("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),Zw("process",this.parser||this.Parser),Qw("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(s,o){const l=sg(t),u=r.parse(l);r.run(u,l,function(h,p,y){if(h||!p||!y)return d(h);const v=p,_=r.stringify(v,y);I0e(_)?y.value=_:y.result=_,d(h,y)});function d(h,p){h||!p?o(h):s?s(p):n(void 0,p)}}}processSync(t){let n=!1,r;return this.freeze(),Zw("processSync",this.parser||this.Parser),Qw("processSync",this.compiler||this.Compiler),this.process(t,i),VO("processSync","process",n),r;function i(s,o){n=!0,HO(s),r=o}}run(t,n,r){qO(t),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?s(void 0,r):new Promise(s);function s(o,l){const u=sg(n);i.run(t,u,d);function d(h,p,y){const v=p||t;h?l(h):o?o(v):r(void 0,v,y)}}}runSync(t,n){let r=!1,i;return this.run(t,n,s),VO("runSync","run",r),i;function s(o,l){HO(o),i=l,r=!0}}stringify(t,n){this.freeze();const r=sg(n),i=this.compiler||this.Compiler;return Qw("stringify",i),qO(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(Jw("use",this.frozen),t!=null)if(typeof t=="function")u(t,n);else if(typeof t=="object")Array.isArray(t)?l(t):o(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function s(d){if(typeof d=="function")u(d,[]);else if(typeof d=="object")if(Array.isArray(d)){const[h,...p]=d;u(h,p)}else o(d);else throw new TypeError("Expected usable value, not `"+d+"`")}function o(d){if(!("plugins"in d)&&!("settings"in d))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(d.plugins),d.settings&&(i.settings=Yw(!0,i.settings,d.settings))}function l(d){let h=-1;if(d!=null)if(Array.isArray(d))for(;++h<d.length;){const p=d[h];s(p)}else throw new TypeError("Expected a list of plugins, not `"+d+"`")}function u(d,h){let p=-1,y=-1;for(;++p<r.length;)if(r[p][0]===d){y=p;break}if(y===-1)r.push([d,...h]);else if(h.length>0){let[v,..._]=h;const w=r[y][1];sx(w)&&sx(v)&&(v=Yw(!0,w,v)),r[y]=[d,v,..._]}}}}const P0e=new LE().freeze();function Zw(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Qw(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Jw(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function qO(e){if(!sx(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function VO(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function sg(e){return L0e(e)?e:new N4(e)}function L0e(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function I0e(e){return typeof e=="string"||z0e(e)}function z0e(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const B0e="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",YO=[],KO={allowDangerousHtml:!0},j0e=/^(https?|ircs?|mailto|xmpp)$/i,F0e=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function $0e(e){const t=H0e(e),n=U0e(e);return W0e(t.runSync(t.parse(n),n),e)}function H0e(e){const t=e.rehypePlugins||YO,n=e.remarkPlugins||YO,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...KO}:KO;return P0e().use(Swe).use(n).use(g0e,r).use(t)}function U0e(e){const t=e.children||"",n=new N4;return typeof t=="string"&&(n.value=t),n}function W0e(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,s=t.disallowedElements,o=t.skipHtml,l=t.unwrapDisallowed,u=t.urlTransform||M4;for(const h of F0e)Object.hasOwn(t,h.from)&&(""+h.from+(h.to?"use `"+h.to+"` instead":"remove it")+B0e+h.id,void 0);return hy(e,d),sbe(e,{Fragment:g.Fragment,components:i,ignoreInvalidStyle:!0,jsx:g.jsx,jsxs:g.jsxs,passKeys:!0,passNode:!0});function d(h,p,y){if(h.type==="raw"&&y&&typeof p=="number")return o?y.children.splice(p,1):y.children[p]={type:"text",value:h.value},p;if(h.type==="element"){let v;for(v in Uw)if(Object.hasOwn(Uw,v)&&Object.hasOwn(h.properties,v)){const _=h.properties[v],w=Uw[v];(w===null||w.includes(h.tagName))&&(h.properties[v]=u(String(_||""),v,h))}}if(h.type==="element"){let v=n?!n.includes(h.tagName):s?s.includes(h.tagName):!1;if(!v&&r&&typeof p=="number"&&(v=!r(h,p,y)),v&&y&&typeof p=="number")return l&&h.children?y.children.splice(p,1,...h.children):y.children.splice(p,1),p}}}function M4(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||j0e.test(e.slice(0,t))?e:""}function GO(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function q0e(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function V0e(e,t,n){const i=ip((n||{}).ignore||[]),s=Y0e(t);let o=-1;for(;++o<s.length;)A4(e,"text",l);function l(d,h){let p=-1,y;for(;++p<h.length;){const v=h[p],_=y?y.children:void 0;if(i(v,_?_.indexOf(v):void 0,y))return;y=v}if(y)return u(d,h)}function u(d,h){const p=h[h.length-1],y=s[o][0],v=s[o][1];let _=0;const x=p.children.indexOf(d);let E=!1,k=[];y.lastIndex=0;let R=y.exec(d.value);for(;R;){const A=R.index,I={index:R.index,input:R.input,stack:[...h,d]};let T=v(...R,I);if(typeof T=="string"&&(T=T.length>0?{type:"text",value:T}:void 0),T===!1?y.lastIndex=A+1:(_!==A&&k.push({type:"text",value:d.value.slice(_,A)}),Array.isArray(T)?k.push(...T):T&&k.push(T),_=A+R[0].length,E=!0),!y.global)break;R=y.exec(d.value)}return E?(_<d.value.length&&k.push({type:"text",value:d.value.slice(_)}),p.children.splice(x,1,...k)):k=[d],x+k.length}}function Y0e(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const i=n[r];t.push([K0e(i[0]),G0e(i[1])])}return t}function K0e(e){return typeof e=="string"?new RegExp(q0e(e),"g"):e}function G0e(e){return typeof e=="function"?e:function(){return e}}const e0="phrasing",t0=["autolink","link","image","label"];function X0e(){return{transforms:[rSe],enter:{literalAutolink:Q0e,literalAutolinkEmail:n0,literalAutolinkHttp:n0,literalAutolinkWww:n0},exit:{literalAutolink:nSe,literalAutolinkEmail:tSe,literalAutolinkHttp:J0e,literalAutolinkWww:eSe}}}function Z0e(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:e0,notInConstruct:t0},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:e0,notInConstruct:t0},{character:":",before:"[ps]",after:"\\/",inConstruct:e0,notInConstruct:t0}]}}function Q0e(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function n0(e){this.config.enter.autolinkProtocol.call(this,e)}function J0e(e){this.config.exit.autolinkProtocol.call(this,e)}function eSe(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function tSe(e){this.config.exit.autolinkEmail.call(this,e)}function nSe(e){this.exit(e)}function rSe(e){V0e(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,iSe],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),sSe]],{ignore:["link","linkReference"]})}function iSe(e,t,n,r,i){let s="";if(!O4(i)||(/^w/i.test(t)&&(n=t+n,t="",s="http://"),!oSe(n)))return!1;const o=aSe(n+r);if(!o[0])return!1;const l={type:"link",title:null,url:s+t+o[0],children:[{type:"text",value:t+o[0]}]};return o[1]?[l,{type:"text",value:o[1]}]:l}function sSe(e,t,n,r){return!O4(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function oSe(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function aSe(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const i=GO(e,"(");let s=GO(e,")");for(;r!==-1&&i>s;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),s++;return[e,n]}function O4(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||fc(n)||ly(n))&&(!t||n!==47)}D4.peek=gSe;function lSe(){this.buffer()}function cSe(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function uSe(){this.buffer()}function dSe(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function hSe(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ks(this.sliceSerialize(e)).toLowerCase(),n.label=t}function fSe(e){this.exit(e)}function pSe(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ks(this.sliceSerialize(e)).toLowerCase(),n.label=t}function mSe(e){this.exit(e)}function gSe(){return"["}function D4(e,t,n,r){const i=n.createTracker(r);let s=i.move("[^");const o=n.enter("footnoteReference"),l=n.enter("reference");return s+=i.move(n.safe(n.associationId(e),{after:"]",before:s})),l(),o(),s+=i.move("]"),s}function vSe(){return{enter:{gfmFootnoteCallString:lSe,gfmFootnoteCall:cSe,gfmFootnoteDefinitionLabelString:uSe,gfmFootnoteDefinition:dSe},exit:{gfmFootnoteCallString:hSe,gfmFootnoteCall:fSe,gfmFootnoteDefinitionLabelString:pSe,gfmFootnoteDefinition:mSe}}}function ySe(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:D4},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,i,s,o){const l=s.createTracker(o);let u=l.move("[^");const d=s.enter("footnoteDefinition"),h=s.enter("label");return u+=l.move(s.safe(s.associationId(r),{before:u,after:"]"})),h(),u+=l.move("]:"),r.children&&r.children.length>0&&(l.shift(4),u+=l.move((t?`
666
- `:" ")+s.indentLines(s.containerFlow(r,l.current()),t?P4:bSe))),d(),u}}function bSe(e,t,n){return t===0?e:P4(e,t,n)}function P4(e,t,n){return(n?"":" ")+e}const _Se=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];L4.peek=CSe;function wSe(){return{canContainEols:["delete"],enter:{strikethrough:xSe},exit:{strikethrough:ESe}}}function SSe(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:_Se}],handlers:{delete:L4}}}function xSe(e){this.enter({type:"delete",children:[]},e)}function ESe(e){this.exit(e)}function L4(e,t,n,r){const i=n.createTracker(r),s=n.enter("strikethrough");let o=i.move("~~");return o+=n.containerPhrasing(e,{...i.current(),before:o,after:"~"}),o+=i.move("~~"),s(),o}function CSe(){return"~"}function kSe(e){return e.length}function TSe(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||kSe,s=[],o=[],l=[],u=[];let d=0,h=-1;for(;++h<e.length;){const w=[],x=[];let E=-1;for(e[h].length>d&&(d=e[h].length);++E<e[h].length;){const k=RSe(e[h][E]);if(n.alignDelimiters!==!1){const R=i(k);x[E]=R,(u[E]===void 0||R>u[E])&&(u[E]=R)}w.push(k)}o[h]=w,l[h]=x}let p=-1;if(typeof r=="object"&&"length"in r)for(;++p<d;)s[p]=XO(r[p]);else{const w=XO(r);for(;++p<d;)s[p]=w}p=-1;const y=[],v=[];for(;++p<d;){const w=s[p];let x="",E="";w===99?(x=":",E=":"):w===108?x=":":w===114&&(E=":");let k=n.alignDelimiters===!1?1:Math.max(1,u[p]-x.length-E.length);const R=x+"-".repeat(k)+E;n.alignDelimiters!==!1&&(k=x.length+k+E.length,k>u[p]&&(u[p]=k),v[p]=k),y[p]=R}o.splice(1,0,y),l.splice(1,0,v),h=-1;const _=[];for(;++h<o.length;){const w=o[h],x=l[h];p=-1;const E=[];for(;++p<d;){const k=w[p]||"";let R="",A="";if(n.alignDelimiters!==!1){const I=u[p]-(x[p]||0),T=s[p];T===114?R=" ".repeat(I):T===99?I%2?(R=" ".repeat(I/2+.5),A=" ".repeat(I/2-.5)):(R=" ".repeat(I/2),A=R):A=" ".repeat(I)}n.delimiterStart!==!1&&!p&&E.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&k==="")&&(n.delimiterStart!==!1||p)&&E.push(" "),n.alignDelimiters!==!1&&E.push(R),E.push(k),n.alignDelimiters!==!1&&E.push(A),n.padding!==!1&&E.push(" "),(n.delimiterEnd!==!1||p!==d-1)&&E.push("|")}_.push(n.delimiterEnd===!1?E.join("").replace(/ +$/,""):E.join(""))}return _.join(`
665
+ `},i),s}function g0e(e,t){return e&&"run"in e?async function(n,r){const i=$O(n,{file:r,...t});await e.run(i,r)}:function(n,r){return $O(n,{file:r,...e||t})}}function HO(e){if(e)throw e}var Vw,UO;function v0e(){if(UO)return Vw;UO=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(d){return typeof Array.isArray=="function"?Array.isArray(d):t.call(d)==="[object Array]"},s=function(d){if(!d||t.call(d)!=="[object Object]")return!1;var h=e.call(d,"constructor"),p=d.constructor&&d.constructor.prototype&&e.call(d.constructor.prototype,"isPrototypeOf");if(d.constructor&&!h&&!p)return!1;var y;for(y in d);return typeof y>"u"||e.call(d,y)},o=function(d,h){n&&h.name==="__proto__"?n(d,h.name,{enumerable:!0,configurable:!0,value:h.newValue,writable:!0}):d[h.name]=h.newValue},l=function(d,h){if(h==="__proto__")if(e.call(d,h)){if(r)return r(d,h).value}else return;return d[h]};return Vw=function u(){var d,h,p,y,v,_,w=arguments[0],x=1,E=arguments.length,k=!1;for(typeof w=="boolean"&&(k=w,w=arguments[1]||{},x=2),(w==null||typeof w!="object"&&typeof w!="function")&&(w={});x<E;++x)if(d=arguments[x],d!=null)for(h in d)p=l(w,h),y=l(d,h),w!==y&&(k&&y&&(s(y)||(v=i(y)))?(v?(v=!1,_=p&&i(p)?p:[]):_=p&&s(p)?p:{},o(w,{name:h,newValue:u(k,_,y)})):typeof y<"u"&&o(w,{name:h,newValue:y}));return w},Vw}var y0e=v0e();const Yw=Af(y0e);function sx(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function b0e(){const e=[],t={run:n,use:r};return t;function n(...i){let s=-1;const o=i.pop();if(typeof o!="function")throw new TypeError("Expected function as last argument, not "+o);l(null,...i);function l(u,...d){const h=e[++s];let p=-1;if(u){o(u);return}for(;++p<i.length;)(d[p]===null||d[p]===void 0)&&(d[p]=i[p]);i=d,h?_0e(h,l)(...d):o(null,...d)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function _0e(e,t){let n;return r;function r(...o){const l=e.length>o.length;let u;l&&o.push(i);try{u=e.apply(this,o)}catch(d){const h=d;if(l&&n)throw h;return i(h)}l||(u&&u.then&&typeof u.then=="function"?u.then(s,i):u instanceof Error?i(u):s(u))}function i(o,...l){n||(n=!0,t(o,...l))}function s(o){i(null,o)}}const mo={basename:w0e,dirname:S0e,extname:x0e,join:E0e,sep:"/"};function w0e(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');sp(e);let n=0,r=-1,i=e.length,s;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else r<0&&(s=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let o=-1,l=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else o<0&&(s=!0,o=i+1),l>-1&&(e.codePointAt(i)===t.codePointAt(l--)?l<0&&(r=i):(l=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function S0e(e){if(sp(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function x0e(e){sp(e);let t=e.length,n=-1,r=0,i=-1,s=0,o;for(;t--;){const l=e.codePointAt(t);if(l===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),l===46?i<0?i=t:s!==1&&(s=1):i>-1&&(s=-1)}return i<0||n<0||s===0||s===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function E0e(...e){let t=-1,n;for(;++t<e.length;)sp(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":C0e(n)}function C0e(e){sp(e);const t=e.codePointAt(0)===47;let n=k0e(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function k0e(e,t){let n="",r=0,i=-1,s=0,o=-1,l,u;for(;++o<=e.length;){if(o<e.length)l=e.codePointAt(o);else{if(l===47)break;l=47}if(l===47){if(!(i===o-1||s===1))if(i!==o-1&&s===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(u=n.lastIndexOf("/"),u!==n.length-1){u<0?(n="",r=0):(n=n.slice(0,u),r=n.length-1-n.lastIndexOf("/")),i=o,s=0;continue}}else if(n.length>0){n="",r=0,i=o,s=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,s=0}else l===46&&s>-1?s++:s=-1}return n}function sp(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const T0e={cwd:R0e};function R0e(){return"/"}function ox(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function A0e(e){if(typeof e=="string")e=new URL(e);else if(!ox(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return N0e(e)}function N0e(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(t)}const Kw=["history","path","basename","stem","extname","dirname"];class Nj{constructor(t){let n;t?ox(t)?n={path:t}:typeof t=="string"||M0e(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":T0e.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Kw.length;){const s=Kw[r];s in n&&n[s]!==void 0&&n[s]!==null&&(this[s]=s==="history"?[...n[s]]:n[s])}let i;for(i in n)Kw.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?mo.basename(this.path):void 0}set basename(t){Xw(t,"basename"),Gw(t,"basename"),this.path=mo.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?mo.dirname(this.path):void 0}set dirname(t){WO(this.basename,"dirname"),this.path=mo.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?mo.extname(this.path):void 0}set extname(t){if(Gw(t,"extname"),WO(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=mo.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){ox(t)&&(t=A0e(t)),Xw(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?mo.basename(this.path,this.extname):void 0}set stem(t){Xw(t,"stem"),Gw(t,"stem"),this.path=mo.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const i=this.message(t,n,r);throw i.fatal=!0,i}info(t,n,r){const i=this.message(t,n,r);return i.fatal=void 0,i}message(t,n,r){const i=new ki(t,n,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Gw(e,t){if(e&&e.includes(mo.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+mo.sep+"`")}function Xw(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function WO(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function M0e(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const O0e=(function(e){const r=this.constructor.prototype,i=r[e],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s}),D0e={}.hasOwnProperty;class LE extends O0e{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=b0e()}copy(){const t=new LE;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Yw(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Jw("data",this.frozen),this.namespace[t]=n,this):D0e.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Jw("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const i=n.call(t,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=sg(t),r=this.parser||this.Parser;return Zw("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),Zw("process",this.parser||this.Parser),Qw("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(s,o){const l=sg(t),u=r.parse(l);r.run(u,l,function(h,p,y){if(h||!p||!y)return d(h);const v=p,_=r.stringify(v,y);I0e(_)?y.value=_:y.result=_,d(h,y)});function d(h,p){h||!p?o(h):s?s(p):n(void 0,p)}}}processSync(t){let n=!1,r;return this.freeze(),Zw("processSync",this.parser||this.Parser),Qw("processSync",this.compiler||this.Compiler),this.process(t,i),VO("processSync","process",n),r;function i(s,o){n=!0,HO(s),r=o}}run(t,n,r){qO(t),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?s(void 0,r):new Promise(s);function s(o,l){const u=sg(n);i.run(t,u,d);function d(h,p,y){const v=p||t;h?l(h):o?o(v):r(void 0,v,y)}}}runSync(t,n){let r=!1,i;return this.run(t,n,s),VO("runSync","run",r),i;function s(o,l){HO(o),i=l,r=!0}}stringify(t,n){this.freeze();const r=sg(n),i=this.compiler||this.Compiler;return Qw("stringify",i),qO(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(Jw("use",this.frozen),t!=null)if(typeof t=="function")u(t,n);else if(typeof t=="object")Array.isArray(t)?l(t):o(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function s(d){if(typeof d=="function")u(d,[]);else if(typeof d=="object")if(Array.isArray(d)){const[h,...p]=d;u(h,p)}else o(d);else throw new TypeError("Expected usable value, not `"+d+"`")}function o(d){if(!("plugins"in d)&&!("settings"in d))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(d.plugins),d.settings&&(i.settings=Yw(!0,i.settings,d.settings))}function l(d){let h=-1;if(d!=null)if(Array.isArray(d))for(;++h<d.length;){const p=d[h];s(p)}else throw new TypeError("Expected a list of plugins, not `"+d+"`")}function u(d,h){let p=-1,y=-1;for(;++p<r.length;)if(r[p][0]===d){y=p;break}if(y===-1)r.push([d,...h]);else if(h.length>0){let[v,..._]=h;const w=r[y][1];sx(w)&&sx(v)&&(v=Yw(!0,w,v)),r[y]=[d,v,..._]}}}}const P0e=new LE().freeze();function Zw(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Qw(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Jw(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function qO(e){if(!sx(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function VO(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function sg(e){return L0e(e)?e:new Nj(e)}function L0e(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function I0e(e){return typeof e=="string"||z0e(e)}function z0e(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const B0e="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",YO=[],KO={allowDangerousHtml:!0},j0e=/^(https?|ircs?|mailto|xmpp)$/i,F0e=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function $0e(e){const t=H0e(e),n=U0e(e);return W0e(t.runSync(t.parse(n),n),e)}function H0e(e){const t=e.rehypePlugins||YO,n=e.remarkPlugins||YO,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...KO}:KO;return P0e().use(Swe).use(n).use(g0e,r).use(t)}function U0e(e){const t=e.children||"",n=new Nj;return typeof t=="string"&&(n.value=t),n}function W0e(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,s=t.disallowedElements,o=t.skipHtml,l=t.unwrapDisallowed,u=t.urlTransform||Mj;for(const h of F0e)Object.hasOwn(t,h.from)&&(""+h.from+(h.to?"use `"+h.to+"` instead":"remove it")+B0e+h.id,void 0);return hy(e,d),sbe(e,{Fragment:g.Fragment,components:i,ignoreInvalidStyle:!0,jsx:g.jsx,jsxs:g.jsxs,passKeys:!0,passNode:!0});function d(h,p,y){if(h.type==="raw"&&y&&typeof p=="number")return o?y.children.splice(p,1):y.children[p]={type:"text",value:h.value},p;if(h.type==="element"){let v;for(v in Uw)if(Object.hasOwn(Uw,v)&&Object.hasOwn(h.properties,v)){const _=h.properties[v],w=Uw[v];(w===null||w.includes(h.tagName))&&(h.properties[v]=u(String(_||""),v,h))}}if(h.type==="element"){let v=n?!n.includes(h.tagName):s?s.includes(h.tagName):!1;if(!v&&r&&typeof p=="number"&&(v=!r(h,p,y)),v&&y&&typeof p=="number")return l&&h.children?y.children.splice(p,1,...h.children):y.children.splice(p,1),p}}}function Mj(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||j0e.test(e.slice(0,t))?e:""}function GO(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function q0e(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function V0e(e,t,n){const i=ip((n||{}).ignore||[]),s=Y0e(t);let o=-1;for(;++o<s.length;)Aj(e,"text",l);function l(d,h){let p=-1,y;for(;++p<h.length;){const v=h[p],_=y?y.children:void 0;if(i(v,_?_.indexOf(v):void 0,y))return;y=v}if(y)return u(d,h)}function u(d,h){const p=h[h.length-1],y=s[o][0],v=s[o][1];let _=0;const x=p.children.indexOf(d);let E=!1,k=[];y.lastIndex=0;let R=y.exec(d.value);for(;R;){const A=R.index,I={index:R.index,input:R.input,stack:[...h,d]};let T=v(...R,I);if(typeof T=="string"&&(T=T.length>0?{type:"text",value:T}:void 0),T===!1?y.lastIndex=A+1:(_!==A&&k.push({type:"text",value:d.value.slice(_,A)}),Array.isArray(T)?k.push(...T):T&&k.push(T),_=A+R[0].length,E=!0),!y.global)break;R=y.exec(d.value)}return E?(_<d.value.length&&k.push({type:"text",value:d.value.slice(_)}),p.children.splice(x,1,...k)):k=[d],x+k.length}}function Y0e(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const i=n[r];t.push([K0e(i[0]),G0e(i[1])])}return t}function K0e(e){return typeof e=="string"?new RegExp(q0e(e),"g"):e}function G0e(e){return typeof e=="function"?e:function(){return e}}const e0="phrasing",t0=["autolink","link","image","label"];function X0e(){return{transforms:[rSe],enter:{literalAutolink:Q0e,literalAutolinkEmail:n0,literalAutolinkHttp:n0,literalAutolinkWww:n0},exit:{literalAutolink:nSe,literalAutolinkEmail:tSe,literalAutolinkHttp:J0e,literalAutolinkWww:eSe}}}function Z0e(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:e0,notInConstruct:t0},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:e0,notInConstruct:t0},{character:":",before:"[ps]",after:"\\/",inConstruct:e0,notInConstruct:t0}]}}function Q0e(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function n0(e){this.config.enter.autolinkProtocol.call(this,e)}function J0e(e){this.config.exit.autolinkProtocol.call(this,e)}function eSe(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function tSe(e){this.config.exit.autolinkEmail.call(this,e)}function nSe(e){this.exit(e)}function rSe(e){V0e(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,iSe],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),sSe]],{ignore:["link","linkReference"]})}function iSe(e,t,n,r,i){let s="";if(!Oj(i)||(/^w/i.test(t)&&(n=t+n,t="",s="http://"),!oSe(n)))return!1;const o=aSe(n+r);if(!o[0])return!1;const l={type:"link",title:null,url:s+t+o[0],children:[{type:"text",value:t+o[0]}]};return o[1]?[l,{type:"text",value:o[1]}]:l}function sSe(e,t,n,r){return!Oj(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function oSe(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function aSe(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const i=GO(e,"(");let s=GO(e,")");for(;r!==-1&&i>s;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),s++;return[e,n]}function Oj(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||fc(n)||ly(n))&&(!t||n!==47)}Dj.peek=gSe;function lSe(){this.buffer()}function cSe(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function uSe(){this.buffer()}function dSe(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function hSe(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ks(this.sliceSerialize(e)).toLowerCase(),n.label=t}function fSe(e){this.exit(e)}function pSe(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ks(this.sliceSerialize(e)).toLowerCase(),n.label=t}function mSe(e){this.exit(e)}function gSe(){return"["}function Dj(e,t,n,r){const i=n.createTracker(r);let s=i.move("[^");const o=n.enter("footnoteReference"),l=n.enter("reference");return s+=i.move(n.safe(n.associationId(e),{after:"]",before:s})),l(),o(),s+=i.move("]"),s}function vSe(){return{enter:{gfmFootnoteCallString:lSe,gfmFootnoteCall:cSe,gfmFootnoteDefinitionLabelString:uSe,gfmFootnoteDefinition:dSe},exit:{gfmFootnoteCallString:hSe,gfmFootnoteCall:fSe,gfmFootnoteDefinitionLabelString:pSe,gfmFootnoteDefinition:mSe}}}function ySe(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Dj},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,i,s,o){const l=s.createTracker(o);let u=l.move("[^");const d=s.enter("footnoteDefinition"),h=s.enter("label");return u+=l.move(s.safe(s.associationId(r),{before:u,after:"]"})),h(),u+=l.move("]:"),r.children&&r.children.length>0&&(l.shift(4),u+=l.move((t?`
666
+ `:" ")+s.indentLines(s.containerFlow(r,l.current()),t?Pj:bSe))),d(),u}}function bSe(e,t,n){return t===0?e:Pj(e,t,n)}function Pj(e,t,n){return(n?"":" ")+e}const _Se=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Lj.peek=CSe;function wSe(){return{canContainEols:["delete"],enter:{strikethrough:xSe},exit:{strikethrough:ESe}}}function SSe(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:_Se}],handlers:{delete:Lj}}}function xSe(e){this.enter({type:"delete",children:[]},e)}function ESe(e){this.exit(e)}function Lj(e,t,n,r){const i=n.createTracker(r),s=n.enter("strikethrough");let o=i.move("~~");return o+=n.containerPhrasing(e,{...i.current(),before:o,after:"~"}),o+=i.move("~~"),s(),o}function CSe(){return"~"}function kSe(e){return e.length}function TSe(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||kSe,s=[],o=[],l=[],u=[];let d=0,h=-1;for(;++h<e.length;){const w=[],x=[];let E=-1;for(e[h].length>d&&(d=e[h].length);++E<e[h].length;){const k=RSe(e[h][E]);if(n.alignDelimiters!==!1){const R=i(k);x[E]=R,(u[E]===void 0||R>u[E])&&(u[E]=R)}w.push(k)}o[h]=w,l[h]=x}let p=-1;if(typeof r=="object"&&"length"in r)for(;++p<d;)s[p]=XO(r[p]);else{const w=XO(r);for(;++p<d;)s[p]=w}p=-1;const y=[],v=[];for(;++p<d;){const w=s[p];let x="",E="";w===99?(x=":",E=":"):w===108?x=":":w===114&&(E=":");let k=n.alignDelimiters===!1?1:Math.max(1,u[p]-x.length-E.length);const R=x+"-".repeat(k)+E;n.alignDelimiters!==!1&&(k=x.length+k+E.length,k>u[p]&&(u[p]=k),v[p]=k),y[p]=R}o.splice(1,0,y),l.splice(1,0,v),h=-1;const _=[];for(;++h<o.length;){const w=o[h],x=l[h];p=-1;const E=[];for(;++p<d;){const k=w[p]||"";let R="",A="";if(n.alignDelimiters!==!1){const I=u[p]-(x[p]||0),T=s[p];T===114?R=" ".repeat(I):T===99?I%2?(R=" ".repeat(I/2+.5),A=" ".repeat(I/2-.5)):(R=" ".repeat(I/2),A=R):A=" ".repeat(I)}n.delimiterStart!==!1&&!p&&E.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&k==="")&&(n.delimiterStart!==!1||p)&&E.push(" "),n.alignDelimiters!==!1&&E.push(R),E.push(k),n.alignDelimiters!==!1&&E.push(A),n.padding!==!1&&E.push(" "),(n.delimiterEnd!==!1||p!==d-1)&&E.push("|")}_.push(n.delimiterEnd===!1?E.join("").replace(/ +$/,""):E.join(""))}return _.join(`
667
667
  `)}function RSe(e){return e==null?"":String(e)}function XO(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function ASe(e,t,n,r){const i=n.enter("blockquote"),s=n.createTracker(r);s.move("> "),s.shift(2);const o=n.indentLines(n.containerFlow(e,s.current()),NSe);return i(),o}function NSe(e,t,n){return">"+(n?"":" ")+e}function MSe(e,t){return ZO(e,t.inConstruct,!0)&&!ZO(e,t.notInConstruct,!1)}function ZO(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function QO(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
668
668
  `&&MSe(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
669
669
  `}function OSe(e,t){const n=String(e);let r=n.indexOf(t),i=r,s=0,o=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++s>o&&(o=s):s=1,i=r+t.length,r=n.indexOf(t,i);return o}function DSe(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function PSe(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function LSe(e,t,n,r){const i=PSe(n),s=e.value||"",o=i==="`"?"GraveAccent":"Tilde";if(DSe(e,n)){const p=n.enter("codeIndented"),y=n.indentLines(s,ISe);return p(),y}const l=n.createTracker(r),u=i.repeat(Math.max(OSe(s,i)+1,3)),d=n.enter("codeFenced");let h=l.move(u);if(e.lang){const p=n.enter(`codeFencedLang${o}`);h+=l.move(n.safe(e.lang,{before:h,after:" ",encode:["`"],...l.current()})),p()}if(e.lang&&e.meta){const p=n.enter(`codeFencedMeta${o}`);h+=l.move(" "),h+=l.move(n.safe(e.meta,{before:h,after:`
670
670
  `,encode:["`"],...l.current()})),p()}return h+=l.move(`
671
671
  `),s&&(h+=l.move(s+`
672
672
  `)),h+=l.move(u),d(),h}function ISe(e,t,n){return(n?"":" ")+e}function IE(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function zSe(e,t,n,r){const i=IE(n),s=i==='"'?"Quote":"Apostrophe",o=n.enter("definition");let l=n.enter("label");const u=n.createTracker(r);let d=u.move("[");return d+=u.move(n.safe(n.associationId(e),{before:d,after:"]",...u.current()})),d+=u.move("]: "),l(),!e.url||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),d+=u.move("<"),d+=u.move(n.safe(e.url,{before:d,after:">",...u.current()})),d+=u.move(">")):(l=n.enter("destinationRaw"),d+=u.move(n.safe(e.url,{before:d,after:e.title?" ":`
673
- `,...u.current()}))),l(),e.title&&(l=n.enter(`title${s}`),d+=u.move(" "+i),d+=u.move(n.safe(e.title,{before:d,after:i,...u.current()})),d+=u.move(i),l()),o(),d}function BSe(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Rf(e){return"&#x"+e.toString(16).toUpperCase()+";"}function hv(e,t,n){const r=ed(e),i=ed(t);return r===void 0?i===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}I4.peek=jSe;function I4(e,t,n,r){const i=BSe(n),s=n.enter("emphasis"),o=n.createTracker(r),l=o.move(i);let u=o.move(n.containerPhrasing(e,{after:i,before:l,...o.current()}));const d=u.charCodeAt(0),h=hv(r.before.charCodeAt(r.before.length-1),d,i);h.inside&&(u=Rf(d)+u.slice(1));const p=u.charCodeAt(u.length-1),y=hv(r.after.charCodeAt(0),p,i);y.inside&&(u=u.slice(0,-1)+Rf(p));const v=o.move(i);return s(),n.attentionEncodeSurroundingInfo={after:y.outside,before:h.outside},l+u+v}function jSe(e,t,n){return n.options.emphasis||"*"}function FSe(e,t){let n=!1;return hy(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,rx}),!!((!e.depth||e.depth<3)&&RE(e)&&(t.options.setext||n))}function $Se(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(r);if(FSe(e,n)){const h=n.enter("headingSetext"),p=n.enter("phrasing"),y=n.containerPhrasing(e,{...s.current(),before:`
673
+ `,...u.current()}))),l(),e.title&&(l=n.enter(`title${s}`),d+=u.move(" "+i),d+=u.move(n.safe(e.title,{before:d,after:i,...u.current()})),d+=u.move(i),l()),o(),d}function BSe(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Rf(e){return"&#x"+e.toString(16).toUpperCase()+";"}function hv(e,t,n){const r=ed(e),i=ed(t);return r===void 0?i===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}Ij.peek=jSe;function Ij(e,t,n,r){const i=BSe(n),s=n.enter("emphasis"),o=n.createTracker(r),l=o.move(i);let u=o.move(n.containerPhrasing(e,{after:i,before:l,...o.current()}));const d=u.charCodeAt(0),h=hv(r.before.charCodeAt(r.before.length-1),d,i);h.inside&&(u=Rf(d)+u.slice(1));const p=u.charCodeAt(u.length-1),y=hv(r.after.charCodeAt(0),p,i);y.inside&&(u=u.slice(0,-1)+Rf(p));const v=o.move(i);return s(),n.attentionEncodeSurroundingInfo={after:y.outside,before:h.outside},l+u+v}function jSe(e,t,n){return n.options.emphasis||"*"}function FSe(e,t){let n=!1;return hy(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,rx}),!!((!e.depth||e.depth<3)&&RE(e)&&(t.options.setext||n))}function $Se(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(r);if(FSe(e,n)){const h=n.enter("headingSetext"),p=n.enter("phrasing"),y=n.containerPhrasing(e,{...s.current(),before:`
674
674
  `,after:`
675
675
  `});return p(),h(),y+`
676
676
  `+(i===1?"=":"-").repeat(y.length-(Math.max(y.lastIndexOf("\r"),y.lastIndexOf(`
677
677
  `))+1))}const o="#".repeat(i),l=n.enter("headingAtx"),u=n.enter("phrasing");s.move(o+" ");let d=n.containerPhrasing(e,{before:"# ",after:`
678
- `,...s.current()});return/^[\t ]/.test(d)&&(d=Rf(d.charCodeAt(0))+d.slice(1)),d=d?o+" "+d:o,n.options.closeAtx&&(d+=" "+o),u(),l(),d}z4.peek=HSe;function z4(e){return e.value||""}function HSe(){return"<"}B4.peek=USe;function B4(e,t,n,r){const i=IE(n),s=i==='"'?"Quote":"Apostrophe",o=n.enter("image");let l=n.enter("label");const u=n.createTracker(r);let d=u.move("![");return d+=u.move(n.safe(e.alt,{before:d,after:"]",...u.current()})),d+=u.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),d+=u.move("<"),d+=u.move(n.safe(e.url,{before:d,after:">",...u.current()})),d+=u.move(">")):(l=n.enter("destinationRaw"),d+=u.move(n.safe(e.url,{before:d,after:e.title?" ":")",...u.current()}))),l(),e.title&&(l=n.enter(`title${s}`),d+=u.move(" "+i),d+=u.move(n.safe(e.title,{before:d,after:i,...u.current()})),d+=u.move(i),l()),d+=u.move(")"),o(),d}function USe(){return"!"}j4.peek=WSe;function j4(e,t,n,r){const i=e.referenceType,s=n.enter("imageReference");let o=n.enter("label");const l=n.createTracker(r);let u=l.move("![");const d=n.safe(e.alt,{before:u,after:"]",...l.current()});u+=l.move(d+"]["),o();const h=n.stack;n.stack=[],o=n.enter("reference");const p=n.safe(n.associationId(e),{before:u,after:"]",...l.current()});return o(),n.stack=h,s(),i==="full"||!d||d!==p?u+=l.move(p+"]"):i==="shortcut"?u=u.slice(0,-1):u+=l.move("]"),u}function WSe(){return"!"}F4.peek=qSe;function F4(e,t,n){let r=e.value||"",i="`",s=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++s<n.unsafe.length;){const o=n.unsafe[s],l=n.compilePattern(o);let u;if(o.atBreak)for(;u=l.exec(r);){let d=u.index;r.charCodeAt(d)===10&&r.charCodeAt(d-1)===13&&d--,r=r.slice(0,d)+" "+r.slice(u.index+1)}}return i+r+i}function qSe(){return"`"}function $4(e,t){const n=RE(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}H4.peek=VSe;function H4(e,t,n,r){const i=IE(n),s=i==='"'?"Quote":"Apostrophe",o=n.createTracker(r);let l,u;if($4(e,n)){const h=n.stack;n.stack=[],l=n.enter("autolink");let p=o.move("<");return p+=o.move(n.containerPhrasing(e,{before:p,after:">",...o.current()})),p+=o.move(">"),l(),n.stack=h,p}l=n.enter("link"),u=n.enter("label");let d=o.move("[");return d+=o.move(n.containerPhrasing(e,{before:d,after:"](",...o.current()})),d+=o.move("]("),u(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(u=n.enter("destinationLiteral"),d+=o.move("<"),d+=o.move(n.safe(e.url,{before:d,after:">",...o.current()})),d+=o.move(">")):(u=n.enter("destinationRaw"),d+=o.move(n.safe(e.url,{before:d,after:e.title?" ":")",...o.current()}))),u(),e.title&&(u=n.enter(`title${s}`),d+=o.move(" "+i),d+=o.move(n.safe(e.title,{before:d,after:i,...o.current()})),d+=o.move(i),u()),d+=o.move(")"),l(),d}function VSe(e,t,n){return $4(e,n)?"<":"["}U4.peek=YSe;function U4(e,t,n,r){const i=e.referenceType,s=n.enter("linkReference");let o=n.enter("label");const l=n.createTracker(r);let u=l.move("[");const d=n.containerPhrasing(e,{before:u,after:"]",...l.current()});u+=l.move(d+"]["),o();const h=n.stack;n.stack=[],o=n.enter("reference");const p=n.safe(n.associationId(e),{before:u,after:"]",...l.current()});return o(),n.stack=h,s(),i==="full"||!d||d!==p?u+=l.move(p+"]"):i==="shortcut"?u=u.slice(0,-1):u+=l.move("]"),u}function YSe(){return"["}function zE(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function KSe(e){const t=zE(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function GSe(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function W4(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function XSe(e,t,n,r){const i=n.enter("list"),s=n.bulletCurrent;let o=e.ordered?GSe(n):zE(n);const l=e.ordered?o==="."?")":".":KSe(n);let u=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){const h=e.children?e.children[0]:void 0;if((o==="*"||o==="-")&&h&&(!h.children||!h.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(u=!0),W4(n)===o&&h){let p=-1;for(;++p<e.children.length;){const y=e.children[p];if(y&&y.type==="listItem"&&y.children&&y.children[0]&&y.children[0].type==="thematicBreak"){u=!0;break}}}}u&&(o=l),n.bulletCurrent=o;const d=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=s,i(),d}function ZSe(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function QSe(e,t,n,r){const i=ZSe(n);let s=n.bulletCurrent||zE(n);t&&t.type==="list"&&t.ordered&&(s=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+s);let o=s.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);const l=n.createTracker(r);l.move(s+" ".repeat(o-s.length)),l.shift(o);const u=n.enter("listItem"),d=n.indentLines(n.containerFlow(e,l.current()),h);return u(),d;function h(p,y,v){return y?(v?"":" ".repeat(o))+p:(v?s:s+" ".repeat(o-s.length))+p}}function JSe(e,t,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),o=n.containerPhrasing(e,r);return s(),i(),o}const exe=ip(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function txe(e,t,n,r){return(e.children.some(function(o){return exe(o)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function nxe(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}q4.peek=rxe;function q4(e,t,n,r){const i=nxe(n),s=n.enter("strong"),o=n.createTracker(r),l=o.move(i+i);let u=o.move(n.containerPhrasing(e,{after:i,before:l,...o.current()}));const d=u.charCodeAt(0),h=hv(r.before.charCodeAt(r.before.length-1),d,i);h.inside&&(u=Rf(d)+u.slice(1));const p=u.charCodeAt(u.length-1),y=hv(r.after.charCodeAt(0),p,i);y.inside&&(u=u.slice(0,-1)+Rf(p));const v=o.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:y.outside,before:h.outside},l+u+v}function rxe(e,t,n){return n.options.strong||"*"}function ixe(e,t,n,r){return n.safe(e.value,r)}function sxe(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function oxe(e,t,n){const r=(W4(n)+(n.options.ruleSpaces?" ":"")).repeat(sxe(n));return n.options.ruleSpaces?r.slice(0,-1):r}const V4={blockquote:ASe,break:QO,code:LSe,definition:zSe,emphasis:I4,hardBreak:QO,heading:$Se,html:z4,image:B4,imageReference:j4,inlineCode:F4,link:H4,linkReference:U4,list:XSe,listItem:QSe,paragraph:JSe,root:txe,strong:q4,text:ixe,thematicBreak:oxe};function axe(){return{enter:{table:lxe,tableData:JO,tableHeader:JO,tableRow:uxe},exit:{codeText:dxe,table:cxe,tableData:r0,tableHeader:r0,tableRow:r0}}}function lxe(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function cxe(e){this.exit(e),this.data.inTable=void 0}function uxe(e){this.enter({type:"tableRow",children:[]},e)}function r0(e){this.exit(e)}function JO(e){this.enter({type:"tableCell",children:[]},e)}function dxe(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,hxe));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function hxe(e,t){return t==="|"?t:e}function fxe(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
678
+ `,...s.current()});return/^[\t ]/.test(d)&&(d=Rf(d.charCodeAt(0))+d.slice(1)),d=d?o+" "+d:o,n.options.closeAtx&&(d+=" "+o),u(),l(),d}zj.peek=HSe;function zj(e){return e.value||""}function HSe(){return"<"}Bj.peek=USe;function Bj(e,t,n,r){const i=IE(n),s=i==='"'?"Quote":"Apostrophe",o=n.enter("image");let l=n.enter("label");const u=n.createTracker(r);let d=u.move("![");return d+=u.move(n.safe(e.alt,{before:d,after:"]",...u.current()})),d+=u.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),d+=u.move("<"),d+=u.move(n.safe(e.url,{before:d,after:">",...u.current()})),d+=u.move(">")):(l=n.enter("destinationRaw"),d+=u.move(n.safe(e.url,{before:d,after:e.title?" ":")",...u.current()}))),l(),e.title&&(l=n.enter(`title${s}`),d+=u.move(" "+i),d+=u.move(n.safe(e.title,{before:d,after:i,...u.current()})),d+=u.move(i),l()),d+=u.move(")"),o(),d}function USe(){return"!"}jj.peek=WSe;function jj(e,t,n,r){const i=e.referenceType,s=n.enter("imageReference");let o=n.enter("label");const l=n.createTracker(r);let u=l.move("![");const d=n.safe(e.alt,{before:u,after:"]",...l.current()});u+=l.move(d+"]["),o();const h=n.stack;n.stack=[],o=n.enter("reference");const p=n.safe(n.associationId(e),{before:u,after:"]",...l.current()});return o(),n.stack=h,s(),i==="full"||!d||d!==p?u+=l.move(p+"]"):i==="shortcut"?u=u.slice(0,-1):u+=l.move("]"),u}function WSe(){return"!"}Fj.peek=qSe;function Fj(e,t,n){let r=e.value||"",i="`",s=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++s<n.unsafe.length;){const o=n.unsafe[s],l=n.compilePattern(o);let u;if(o.atBreak)for(;u=l.exec(r);){let d=u.index;r.charCodeAt(d)===10&&r.charCodeAt(d-1)===13&&d--,r=r.slice(0,d)+" "+r.slice(u.index+1)}}return i+r+i}function qSe(){return"`"}function $j(e,t){const n=RE(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}Hj.peek=VSe;function Hj(e,t,n,r){const i=IE(n),s=i==='"'?"Quote":"Apostrophe",o=n.createTracker(r);let l,u;if($j(e,n)){const h=n.stack;n.stack=[],l=n.enter("autolink");let p=o.move("<");return p+=o.move(n.containerPhrasing(e,{before:p,after:">",...o.current()})),p+=o.move(">"),l(),n.stack=h,p}l=n.enter("link"),u=n.enter("label");let d=o.move("[");return d+=o.move(n.containerPhrasing(e,{before:d,after:"](",...o.current()})),d+=o.move("]("),u(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(u=n.enter("destinationLiteral"),d+=o.move("<"),d+=o.move(n.safe(e.url,{before:d,after:">",...o.current()})),d+=o.move(">")):(u=n.enter("destinationRaw"),d+=o.move(n.safe(e.url,{before:d,after:e.title?" ":")",...o.current()}))),u(),e.title&&(u=n.enter(`title${s}`),d+=o.move(" "+i),d+=o.move(n.safe(e.title,{before:d,after:i,...o.current()})),d+=o.move(i),u()),d+=o.move(")"),l(),d}function VSe(e,t,n){return $j(e,n)?"<":"["}Uj.peek=YSe;function Uj(e,t,n,r){const i=e.referenceType,s=n.enter("linkReference");let o=n.enter("label");const l=n.createTracker(r);let u=l.move("[");const d=n.containerPhrasing(e,{before:u,after:"]",...l.current()});u+=l.move(d+"]["),o();const h=n.stack;n.stack=[],o=n.enter("reference");const p=n.safe(n.associationId(e),{before:u,after:"]",...l.current()});return o(),n.stack=h,s(),i==="full"||!d||d!==p?u+=l.move(p+"]"):i==="shortcut"?u=u.slice(0,-1):u+=l.move("]"),u}function YSe(){return"["}function zE(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function KSe(e){const t=zE(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function GSe(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Wj(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function XSe(e,t,n,r){const i=n.enter("list"),s=n.bulletCurrent;let o=e.ordered?GSe(n):zE(n);const l=e.ordered?o==="."?")":".":KSe(n);let u=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){const h=e.children?e.children[0]:void 0;if((o==="*"||o==="-")&&h&&(!h.children||!h.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(u=!0),Wj(n)===o&&h){let p=-1;for(;++p<e.children.length;){const y=e.children[p];if(y&&y.type==="listItem"&&y.children&&y.children[0]&&y.children[0].type==="thematicBreak"){u=!0;break}}}}u&&(o=l),n.bulletCurrent=o;const d=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=s,i(),d}function ZSe(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function QSe(e,t,n,r){const i=ZSe(n);let s=n.bulletCurrent||zE(n);t&&t.type==="list"&&t.ordered&&(s=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+s);let o=s.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);const l=n.createTracker(r);l.move(s+" ".repeat(o-s.length)),l.shift(o);const u=n.enter("listItem"),d=n.indentLines(n.containerFlow(e,l.current()),h);return u(),d;function h(p,y,v){return y?(v?"":" ".repeat(o))+p:(v?s:s+" ".repeat(o-s.length))+p}}function JSe(e,t,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),o=n.containerPhrasing(e,r);return s(),i(),o}const exe=ip(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function txe(e,t,n,r){return(e.children.some(function(o){return exe(o)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function nxe(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}qj.peek=rxe;function qj(e,t,n,r){const i=nxe(n),s=n.enter("strong"),o=n.createTracker(r),l=o.move(i+i);let u=o.move(n.containerPhrasing(e,{after:i,before:l,...o.current()}));const d=u.charCodeAt(0),h=hv(r.before.charCodeAt(r.before.length-1),d,i);h.inside&&(u=Rf(d)+u.slice(1));const p=u.charCodeAt(u.length-1),y=hv(r.after.charCodeAt(0),p,i);y.inside&&(u=u.slice(0,-1)+Rf(p));const v=o.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:y.outside,before:h.outside},l+u+v}function rxe(e,t,n){return n.options.strong||"*"}function ixe(e,t,n,r){return n.safe(e.value,r)}function sxe(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function oxe(e,t,n){const r=(Wj(n)+(n.options.ruleSpaces?" ":"")).repeat(sxe(n));return n.options.ruleSpaces?r.slice(0,-1):r}const Vj={blockquote:ASe,break:QO,code:LSe,definition:zSe,emphasis:Ij,hardBreak:QO,heading:$Se,html:zj,image:Bj,imageReference:jj,inlineCode:Fj,link:Hj,linkReference:Uj,list:XSe,listItem:QSe,paragraph:JSe,root:txe,strong:qj,text:ixe,thematicBreak:oxe};function axe(){return{enter:{table:lxe,tableData:JO,tableHeader:JO,tableRow:uxe},exit:{codeText:dxe,table:cxe,tableData:r0,tableHeader:r0,tableRow:r0}}}function lxe(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function cxe(e){this.exit(e),this.data.inTable=void 0}function uxe(e){this.enter({type:"tableRow",children:[]},e)}function r0(e){this.exit(e)}function JO(e){this.enter({type:"tableCell",children:[]},e)}function dxe(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,hxe));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function hxe(e,t){return t==="|"?t:e}function fxe(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
679
679
  `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:y,table:o,tableCell:u,tableRow:l}};function o(v,_,w,x){return d(h(v,w,x),v.align)}function l(v,_,w,x){const E=p(v,w,x),k=d([E]);return k.slice(0,k.indexOf(`
680
- `))}function u(v,_,w,x){const E=w.enter("tableCell"),k=w.enter("phrasing"),R=w.containerPhrasing(v,{...x,before:s,after:s});return k(),E(),R}function d(v,_){return TSe(v,{align:_,alignDelimiters:r,padding:n,stringLength:i})}function h(v,_,w){const x=v.children;let E=-1;const k=[],R=_.enter("table");for(;++E<x.length;)k[E]=p(x[E],_,w);return R(),k}function p(v,_,w){const x=v.children;let E=-1;const k=[],R=_.enter("tableRow");for(;++E<x.length;)k[E]=u(x[E],v,_,w);return R(),k}function y(v,_,w){let x=V4.inlineCode(v,_,w);return w.stack.includes("tableCell")&&(x=x.replace(/\|/g,"\\$&")),x}}function pxe(){return{exit:{taskListCheckValueChecked:eD,taskListCheckValueUnchecked:eD,paragraph:gxe}}}function mxe(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:vxe}}}function eD(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function gxe(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let s=-1,o;for(;++s<i.length;){const l=i[s];if(l.type==="paragraph"){o=l;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function vxe(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",l=n.createTracker(r);s&&l.move(o);let u=V4.listItem(e,t,n,{...r,...l.current()});return s&&(u=u.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,d)),u;function d(h){return h+o}}function yxe(){return[X0e(),vSe(),wSe(),axe(),pxe()]}function bxe(e){return{extensions:[Z0e(),ySe(e),SSe(),fxe(e),mxe()]}}const _xe={tokenize:kxe,partial:!0},Y4={tokenize:Txe,partial:!0},K4={tokenize:Rxe,partial:!0},G4={tokenize:Axe,partial:!0},wxe={tokenize:Nxe,partial:!0},X4={name:"wwwAutolink",tokenize:Exe,previous:Q4},Z4={name:"protocolAutolink",tokenize:Cxe,previous:J4},ca={name:"emailAutolink",tokenize:xxe,previous:eF},Ao={};function Sxe(){return{text:Ao}}let Vl=48;for(;Vl<123;)Ao[Vl]=ca,Vl++,Vl===58?Vl=65:Vl===91&&(Vl=97);Ao[43]=ca;Ao[45]=ca;Ao[46]=ca;Ao[95]=ca;Ao[72]=[ca,Z4];Ao[104]=[ca,Z4];Ao[87]=[ca,X4];Ao[119]=[ca,X4];function xxe(e,t,n){const r=this;let i,s;return o;function o(p){return!ax(p)||!eF.call(r,r.previous)||BE(r.events)?n(p):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),l(p))}function l(p){return ax(p)?(e.consume(p),l):p===64?(e.consume(p),u):n(p)}function u(p){return p===46?e.check(wxe,h,d)(p):p===45||p===95||xi(p)?(s=!0,e.consume(p),u):h(p)}function d(p){return e.consume(p),i=!0,u}function h(p){return s&&i&&Di(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(p)):n(p)}}function Exe(e,t,n){const r=this;return i;function i(o){return o!==87&&o!==119||!Q4.call(r,r.previous)||BE(r.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(_xe,e.attempt(Y4,e.attempt(K4,s),n),n)(o))}function s(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function Cxe(e,t,n){const r=this;let i="",s=!1;return o;function o(p){return(p===72||p===104)&&J4.call(r,r.previous)&&!BE(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(p),e.consume(p),l):n(p)}function l(p){if(Di(p)&&i.length<5)return i+=String.fromCodePoint(p),e.consume(p),l;if(p===58){const y=i.toLowerCase();if(y==="http"||y==="https")return e.consume(p),u}return n(p)}function u(p){return p===47?(e.consume(p),s?d:(s=!0,u)):n(p)}function d(p){return p===null||cv(p)||Gn(p)||fc(p)||ly(p)?n(p):e.attempt(Y4,e.attempt(K4,h),n)(p)}function h(p){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(p)}}function kxe(e,t,n){let r=0;return i;function i(o){return(o===87||o===119)&&r<3?(r++,e.consume(o),i):o===46&&r===3?(e.consume(o),s):n(o)}function s(o){return o===null?n(o):t(o)}}function Txe(e,t,n){let r,i,s;return o;function o(d){return d===46||d===95?e.check(G4,u,l)(d):d===null||Gn(d)||fc(d)||d!==45&&ly(d)?u(d):(s=!0,e.consume(d),o)}function l(d){return d===95?r=!0:(i=r,r=void 0),e.consume(d),o}function u(d){return i||r||!s?n(d):t(d)}}function Rxe(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?s(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(G4,t,s)(o):o===null||Gn(o)||fc(o)?t(o):(e.consume(o),i)}function s(o){return o===41&&r++,e.consume(o),i}}function Axe(e,t,n){return r;function r(l){return l===33||l===34||l===39||l===41||l===42||l===44||l===46||l===58||l===59||l===63||l===95||l===126?(e.consume(l),r):l===38?(e.consume(l),s):l===93?(e.consume(l),i):l===60||l===null||Gn(l)||fc(l)?t(l):n(l)}function i(l){return l===null||l===40||l===91||Gn(l)||fc(l)?t(l):r(l)}function s(l){return Di(l)?o(l):n(l)}function o(l){return l===59?(e.consume(l),r):Di(l)?(e.consume(l),o):n(l)}}function Nxe(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return xi(s)?n(s):t(s)}}function Q4(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Gn(e)}function J4(e){return!Di(e)}function eF(e){return!(e===47||ax(e))}function ax(e){return e===43||e===45||e===46||e===95||xi(e)}function BE(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const Mxe={tokenize:jxe,partial:!0};function Oxe(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:Ixe,continuation:{tokenize:zxe},exit:Bxe}},text:{91:{name:"gfmFootnoteCall",tokenize:Lxe},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Dxe,resolveTo:Pxe}}}}function Dxe(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;i--;){const u=r.events[i][1];if(u.type==="labelImage"){o=u;break}if(u.type==="gfmFootnoteCall"||u.type==="labelLink"||u.type==="label"||u.type==="image"||u.type==="link")break}return l;function l(u){if(!o||!o._balanced)return n(u);const d=Ks(r.sliceSerialize({start:o.end,end:r.now()}));return d.codePointAt(0)!==94||!s.includes(d.slice(1))?n(u):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(u),e.exit("gfmFootnoteCallLabelMarker"),t(u))}}function Pxe(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},l=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",o,t],["exit",o,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...l),e}function Lxe(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,o;return l;function l(p){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),u}function u(p){return p!==94?n(p):(e.enter("gfmFootnoteCallMarker"),e.consume(p),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",d)}function d(p){if(s>999||p===93&&!o||p===null||p===91||Gn(p))return n(p);if(p===93){e.exit("chunkString");const y=e.exit("gfmFootnoteCallString");return i.includes(Ks(r.sliceSerialize(y)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(p)}return Gn(p)||(o=!0),s++,e.consume(p),p===92?h:d}function h(p){return p===91||p===92||p===93?(e.consume(p),s++,d):d(p)}}function Ixe(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,o=0,l;return u;function u(_){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(_),e.exit("gfmFootnoteDefinitionLabelMarker"),d}function d(_){return _===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(_),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",h):n(_)}function h(_){if(o>999||_===93&&!l||_===null||_===91||Gn(_))return n(_);if(_===93){e.exit("chunkString");const w=e.exit("gfmFootnoteDefinitionLabelString");return s=Ks(r.sliceSerialize(w)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(_),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),y}return Gn(_)||(l=!0),o++,e.consume(_),_===92?p:h}function p(_){return _===91||_===92||_===93?(e.consume(_),o++,h):h(_)}function y(_){return _===58?(e.enter("definitionMarker"),e.consume(_),e.exit("definitionMarker"),i.includes(s)||i.push(s),Mn(e,v,"gfmFootnoteDefinitionWhitespace")):n(_)}function v(_){return t(_)}}function zxe(e,t,n){return e.check(rp,t,e.attempt(Mxe,t,n))}function Bxe(e){e.exit("gfmFootnoteDefinition")}function jxe(e,t,n){const r=this;return Mn(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?t(s):n(s)}}function Fxe(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,l){let u=-1;for(;++u<o.length;)if(o[u][0]==="enter"&&o[u][1].type==="strikethroughSequenceTemporary"&&o[u][1]._close){let d=u;for(;d--;)if(o[d][0]==="exit"&&o[d][1].type==="strikethroughSequenceTemporary"&&o[d][1]._open&&o[u][1].end.offset-o[u][1].start.offset===o[d][1].end.offset-o[d][1].start.offset){o[u][1].type="strikethroughSequence",o[d][1].type="strikethroughSequence";const h={type:"strikethrough",start:Object.assign({},o[d][1].start),end:Object.assign({},o[u][1].end)},p={type:"strikethroughText",start:Object.assign({},o[d][1].end),end:Object.assign({},o[u][1].start)},y=[["enter",h,l],["enter",o[d][1],l],["exit",o[d][1],l],["enter",p,l]],v=l.parser.constructs.insideSpan.null;v&&us(y,y.length,0,cy(v,o.slice(d+1,u),l)),us(y,y.length,0,[["exit",p,l],["enter",o[u][1],l],["exit",o[u][1],l],["exit",h,l]]),us(o,d-1,u-d+3,y),u=d+y.length-2;break}}for(u=-1;++u<o.length;)o[u][1].type==="strikethroughSequenceTemporary"&&(o[u][1].type="data");return o}function s(o,l,u){const d=this.previous,h=this.events;let p=0;return y;function y(_){return d===126&&h[h.length-1][1].type!=="characterEscape"?u(_):(o.enter("strikethroughSequenceTemporary"),v(_))}function v(_){const w=ed(d);if(_===126)return p>1?u(_):(o.consume(_),p++,v);if(p<2&&!n)return u(_);const x=o.exit("strikethroughSequenceTemporary"),E=ed(_);return x._open=!E||E===2&&!!w,x._close=!w||w===2&&!!E,l(_)}}}class $xe{constructor(){this.map=[]}add(t,n,r){Hxe(this,t,n,r)}consume(t){if(this.map.sort(function(s,o){return s[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const s of i)t.push(s);i=r.pop()}this.map.length=0}}function Hxe(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function Uxe(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function Wxe(){return{flow:{null:{name:"table",tokenize:qxe,resolveAll:Vxe}}}}function qxe(e,t,n){const r=this;let i=0,s=0,o;return l;function l(U){let F=r.events.length-1;for(;F>-1;){const B=r.events[F][1].type;if(B==="lineEnding"||B==="linePrefix")F--;else break}const O=F>-1?r.events[F][1].type:null,M=O==="tableHead"||O==="tableRow"?T:u;return M===T&&r.parser.lazy[r.now().line]?n(U):M(U)}function u(U){return e.enter("tableHead"),e.enter("tableRow"),d(U)}function d(U){return U===124||(o=!0,s+=1),h(U)}function h(U){return U===null?n(U):Ft(U)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(U),e.exit("lineEnding"),v):n(U):Sn(U)?Mn(e,h,"whitespace")(U):(s+=1,o&&(o=!1,i+=1),U===124?(e.enter("tableCellDivider"),e.consume(U),e.exit("tableCellDivider"),o=!0,h):(e.enter("data"),p(U)))}function p(U){return U===null||U===124||Gn(U)?(e.exit("data"),h(U)):(e.consume(U),U===92?y:p)}function y(U){return U===92||U===124?(e.consume(U),p):p(U)}function v(U){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(U):(e.enter("tableDelimiterRow"),o=!1,Sn(U)?Mn(e,_,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(U):_(U))}function _(U){return U===45||U===58?x(U):U===124?(o=!0,e.enter("tableCellDivider"),e.consume(U),e.exit("tableCellDivider"),w):I(U)}function w(U){return Sn(U)?Mn(e,x,"whitespace")(U):x(U)}function x(U){return U===58?(s+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(U),e.exit("tableDelimiterMarker"),E):U===45?(s+=1,E(U)):U===null||Ft(U)?A(U):I(U)}function E(U){return U===45?(e.enter("tableDelimiterFiller"),k(U)):I(U)}function k(U){return U===45?(e.consume(U),k):U===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(U),e.exit("tableDelimiterMarker"),R):(e.exit("tableDelimiterFiller"),R(U))}function R(U){return Sn(U)?Mn(e,A,"whitespace")(U):A(U)}function A(U){return U===124?_(U):U===null||Ft(U)?!o||i!==s?I(U):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(U)):I(U)}function I(U){return n(U)}function T(U){return e.enter("tableRow"),H(U)}function H(U){return U===124?(e.enter("tableCellDivider"),e.consume(U),e.exit("tableCellDivider"),H):U===null||Ft(U)?(e.exit("tableRow"),t(U)):Sn(U)?Mn(e,H,"whitespace")(U):(e.enter("data"),D(U))}function D(U){return U===null||U===124||Gn(U)?(e.exit("data"),H(U)):(e.consume(U),U===92?W:D)}function W(U){return U===92||U===124?(e.consume(U),D):D(U)}}function Vxe(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],o=[0,0,0,0],l=!1,u=0,d,h,p;const y=new $xe;for(;++n<e.length;){const v=e[n],_=v[1];v[0]==="enter"?_.type==="tableHead"?(l=!1,u!==0&&(tD(y,t,u,d,h),h=void 0,u=0),d={type:"table",start:Object.assign({},_.start),end:Object.assign({},_.end)},y.add(n,0,[["enter",d,t]])):_.type==="tableRow"||_.type==="tableDelimiterRow"?(r=!0,p=void 0,s=[0,0,0,0],o=[0,n+1,0,0],l&&(l=!1,h={type:"tableBody",start:Object.assign({},_.start),end:Object.assign({},_.end)},y.add(n,0,[["enter",h,t]])),i=_.type==="tableDelimiterRow"?2:h?3:1):i&&(_.type==="data"||_.type==="tableDelimiterMarker"||_.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(s[1]!==0&&(o[0]=o[1],p=og(y,t,s,i,void 0,p),s=[0,0,0,0]),o[2]=n)):_.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(o[0]=o[1],p=og(y,t,s,i,void 0,p)),s=o,o=[s[1],n,0,0])):_.type==="tableHead"?(l=!0,u=n):_.type==="tableRow"||_.type==="tableDelimiterRow"?(u=n,s[1]!==0?(o[0]=o[1],p=og(y,t,s,i,n,p)):o[1]!==0&&(p=og(y,t,o,i,n,p)),i=0):i&&(_.type==="data"||_.type==="tableDelimiterMarker"||_.type==="tableDelimiterFiller")&&(o[3]=n)}for(u!==0&&tD(y,t,u,d,h),y.consume(t.events),n=-1;++n<t.events.length;){const v=t.events[n];v[0]==="enter"&&v[1].type==="table"&&(v[1]._align=Uxe(t.events,n))}return e}function og(e,t,n,r,i,s){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",l="tableContent";n[0]!==0&&(s.end=Object.assign({},xu(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const u=xu(t.events,n[1]);if(s={type:o,start:Object.assign({},u),end:Object.assign({},u)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const d=xu(t.events,n[2]),h=xu(t.events,n[3]),p={type:l,start:Object.assign({},d),end:Object.assign({},h)};if(e.add(n[2],0,[["enter",p,t]]),r!==2){const y=t.events[n[2]],v=t.events[n[3]];if(y[1].end=Object.assign({},v[1].end),y[1].type="chunkText",y[1].contentType="text",n[3]>n[2]+1){const _=n[2]+1,w=n[3]-n[2]-1;e.add(_,w,[])}}e.add(n[3]+1,0,[["exit",p,t]])}return i!==void 0&&(s.end=Object.assign({},xu(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function tD(e,t,n,r,i){const s=[],o=xu(t.events,n);i&&(i.end=Object.assign({},o),s.push(["exit",i,t])),r.end=Object.assign({},o),s.push(["exit",r,t]),e.add(n+1,0,s)}function xu(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const Yxe={name:"tasklistCheck",tokenize:Gxe};function Kxe(){return{text:{91:Yxe}}}function Gxe(e,t,n){const r=this;return i;function i(u){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(u):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(u),e.exit("taskListCheckMarker"),s)}function s(u){return Gn(u)?(e.enter("taskListCheckValueUnchecked"),e.consume(u),e.exit("taskListCheckValueUnchecked"),o):u===88||u===120?(e.enter("taskListCheckValueChecked"),e.consume(u),e.exit("taskListCheckValueChecked"),o):n(u)}function o(u){return u===93?(e.enter("taskListCheckMarker"),e.consume(u),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),l):n(u)}function l(u){return Ft(u)?t(u):Sn(u)?e.check({tokenize:Xxe},t,n)(u):n(u)}}function Xxe(e,t,n){return Mn(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function Zxe(e){return u4([Sxe(),Oxe(),Fxe(e),Wxe(),Kxe()])}const Qxe={};function Jxe(e){const t=this,n=e||Qxe,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(Zxe(n)),s.push(yxe()),o.push(bxe(n))}const nD=(function(e,t,n){const r=ip(n);if(!e||!e.type||!e.children)throw new Error("Expected parent node");if(typeof t=="number"){if(t<0||t===Number.POSITIVE_INFINITY)throw new Error("Expected positive finite number as index")}else if(t=e.children.indexOf(t),t<0)throw new Error("Expected child node or index");for(;++t<e.children.length;)if(r(e.children[t],t,e))return e.children[t]}),Rc=(function(e){if(e==null)return n1e;if(typeof e=="string")return t1e(e);if(typeof e=="object")return e1e(e);if(typeof e=="function")return jE(e);throw new Error("Expected function, string, or array as `test`")});function e1e(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Rc(e[n]);return jE(r);function r(...i){let s=-1;for(;++s<t.length;)if(t[s].apply(this,i))return!0;return!1}}function t1e(e){return jE(t);function t(n){return n.tagName===e}}function jE(e){return t;function t(n,r,i){return!!(r1e(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function n1e(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="element"&&"tagName"in e&&typeof e.tagName=="string")}function r1e(e){return e!==null&&typeof e=="object"&&"type"in e&&"tagName"in e}const rD=/\n/g,iD=/[\t ]+/g,lx=Rc("br"),sD=Rc(d1e),i1e=Rc("p"),oD=Rc("tr"),s1e=Rc(["datalist","head","noembed","noframes","noscript","rp","script","style","template","title",u1e,h1e]),tF=Rc(["address","article","aside","blockquote","body","caption","center","dd","dialog","dir","dl","dt","div","figure","figcaption","footer","form,","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","legend","li","listing","main","menu","nav","ol","p","plaintext","pre","section","ul","xmp"]);function o1e(e,t){const n=t||{},r="children"in e?e.children:[],i=tF(e),s=iF(e,{whitespace:n.whitespace||"normal"}),o=[];(e.type==="text"||e.type==="comment")&&o.push(...rF(e,{breakBefore:!0,breakAfter:!0}));let l=-1;for(;++l<r.length;)o.push(...nF(r[l],e,{whitespace:s,breakBefore:l?void 0:i,breakAfter:l<r.length-1?lx(r[l+1]):i}));const u=[];let d;for(l=-1;++l<o.length;){const h=o[l];typeof h=="number"?d!==void 0&&h>d&&(d=h):h&&(d!==void 0&&d>-1&&u.push(`
680
+ `))}function u(v,_,w,x){const E=w.enter("tableCell"),k=w.enter("phrasing"),R=w.containerPhrasing(v,{...x,before:s,after:s});return k(),E(),R}function d(v,_){return TSe(v,{align:_,alignDelimiters:r,padding:n,stringLength:i})}function h(v,_,w){const x=v.children;let E=-1;const k=[],R=_.enter("table");for(;++E<x.length;)k[E]=p(x[E],_,w);return R(),k}function p(v,_,w){const x=v.children;let E=-1;const k=[],R=_.enter("tableRow");for(;++E<x.length;)k[E]=u(x[E],v,_,w);return R(),k}function y(v,_,w){let x=Vj.inlineCode(v,_,w);return w.stack.includes("tableCell")&&(x=x.replace(/\|/g,"\\$&")),x}}function pxe(){return{exit:{taskListCheckValueChecked:eD,taskListCheckValueUnchecked:eD,paragraph:gxe}}}function mxe(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:vxe}}}function eD(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function gxe(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let s=-1,o;for(;++s<i.length;){const l=i[s];if(l.type==="paragraph"){o=l;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function vxe(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",l=n.createTracker(r);s&&l.move(o);let u=Vj.listItem(e,t,n,{...r,...l.current()});return s&&(u=u.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,d)),u;function d(h){return h+o}}function yxe(){return[X0e(),vSe(),wSe(),axe(),pxe()]}function bxe(e){return{extensions:[Z0e(),ySe(e),SSe(),fxe(e),mxe()]}}const _xe={tokenize:kxe,partial:!0},Yj={tokenize:Txe,partial:!0},Kj={tokenize:Rxe,partial:!0},Gj={tokenize:Axe,partial:!0},wxe={tokenize:Nxe,partial:!0},Xj={name:"wwwAutolink",tokenize:Exe,previous:Qj},Zj={name:"protocolAutolink",tokenize:Cxe,previous:Jj},ca={name:"emailAutolink",tokenize:xxe,previous:eF},Ao={};function Sxe(){return{text:Ao}}let Vl=48;for(;Vl<123;)Ao[Vl]=ca,Vl++,Vl===58?Vl=65:Vl===91&&(Vl=97);Ao[43]=ca;Ao[45]=ca;Ao[46]=ca;Ao[95]=ca;Ao[72]=[ca,Zj];Ao[104]=[ca,Zj];Ao[87]=[ca,Xj];Ao[119]=[ca,Xj];function xxe(e,t,n){const r=this;let i,s;return o;function o(p){return!ax(p)||!eF.call(r,r.previous)||BE(r.events)?n(p):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),l(p))}function l(p){return ax(p)?(e.consume(p),l):p===64?(e.consume(p),u):n(p)}function u(p){return p===46?e.check(wxe,h,d)(p):p===45||p===95||xi(p)?(s=!0,e.consume(p),u):h(p)}function d(p){return e.consume(p),i=!0,u}function h(p){return s&&i&&Di(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(p)):n(p)}}function Exe(e,t,n){const r=this;return i;function i(o){return o!==87&&o!==119||!Qj.call(r,r.previous)||BE(r.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(_xe,e.attempt(Yj,e.attempt(Kj,s),n),n)(o))}function s(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function Cxe(e,t,n){const r=this;let i="",s=!1;return o;function o(p){return(p===72||p===104)&&Jj.call(r,r.previous)&&!BE(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(p),e.consume(p),l):n(p)}function l(p){if(Di(p)&&i.length<5)return i+=String.fromCodePoint(p),e.consume(p),l;if(p===58){const y=i.toLowerCase();if(y==="http"||y==="https")return e.consume(p),u}return n(p)}function u(p){return p===47?(e.consume(p),s?d:(s=!0,u)):n(p)}function d(p){return p===null||cv(p)||Gn(p)||fc(p)||ly(p)?n(p):e.attempt(Yj,e.attempt(Kj,h),n)(p)}function h(p){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(p)}}function kxe(e,t,n){let r=0;return i;function i(o){return(o===87||o===119)&&r<3?(r++,e.consume(o),i):o===46&&r===3?(e.consume(o),s):n(o)}function s(o){return o===null?n(o):t(o)}}function Txe(e,t,n){let r,i,s;return o;function o(d){return d===46||d===95?e.check(Gj,u,l)(d):d===null||Gn(d)||fc(d)||d!==45&&ly(d)?u(d):(s=!0,e.consume(d),o)}function l(d){return d===95?r=!0:(i=r,r=void 0),e.consume(d),o}function u(d){return i||r||!s?n(d):t(d)}}function Rxe(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?s(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(Gj,t,s)(o):o===null||Gn(o)||fc(o)?t(o):(e.consume(o),i)}function s(o){return o===41&&r++,e.consume(o),i}}function Axe(e,t,n){return r;function r(l){return l===33||l===34||l===39||l===41||l===42||l===44||l===46||l===58||l===59||l===63||l===95||l===126?(e.consume(l),r):l===38?(e.consume(l),s):l===93?(e.consume(l),i):l===60||l===null||Gn(l)||fc(l)?t(l):n(l)}function i(l){return l===null||l===40||l===91||Gn(l)||fc(l)?t(l):r(l)}function s(l){return Di(l)?o(l):n(l)}function o(l){return l===59?(e.consume(l),r):Di(l)?(e.consume(l),o):n(l)}}function Nxe(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return xi(s)?n(s):t(s)}}function Qj(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Gn(e)}function Jj(e){return!Di(e)}function eF(e){return!(e===47||ax(e))}function ax(e){return e===43||e===45||e===46||e===95||xi(e)}function BE(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const Mxe={tokenize:jxe,partial:!0};function Oxe(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:Ixe,continuation:{tokenize:zxe},exit:Bxe}},text:{91:{name:"gfmFootnoteCall",tokenize:Lxe},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Dxe,resolveTo:Pxe}}}}function Dxe(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;i--;){const u=r.events[i][1];if(u.type==="labelImage"){o=u;break}if(u.type==="gfmFootnoteCall"||u.type==="labelLink"||u.type==="label"||u.type==="image"||u.type==="link")break}return l;function l(u){if(!o||!o._balanced)return n(u);const d=Ks(r.sliceSerialize({start:o.end,end:r.now()}));return d.codePointAt(0)!==94||!s.includes(d.slice(1))?n(u):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(u),e.exit("gfmFootnoteCallLabelMarker"),t(u))}}function Pxe(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},l=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",o,t],["exit",o,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...l),e}function Lxe(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,o;return l;function l(p){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),u}function u(p){return p!==94?n(p):(e.enter("gfmFootnoteCallMarker"),e.consume(p),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",d)}function d(p){if(s>999||p===93&&!o||p===null||p===91||Gn(p))return n(p);if(p===93){e.exit("chunkString");const y=e.exit("gfmFootnoteCallString");return i.includes(Ks(r.sliceSerialize(y)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(p)}return Gn(p)||(o=!0),s++,e.consume(p),p===92?h:d}function h(p){return p===91||p===92||p===93?(e.consume(p),s++,d):d(p)}}function Ixe(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,o=0,l;return u;function u(_){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(_),e.exit("gfmFootnoteDefinitionLabelMarker"),d}function d(_){return _===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(_),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",h):n(_)}function h(_){if(o>999||_===93&&!l||_===null||_===91||Gn(_))return n(_);if(_===93){e.exit("chunkString");const w=e.exit("gfmFootnoteDefinitionLabelString");return s=Ks(r.sliceSerialize(w)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(_),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),y}return Gn(_)||(l=!0),o++,e.consume(_),_===92?p:h}function p(_){return _===91||_===92||_===93?(e.consume(_),o++,h):h(_)}function y(_){return _===58?(e.enter("definitionMarker"),e.consume(_),e.exit("definitionMarker"),i.includes(s)||i.push(s),Mn(e,v,"gfmFootnoteDefinitionWhitespace")):n(_)}function v(_){return t(_)}}function zxe(e,t,n){return e.check(rp,t,e.attempt(Mxe,t,n))}function Bxe(e){e.exit("gfmFootnoteDefinition")}function jxe(e,t,n){const r=this;return Mn(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?t(s):n(s)}}function Fxe(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,l){let u=-1;for(;++u<o.length;)if(o[u][0]==="enter"&&o[u][1].type==="strikethroughSequenceTemporary"&&o[u][1]._close){let d=u;for(;d--;)if(o[d][0]==="exit"&&o[d][1].type==="strikethroughSequenceTemporary"&&o[d][1]._open&&o[u][1].end.offset-o[u][1].start.offset===o[d][1].end.offset-o[d][1].start.offset){o[u][1].type="strikethroughSequence",o[d][1].type="strikethroughSequence";const h={type:"strikethrough",start:Object.assign({},o[d][1].start),end:Object.assign({},o[u][1].end)},p={type:"strikethroughText",start:Object.assign({},o[d][1].end),end:Object.assign({},o[u][1].start)},y=[["enter",h,l],["enter",o[d][1],l],["exit",o[d][1],l],["enter",p,l]],v=l.parser.constructs.insideSpan.null;v&&us(y,y.length,0,cy(v,o.slice(d+1,u),l)),us(y,y.length,0,[["exit",p,l],["enter",o[u][1],l],["exit",o[u][1],l],["exit",h,l]]),us(o,d-1,u-d+3,y),u=d+y.length-2;break}}for(u=-1;++u<o.length;)o[u][1].type==="strikethroughSequenceTemporary"&&(o[u][1].type="data");return o}function s(o,l,u){const d=this.previous,h=this.events;let p=0;return y;function y(_){return d===126&&h[h.length-1][1].type!=="characterEscape"?u(_):(o.enter("strikethroughSequenceTemporary"),v(_))}function v(_){const w=ed(d);if(_===126)return p>1?u(_):(o.consume(_),p++,v);if(p<2&&!n)return u(_);const x=o.exit("strikethroughSequenceTemporary"),E=ed(_);return x._open=!E||E===2&&!!w,x._close=!w||w===2&&!!E,l(_)}}}class $xe{constructor(){this.map=[]}add(t,n,r){Hxe(this,t,n,r)}consume(t){if(this.map.sort(function(s,o){return s[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const s of i)t.push(s);i=r.pop()}this.map.length=0}}function Hxe(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function Uxe(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function Wxe(){return{flow:{null:{name:"table",tokenize:qxe,resolveAll:Vxe}}}}function qxe(e,t,n){const r=this;let i=0,s=0,o;return l;function l(U){let F=r.events.length-1;for(;F>-1;){const B=r.events[F][1].type;if(B==="lineEnding"||B==="linePrefix")F--;else break}const O=F>-1?r.events[F][1].type:null,M=O==="tableHead"||O==="tableRow"?T:u;return M===T&&r.parser.lazy[r.now().line]?n(U):M(U)}function u(U){return e.enter("tableHead"),e.enter("tableRow"),d(U)}function d(U){return U===124||(o=!0,s+=1),h(U)}function h(U){return U===null?n(U):Ft(U)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(U),e.exit("lineEnding"),v):n(U):Sn(U)?Mn(e,h,"whitespace")(U):(s+=1,o&&(o=!1,i+=1),U===124?(e.enter("tableCellDivider"),e.consume(U),e.exit("tableCellDivider"),o=!0,h):(e.enter("data"),p(U)))}function p(U){return U===null||U===124||Gn(U)?(e.exit("data"),h(U)):(e.consume(U),U===92?y:p)}function y(U){return U===92||U===124?(e.consume(U),p):p(U)}function v(U){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(U):(e.enter("tableDelimiterRow"),o=!1,Sn(U)?Mn(e,_,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(U):_(U))}function _(U){return U===45||U===58?x(U):U===124?(o=!0,e.enter("tableCellDivider"),e.consume(U),e.exit("tableCellDivider"),w):I(U)}function w(U){return Sn(U)?Mn(e,x,"whitespace")(U):x(U)}function x(U){return U===58?(s+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(U),e.exit("tableDelimiterMarker"),E):U===45?(s+=1,E(U)):U===null||Ft(U)?A(U):I(U)}function E(U){return U===45?(e.enter("tableDelimiterFiller"),k(U)):I(U)}function k(U){return U===45?(e.consume(U),k):U===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(U),e.exit("tableDelimiterMarker"),R):(e.exit("tableDelimiterFiller"),R(U))}function R(U){return Sn(U)?Mn(e,A,"whitespace")(U):A(U)}function A(U){return U===124?_(U):U===null||Ft(U)?!o||i!==s?I(U):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(U)):I(U)}function I(U){return n(U)}function T(U){return e.enter("tableRow"),H(U)}function H(U){return U===124?(e.enter("tableCellDivider"),e.consume(U),e.exit("tableCellDivider"),H):U===null||Ft(U)?(e.exit("tableRow"),t(U)):Sn(U)?Mn(e,H,"whitespace")(U):(e.enter("data"),D(U))}function D(U){return U===null||U===124||Gn(U)?(e.exit("data"),H(U)):(e.consume(U),U===92?W:D)}function W(U){return U===92||U===124?(e.consume(U),D):D(U)}}function Vxe(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],o=[0,0,0,0],l=!1,u=0,d,h,p;const y=new $xe;for(;++n<e.length;){const v=e[n],_=v[1];v[0]==="enter"?_.type==="tableHead"?(l=!1,u!==0&&(tD(y,t,u,d,h),h=void 0,u=0),d={type:"table",start:Object.assign({},_.start),end:Object.assign({},_.end)},y.add(n,0,[["enter",d,t]])):_.type==="tableRow"||_.type==="tableDelimiterRow"?(r=!0,p=void 0,s=[0,0,0,0],o=[0,n+1,0,0],l&&(l=!1,h={type:"tableBody",start:Object.assign({},_.start),end:Object.assign({},_.end)},y.add(n,0,[["enter",h,t]])),i=_.type==="tableDelimiterRow"?2:h?3:1):i&&(_.type==="data"||_.type==="tableDelimiterMarker"||_.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(s[1]!==0&&(o[0]=o[1],p=og(y,t,s,i,void 0,p),s=[0,0,0,0]),o[2]=n)):_.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(o[0]=o[1],p=og(y,t,s,i,void 0,p)),s=o,o=[s[1],n,0,0])):_.type==="tableHead"?(l=!0,u=n):_.type==="tableRow"||_.type==="tableDelimiterRow"?(u=n,s[1]!==0?(o[0]=o[1],p=og(y,t,s,i,n,p)):o[1]!==0&&(p=og(y,t,o,i,n,p)),i=0):i&&(_.type==="data"||_.type==="tableDelimiterMarker"||_.type==="tableDelimiterFiller")&&(o[3]=n)}for(u!==0&&tD(y,t,u,d,h),y.consume(t.events),n=-1;++n<t.events.length;){const v=t.events[n];v[0]==="enter"&&v[1].type==="table"&&(v[1]._align=Uxe(t.events,n))}return e}function og(e,t,n,r,i,s){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",l="tableContent";n[0]!==0&&(s.end=Object.assign({},xu(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const u=xu(t.events,n[1]);if(s={type:o,start:Object.assign({},u),end:Object.assign({},u)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const d=xu(t.events,n[2]),h=xu(t.events,n[3]),p={type:l,start:Object.assign({},d),end:Object.assign({},h)};if(e.add(n[2],0,[["enter",p,t]]),r!==2){const y=t.events[n[2]],v=t.events[n[3]];if(y[1].end=Object.assign({},v[1].end),y[1].type="chunkText",y[1].contentType="text",n[3]>n[2]+1){const _=n[2]+1,w=n[3]-n[2]-1;e.add(_,w,[])}}e.add(n[3]+1,0,[["exit",p,t]])}return i!==void 0&&(s.end=Object.assign({},xu(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function tD(e,t,n,r,i){const s=[],o=xu(t.events,n);i&&(i.end=Object.assign({},o),s.push(["exit",i,t])),r.end=Object.assign({},o),s.push(["exit",r,t]),e.add(n+1,0,s)}function xu(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const Yxe={name:"tasklistCheck",tokenize:Gxe};function Kxe(){return{text:{91:Yxe}}}function Gxe(e,t,n){const r=this;return i;function i(u){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(u):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(u),e.exit("taskListCheckMarker"),s)}function s(u){return Gn(u)?(e.enter("taskListCheckValueUnchecked"),e.consume(u),e.exit("taskListCheckValueUnchecked"),o):u===88||u===120?(e.enter("taskListCheckValueChecked"),e.consume(u),e.exit("taskListCheckValueChecked"),o):n(u)}function o(u){return u===93?(e.enter("taskListCheckMarker"),e.consume(u),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),l):n(u)}function l(u){return Ft(u)?t(u):Sn(u)?e.check({tokenize:Xxe},t,n)(u):n(u)}}function Xxe(e,t,n){return Mn(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function Zxe(e){return uj([Sxe(),Oxe(),Fxe(e),Wxe(),Kxe()])}const Qxe={};function Jxe(e){const t=this,n=e||Qxe,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(Zxe(n)),s.push(yxe()),o.push(bxe(n))}const nD=(function(e,t,n){const r=ip(n);if(!e||!e.type||!e.children)throw new Error("Expected parent node");if(typeof t=="number"){if(t<0||t===Number.POSITIVE_INFINITY)throw new Error("Expected positive finite number as index")}else if(t=e.children.indexOf(t),t<0)throw new Error("Expected child node or index");for(;++t<e.children.length;)if(r(e.children[t],t,e))return e.children[t]}),Rc=(function(e){if(e==null)return n1e;if(typeof e=="string")return t1e(e);if(typeof e=="object")return e1e(e);if(typeof e=="function")return jE(e);throw new Error("Expected function, string, or array as `test`")});function e1e(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Rc(e[n]);return jE(r);function r(...i){let s=-1;for(;++s<t.length;)if(t[s].apply(this,i))return!0;return!1}}function t1e(e){return jE(t);function t(n){return n.tagName===e}}function jE(e){return t;function t(n,r,i){return!!(r1e(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function n1e(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="element"&&"tagName"in e&&typeof e.tagName=="string")}function r1e(e){return e!==null&&typeof e=="object"&&"type"in e&&"tagName"in e}const rD=/\n/g,iD=/[\t ]+/g,lx=Rc("br"),sD=Rc(d1e),i1e=Rc("p"),oD=Rc("tr"),s1e=Rc(["datalist","head","noembed","noframes","noscript","rp","script","style","template","title",u1e,h1e]),tF=Rc(["address","article","aside","blockquote","body","caption","center","dd","dialog","dir","dl","dt","div","figure","figcaption","footer","form,","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","legend","li","listing","main","menu","nav","ol","p","plaintext","pre","section","ul","xmp"]);function o1e(e,t){const n=t||{},r="children"in e?e.children:[],i=tF(e),s=iF(e,{whitespace:n.whitespace||"normal"}),o=[];(e.type==="text"||e.type==="comment")&&o.push(...rF(e,{breakBefore:!0,breakAfter:!0}));let l=-1;for(;++l<r.length;)o.push(...nF(r[l],e,{whitespace:s,breakBefore:l?void 0:i,breakAfter:l<r.length-1?lx(r[l+1]):i}));const u=[];let d;for(l=-1;++l<o.length;){const h=o[l];typeof h=="number"?d!==void 0&&h>d&&(d=h):h&&(d!==void 0&&d>-1&&u.push(`
681
681
  `.repeat(d)||" "),d=-1,u.push(h))}return u.join("")}function nF(e,t,n){return e.type==="element"?a1e(e,t,n):e.type==="text"?n.whitespace==="normal"?rF(e,n):l1e(e):[]}function a1e(e,t,n){const r=iF(e,n),i=e.children||[];let s=-1,o=[];if(s1e(e))return o;let l,u;for(lx(e)||oD(e)&&nD(t,e,oD)?u=`
682
682
  `:i1e(e)?(l=2,u=2):tF(e)&&(l=1,u=1);++s<i.length;)o=o.concat(nF(i[s],e,{whitespace:r,breakBefore:s?void 0:l,breakAfter:s<i.length-1?lx(i[s+1]):u}));return sD(e)&&nD(t,e,sD)&&o.push(" "),l&&o.unshift(l),u&&o.push(u),o}function rF(e,t){const n=String(e.value),r=[],i=[];let s=0;for(;s<=n.length;){rD.lastIndex=s;const u=rD.exec(n),d=u&&"index"in u?u.index:n.length;r.push(c1e(n.slice(s,d).replace(/[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g,""),s===0?t.breakBefore:!0,d===n.length?t.breakAfter:!0)),s=d+1}let o=-1,l;for(;++o<r.length;)r[o].charCodeAt(r[o].length-1)===8203||o<r.length-1&&r[o+1].charCodeAt(0)===8203?(i.push(r[o]),l=void 0):r[o]?(typeof l=="number"&&i.push(l),i.push(r[o]),l=0):(o===0||o===r.length-1)&&i.push(0);return i}function l1e(e){return[String(e.value)]}function c1e(e,t,n){const r=[];let i=0,s;for(;i<e.length;){iD.lastIndex=i;const o=iD.exec(e);s=o?o.index:e.length,!i&&!s&&o&&!t&&r.push(""),i!==s&&r.push(e.slice(i,s)),i=o?s+o[0].length:s}return i!==s&&!n&&r.push(""),r.join(" ")}function iF(e,t){if(e.type==="element"){const n=e.properties||{};switch(e.tagName){case"listing":case"plaintext":case"xmp":return"pre";case"nobr":return"nowrap";case"pre":return n.wrap?"pre-wrap":"pre";case"td":case"th":return n.noWrap?"nowrap":t.whitespace;case"textarea":return"pre-wrap"}}return t.whitespace}function u1e(e){return!!(e.properties||{}).hidden}function d1e(e){return e.tagName==="td"||e.tagName==="th"}function h1e(e){return e.tagName==="dialog"&&!(e.properties||{}).open}function f1e(e){const t=e.regex,n=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",i="[a-zA-Z_]\\w*::",o="(?!struct)("+r+"|"+t.optional(i)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",l={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},d={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},h={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},p={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(d,{className:"string"}),{className:"string",begin:/<.*?>/},n,e.C_BLOCK_COMMENT_MODE]},y={className:"title",begin:t.optional(i)+e.IDENT_RE,relevance:0},v=t.optional(i)+e.IDENT_RE+"\\s*\\(",_=["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],w=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],x=["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"],E=["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"],A={type:w,keyword:_,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:x},I={className:"function.dispatch",relevance:0,keywords:{_hint:E},begin:t.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,e.IDENT_RE,t.lookahead(/(<[^<>]+>|)\s*\(/))},T=[I,p,l,n,e.C_BLOCK_COMMENT_MODE,h,d],H={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:A,contains:T.concat([{begin:/\(/,end:/\)/,keywords:A,contains:T.concat(["self"]),relevance:0}]),relevance:0},D={className:"function",begin:"("+o+"[\\*&\\s]+)+"+v,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:A,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:A,relevance:0},{begin:v,returnBegin:!0,contains:[y],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[d,h]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:A,relevance:0,contains:[n,e.C_BLOCK_COMMENT_MODE,d,h,l,{begin:/\(/,end:/\)/,keywords:A,relevance:0,contains:["self",n,e.C_BLOCK_COMMENT_MODE,d,h,l]}]},l,n,e.C_BLOCK_COMMENT_MODE,p]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:A,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(H,D,I,T,[p,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:A,contains:["self",l]},{begin:e.IDENT_RE+"::",keywords:A},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function p1e(e){const t={type:["boolean","byte","word","String"],built_in:["KeyboardController","MouseController","SoftwareSerial","EthernetServer","EthernetClient","LiquidCrystal","RobotControl","GSMVoiceCall","EthernetUDP","EsploraTFT","HttpClient","RobotMotor","WiFiClient","GSMScanner","FileSystem","Scheduler","GSMServer","YunClient","YunServer","IPAddress","GSMClient","GSMModem","Keyboard","Ethernet","Console","GSMBand","Esplora","Stepper","Process","WiFiUDP","GSM_SMS","Mailbox","USBHost","Firmata","PImage","Client","Server","GSMPIN","FileIO","Bridge","Serial","EEPROM","Stream","Mouse","Audio","Servo","File","Task","GPRS","WiFi","Wire","TFT","GSM","SPI","SD"],_hints:["setup","loop","runShellCommandAsynchronously","analogWriteResolution","retrieveCallingNumber","printFirmwareVersion","analogReadResolution","sendDigitalPortPair","noListenOnLocalhost","readJoystickButton","setFirmwareVersion","readJoystickSwitch","scrollDisplayRight","getVoiceCallStatus","scrollDisplayLeft","writeMicroseconds","delayMicroseconds","beginTransmission","getSignalStrength","runAsynchronously","getAsynchronously","listenOnLocalhost","getCurrentCarrier","readAccelerometer","messageAvailable","sendDigitalPorts","lineFollowConfig","countryNameWrite","runShellCommand","readStringUntil","rewindDirectory","readTemperature","setClockDivider","readLightSensor","endTransmission","analogReference","detachInterrupt","countryNameRead","attachInterrupt","encryptionType","readBytesUntil","robotNameWrite","readMicrophone","robotNameRead","cityNameWrite","userNameWrite","readJoystickY","readJoystickX","mouseReleased","openNextFile","scanNetworks","noInterrupts","digitalWrite","beginSpeaker","mousePressed","isActionDone","mouseDragged","displayLogos","noAutoscroll","addParameter","remoteNumber","getModifiers","keyboardRead","userNameRead","waitContinue","processInput","parseCommand","printVersion","readNetworks","writeMessage","blinkVersion","cityNameRead","readMessage","setDataMode","parsePacket","isListening","setBitOrder","beginPacket","isDirectory","motorsWrite","drawCompass","digitalRead","clearScreen","serialEvent","rightToLeft","setTextSize","leftToRight","requestFrom","keyReleased","compassRead","analogWrite","interrupts","WiFiServer","disconnect","playMelody","parseFloat","autoscroll","getPINUsed","setPINUsed","setTimeout","sendAnalog","readSlider","analogRead","beginWrite","createChar","motorsStop","keyPressed","tempoWrite","readButton","subnetMask","debugPrint","macAddress","writeGreen","randomSeed","attachGPRS","readString","sendString","remotePort","releaseAll","mouseMoved","background","getXChange","getYChange","answerCall","getResult","voiceCall","endPacket","constrain","getSocket","writeJSON","getButton","available","connected","findUntil","readBytes","exitValue","readGreen","writeBlue","startLoop","IPAddress","isPressed","sendSysex","pauseMode","gatewayIP","setCursor","getOemKey","tuneWrite","noDisplay","loadImage","switchPIN","onRequest","onReceive","changePIN","playFile","noBuffer","parseInt","overflow","checkPIN","knobRead","beginTFT","bitClear","updateIR","bitWrite","position","writeRGB","highByte","writeRed","setSpeed","readBlue","noStroke","remoteIP","transfer","shutdown","hangCall","beginSMS","endWrite","attached","maintain","noCursor","checkReg","checkPUK","shiftOut","isValid","shiftIn","pulseIn","connect","println","localIP","pinMode","getIMEI","display","noBlink","process","getBand","running","beginSD","drawBMP","lowByte","setBand","release","bitRead","prepare","pointTo","readRed","setMode","noFill","remove","listen","stroke","detach","attach","noTone","exists","buffer","height","bitSet","circle","config","cursor","random","IRread","setDNS","endSMS","getKey","micros","millis","begin","print","write","ready","flush","width","isPIN","blink","clear","press","mkdir","rmdir","close","point","yield","image","BSSID","click","delay","read","text","move","peek","beep","rect","line","open","seek","fill","size","turn","stop","home","find","step","tone","sqrt","RSSI","SSID","end","bit","tan","cos","sin","pow","map","abs","max","min","get","run","put"],literal:["DIGITAL_MESSAGE","FIRMATA_STRING","ANALOG_MESSAGE","REPORT_DIGITAL","REPORT_ANALOG","INPUT_PULLUP","SET_PIN_MODE","INTERNAL2V56","SYSTEM_RESET","LED_BUILTIN","INTERNAL1V1","SYSEX_START","INTERNAL","EXTERNAL","DEFAULT","OUTPUT","INPUT","HIGH","LOW"]},n=f1e(e),r=n.keywords;return r.type=[...r.type,...t.type],r.literal=[...r.literal,...t.literal],r.built_in=[...r.built_in,...t.built_in],r._hints=t._hints,n.name="Arduino",n.aliases=["ino"],n.supersetOf="cpp",n}function m1e(e){const t=e.regex,n={},r={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]};Object.assign(n,{className:"variable",variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},r]});const i={className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},s=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),o={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},l={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,i]};i.contains.push(l);const u={match:/\\"/},d={className:"string",begin:/'/,end:/'/},h={match:/\\'/},p={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,n]},y=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],v=e.SHEBANG({binary:`(${y.join("|")})`,relevance:10}),_={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},w=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],x=["true","false"],E={match:/(\/[a-z._-]+)+/},k=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],R=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],A=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],I=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:w,literal:x,built_in:[...k,...R,"set","shopt",...A,...I]},contains:[v,e.SHEBANG(),_,p,s,o,E,l,u,d,h,n]}}function g1e(e){const t=e.regex,n=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",i="[a-zA-Z_]\\w*::",o="("+r+"|"+t.optional(i)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",l={className:"type",variants:[{begin:"\\b[a-z\\d_]*_t\\b"},{match:/\batomic_[a-z]{3,6}\b/}]},d={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},h={className:"number",variants:[{match:/\b(0b[01']+)/},{match:/(-?)\b([\d']+(\.[\d']*)?|\.[\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)/},{match:/(-?)\b(0[xX][a-fA-F0-9]+(?:'[a-fA-F0-9]+)*(?:\.[a-fA-F0-9]*(?:'[a-fA-F0-9]*)*)?(?:[pP][-+]?[0-9]+)?(l|L)?(u|U)?)/},{match:/(-?)\b\d+(?:'\d+)*(?:\.\d*(?:'\d*)*)?(?:[eE][-+]?\d+)?/}],relevance:0},p={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef elifdef elifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(d,{className:"string"}),{className:"string",begin:/<.*?>/},n,e.C_BLOCK_COMMENT_MODE]},y={className:"title",begin:t.optional(i)+e.IDENT_RE,relevance:0},v=t.optional(i)+e.IDENT_RE+"\\s*\\(",x={keyword:["asm","auto","break","case","continue","default","do","else","enum","extern","for","fortran","goto","if","inline","register","restrict","return","sizeof","typeof","typeof_unqual","struct","switch","typedef","union","volatile","while","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","noreturn","static_assert","thread_local","_Pragma"],type:["float","double","signed","unsigned","int","short","long","char","void","_Bool","_BitInt","_Complex","_Imaginary","_Decimal32","_Decimal64","_Decimal96","_Decimal128","_Decimal64x","_Decimal128x","_Float16","_Float32","_Float64","_Float128","_Float32x","_Float64x","_Float128x","const","static","constexpr","complex","bool","imaginary"],literal:"true false NULL",built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr"},E=[p,l,n,e.C_BLOCK_COMMENT_MODE,h,d],k={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:x,contains:E.concat([{begin:/\(/,end:/\)/,keywords:x,contains:E.concat(["self"]),relevance:0}]),relevance:0},R={begin:"("+o+"[\\*&\\s]+)+"+v,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:x,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:x,relevance:0},{begin:v,returnBegin:!0,contains:[e.inherit(y,{className:"title.function"})],relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:x,relevance:0,contains:[n,e.C_BLOCK_COMMENT_MODE,d,h,l,{begin:/\(/,end:/\)/,keywords:x,relevance:0,contains:["self",n,e.C_BLOCK_COMMENT_MODE,d,h,l]}]},l,n,e.C_BLOCK_COMMENT_MODE,p]};return{name:"C",aliases:["h"],keywords:x,disableAutodetect:!0,illegal:"</",contains:[].concat(k,R,E,[p,{begin:e.IDENT_RE+"::",keywords:x},{className:"class",beginKeywords:"enum class struct union",end:/[{;:<>=]/,contains:[{beginKeywords:"final class struct"},e.TITLE_MODE]}]),exports:{preprocessor:p,strings:d,keywords:x}}}function v1e(e){const t=e.regex,n=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",i="[a-zA-Z_]\\w*::",o="(?!struct)("+r+"|"+t.optional(i)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",l={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},d={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},h={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},p={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(d,{className:"string"}),{className:"string",begin:/<.*?>/},n,e.C_BLOCK_COMMENT_MODE]},y={className:"title",begin:t.optional(i)+e.IDENT_RE,relevance:0},v=t.optional(i)+e.IDENT_RE+"\\s*\\(",_=["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],w=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],x=["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"],E=["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"],A={type:w,keyword:_,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:x},I={className:"function.dispatch",relevance:0,keywords:{_hint:E},begin:t.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,e.IDENT_RE,t.lookahead(/(<[^<>]+>|)\s*\(/))},T=[I,p,l,n,e.C_BLOCK_COMMENT_MODE,h,d],H={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:A,contains:T.concat([{begin:/\(/,end:/\)/,keywords:A,contains:T.concat(["self"]),relevance:0}]),relevance:0},D={className:"function",begin:"("+o+"[\\*&\\s]+)+"+v,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:A,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:A,relevance:0},{begin:v,returnBegin:!0,contains:[y],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[d,h]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:A,relevance:0,contains:[n,e.C_BLOCK_COMMENT_MODE,d,h,l,{begin:/\(/,end:/\)/,keywords:A,relevance:0,contains:["self",n,e.C_BLOCK_COMMENT_MODE,d,h,l]}]},l,n,e.C_BLOCK_COMMENT_MODE,p]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:A,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(H,D,I,T,[p,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:A,contains:["self",l]},{begin:e.IDENT_RE+"::",keywords:A},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function y1e(e){const t=["bool","byte","char","decimal","delegate","double","dynamic","enum","float","int","long","nint","nuint","object","sbyte","short","string","ulong","uint","ushort"],n=["public","private","protected","static","internal","protected","abstract","async","extern","override","unsafe","virtual","new","sealed","partial"],r=["default","false","null","true"],i=["abstract","as","base","break","case","catch","class","const","continue","do","else","event","explicit","extern","finally","fixed","for","foreach","goto","if","implicit","in","interface","internal","is","lock","namespace","new","operator","out","override","params","private","protected","public","readonly","record","ref","return","scoped","sealed","sizeof","stackalloc","static","struct","switch","this","throw","try","typeof","unchecked","unsafe","using","virtual","void","volatile","while"],s=["add","alias","and","ascending","args","async","await","by","descending","dynamic","equals","file","from","get","global","group","init","into","join","let","nameof","not","notnull","on","or","orderby","partial","record","remove","required","scoped","select","set","unmanaged","value|0","var","when","where","with","yield"],o={keyword:i.concat(s),built_in:t,literal:r},l=e.inherit(e.TITLE_MODE,{begin:"[a-zA-Z](\\.?\\w)*"}),u={className:"number",variants:[{begin:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],relevance:0},d={className:"string",begin:/"""("*)(?!")(.|\n)*?"""\1/,relevance:1},h={className:"string",begin:'@"',end:'"',contains:[{begin:'""'}]},p=e.inherit(h,{illegal:/\n/}),y={className:"subst",begin:/\{/,end:/\}/,keywords:o},v=e.inherit(y,{illegal:/\n/}),_={className:"string",begin:/\$"/,end:'"',illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},e.BACKSLASH_ESCAPE,v]},w={className:"string",begin:/\$@"/,end:'"',contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},y]},x=e.inherit(w,{illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},v]});y.contains=[w,_,h,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,u,e.C_BLOCK_COMMENT_MODE],v.contains=[x,_,p,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,u,e.inherit(e.C_BLOCK_COMMENT_MODE,{illegal:/\n/})];const E={variants:[d,w,_,h,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},k={begin:"<",end:">",contains:[{beginKeywords:"in out"},l]},R=e.IDENT_RE+"(<"+e.IDENT_RE+"(\\s*,\\s*"+e.IDENT_RE+")*>)?(\\[\\])?",A={begin:"@"+e.IDENT_RE,relevance:0};return{name:"C#",aliases:["cs","c#"],keywords:o,illegal:/::/,contains:[e.COMMENT("///","$",{returnBegin:!0,contains:[{className:"doctag",variants:[{begin:"///",relevance:0},{begin:"<!--|-->"},{begin:"</?",end:">"}]}]}),e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"meta",begin:"#",end:"$",keywords:{keyword:"if else elif endif define undef warning error line region endregion pragma checksum"}},E,u,{beginKeywords:"class interface",relevance:0,end:/[{;=]/,illegal:/[^\s:,]/,contains:[{beginKeywords:"where class"},l,k,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"namespace",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[l,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"record",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[l,k,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"meta",begin:"^\\s*\\[(?=[\\w])",excludeBegin:!0,end:"\\]",excludeEnd:!0,contains:[{className:"string",begin:/"/,end:/"/}]},{beginKeywords:"new return throw await else",relevance:0},{className:"function",begin:"("+R+"\\s+)+"+e.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,end:/\s*[{;=]/,excludeEnd:!0,keywords:o,contains:[{beginKeywords:n.join(" "),relevance:0},{begin:e.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,contains:[e.TITLE_MODE,k],relevance:0},{match:/\(\)/},{className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,relevance:0,contains:[E,u,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},A]}}const b1e=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),_1e=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],w1e=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],S1e=[..._1e,...w1e],x1e=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),E1e=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),C1e=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),k1e=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function T1e(e){const t=e.regex,n=b1e(e),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},i="and or not only",s=/@-?\w[\w]*(-\w+)*/,o="[a-zA-Z-][a-zA-Z0-9_-]*",l=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,r,n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+o,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+E1e.join("|")+")"},{begin:":(:)?("+C1e.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+k1e.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...l,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...l,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:s},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:i,attribute:x1e.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...l,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+S1e.join("|")+")\\b"}]}}function R1e(e){const t=e.regex;return{name:"Diff",aliases:["patch"],contains:[{className:"meta",relevance:10,match:t.either(/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,/^\*\*\* +\d+,\d+ +\*\*\*\*$/,/^--- +\d+,\d+ +----$/)},{className:"comment",variants:[{begin:t.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\*{3} /,/^\+{3}/,/^diff --git/),end:/$/},{match:/^\*{15}$/}]},{className:"addition",begin:/^\+/,end:/$/},{className:"deletion",begin:/^-/,end:/$/},{className:"addition",begin:/^!/,end:/$/}]}}function A1e(e){const s={keyword:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],type:["bool","byte","complex64","complex128","error","float32","float64","int8","int16","int32","int64","string","uint8","uint16","uint32","uint64","int","uint","uintptr","rune"],literal:["true","false","iota","nil"],built_in:["append","cap","close","complex","copy","imag","len","make","new","panic","print","println","real","recover","delete"]};return{name:"Go",aliases:["golang"],keywords:s,illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"string",variants:[e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{begin:"`",end:"`"}]},{className:"number",variants:[{match:/-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/,relevance:0},{match:/-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b0[oO](_?[0-7])*i?/,relevance:0},{match:/-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/,relevance:0}]},{begin:/:=/},{className:"function",beginKeywords:"func",end:"\\s*(\\{|$)",excludeEnd:!0,contains:[e.TITLE_MODE,{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:s,illegal:/["']/}]}]}}function N1e(e){const t=e.regex,n=/[_A-Za-z][_0-9A-Za-z]*/;return{name:"GraphQL",aliases:["gql"],case_insensitive:!0,disableAutodetect:!1,keywords:{keyword:["query","mutation","subscription","type","input","schema","directive","interface","union","scalar","fragment","enum","on"],literal:["true","false","null"]},contains:[e.HASH_COMMENT_MODE,e.QUOTE_STRING_MODE,e.NUMBER_MODE,{scope:"punctuation",match:/[.]{3}/,relevance:0},{scope:"punctuation",begin:/[\!\(\)\:\=\[\]\{\|\}]{1}/,relevance:0},{scope:"variable",begin:/\$/,end:/\W/,excludeEnd:!0,relevance:0},{scope:"meta",match:/@\w+/,excludeEnd:!0},{scope:"symbol",begin:t.concat(n,t.lookahead(/\s*:/)),relevance:0}],illegal:[/[;<']/,/BEGIN/]}}function M1e(e){const t=e.regex,n={className:"number",relevance:0,variants:[{begin:/([+-]+)?[\d]+_[\d_]+/},{begin:e.NUMBER_RE}]},r=e.COMMENT();r.variants=[{begin:/;/,end:/$/},{begin:/#/,end:/$/}];const i={className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/}]},s={className:"literal",begin:/\bon|off|true|false|yes|no\b/},o={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}]},l={begin:/\[/,end:/\]/,contains:[r,s,i,o,n,"self"],relevance:0},u=/[A-Za-z0-9_-]+/,d=/"(\\"|[^"])*"/,h=/'[^']*'/,p=t.either(u,d,h),y=t.concat(p,"(\\s*\\.\\s*",p,")*",t.lookahead(/\s*=\s*[^#\s]/));return{name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,contains:[r,{className:"section",begin:/\[+/,end:/\]+/},{begin:y,className:"attr",starts:{end:/$/,contains:[r,l,s,i,o,n]}}]}}var Eu="[0-9](_*[0-9])*",ag=`\\.(${Eu})`,lg="[0-9a-fA-F](_*[0-9a-fA-F])*",aD={className:"number",variants:[{begin:`(\\b(${Eu})((${ag})|\\.)?|(${ag}))[eE][+-]?(${Eu})[fFdD]?\\b`},{begin:`\\b(${Eu})((${ag})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${ag})[fFdD]?\\b`},{begin:`\\b(${Eu})[fFdD]\\b`},{begin:`\\b0[xX]((${lg})\\.?|(${lg})?\\.(${lg}))[pP][+-]?(${Eu})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${lg})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function sF(e,t,n){return n===-1?"":e.replace(t,r=>sF(e,t,n-1))}function O1e(e){const t=e.regex,n="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",r=n+sF("(?:<"+n+"~~~(?:\\s*,\\s*"+n+"~~~)*>)?",/~~~/g,2),u={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits","goto","when"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},d={className:"meta",begin:"@"+n,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},h={className:"params",begin:/\(/,end:/\)/,keywords:u,relevance:0,contains:[e.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:u,illegal:/<\/|#/,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[e.BACKSLASH_ESCAPE]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,n],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{begin:[t.concat(/(?!else)/,n),/\s+/,n,/\s+/,/=(?!=)/],className:{1:"type",3:"variable",5:"operator"}},{begin:[/record/,/\s+/,n],className:{1:"keyword",3:"title.class"},contains:[h,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"new throw return else",relevance:0},{begin:["(?:"+r+"\\s+)",e.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:"title.function"},keywords:u,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:u,relevance:0,contains:[d,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,aD,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},aD,d]}}const lD="[A-Za-z$_][0-9A-Za-z$_]*",D1e=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],P1e=["true","false","null","undefined","NaN","Infinity"],oF=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],aF=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],lF=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],L1e=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],I1e=[].concat(lF,oF,aF);function z1e(e){const t=e.regex,n=(Y,{after:$})=>{const P="</"+Y[0].slice(1);return Y.input.indexOf(P,$)!==-1},r=lD,i={begin:"<>",end:"</>"},s=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(Y,$)=>{const P=Y[0].length+Y.index,q=Y.input[P];if(q==="<"||q===","){$.ignoreMatch();return}q===">"&&(n(Y,{after:P})||$.ignoreMatch());let K;const z=Y.input.substring(P);if(K=z.match(/^\s*=/)){$.ignoreMatch();return}if((K=z.match(/^\s+extends\s+/))&&K.index===0){$.ignoreMatch();return}}},l={$pattern:lD,keyword:D1e,literal:P1e,built_in:I1e,"variable.language":L1e},u="[0-9](_?[0-9])*",d=`\\.(${u})`,h="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",p={className:"number",variants:[{begin:`(\\b(${h})((${d})|\\.)?|(${d}))[eE][+-]?(${u})\\b`},{begin:`\\b(${h})\\b((${d})\\b|\\.)?|(${d})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},y={className:"subst",begin:"\\$\\{",end:"\\}",keywords:l,contains:[]},v={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,y],subLanguage:"xml"}},_={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,y],subLanguage:"css"}},w={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,y],subLanguage:"graphql"}},x={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,y]},k={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},R=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,v,_,w,x,{match:/\$\d+/},p];y.contains=R.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(R)});const A=[].concat(k,y.contains),I=A.concat([{begin:/(\s*)\(/,end:/\)/,keywords:l,contains:["self"].concat(A)}]),T={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:I},H={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,"(",t.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},D={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...oF,...aF]}},W={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},U={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[T],illegal:/%/},F={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function O(Y){return t.concat("(?!",Y.join("|"),")")}const M={match:t.concat(/\b/,O([...lF,"super","import"].map(Y=>`${Y}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},B={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},L={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},T]},N="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",V={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(N)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[T]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:I,CLASS_REFERENCE:D},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),W,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,v,_,w,x,k,{match:/\$\d+/},p,D,{scope:"attr",match:r+t.lookahead(":"),relevance:0},V,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[k,e.REGEXP_MODE,{className:"function",begin:N,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:I}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:s},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:"xml",contains:[{begin:o.begin,end:o.end,skip:!0,contains:["self"]}]}]},U,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[T,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},B,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[T]},M,F,H,L,{match:/\$[(.]/}]}}function B1e(e){const t={className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:"punctuation",relevance:0},r=["true","false","null"],i={scope:"literal",beginKeywords:r.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:r},contains:[t,n,e.QUOTE_STRING_MODE,i,e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}var Cu="[0-9](_*[0-9])*",cg=`\\.(${Cu})`,ug="[0-9a-fA-F](_*[0-9a-fA-F])*",j1e={className:"number",variants:[{begin:`(\\b(${Cu})((${cg})|\\.)?|(${cg}))[eE][+-]?(${Cu})[fFdD]?\\b`},{begin:`\\b(${Cu})((${cg})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${cg})[fFdD]?\\b`},{begin:`\\b(${Cu})[fFdD]\\b`},{begin:`\\b0[xX]((${ug})\\.?|(${ug})?\\.(${ug}))[pP][+-]?(${Cu})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${ug})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function F1e(e){const t={keyword:"abstract as val var vararg get set class object open private protected public noinline crossinline dynamic final enum if else do while for when throw try catch finally import package is in fun override companion reified inline lateinit init interface annotation data sealed internal infix operator out by constructor super tailrec where const inner suspend typealias external expect actual",built_in:"Byte Short Char Int Long Boolean Float Double Void Unit Nothing",literal:"true false null"},n={className:"keyword",begin:/\b(break|continue|return|this)\b/,starts:{contains:[{className:"symbol",begin:/@\w+/}]}},r={className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"@"},i={className:"subst",begin:/\$\{/,end:/\}/,contains:[e.C_NUMBER_MODE]},s={className:"variable",begin:"\\$"+e.UNDERSCORE_IDENT_RE},o={className:"string",variants:[{begin:'"""',end:'"""(?=[^"])',contains:[s,i]},{begin:"'",end:"'",illegal:/\n/,contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"',illegal:/\n/,contains:[e.BACKSLASH_ESCAPE,s,i]}]};i.contains.push(o);const l={className:"meta",begin:"@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*"+e.UNDERSCORE_IDENT_RE+")?"},u={className:"meta",begin:"@"+e.UNDERSCORE_IDENT_RE,contains:[{begin:/\(/,end:/\)/,contains:[e.inherit(o,{className:"string"}),"self"]}]},d=j1e,h=e.COMMENT("/\\*","\\*/",{contains:[e.C_BLOCK_COMMENT_MODE]}),p={variants:[{className:"type",begin:e.UNDERSCORE_IDENT_RE},{begin:/\(/,end:/\)/,contains:[]}]},y=p;return y.variants[1].contains=[p],p.variants[1].contains=[y],{name:"Kotlin",aliases:["kt","kts"],keywords:t,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"}]}),e.C_LINE_COMMENT_MODE,h,n,r,l,u,{className:"function",beginKeywords:"fun",end:"[(]|$",returnBegin:!0,excludeEnd:!0,keywords:t,relevance:5,contains:[{begin:e.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,relevance:0,contains:[e.UNDERSCORE_TITLE_MODE]},{className:"type",begin:/</,end:/>/,keywords:"reified",relevance:0},{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:t,relevance:0,contains:[{begin:/:/,end:/[=,\/]/,endsWithParent:!0,contains:[p,e.C_LINE_COMMENT_MODE,h],relevance:0},e.C_LINE_COMMENT_MODE,h,l,u,o,e.C_NUMBER_MODE]},h]},{begin:[/class|interface|trait/,/\s+/,e.UNDERSCORE_IDENT_RE],beginScope:{3:"title.class"},keywords:"class interface trait",end:/[:\{(]|$/,excludeEnd:!0,illegal:"extends implements",contains:[{beginKeywords:"public protected internal private constructor"},e.UNDERSCORE_TITLE_MODE,{className:"type",begin:/</,end:/>/,excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:/[,:]\s*/,end:/[<\(,){\s]|$/,excludeBegin:!0,returnEnd:!0},l,u]},o,{className:"meta",begin:"^#!/usr/bin/env",end:"$",illegal:`
683
683
  `},d]}}const $1e=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),H1e=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],U1e=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],W1e=[...H1e,...U1e],q1e=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),cF=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),uF=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),V1e=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse(),Y1e=cF.concat(uF).sort().reverse();function K1e(e){const t=$1e(e),n=Y1e,r="and or not only",i="[\\w-]+",s="("+i+"|@\\{"+i+"\\})",o=[],l=[],u=function(R){return{className:"string",begin:"~?"+R+".*?"+R}},d=function(R,A,I){return{className:R,begin:A,relevance:I}},h={$pattern:/[a-z-]+/,keyword:r,attribute:q1e.join(" ")},p={begin:"\\(",end:"\\)",contains:l,keywords:h,relevance:0};l.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,u("'"),u('"'),t.CSS_NUMBER_MODE,{begin:"(url|data-uri)\\(",starts:{className:"string",end:"[\\)\\n]",excludeEnd:!0}},t.HEXCOLOR,p,d("variable","@@?"+i,10),d("variable","@\\{"+i+"\\}"),d("built_in","~?`[^`]*?`"),{className:"attribute",begin:i+"\\s*:",end:":",returnBegin:!0,excludeEnd:!0},t.IMPORTANT,{beginKeywords:"and not"},t.FUNCTION_DISPATCH);const y=l.concat({begin:/\{/,end:/\}/,contains:o}),v={beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not"}].concat(l)},_={begin:s+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+V1e.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:l}}]},w={className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",keywords:h,returnEnd:!0,contains:l,relevance:0}},x={className:"variable",variants:[{begin:"@"+i+"\\s*:",relevance:15},{begin:"@"+i}],starts:{end:"[;}]",returnEnd:!0,contains:y}},E={variants:[{begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:s,end:/\{/}],returnBegin:!0,returnEnd:!0,illegal:`[<='$"]`,relevance:0,contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,v,d("keyword","all\\b"),d("variable","@\\{"+i+"\\}"),{begin:"\\b("+W1e.join("|")+")\\b",className:"selector-tag"},t.CSS_NUMBER_MODE,d("selector-tag",s,0),d("selector-id","#"+s),d("selector-class","\\."+s,0),d("selector-tag","&",0),t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",begin:":("+cF.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+uF.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:y},{begin:"!important"},t.FUNCTION_DISPATCH]},k={begin:i+`:(:)?(${n.join("|")})`,returnBegin:!0,contains:[E]};return o.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,w,x,k,_,E,v,t.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:`[=>'/<($"]`,contains:o}}function G1e(e){const t="\\[=*\\[",n="\\]=*\\]",r={begin:t,end:n,contains:["self"]},i=[e.COMMENT("--(?!"+t+")","$"),e.COMMENT("--"+t,n,{contains:[r],relevance:10})];return{name:"Lua",aliases:["pluto"],keywords:{$pattern:e.UNDERSCORE_IDENT_RE,literal:"true false nil",keyword:"and break do else elseif end for goto if in local not or repeat return then until while",built_in:"_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove"},contains:i.concat([{className:"function",beginKeywords:"function",end:"\\)",contains:[e.inherit(e.TITLE_MODE,{begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{className:"params",begin:"\\(",endsWithParent:!0,contains:i}].concat(i)},e.C_NUMBER_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{className:"string",begin:t,end:n,contains:[r],relevance:5}])}}function X1e(e){const t={className:"variable",variants:[{begin:"\\$\\("+e.UNDERSCORE_IDENT_RE+"\\)",contains:[e.BACKSLASH_ESCAPE]},{begin:/\$[@%<?\^\+\*]/}]},n={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,t]},r={className:"variable",begin:/\$\([\w-]+\s/,end:/\)/,keywords:{built_in:"subst patsubst strip findstring filter filter-out sort word wordlist firstword lastword dir notdir suffix basename addsuffix addprefix join wildcard realpath abspath error warning shell origin flavor foreach if or and call eval file value"},contains:[t,n]},i={begin:"^"+e.UNDERSCORE_IDENT_RE+"\\s*(?=[:+?]?=)"},s={className:"meta",begin:/^\.PHONY:/,end:/$/,keywords:{$pattern:/[\.\w]+/,keyword:".PHONY"}},o={className:"section",begin:/^[^\s]+:/,end:/$/,contains:[t]};return{name:"Makefile",aliases:["mk","mak","make"],keywords:{$pattern:/[\w-]+/,keyword:"define endef undefine ifdef ifndef ifeq ifneq else endif include -include sinclude override export unexport private vpath"},contains:[e.HASH_COMMENT_MODE,t,n,r,i,s,o]}}function Z1e(e){const t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},r={begin:"^[-\\*]{3,}",end:"$"},i={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},s={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},o={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},l=/[A-Za-z][A-Za-z0-9+.-]*/,u={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,l,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},d={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},h={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},p=e.inherit(d,{contains:[]}),y=e.inherit(h,{contains:[]});d.contains.push(y),h.contains.push(p);let v=[n,u];return[d,h,p,y].forEach(E=>{E.contains=E.contains.concat(v)}),v=v.concat(d,h),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:v},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:v}]}]},n,s,d,h,{className:"quote",begin:"^>\\s+",contains:v,end:"$"},i,r,u,o,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function Q1e(e){const t={className:"built_in",begin:"\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+"},n=/[a-zA-Z@][a-zA-Z0-9_]*/,l={"variable.language":["this","super"],$pattern:n,keyword:["while","export","sizeof","typedef","const","struct","for","union","volatile","static","mutable","if","do","return","goto","enum","else","break","extern","asm","case","default","register","explicit","typename","switch","continue","inline","readonly","assign","readwrite","self","@synchronized","id","typeof","nonatomic","IBOutlet","IBAction","strong","weak","copy","in","out","inout","bycopy","byref","oneway","__strong","__weak","__block","__autoreleasing","@private","@protected","@public","@try","@property","@end","@throw","@catch","@finally","@autoreleasepool","@synthesize","@dynamic","@selector","@optional","@required","@encode","@package","@import","@defs","@compatibility_alias","__bridge","__bridge_transfer","__bridge_retained","__bridge_retain","__covariant","__contravariant","__kindof","_Nonnull","_Nullable","_Null_unspecified","__FUNCTION__","__PRETTY_FUNCTION__","__attribute__","getter","setter","retain","unsafe_unretained","nonnull","nullable","null_unspecified","null_resettable","class","instancetype","NS_DESIGNATED_INITIALIZER","NS_UNAVAILABLE","NS_REQUIRES_SUPER","NS_RETURNS_INNER_POINTER","NS_INLINE","NS_AVAILABLE","NS_DEPRECATED","NS_ENUM","NS_OPTIONS","NS_SWIFT_UNAVAILABLE","NS_ASSUME_NONNULL_BEGIN","NS_ASSUME_NONNULL_END","NS_REFINED_FOR_SWIFT","NS_SWIFT_NAME","NS_SWIFT_NOTHROW","NS_DURING","NS_HANDLER","NS_ENDHANDLER","NS_VALUERETURN","NS_VOIDRETURN"],literal:["false","true","FALSE","TRUE","nil","YES","NO","NULL"],built_in:["dispatch_once_t","dispatch_queue_t","dispatch_sync","dispatch_async","dispatch_once"],type:["int","float","char","unsigned","signed","short","long","double","wchar_t","unichar","void","bool","BOOL","id|0","_Bool"]},u={$pattern:n,keyword:["@interface","@class","@protocol","@implementation"]};return{name:"Objective-C",aliases:["mm","objc","obj-c","obj-c++","objective-c++"],keywords:l,illegal:"</",contains:[t,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.C_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{className:"string",variants:[{begin:'@"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]}]},{className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),{className:"string",begin:/<.*?>/,end:/$/,illegal:"\\n"},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"class",begin:"("+u.keyword.join("|")+")\\b",end:/(\{|$)/,excludeEnd:!0,keywords:u,contains:[e.UNDERSCORE_TITLE_MODE]},{begin:"\\."+e.UNDERSCORE_IDENT_RE,relevance:0}]}}function J1e(e){const t=e.regex,n=["abs","accept","alarm","and","atan2","bind","binmode","bless","break","caller","chdir","chmod","chomp","chop","chown","chr","chroot","class","close","closedir","connect","continue","cos","crypt","dbmclose","dbmopen","defined","delete","die","do","dump","each","else","elsif","endgrent","endhostent","endnetent","endprotoent","endpwent","endservent","eof","eval","exec","exists","exit","exp","fcntl","field","fileno","flock","for","foreach","fork","format","formline","getc","getgrent","getgrgid","getgrnam","gethostbyaddr","gethostbyname","gethostent","getlogin","getnetbyaddr","getnetbyname","getnetent","getpeername","getpgrp","getpriority","getprotobyname","getprotobynumber","getprotoent","getpwent","getpwnam","getpwuid","getservbyname","getservbyport","getservent","getsockname","getsockopt","given","glob","gmtime","goto","grep","gt","hex","if","index","int","ioctl","join","keys","kill","last","lc","lcfirst","length","link","listen","local","localtime","log","lstat","lt","ma","map","method","mkdir","msgctl","msgget","msgrcv","msgsnd","my","ne","next","no","not","oct","open","opendir","or","ord","our","pack","package","pipe","pop","pos","print","printf","prototype","push","q|0","qq","quotemeta","qw","qx","rand","read","readdir","readline","readlink","readpipe","recv","redo","ref","rename","require","reset","return","reverse","rewinddir","rindex","rmdir","say","scalar","seek","seekdir","select","semctl","semget","semop","send","setgrent","sethostent","setnetent","setpgrp","setpriority","setprotoent","setpwent","setservent","setsockopt","shift","shmctl","shmget","shmread","shmwrite","shutdown","sin","sleep","socket","socketpair","sort","splice","split","sprintf","sqrt","srand","stat","state","study","sub","substr","symlink","syscall","sysopen","sysread","sysseek","system","syswrite","tell","telldir","tie","tied","time","times","tr","truncate","uc","ucfirst","umask","undef","unless","unlink","unpack","unshift","untie","until","use","utime","values","vec","wait","waitpid","wantarray","warn","when","while","write","x|0","xor","y|0"],r=/[dualxmsipngr]{0,12}/,i={$pattern:/[\w.]+/,keyword:n.join(" ")},s={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:i},o={begin:/->\{/,end:/\}/},l={scope:"attr",match:/\s+:\s*\w+(\s*\(.*?\))?/},u={scope:"variable",variants:[{begin:/\$\d/},{begin:t.concat(/[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,"(?![A-Za-z])(?![@$%])")},{begin:/[$%@](?!")[^\s\w{=]|\$=/,relevance:0}],contains:[l]},d={className:"number",variants:[{match:/0?\.[0-9][0-9_]+\b/},{match:/\bv?(0|[1-9][0-9_]*(\.[0-9_]+)?|[1-9][0-9_]*)\b/},{match:/\b0[0-7][0-7_]*\b/},{match:/\b0x[0-9a-fA-F][0-9a-fA-F_]*\b/},{match:/\b0b[0-1][0-1_]*\b/}],relevance:0},h=[e.BACKSLASH_ESCAPE,s,u],p=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],y=(w,x,E="\\1")=>{const k=E==="\\1"?E:t.concat(E,x);return t.concat(t.concat("(?:",w,")"),x,/(?:\\.|[^\\\/])*?/,k,/(?:\\.|[^\\\/])*?/,E,r)},v=(w,x,E)=>t.concat(t.concat("(?:",w,")"),x,/(?:\\.|[^\\\/])*?/,E,r),_=[u,e.HASH_COMMENT_MODE,e.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),o,{className:"string",contains:h,variants:[{begin:"q[qwxr]?\\s*\\(",end:"\\)",relevance:5},{begin:"q[qwxr]?\\s*\\[",end:"\\]",relevance:5},{begin:"q[qwxr]?\\s*\\{",end:"\\}",relevance:5},{begin:"q[qwxr]?\\s*\\|",end:"\\|",relevance:5},{begin:"q[qwxr]?\\s*<",end:">",relevance:5},{begin:"qw\\s+q",end:"q",relevance:5},{begin:"'",end:"'",contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"'},{begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE]},{begin:/\{\w+\}/,relevance:0},{begin:"-?\\w+\\s*=>",relevance:0}]},d,{begin:"(\\/\\/|"+e.RE_STARTERS_RE+"|\\b(split|return|print|reverse|grep)\\b)\\s*",keywords:"split return print reverse grep",relevance:0,contains:[e.HASH_COMMENT_MODE,{className:"regexp",variants:[{begin:y("s|tr|y",t.either(...p,{capture:!0}))},{begin:y("s|tr|y","\\(","\\)")},{begin:y("s|tr|y","\\[","\\]")},{begin:y("s|tr|y","\\{","\\}")}],relevance:2},{className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:v("(?:m|qr)?",/\//,/\//)},{begin:v("m|qr",t.either(...p,{capture:!0}),/\1/)},{begin:v("m|qr",/\(/,/\)/)},{begin:v("m|qr",/\[/,/\]/)},{begin:v("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub method",end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,l]},{className:"class",beginKeywords:"class",end:"[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,l,d]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return s.contains=_,o.contains=_,{name:"Perl",aliases:["pl","pm"],keywords:i,contains:_}}function eEe(e){const t=e.regex,n=/(?![A-Za-z0-9])(?![$])/,r=t.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,n),i=t.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,n),s=t.concat(/[A-Z]+/,n),o={scope:"variable",match:"\\$+"+r},l={scope:"meta",variants:[{begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{begin:/\?>/}]},u={scope:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},d=e.inherit(e.APOS_STRING_MODE,{illegal:null}),h=e.inherit(e.QUOTE_STRING_MODE,{illegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(u)}),p={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:e.QUOTE_STRING_MODE.contains.concat(u),"on:begin":(B,L)=>{L.data._beginMatch=B[1]||B[2]},"on:end":(B,L)=>{L.data._beginMatch!==B[1]&&L.ignoreMatch()}},y=e.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),v=`[
684
684
  ]`,_={scope:"string",variants:[h,d,p,y]},w={scope:"number",variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"}],relevance:0},x=["false","null","true"],E=["__CLASS__","__DIR__","__FILE__","__FUNCTION__","__COMPILER_HALT_OFFSET__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__","die","echo","exit","include","include_once","print","require","require_once","array","abstract","and","as","binary","bool","boolean","break","callable","case","catch","class","clone","const","continue","declare","default","do","double","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","extends","final","finally","float","for","foreach","from","global","goto","if","implements","instanceof","insteadof","int","integer","interface","isset","iterable","list","match|0","mixed","new","never","object","or","private","protected","public","readonly","real","return","string","switch","throw","trait","try","unset","use","var","void","while","xor","yield"],k=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],A={keyword:E,literal:(B=>{const L=[];return B.forEach(N=>{L.push(N),N.toLowerCase()===N?L.push(N.toUpperCase()):L.push(N.toLowerCase())}),L})(x),built_in:k},I=B=>B.map(L=>L.replace(/\|\d+$/,"")),T={variants:[{match:[/new/,t.concat(v,"+"),t.concat("(?!",I(k).join("\\b|"),"\\b)"),i],scope:{1:"keyword",4:"title.class"}}]},H=t.concat(r,"\\b(?!\\()"),D={variants:[{match:[t.concat(/::/,t.lookahead(/(?!class\b)/)),H],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[i,t.concat(/::/,t.lookahead(/(?!class\b)/)),H],scope:{1:"title.class",3:"variable.constant"}},{match:[i,t.concat("::",t.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[i,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},W={scope:"attr",match:t.concat(r,t.lookahead(":"),t.lookahead(/(?!::)/))},U={relevance:0,begin:/\(/,end:/\)/,keywords:A,contains:[W,o,D,e.C_BLOCK_COMMENT_MODE,_,w,T]},F={relevance:0,match:[/\b/,t.concat("(?!fn\\b|function\\b|",I(E).join("\\b|"),"|",I(k).join("\\b|"),"\\b)"),r,t.concat(v,"*"),t.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[U]};U.contains.push(F);const O=[W,D,e.C_BLOCK_COMMENT_MODE,_,w,T],M={begin:t.concat(/#\[\s*\\?/,t.either(i,s)),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:x,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:x,keyword:["new","array"]},contains:["self",...O]},...O,{scope:"meta",variants:[{match:i},{match:s}]}]};return{case_insensitive:!1,keywords:A,contains:[M,e.HASH_COMMENT_MODE,e.COMMENT("//","$"),e.COMMENT("/\\*","\\*/",{contains:[{scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/,keywords:"__halt_compiler",starts:{scope:"comment",end:e.MATCH_NOTHING_RE,contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},l,{scope:"variable.language",match:/\$this\b/},o,F,D,{match:[/const/,/\s/,r],scope:{1:"keyword",3:"variable.constant"}},T,{scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"},e.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:A,contains:["self",M,o,D,e.C_BLOCK_COMMENT_MODE,_,w]}]},{scope:"class",variants:[{beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{beginKeywords:"extends implements"},e.UNDERSCORE_TITLE_MODE]},{beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,contains:[e.inherit(e.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{beginKeywords:"use",relevance:0,end:";",contains:[{match:/\b(as|const|function)\b/,scope:"keyword"},e.UNDERSCORE_TITLE_MODE]},_,w]}}function tEe(e){return{name:"PHP template",subLanguage:"xml",contains:[{begin:/<\?(php|=)?/,end:/\?>/,subLanguage:"php",contains:[{begin:"/\\*",end:"\\*/",skip:!0},{begin:'b"',end:'"',skip:!0},{begin:"b'",end:"'",skip:!0},e.inherit(e.APOS_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0}),e.inherit(e.QUOTE_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0})]}]}}function nEe(e){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}function rEe(e){const t=e.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],l={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},u={className:"meta",begin:/^(>>>|\.\.\.) /},d={className:"subst",begin:/\{/,end:/\}/,keywords:l,illegal:/#/},h={begin:/\{\{/,relevance:0},p={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,u],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,u],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,u,h,d]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,u,h,d]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,h,d]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,h,d]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},y="[0-9](_?[0-9])*",v=`(\\b(${y}))?\\.(${y})|\\b(${y})\\.`,_=`\\b|${r.join("|")}`,w={className:"number",relevance:0,variants:[{begin:`(\\b(${y})|(${v}))[eE][+-]?(${y})[jJ]?(?=${_})`},{begin:`(${v})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${_})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${_})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${_})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${_})`},{begin:`\\b(${y})[jJ](?=${_})`}]},x={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:l,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},E={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:["self",u,w,p,e.HASH_COMMENT_MODE]}]};return d.contains=[p,w,u],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:l,illegal:/(<\/|\?)|=>/,contains:[u,w,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},p,x,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[E]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[w,E,p]}]}}function iEe(e){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}function sEe(e){const t=e.regex,n=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,r=t.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/,/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/),i=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,s=t.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/);return{name:"R",keywords:{$pattern:n,keyword:"function if in break next repeat else for while",literal:"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10",built_in:"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm"},contains:[e.COMMENT(/#'/,/$/,{contains:[{scope:"doctag",match:/@examples/,starts:{end:t.lookahead(t.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)),endsParent:!0}},{scope:"doctag",begin:"@param",end:/$/,contains:[{scope:"variable",variants:[{match:n},{match:/`(?:\\.|[^`\\])+`/}],endsParent:!0}]},{scope:"doctag",match:/@[a-zA-Z]+/},{scope:"keyword",match:/\\[a-zA-Z]+/}]}),e.HASH_COMMENT_MODE,{scope:"string",contains:[e.BACKSLASH_ESCAPE],variants:[e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:'"',end:'"',relevance:0},{begin:"'",end:"'",relevance:0}]},{relevance:0,variants:[{scope:{1:"operator",2:"number"},match:[i,r]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,r]},{scope:{1:"punctuation",2:"number"},match:[s,r]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,r]}]},{scope:{3:"operator"},match:[n,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:i},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:s},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}}function oEe(e){const t=e.regex,n="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",r=t.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),i=t.concat(r,/(::\w+)*/),o={"variable.constant":["__FILE__","__LINE__","__ENCODING__"],"variable.language":["self","super"],keyword:["alias","and","begin","BEGIN","break","case","class","defined","do","else","elsif","end","END","ensure","for","if","in","module","next","not","or","redo","require","rescue","retry","return","then","undef","unless","until","when","while","yield",...["include","extend","prepend","public","private","protected","raise","throw"]],built_in:["proc","lambda","attr_accessor","attr_reader","attr_writer","define_method","private_constant","module_function"],literal:["true","false","nil"]},l={className:"doctag",begin:"@[A-Za-z]+"},u={begin:"#<",end:">"},d=[e.COMMENT("#","$",{contains:[l]}),e.COMMENT("^=begin","^=end",{contains:[l],relevance:10}),e.COMMENT("^__END__",e.MATCH_NOTHING_RE)],h={className:"subst",begin:/#\{/,end:/\}/,keywords:o},p={className:"string",contains:[e.BACKSLASH_ESCAPE,h],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:/%[qQwWx]?\(/,end:/\)/},{begin:/%[qQwWx]?\[/,end:/\]/},{begin:/%[qQwWx]?\{/,end:/\}/},{begin:/%[qQwWx]?</,end:/>/},{begin:/%[qQwWx]?\//,end:/\//},{begin:/%[qQwWx]?%/,end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{begin:/%[qQwWx]?\|/,end:/\|/},{begin:/\B\?(\\\d{1,3})/},{begin:/\B\?(\\x[A-Fa-f0-9]{1,2})/},{begin:/\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/},{begin:/\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/},{begin:/\B\?\\(c|C-)[\x20-\x7e]/},{begin:/\B\?\\?\S/},{begin:t.concat(/<<[-~]?'?/,t.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)),contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[e.BACKSLASH_ESCAPE,h]})]}]},y="[1-9](_?[0-9])*|0",v="[0-9](_?[0-9])*",_={className:"number",relevance:0,variants:[{begin:`\\b(${y})(\\.(${v}))?([eE][+-]?(${v})|r)?i?\\b`},{begin:"\\b0[dD][0-9](_?[0-9])*r?i?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*r?i?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*r?i?\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b"},{begin:"\\b0(_?[0-7])+r?i?\\b"}]},w={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:o}]},T=[p,{variants:[{match:[/class\s+/,i,/\s+<\s+/,i]},{match:[/\b(class|module)\s+/,i]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:o},{match:[/(include|extend)\s+/,i],scope:{2:"title.class"},keywords:o},{relevance:0,match:[i,/\.new[. (]/],scope:{1:"title.class"}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},{relevance:0,match:r,scope:"title.class"},{match:[/def/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[w]},{begin:e.IDENT_RE+"::"},{className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[p,{begin:n}],relevance:0},_,{className:"variable",begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{className:"params",begin:/\|(?!=)/,end:/\|/,excludeBegin:!0,excludeEnd:!0,relevance:0,keywords:o},{begin:"("+e.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{className:"regexp",contains:[e.BACKSLASH_ESCAPE,h],illegal:/\n/,variants:[{begin:"/",end:"/[a-z]*"},{begin:/%r\{/,end:/\}[a-z]*/},{begin:"%r\\(",end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[",end:"\\][a-z]*"}]}].concat(u,d),relevance:0}].concat(u,d);h.contains=T,w.contains=T;const U=[{begin:/^\s*=>/,starts:{end:"$",contains:T}},{className:"meta.prompt",begin:"^("+"[>?]>"+"|"+"[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]"+"|"+"(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>"+")(?=[ ])",starts:{end:"$",keywords:o,contains:T}}];return d.unshift(u),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:o,illegal:/\/\*/,contains:[e.SHEBANG({binary:"ruby"})].concat(U).concat(d).concat(T)}}function aEe(e){const t=e.regex,n=/(r#)?/,r=t.concat(n,e.UNDERSCORE_IDENT_RE),i=t.concat(n,e.IDENT_RE),s={className:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!let|for|while|if|else|match\b)/,i,t.lookahead(/\s*\(/))},o="([ui](8|16|32|64|128|size)|f(32|64))?",l=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],u=["true","false","Some","None","Ok","Err"],d=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],h=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",type:h,keyword:l,literal:u,built_in:d},illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{className:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{className:"number",variants:[{begin:"\\b0b([01_]+)"+o},{begin:"\\b0o([0-7_]+)"+o},{begin:"\\b0x([A-Fa-f0-9_]+)"+o},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+o}],relevance:0},{begin:[/fn/,/\s+/,r],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,r],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,r,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:d,type:h}},{className:"punctuation",begin:"->"},s]}}const lEe=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),cEe=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],uEe=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],dEe=[...cEe,...uEe],hEe=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),fEe=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),pEe=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),mEe=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function gEe(e){const t=lEe(e),n=pEe,r=fEe,i="@[a-z-]+",s="and or not only",l={className:"variable",begin:"(\\$"+"[a-zA-Z-][a-zA-Z0-9_-]*"+")\\b",relevance:0};return{name:"SCSS",case_insensitive:!0,illegal:"[=/|']",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,t.CSS_NUMBER_MODE,{className:"selector-id",begin:"#[A-Za-z0-9_-]+",relevance:0},{className:"selector-class",begin:"\\.[A-Za-z0-9_-]+",relevance:0},t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-tag",begin:"\\b("+dEe.join("|")+")\\b",relevance:0},{className:"selector-pseudo",begin:":("+r.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+n.join("|")+")"},l,{begin:/\(/,end:/\)/,contains:[t.CSS_NUMBER_MODE]},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+mEe.join("|")+")\\b"},{begin:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b"},{begin:/:/,end:/[;}{]/,relevance:0,contains:[t.BLOCK_COMMENT,l,t.HEXCOLOR,t.CSS_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.IMPORTANT,t.FUNCTION_DISPATCH]},{begin:"@(page|font-face)",keywords:{$pattern:i,keyword:"@page @font-face"}},{begin:"@",end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/,keyword:s,attribute:hEe.join(" ")},contains:[{begin:i,className:"keyword"},{begin:/[a-z-]+(?=:)/,className:"attribute"},l,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.HEXCOLOR,t.CSS_NUMBER_MODE]},t.FUNCTION_DISPATCH]}}function vEe(e){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function yEe(e){const t=e.regex,n=e.COMMENT("--","$"),r={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},i={begin:/"/,end:/"/,contains:[{match:/""/}]},s=["true","false","unknown"],o=["double precision","large object","with timezone","without timezone"],l=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],u=["add","asc","collation","desc","final","first","last","view"],d=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],h=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],p=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],y=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],v=h,_=[...d,...u].filter(I=>!h.includes(I)),w={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},x={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},E={match:t.concat(/\b/,t.either(...v),/\s*\(/),relevance:0,keywords:{built_in:v}};function k(I){return t.concat(/\b/,t.either(...I.map(T=>T.replace(/\s+/,"\\s+"))),/\b/)}const R={scope:"keyword",match:k(y),relevance:0};function A(I,{exceptions:T,when:H}={}){const D=H;return T=T||[],I.map(W=>W.match(/\|\d+$/)||T.includes(W)?W:D(W)?`${W}|0`:W)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:A(_,{when:I=>I.length<3}),literal:s,type:l,built_in:p},contains:[{scope:"type",match:k(o)},R,E,w,r,i,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,x]}}function dF(e){return e?typeof e=="string"?e:e.source:null}function Rh(e){return Yn("(?=",e,")")}function Yn(...e){return e.map(n=>dF(n)).join("")}function bEe(e){const t=e[e.length-1];return typeof t=="object"&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function Oi(...e){return"("+(bEe(e).capture?"":"?:")+e.map(r=>dF(r)).join("|")+")"}const FE=e=>Yn(/\b/,e,/\w$/.test(e)?/\b/:/\B/),_Ee=["Protocol","Type"].map(FE),cD=["init","self"].map(FE),wEe=["Any","Self"],i0=["actor","any","associatedtype","async","await",/as\?/,/as!/,"as","borrowing","break","case","catch","class","consume","consuming","continue","convenience","copy","default","defer","deinit","didSet","distributed","do","dynamic","each","else","enum","extension","fallthrough",/fileprivate\(set\)/,"fileprivate","final","for","func","get","guard","if","import","indirect","infix",/init\?/,/init!/,"inout",/internal\(set\)/,"internal","in","is","isolated","nonisolated","lazy","let","macro","mutating","nonmutating",/open\(set\)/,"open","operator","optional","override","package","postfix","precedencegroup","prefix",/private\(set\)/,"private","protocol",/public\(set\)/,"public","repeat","required","rethrows","return","set","some","static","struct","subscript","super","switch","throws","throw",/try\?/,/try!/,"try","typealias",/unowned\(safe\)/,/unowned\(unsafe\)/,"unowned","var","weak","where","while","willSet"],uD=["false","nil","true"],SEe=["assignment","associativity","higherThan","left","lowerThan","none","right"],xEe=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],dD=["abs","all","any","assert","assertionFailure","debugPrint","dump","fatalError","getVaList","isKnownUniquelyReferenced","max","min","numericCast","pointwiseMax","pointwiseMin","precondition","preconditionFailure","print","readLine","repeatElement","sequence","stride","swap","swift_unboxFromSwiftValueWithType","transcode","type","unsafeBitCast","unsafeDowncast","withExtendedLifetime","withUnsafeMutablePointer","withUnsafePointer","withVaList","withoutActuallyEscaping","zip"],hF=Oi(/[/=\-+!*%<>&|^~?]/,/[\u00A1-\u00A7]/,/[\u00A9\u00AB]/,/[\u00AC\u00AE]/,/[\u00B0\u00B1]/,/[\u00B6\u00BB\u00BF\u00D7\u00F7]/,/[\u2016-\u2017]/,/[\u2020-\u2027]/,/[\u2030-\u203E]/,/[\u2041-\u2053]/,/[\u2055-\u205E]/,/[\u2190-\u23FF]/,/[\u2500-\u2775]/,/[\u2794-\u2BFF]/,/[\u2E00-\u2E7F]/,/[\u3001-\u3003]/,/[\u3008-\u3020]/,/[\u3030]/),fF=Oi(hF,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),s0=Yn(hF,fF,"*"),pF=Oi(/[a-zA-Z_]/,/[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,/[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,/[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,/[\u1E00-\u1FFF]/,/[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,/[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,/[\u2C00-\u2DFF\u2E80-\u2FFF]/,/[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,/[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,/[\uFE47-\uFEFE\uFF00-\uFFFD]/),fv=Oi(pF,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),po=Yn(pF,fv,"*"),dg=Yn(/[A-Z]/,fv,"*"),EEe=["attached","autoclosure",Yn(/convention\(/,Oi("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",Yn(/objc\(/,po,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],CEe=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];function kEe(e){const t={match:/\s+/,relevance:0},n=e.COMMENT("/\\*","\\*/",{contains:["self"]}),r=[e.C_LINE_COMMENT_MODE,n],i={match:[/\./,Oi(..._Ee,...cD)],className:{2:"keyword"}},s={match:Yn(/\./,Oi(...i0)),relevance:0},o=i0.filter(he=>typeof he=="string").concat(["_|0"]),l=i0.filter(he=>typeof he!="string").concat(wEe).map(FE),u={variants:[{className:"keyword",match:Oi(...l,...cD)}]},d={$pattern:Oi(/\b\w+/,/#\w+/),keyword:o.concat(xEe),literal:uD},h=[i,s,u],p={match:Yn(/\./,Oi(...dD)),relevance:0},y={className:"built_in",match:Yn(/\b/,Oi(...dD),/(?=\()/)},v=[p,y],_={match:/->/,relevance:0},w={className:"operator",relevance:0,variants:[{match:s0},{match:`\\.(\\.|${fF})+`}]},x=[_,w],E="([0-9]_*)+",k="([0-9a-fA-F]_*)+",R={className:"number",relevance:0,variants:[{match:`\\b(${E})(\\.(${E}))?([eE][+-]?(${E}))?\\b`},{match:`\\b0x(${k})(\\.(${k}))?([pP][+-]?(${E}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},A=(he="")=>({className:"subst",variants:[{match:Yn(/\\/,he,/[0\\tnr"']/)},{match:Yn(/\\/,he,/u\{[0-9a-fA-F]{1,8}\}/)}]}),I=(he="")=>({className:"subst",match:Yn(/\\/,he,/[\t ]*(?:[\r\n]|\r\n)/)}),T=(he="")=>({className:"subst",label:"interpol",begin:Yn(/\\/,he,/\(/),end:/\)/}),H=(he="")=>({begin:Yn(he,/"""/),end:Yn(/"""/,he),contains:[A(he),I(he),T(he)]}),D=(he="")=>({begin:Yn(he,/"/),end:Yn(/"/,he),contains:[A(he),T(he)]}),W={className:"string",variants:[H(),H("#"),H("##"),H("###"),D(),D("#"),D("##"),D("###")]},U=[e.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[e.BACKSLASH_ESCAPE]}],F={begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:U},O=he=>{const Ke=Yn(he,/\//),Rt=Yn(/\//,he);return{begin:Ke,end:Rt,contains:[...U,{scope:"comment",begin:`#(?!.*${Rt})`,end:/$/}]}},M={scope:"regexp",variants:[O("###"),O("##"),O("#"),F]},B={match:Yn(/`/,po,/`/)},L={className:"variable",match:/\$\d+/},N={className:"variable",match:`\\$${fv}+`},V=[B,L,N],Y={match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:CEe,contains:[...x,R,W]}]}},$={scope:"keyword",match:Yn(/@/,Oi(...EEe),Rh(Oi(/\(/,/\s+/)))},P={scope:"meta",match:Yn(/@/,po)},q=[Y,$,P],K={match:Rh(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:Yn(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,fv,"+")},{className:"type",match:dg,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:Yn(/\s+&\s+/,Rh(dg)),relevance:0}]},z={begin:/</,end:/>/,keywords:d,contains:[...r,...h,...q,_,K]};K.contains.push(z);const X={match:Yn(po,/\s*:/),keywords:"_|0",relevance:0},ee={begin:/\(/,end:/\)/,relevance:0,keywords:d,contains:["self",X,...r,M,...h,...v,...x,R,W,...V,...q,K]},te={begin:/</,end:/>/,keywords:"repeat each",contains:[...r,K]},Q={begin:Oi(Rh(Yn(po,/\s*:/)),Rh(Yn(po,/\s+/,po,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:po}]},me={begin:/\(/,end:/\)/,keywords:d,contains:[Q,...r,...h,...x,R,W,...q,K,ee],endsParent:!0,illegal:/["']/},ve={match:[/(func|macro)/,/\s+/,Oi(B.match,po,s0)],className:{1:"keyword",3:"title.function"},contains:[te,me,t],illegal:[/\[/,/%/]},Ce={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[te,me,t],illegal:/\[|%/},Me={match:[/operator/,/\s+/,s0],className:{1:"keyword",3:"title"}},Ve={begin:[/precedencegroup/,/\s+/,dg],className:{1:"keyword",3:"title"},contains:[K],keywords:[...SEe,...uD],end:/}/},Qe={match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},ct={match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},Ot={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,po,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:d,contains:[te,...h,{begin:/:/,end:/\{/,keywords:d,contains:[{scope:"title.class.inherited",match:dg},...h],relevance:0}]};for(const he of W.variants){const Ke=he.contains.find(ye=>ye.label==="interpol");Ke.keywords=d;const Rt=[...h,...v,...x,R,W,...V];Ke.contains=[...Rt,{begin:/\(/,end:/\)/,contains:["self",...Rt]}]}return{name:"Swift",keywords:d,contains:[...r,ve,Ce,Qe,ct,Ot,Me,Ve,{beginKeywords:"import",end:/$/,contains:[...r],relevance:0},M,...h,...v,...x,R,W,...V,...q,K,ee]}}const pv="[A-Za-z$_][0-9A-Za-z$_]*",mF=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],gF=["true","false","null","undefined","NaN","Infinity"],vF=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],yF=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],bF=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],_F=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],wF=[].concat(bF,vF,yF);function TEe(e){const t=e.regex,n=(Y,{after:$})=>{const P="</"+Y[0].slice(1);return Y.input.indexOf(P,$)!==-1},r=pv,i={begin:"<>",end:"</>"},s=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(Y,$)=>{const P=Y[0].length+Y.index,q=Y.input[P];if(q==="<"||q===","){$.ignoreMatch();return}q===">"&&(n(Y,{after:P})||$.ignoreMatch());let K;const z=Y.input.substring(P);if(K=z.match(/^\s*=/)){$.ignoreMatch();return}if((K=z.match(/^\s+extends\s+/))&&K.index===0){$.ignoreMatch();return}}},l={$pattern:pv,keyword:mF,literal:gF,built_in:wF,"variable.language":_F},u="[0-9](_?[0-9])*",d=`\\.(${u})`,h="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",p={className:"number",variants:[{begin:`(\\b(${h})((${d})|\\.)?|(${d}))[eE][+-]?(${u})\\b`},{begin:`\\b(${h})\\b((${d})\\b|\\.)?|(${d})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},y={className:"subst",begin:"\\$\\{",end:"\\}",keywords:l,contains:[]},v={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,y],subLanguage:"xml"}},_={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,y],subLanguage:"css"}},w={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,y],subLanguage:"graphql"}},x={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,y]},k={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},R=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,v,_,w,x,{match:/\$\d+/},p];y.contains=R.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(R)});const A=[].concat(k,y.contains),I=A.concat([{begin:/(\s*)\(/,end:/\)/,keywords:l,contains:["self"].concat(A)}]),T={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:I},H={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,"(",t.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},D={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...vF,...yF]}},W={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},U={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[T],illegal:/%/},F={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function O(Y){return t.concat("(?!",Y.join("|"),")")}const M={match:t.concat(/\b/,O([...bF,"super","import"].map(Y=>`${Y}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},B={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},L={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},T]},N="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",V={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(N)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[T]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:I,CLASS_REFERENCE:D},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),W,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,v,_,w,x,k,{match:/\$\d+/},p,D,{scope:"attr",match:r+t.lookahead(":"),relevance:0},V,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[k,e.REGEXP_MODE,{className:"function",begin:N,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:I}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:s},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:"xml",contains:[{begin:o.begin,end:o.end,skip:!0,contains:["self"]}]}]},U,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[T,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},B,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[T]},M,F,H,L,{match:/\$[(.]/}]}}function REe(e){const t=e.regex,n=TEe(e),r=pv,i=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],s={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},o={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:i},contains:[n.exports.CLASS_REFERENCE]},l={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},u=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],d={$pattern:pv,keyword:mF.concat(u),literal:gF,built_in:wF.concat(i),"variable.language":_F},h={className:"meta",begin:"@"+r},p=(w,x,E)=>{const k=w.contains.findIndex(R=>R.label===x);if(k===-1)throw new Error("can not find mode to replace");w.contains.splice(k,1,E)};Object.assign(n.keywords,d),n.exports.PARAMS_CONTAINS.push(h);const y=n.contains.find(w=>w.scope==="attr"),v=Object.assign({},y,{match:t.concat(r,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,y,v]),n.contains=n.contains.concat([h,s,o,v]),p(n,"shebang",e.SHEBANG()),p(n,"use_strict",l);const _=n.contains.find(w=>w.label==="func.def");return _.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function AEe(e){const t=e.regex,n={className:"string",begin:/"(""|[^/n])"C\b/},r={className:"string",begin:/"/,end:/"/,illegal:/\n/,contains:[{begin:/""/}]},i=/\d{1,2}\/\d{1,2}\/\d{4}/,s=/\d{4}-\d{1,2}-\d{1,2}/,o=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,l=/\d{1,2}(:\d{1,2}){1,2}/,u={className:"literal",variants:[{begin:t.concat(/# */,t.either(s,i),/ *#/)},{begin:t.concat(/# */,l,/ *#/)},{begin:t.concat(/# */,o,/ *#/)},{begin:t.concat(/# */,t.either(s,i),/ +/,t.either(o,l),/ *#/)}]},d={className:"number",relevance:0,variants:[{begin:/\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/},{begin:/\b\d[\d_]*((U?[SIL])|[%&])?/},{begin:/&H[\dA-F_]+((U?[SIL])|[%&])?/},{begin:/&O[0-7_]+((U?[SIL])|[%&])?/},{begin:/&B[01_]+((U?[SIL])|[%&])?/}]},h={className:"label",begin:/^\w+:/},p=e.COMMENT(/'''/,/$/,{contains:[{className:"doctag",begin:/<\/?/,end:/>/}]}),y=e.COMMENT(null,/$/,{variants:[{begin:/'/},{begin:/([\t ]|^)REM(?=\s)/}]});return{name:"Visual Basic .NET",aliases:["vb"],case_insensitive:!0,classNameAliases:{label:"symbol"},keywords:{keyword:"addhandler alias aggregate ansi as async assembly auto binary by byref byval call case catch class compare const continue custom declare default delegate dim distinct do each equals else elseif end enum erase error event exit explicit finally for friend from function get global goto group handles if implements imports in inherits interface into iterator join key let lib loop me mid module mustinherit mustoverride mybase myclass namespace narrowing new next notinheritable notoverridable of off on operator option optional order overloads overridable overrides paramarray partial preserve private property protected public raiseevent readonly redim removehandler resume return select set shadows shared skip static step stop structure strict sub synclock take text then throw to try unicode until using when where while widening with withevents writeonly yield",built_in:"addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort",type:"boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort",literal:"true false nothing"},illegal:"//|\\{|\\}|endif|gosub|variant|wend|^\\$ ",contains:[n,r,u,d,h,p,y,{className:"meta",begin:/[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/,end:/$/,keywords:{keyword:"const disable else elseif enable end externalsource if region then"},contains:[y]}]}}function NEe(e){e.regex;const t=e.COMMENT(/\(;/,/;\)/);t.contains.push("self");const n=e.COMMENT(/;;/,/$/),r=["anyfunc","block","br","br_if","br_table","call","call_indirect","data","drop","elem","else","end","export","func","global.get","global.set","local.get","local.set","local.tee","get_global","get_local","global","if","import","local","loop","memory","memory.grow","memory.size","module","mut","nop","offset","param","result","return","select","set_global","set_local","start","table","tee_local","then","type","unreachable"],i={begin:[/(?:func|call|call_indirect)/,/\s+/,/\$[^\s)]+/],className:{1:"keyword",3:"title.function"}},s={className:"variable",begin:/\$[\w_]+/},o={match:/(\((?!;)|\))+/,className:"punctuation",relevance:0},l={className:"number",relevance:0,match:/[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/},u={match:/(i32|i64|f32|f64)(?!\.)/,className:"type"},d={className:"keyword",match:/\b(f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|nearest|neg?|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|store(?:8|16|32)?|sqrt|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))\b/};return{name:"WebAssembly",keywords:{$pattern:/[\w.]+/,keyword:r},contains:[n,t,{match:[/(?:offset|align)/,/\s*/,/=/],className:{1:"keyword",3:"operator"}},s,o,i,e.QUOTE_STRING_MODE,u,d,l]}}function MEe(e){const t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,i={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},s={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},o=e.inherit(s,{begin:/\(/,end:/\)/}),l=e.inherit(e.APOS_STRING_MODE,{className:"string"}),u=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),d={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[i]},{begin:/'/,end:/'/,contains:[i]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[s,u,l,o,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[s,o,u,l]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},i,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[u]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[d],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[d],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:d}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function OEe(e){const t="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",r={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},i={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},s={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},o={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,i]},l=e.inherit(o,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),y={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},v={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},_={begin:/\{/,end:/\}/,contains:[v],illegal:"\\n",relevance:0},w={begin:"\\[",end:"\\]",contains:[v],illegal:"\\n",relevance:0},x=[r,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},y,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},_,w,s,o],E=[...x];return E.pop(),E.push(l),v.contains=E,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:x}}const DEe={arduino:p1e,bash:m1e,c:g1e,cpp:v1e,csharp:y1e,css:T1e,diff:R1e,go:A1e,graphql:N1e,ini:M1e,java:O1e,javascript:z1e,json:B1e,kotlin:F1e,less:K1e,lua:G1e,makefile:X1e,markdown:Z1e,objectivec:Q1e,perl:J1e,php:eEe,"php-template":tEe,plaintext:nEe,python:rEe,"python-repl":iEe,r:sEe,ruby:oEe,rust:aEe,scss:gEe,shell:vEe,sql:yEe,swift:kEe,typescript:REe,vbnet:AEe,wasm:NEe,xml:MEe,yaml:OEe};var o0,hD;function PEe(){if(hD)return o0;hD=1;function e(J){return J instanceof Map?J.clear=J.delete=J.set=function(){throw new Error("map is read-only")}:J instanceof Set&&(J.add=J.clear=J.delete=function(){throw new Error("set is read-only")}),Object.freeze(J),Object.getOwnPropertyNames(J).forEach(_e=>{const Be=J[_e],ht=typeof Be;(ht==="object"||ht==="function")&&!Object.isFrozen(Be)&&e(Be)}),J}class t{constructor(_e){_e.data===void 0&&(_e.data={}),this.data=_e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(J){return J.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function r(J,..._e){const Be=Object.create(null);for(const ht in J)Be[ht]=J[ht];return _e.forEach(function(ht){for(const jt in ht)Be[jt]=ht[jt]}),Be}const i="</span>",s=J=>!!J.scope,o=(J,{prefix:_e})=>{if(J.startsWith("language:"))return J.replace("language:","language-");if(J.includes(".")){const Be=J.split(".");return[`${_e}${Be.shift()}`,...Be.map((ht,jt)=>`${ht}${"_".repeat(jt+1)}`)].join(" ")}return`${_e}${J}`};class l{constructor(_e,Be){this.buffer="",this.classPrefix=Be.classPrefix,_e.walk(this)}addText(_e){this.buffer+=n(_e)}openNode(_e){if(!s(_e))return;const Be=o(_e.scope,{prefix:this.classPrefix});this.span(Be)}closeNode(_e){s(_e)&&(this.buffer+=i)}value(){return this.buffer}span(_e){this.buffer+=`<span class="${_e}">`}}const u=(J={})=>{const _e={children:[]};return Object.assign(_e,J),_e};class d{constructor(){this.rootNode=u(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(_e){this.top.children.push(_e)}openNode(_e){const Be=u({scope:_e});this.add(Be),this.stack.push(Be)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(_e){return this.constructor._walk(_e,this.rootNode)}static _walk(_e,Be){return typeof Be=="string"?_e.addText(Be):Be.children&&(_e.openNode(Be),Be.children.forEach(ht=>this._walk(_e,ht)),_e.closeNode(Be)),_e}static _collapse(_e){typeof _e!="string"&&_e.children&&(_e.children.every(Be=>typeof Be=="string")?_e.children=[_e.children.join("")]:_e.children.forEach(Be=>{d._collapse(Be)}))}}class h extends d{constructor(_e){super(),this.options=_e}addText(_e){_e!==""&&this.add(_e)}startScope(_e){this.openNode(_e)}endScope(){this.closeNode()}__addSublanguage(_e,Be){const ht=_e.root;Be&&(ht.scope=`language:${Be}`),this.add(ht)}toHTML(){return new l(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function p(J){return J?typeof J=="string"?J:J.source:null}function y(J){return w("(?=",J,")")}function v(J){return w("(?:",J,")*")}function _(J){return w("(?:",J,")?")}function w(...J){return J.map(Be=>p(Be)).join("")}function x(J){const _e=J[J.length-1];return typeof _e=="object"&&_e.constructor===Object?(J.splice(J.length-1,1),_e):{}}function E(...J){return"("+(x(J).capture?"":"?:")+J.map(ht=>p(ht)).join("|")+")"}function k(J){return new RegExp(J.toString()+"|").exec("").length-1}function R(J,_e){const Be=J&&J.exec(_e);return Be&&Be.index===0}const A=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function I(J,{joinWith:_e}){let Be=0;return J.map(ht=>{Be+=1;const jt=Be;let re=p(ht),ie="";for(;re.length>0;){const de=A.exec(re);if(!de){ie+=re;break}ie+=re.substring(0,de.index),re=re.substring(de.index+de[0].length),de[0][0]==="\\"&&de[1]?ie+="\\"+String(Number(de[1])+jt):(ie+=de[0],de[0]==="("&&Be++)}return ie}).map(ht=>`(${ht})`).join(_e)}const T=/\b\B/,H="[a-zA-Z]\\w*",D="[a-zA-Z_]\\w*",W="\\b\\d+(\\.\\d+)?",U="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",F="\\b(0b[01]+)",O="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",M=(J={})=>{const _e=/^#![ ]*\//;return J.binary&&(J.begin=w(_e,/.*\b/,J.binary,/\b.*/)),r({scope:"meta",begin:_e,end:/$/,relevance:0,"on:begin":(Be,ht)=>{Be.index!==0&&ht.ignoreMatch()}},J)},B={begin:"\\\\[\\s\\S]",relevance:0},L={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[B]},N={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[B]},V={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},Y=function(J,_e,Be={}){const ht=r({scope:"comment",begin:J,end:_e,contains:[]},Be);ht.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const jt=E("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return ht.contains.push({begin:w(/[ ]+/,"(",jt,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),ht},$=Y("//","$"),P=Y("/\\*","\\*/"),q=Y("#","$"),K={scope:"number",begin:W,relevance:0},z={scope:"number",begin:U,relevance:0},X={scope:"number",begin:F,relevance:0},ee={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[B,{begin:/\[/,end:/\]/,relevance:0,contains:[B]}]},te={scope:"title",begin:H,relevance:0},Q={scope:"title",begin:D,relevance:0},me={begin:"\\.\\s*"+D,relevance:0};var Ce=Object.freeze({__proto__:null,APOS_STRING_MODE:L,BACKSLASH_ESCAPE:B,BINARY_NUMBER_MODE:X,BINARY_NUMBER_RE:F,COMMENT:Y,C_BLOCK_COMMENT_MODE:P,C_LINE_COMMENT_MODE:$,C_NUMBER_MODE:z,C_NUMBER_RE:U,END_SAME_AS_BEGIN:function(J){return Object.assign(J,{"on:begin":(_e,Be)=>{Be.data._beginMatch=_e[1]},"on:end":(_e,Be)=>{Be.data._beginMatch!==_e[1]&&Be.ignoreMatch()}})},HASH_COMMENT_MODE:q,IDENT_RE:H,MATCH_NOTHING_RE:T,METHOD_GUARD:me,NUMBER_MODE:K,NUMBER_RE:W,PHRASAL_WORDS_MODE:V,QUOTE_STRING_MODE:N,REGEXP_MODE:ee,RE_STARTERS_RE:O,SHEBANG:M,TITLE_MODE:te,UNDERSCORE_IDENT_RE:D,UNDERSCORE_TITLE_MODE:Q});function Me(J,_e){J.input[J.index-1]==="."&&_e.ignoreMatch()}function Ve(J,_e){J.className!==void 0&&(J.scope=J.className,delete J.className)}function Qe(J,_e){_e&&J.beginKeywords&&(J.begin="\\b("+J.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",J.__beforeBegin=Me,J.keywords=J.keywords||J.beginKeywords,delete J.beginKeywords,J.relevance===void 0&&(J.relevance=0))}function ct(J,_e){Array.isArray(J.illegal)&&(J.illegal=E(...J.illegal))}function Ot(J,_e){if(J.match){if(J.begin||J.end)throw new Error("begin & end are not supported with match");J.begin=J.match,delete J.match}}function he(J,_e){J.relevance===void 0&&(J.relevance=1)}const Ke=(J,_e)=>{if(!J.beforeMatch)return;if(J.starts)throw new Error("beforeMatch cannot be used with starts");const Be=Object.assign({},J);Object.keys(J).forEach(ht=>{delete J[ht]}),J.keywords=Be.keywords,J.begin=w(Be.beforeMatch,y(Be.begin)),J.starts={relevance:0,contains:[Object.assign(Be,{endsParent:!0})]},J.relevance=0,delete Be.beforeMatch},Rt=["of","and","for","in","not","or","if","then","parent","list","value"],ye="keyword";function He(J,_e,Be=ye){const ht=Object.create(null);return typeof J=="string"?jt(Be,J.split(" ")):Array.isArray(J)?jt(Be,J):Object.keys(J).forEach(function(re){Object.assign(ht,He(J[re],_e,re))}),ht;function jt(re,ie){_e&&(ie=ie.map(de=>de.toLowerCase())),ie.forEach(function(de){const pe=de.split("|");ht[pe[0]]=[re,Ge(pe[0],pe[1])]})}}function Ge(J,_e){return _e?Number(_e):be(J)?0:1}function be(J){return Rt.includes(J.toLowerCase())}const Xe={},rt=J=>{console.error(J)},pt=(J,..._e)=>{console.log(`WARN: ${J}`,..._e)},le=(J,_e)=>{Xe[`${J}/${_e}`]||(console.log(`Deprecated as of ${J}. ${_e}`),Xe[`${J}/${_e}`]=!0)},Ae=new Error;function Ze(J,_e,{key:Be}){let ht=0;const jt=J[Be],re={},ie={};for(let de=1;de<=_e.length;de++)ie[de+ht]=jt[de],re[de+ht]=!0,ht+=k(_e[de-1]);J[Be]=ie,J[Be]._emit=re,J[Be]._multi=!0}function tt(J){if(Array.isArray(J.begin)){if(J.skip||J.excludeBegin||J.returnBegin)throw rt("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),Ae;if(typeof J.beginScope!="object"||J.beginScope===null)throw rt("beginScope must be object"),Ae;Ze(J,J.begin,{key:"beginScope"}),J.begin=I(J.begin,{joinWith:""})}}function dt(J){if(Array.isArray(J.end)){if(J.skip||J.excludeEnd||J.returnEnd)throw rt("skip, excludeEnd, returnEnd not compatible with endScope: {}"),Ae;if(typeof J.endScope!="object"||J.endScope===null)throw rt("endScope must be object"),Ae;Ze(J,J.end,{key:"endScope"}),J.end=I(J.end,{joinWith:""})}}function Dt(J){J.scope&&typeof J.scope=="object"&&J.scope!==null&&(J.beginScope=J.scope,delete J.scope)}function Wt(J){Dt(J),typeof J.beginScope=="string"&&(J.beginScope={_wrap:J.beginScope}),typeof J.endScope=="string"&&(J.endScope={_wrap:J.endScope}),tt(J),dt(J)}function tn(J){function _e(ie,de){return new RegExp(p(ie),"m"+(J.case_insensitive?"i":"")+(J.unicodeRegex?"u":"")+(de?"g":""))}class Be{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(de,pe){pe.position=this.position++,this.matchIndexes[this.matchAt]=pe,this.regexes.push([pe,de]),this.matchAt+=k(de)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const de=this.regexes.map(pe=>pe[1]);this.matcherRe=_e(I(de,{joinWith:"|"}),!0),this.lastIndex=0}exec(de){this.matcherRe.lastIndex=this.lastIndex;const pe=this.matcherRe.exec(de);if(!pe)return null;const Z=pe.findIndex((ae,Te)=>Te>0&&ae!==void 0),ne=this.matchIndexes[Z];return pe.splice(0,Z),Object.assign(pe,ne)}}class ht{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(de){if(this.multiRegexes[de])return this.multiRegexes[de];const pe=new Be;return this.rules.slice(de).forEach(([Z,ne])=>pe.addRule(Z,ne)),pe.compile(),this.multiRegexes[de]=pe,pe}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(de,pe){this.rules.push([de,pe]),pe.type==="begin"&&this.count++}exec(de){const pe=this.getMatcher(this.regexIndex);pe.lastIndex=this.lastIndex;let Z=pe.exec(de);if(this.resumingScanAtSamePosition()&&!(Z&&Z.index===this.lastIndex)){const ne=this.getMatcher(0);ne.lastIndex=this.lastIndex+1,Z=ne.exec(de)}return Z&&(this.regexIndex+=Z.position+1,this.regexIndex===this.count&&this.considerAll()),Z}}function jt(ie){const de=new ht;return ie.contains.forEach(pe=>de.addRule(pe.begin,{rule:pe,type:"begin"})),ie.terminatorEnd&&de.addRule(ie.terminatorEnd,{type:"end"}),ie.illegal&&de.addRule(ie.illegal,{type:"illegal"}),de}function re(ie,de){const pe=ie;if(ie.isCompiled)return pe;[Ve,Ot,Wt,Ke].forEach(ne=>ne(ie,de)),J.compilerExtensions.forEach(ne=>ne(ie,de)),ie.__beforeBegin=null,[Qe,ct,he].forEach(ne=>ne(ie,de)),ie.isCompiled=!0;let Z=null;return typeof ie.keywords=="object"&&ie.keywords.$pattern&&(ie.keywords=Object.assign({},ie.keywords),Z=ie.keywords.$pattern,delete ie.keywords.$pattern),Z=Z||/\w+/,ie.keywords&&(ie.keywords=He(ie.keywords,J.case_insensitive)),pe.keywordPatternRe=_e(Z,!0),de&&(ie.begin||(ie.begin=/\B|\b/),pe.beginRe=_e(pe.begin),!ie.end&&!ie.endsWithParent&&(ie.end=/\B|\b/),ie.end&&(pe.endRe=_e(pe.end)),pe.terminatorEnd=p(pe.end)||"",ie.endsWithParent&&de.terminatorEnd&&(pe.terminatorEnd+=(ie.end?"|":"")+de.terminatorEnd)),ie.illegal&&(pe.illegalRe=_e(ie.illegal)),ie.contains||(ie.contains=[]),ie.contains=[].concat(...ie.contains.map(function(ne){return un(ne==="self"?ie:ne)})),ie.contains.forEach(function(ne){re(ne,pe)}),ie.starts&&re(ie.starts,de),pe.matcher=jt(pe),pe}if(J.compilerExtensions||(J.compilerExtensions=[]),J.contains&&J.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return J.classNameAliases=r(J.classNameAliases||{}),re(J)}function vn(J){return J?J.endsWithParent||vn(J.starts):!1}function un(J){return J.variants&&!J.cachedVariants&&(J.cachedVariants=J.variants.map(function(_e){return r(J,{variants:null},_e)})),J.cachedVariants?J.cachedVariants:vn(J)?r(J,{starts:J.starts?r(J.starts):null}):Object.isFrozen(J)?r(J):J}var Zt="11.11.1";class Xn extends Error{constructor(_e,Be){super(_e),this.name="HTMLInjectionError",this.html=Be}}const Kt=n,Zn=r,ze=Symbol("nomatch"),et=7,Et=function(J){const _e=Object.create(null),Be=Object.create(null),ht=[];let jt=!0;const re="Could not find the language '{}', did you forget to load/include a language module?",ie={disableAutodetect:!0,name:"Plain text",contains:[]};let de={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:h};function pe($e){return de.noHighlightRe.test($e)}function Z($e){let vt=$e.className+" ";vt+=$e.parentNode?$e.parentNode.className:"";const Vt=de.languageDetectRe.exec(vt);if(Vt){const bn=gt(Vt[1]);return bn||(pt(re.replace("{}",Vt[1])),pt("Falling back to no-highlight mode for this block.",$e)),bn?Vt[1]:"no-highlight"}return vt.split(/\s+/).find(bn=>pe(bn)||gt(bn))}function ne($e,vt,Vt){let bn="",Bn="";typeof vt=="object"?(bn=$e,Vt=vt.ignoreIllegals,Bn=vt.language):(le("10.7.0","highlight(lang, code, ...args) has been deprecated."),le("10.7.0",`Please use highlight(code, options) instead.
685
685
  https://github.com/highlightjs/highlight.js/issues/2277`),Bn=$e,bn=vt),Vt===void 0&&(Vt=!0);const zt={code:bn,language:Bn};rr("before:highlight",zt);const Tn=zt.result?zt.result:ae(zt.language,zt.code,Vt);return Tn.code=zt.code,rr("after:highlight",Tn),Tn}function ae($e,vt,Vt,bn){const Bn=Object.create(null);function zt(lt,At){return lt.keywords[At]}function Tn(){if(!qt.keywords){Tr.addText(Fn);return}let lt=0;qt.keywordPatternRe.lastIndex=0;let At=qt.keywordPatternRe.exec(Fn),rn="";for(;At;){rn+=Fn.substring(lt,At.index);const xn=li.case_insensitive?At[0].toLowerCase():At[0],lr=zt(qt,xn);if(lr){const[fs,gd]=lr;if(Tr.addText(rn),rn="",Bn[xn]=(Bn[xn]||0)+1,Bn[xn]<=et&&(da+=gd),fs.startsWith("_"))rn+=At[0];else{const cp=li.classNameAliases[fs]||fs;nn(At[0],cp)}}else rn+=At[0];lt=qt.keywordPatternRe.lastIndex,At=qt.keywordPatternRe.exec(Fn)}rn+=Fn.substring(lt),Tr.addText(rn)}function vr(){if(Fn==="")return;let lt=null;if(typeof qt.subLanguage=="string"){if(!_e[qt.subLanguage]){Tr.addText(Fn);return}lt=ae(qt.subLanguage,Fn,!0,lp[qt.subLanguage]),lp[qt.subLanguage]=lt._top}else lt=je(Fn,qt.subLanguage.length?qt.subLanguage:null);qt.relevance>0&&(da+=lt.relevance),Tr.__addSublanguage(lt._emitter,lt.language)}function Gt(){qt.subLanguage!=null?vr():Tn(),Fn=""}function nn(lt,At){lt!==""&&(Tr.startScope(At),Tr.addText(lt),Tr.endScope())}function Bi(lt,At){let rn=1;const xn=At.length-1;for(;rn<=xn;){if(!lt._emit[rn]){rn++;continue}const lr=li.classNameAliases[lt[rn]]||lt[rn],fs=At[rn];lr?nn(fs,lr):(Fn=fs,Tn(),Fn=""),rn++}}function zr(lt,At){return lt.scope&&typeof lt.scope=="string"&&Tr.openNode(li.classNameAliases[lt.scope]||lt.scope),lt.beginScope&&(lt.beginScope._wrap?(nn(Fn,li.classNameAliases[lt.beginScope._wrap]||lt.beginScope._wrap),Fn=""):lt.beginScope._multi&&(Bi(lt.beginScope,At),Fn="")),qt=Object.create(lt,{parent:{value:qt}}),qt}function Is(lt,At,rn){let xn=R(lt.endRe,rn);if(xn){if(lt["on:end"]){const lr=new t(lt);lt["on:end"](At,lr),lr.isMatchIgnored&&(xn=!1)}if(xn){for(;lt.endsParent&&lt.parent;)lt=lt.parent;return lt}}if(lt.endsWithParent)return Is(lt.parent,At,rn)}function ua(lt){return qt.matcher.regexIndex===0?(Fn+=lt[0],1):(ha=!0,0)}function Ac(lt){const At=lt[0],rn=lt.rule,xn=new t(rn),lr=[rn.__beforeBegin,rn["on:begin"]];for(const fs of lr)if(fs&&(fs(lt,xn),xn.isMatchIgnored))return ua(At);return rn.skip?Fn+=At:(rn.excludeBegin&&(Fn+=At),Gt(),!rn.returnBegin&&!rn.excludeBegin&&(Fn=At)),zr(rn,lt),rn.returnBegin?0:At.length}function ai(lt){const At=lt[0],rn=vt.substring(lt.index),xn=Is(qt,lt,rn);if(!xn)return ze;const lr=qt;qt.endScope&&qt.endScope._wrap?(Gt(),nn(At,qt.endScope._wrap)):qt.endScope&&qt.endScope._multi?(Gt(),Bi(qt.endScope,lt)):lr.skip?Fn+=At:(lr.returnEnd||lr.excludeEnd||(Fn+=At),Gt(),lr.excludeEnd&&(Fn=At));do qt.scope&&Tr.closeNode(),!qt.skip&&!qt.subLanguage&&(da+=qt.relevance),qt=qt.parent;while(qt!==xn.parent);return xn.starts&&zr(xn.starts,lt),lr.returnEnd?0:At.length}function hs(){const lt=[];for(let At=qt;At!==li;At=At.parent)At.scope&&lt.unshift(At.scope);lt.forEach(At=>Tr.openNode(At))}let El={};function Nc(lt,At){const rn=At&&At[0];if(Fn+=lt,rn==null)return Gt(),0;if(El.type==="begin"&&At.type==="end"&&El.index===At.index&&rn===""){if(Fn+=vt.slice(At.index,At.index+1),!jt){const xn=new Error(`0 width match regex (${$e})`);throw xn.languageName=$e,xn.badRule=El.rule,xn}return 1}if(El=At,At.type==="begin")return Ac(At);if(At.type==="illegal"&&!Vt){const xn=new Error('Illegal lexeme "'+rn+'" for mode "'+(qt.scope||"<unnamed>")+'"');throw xn.mode=qt,xn}else if(At.type==="end"){const xn=ai(At);if(xn!==ze)return xn}if(At.type==="illegal"&&rn==="")return Fn+=`
686
- `,1;if(md>1e5&&md>At.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Fn+=rn,rn.length}const li=gt($e);if(!li)throw rt(re.replace("{}",$e)),new Error('Unknown language: "'+$e+'"');const ap=tn(li);let Mc="",qt=bn||ap;const lp={},Tr=new de.__emitter(de);hs();let Fn="",da=0,No=0,md=0,ha=!1;try{if(li.__emitTokens)li.__emitTokens(vt,Tr);else{for(qt.matcher.considerAll();;){md++,ha?ha=!1:qt.matcher.considerAll(),qt.matcher.lastIndex=No;const lt=qt.matcher.exec(vt);if(!lt)break;const At=vt.substring(No,lt.index),rn=Nc(At,lt);No=lt.index+rn}Nc(vt.substring(No))}return Tr.finalize(),Mc=Tr.toHTML(),{language:$e,value:Mc,relevance:da,illegal:!1,_emitter:Tr,_top:qt}}catch(lt){if(lt.message&&lt.message.includes("Illegal"))return{language:$e,value:Kt(vt),illegal:!0,relevance:0,_illegalBy:{message:lt.message,index:No,context:vt.slice(No-100,No+100),mode:lt.mode,resultSoFar:Mc},_emitter:Tr};if(jt)return{language:$e,value:Kt(vt),illegal:!1,relevance:0,errorRaised:lt,_emitter:Tr,_top:qt};throw lt}}function Te($e){const vt={value:Kt($e),illegal:!1,relevance:0,_top:ie,_emitter:new de.__emitter(de)};return vt._emitter.addText($e),vt}function je($e,vt){vt=vt||de.languages||Object.keys(_e);const Vt=Te($e),bn=vt.filter(gt).filter(Tt).map(Gt=>ae(Gt,$e,!1));bn.unshift(Vt);const Bn=bn.sort((Gt,nn)=>{if(Gt.relevance!==nn.relevance)return nn.relevance-Gt.relevance;if(Gt.language&&nn.language){if(gt(Gt.language).supersetOf===nn.language)return 1;if(gt(nn.language).supersetOf===Gt.language)return-1}return 0}),[zt,Tn]=Bn,vr=zt;return vr.secondBest=Tn,vr}function st($e,vt,Vt){const bn=vt&&Be[vt]||Vt;$e.classList.add("hljs"),$e.classList.add(`language-${bn}`)}function ue($e){let vt=null;const Vt=Z($e);if(pe(Vt))return;if(rr("before:highlightElement",{el:$e,language:Vt}),$e.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",$e);return}if($e.children.length>0&&(de.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn($e)),de.throwUnescapedHTML))throw new Xn("One of your code blocks includes unescaped HTML.",$e.innerHTML);vt=$e;const bn=vt.textContent,Bn=Vt?ne(bn,{language:Vt,ignoreIllegals:!0}):je(bn);$e.innerHTML=Bn.value,$e.dataset.highlighted="yes",st($e,Vt,Bn.language),$e.result={language:Bn.language,re:Bn.relevance,relevance:Bn.relevance},Bn.secondBest&&($e.secondBest={language:Bn.secondBest.language,relevance:Bn.secondBest.relevance}),rr("after:highlightElement",{el:$e,result:Bn,text:bn})}function xe($e){de=Zn(de,$e)}const ke=()=>{fe(),le("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function De(){fe(),le("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let se=!1;function fe(){function $e(){fe()}if(document.readyState==="loading"){se||window.addEventListener("DOMContentLoaded",$e,!1),se=!0;return}document.querySelectorAll(de.cssSelector).forEach(ue)}function Oe($e,vt){let Vt=null;try{Vt=vt(J)}catch(bn){if(rt("Language definition for '{}' could not be registered.".replace("{}",$e)),jt)rt(bn);else throw bn;Vt=ie}Vt.name||(Vt.name=$e),_e[$e]=Vt,Vt.rawDefinition=vt.bind(null,J),Vt.aliases&&kt(Vt.aliases,{languageName:$e})}function Ue($e){delete _e[$e];for(const vt of Object.keys(Be))Be[vt]===$e&&delete Be[vt]}function ft(){return Object.keys(_e)}function gt($e){return $e=($e||"").toLowerCase(),_e[$e]||_e[Be[$e]]}function kt($e,{languageName:vt}){typeof $e=="string"&&($e=[$e]),$e.forEach(Vt=>{Be[Vt.toLowerCase()]=vt})}function Tt($e){const vt=gt($e);return vt&&!vt.disableAutodetect}function Ht($e){$e["before:highlightBlock"]&&!$e["before:highlightElement"]&&($e["before:highlightElement"]=vt=>{$e["before:highlightBlock"](Object.assign({block:vt.el},vt))}),$e["after:highlightBlock"]&&!$e["after:highlightElement"]&&($e["after:highlightElement"]=vt=>{$e["after:highlightBlock"](Object.assign({block:vt.el},vt))})}function yn($e){Ht($e),ht.push($e)}function oi($e){const vt=ht.indexOf($e);vt!==-1&&ht.splice(vt,1)}function rr($e,vt){const Vt=$e;ht.forEach(function(bn){bn[Vt]&&bn[Vt](vt)})}function fn($e){return le("10.7.0","highlightBlock will be removed entirely in v12.0"),le("10.7.0","Please use highlightElement now."),ue($e)}Object.assign(J,{highlight:ne,highlightAuto:je,highlightAll:fe,highlightElement:ue,highlightBlock:fn,configure:xe,initHighlighting:ke,initHighlightingOnLoad:De,registerLanguage:Oe,unregisterLanguage:Ue,listLanguages:ft,getLanguage:gt,registerAliases:kt,autoDetection:Tt,inherit:Zn,addPlugin:yn,removePlugin:oi}),J.debugMode=function(){jt=!1},J.safeMode=function(){jt=!0},J.versionString=Zt,J.regex={concat:w,lookahead:y,either:E,optional:_,anyNumberOfTimes:v};for(const $e in Ce)typeof Ce[$e]=="object"&&e(Ce[$e]);return Object.assign(J,Ce),J},Bt=Et({});return Bt.newInstance=()=>Et({}),o0=Bt,Bt.HighlightJS=Bt,Bt.default=Bt,o0}var LEe=PEe();const IEe=Af(LEe),fD={},zEe="hljs-";function BEe(e){const t=IEe.newInstance();return e&&s(e),{highlight:n,highlightAuto:r,listLanguages:i,register:s,registerAlias:o,registered:l};function n(u,d,h){const p=h||fD,y=typeof p.prefix=="string"?p.prefix:zEe;if(!t.getLanguage(u))throw new Error("Unknown language: `"+u+"` is not registered");t.configure({__emitter:jEe,classPrefix:y});const v=t.highlight(d,{ignoreIllegals:!0,language:u});if(v.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:v.errorRaised});const _=v._emitter.root,w=_.data;return w.language=v.language,w.relevance=v.relevance,_}function r(u,d){const p=(d||fD).subset||i();let y=-1,v=0,_;for(;++y<p.length;){const w=p[y];if(!t.getLanguage(w))continue;const x=n(w,u,d);x.data&&x.data.relevance!==void 0&&x.data.relevance>v&&(v=x.data.relevance,_=x)}return _||{type:"root",children:[],data:{language:void 0,relevance:v}}}function i(){return t.listLanguages()}function s(u,d){if(typeof u=="string")t.registerLanguage(u,d);else{let h;for(h in u)Object.hasOwn(u,h)&&t.registerLanguage(h,u[h])}}function o(u,d){if(typeof u=="string")t.registerAliases(typeof d=="string"?d:[...d],{languageName:u});else{let h;for(h in u)if(Object.hasOwn(u,h)){const p=u[h];t.registerAliases(typeof p=="string"?p:[...p],{languageName:h})}}}function l(u){return!!t.getLanguage(u)}}class jEe{constructor(t){this.options=t,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(t){if(t==="")return;const n=this.stack[this.stack.length-1],r=n.children[n.children.length-1];r&&r.type==="text"?r.value+=t:n.children.push({type:"text",value:t})}startScope(t){this.openNode(String(t))}endScope(){this.closeNode()}__addSublanguage(t,n){const r=this.stack[this.stack.length-1],i=t.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:i}):r.children.push(...i)}openNode(t){const n=this,r=t.split(".").map(function(o,l){return l?o+"_".repeat(l):n.options.classPrefix+o}),i=this.stack[this.stack.length-1],s={type:"element",tagName:"span",properties:{className:r},children:[]};i.children.push(s),this.stack.push(s)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const FEe={};function $Ee(e){const t=e||FEe,n=t.aliases,r=t.detect||!1,i=t.languages||DEe,s=t.plainText,o=t.prefix,l=t.subset;let u="hljs";const d=BEe(i);if(n&&d.registerAlias(n),o){const h=o.indexOf("-");u=h===-1?o:o.slice(0,h)}return function(h,p){hy(h,"element",function(y,v,_){if(y.tagName!=="code"||!_||_.type!=="element"||_.tagName!=="pre")return;const w=HEe(y);if(w===!1||!w&&!r||w&&s&&s.includes(w))return;Array.isArray(y.properties.className)||(y.properties.className=[]),y.properties.className.includes(u)||y.properties.className.unshift(u);const x=o1e(y,{whitespace:"pre"});let E;try{E=w?d.highlight(w,x,{prefix:o}):d.highlightAuto(x,{prefix:o,subset:l})}catch(k){const R=k;if(w&&/Unknown language/.test(R.message)){p.message("Cannot highlight as `"+w+"`, it’s not registered",{ancestors:[_,y],cause:R,place:y.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw R}!w&&E.data&&E.data.language&&y.properties.className.push("language-"+E.data.language),E.children.length>0&&(y.children=E.children)})}}function HEe(e){const t=e.properties.className;let n=-1;if(!Array.isArray(t))return;let r;for(;++n<t.length;){const i=String(t[n]);if(i==="no-highlight"||i==="nohighlight")return!1;!r&&i.slice(0,5)==="lang-"&&(r=i.slice(5)),!r&&i.slice(0,9)==="language-"&&(r=i.slice(9))}return r}function SF(e){const t=yj(e).map(n=>({kind:"image",...n}));for(const n of Ej(e)){const{start:r,end:i}=n;t.some(s=>r<s.end&&i>s.start)||t.push({kind:"file",...n})}return t.sort((n,r)=>n.start-r.start)}const UEe=new RegExp("(?<![A-Za-z0-9@:/])(?:[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?\\.)+[A-Za-z]{2,}(?:\\/[A-Za-z0-9._~:/?#[\\]@!$&'()*+,;=%-]*)?(?=[\\s`\"'<>),.;:!?,。;:!?、]|$)","gi");function WEe(e){return e.replace(/[)\].,;:!?,。;:!?、]+$/u,"")}function qEe(e){const t=[];for(const n of e.matchAll(UEe)){const r=n[0]??"",i=n.index??-1;if(i<0)continue;const s=WEe(r);gE(s)&&t.push({text:s,url:`https://${s}`,start:i,end:i+r.length})}return t}const xF=b.createContext(null);function VEe(){return b.useContext(xF)??{download:()=>{}}}function YEe({sessionId:e,children:t}){const n=b.useCallback(i=>{const s=Pt;if(!s){nt.error("请先连接开发机");return}const o=nt.loading(`下载 ${i} ...`);Y1({relay:s,sessionId:e,path:i}).then(l=>{l.ok?nt.success(`已开始下载 ${i}`,{id:o}):nt.error(l.error,{id:o})})},[e]),r=b.useMemo(()=>({download:n}),[n]);return g.jsx(xF.Provider,{value:r,children:t})}const cx="",mv="dev-anywhere-path:",KEe=/^:[^\s`"'<>),,。;:!?、]+/u,GEe=/^:[A-Za-z0-9._~%+-]+(?:\/[A-Za-z0-9._~%+-]+)+$/;function ux(e,t){if(typeof e=="string"){const n=e.indexOf(cx);return n===-1?e:g.jsxs(g.Fragment,{children:[e.slice(0,n),t,e.slice(n+cx.length)]})}return Array.isArray(e)?e.map(n=>ux(n,t)):b.isValidElement(e)&&e.props.children?b.cloneElement(e,void 0,ux(e.props.children,t)):e}function pD(e,t){return t?b.Children.map(e,n=>ux(n,t)):e}function XEe(e,t){return`${mv}${e}:${encodeURIComponent(t)}`}function ZEe(e){if(!e.startsWith(mv))return null;const t=e.slice(mv.length),n=t.indexOf(":");if(n===-1)return null;const r=t.slice(0,n);return r!=="file"&&r!=="image"?null:{kind:r,path:decodeURIComponent(t.slice(n+1))}}function EF(e){try{return decodeURIComponent(e)}catch{return e}}function QEe(e){return e.replace(/:\d+(?::\d+)?$/,"")}function JEe(e){if(!e||e.startsWith("#")||/^[a-z][a-z0-9+.-]*:/i.test(e))return null;const t=QEe(EF(e));return vj(t)?{kind:"image",path:t}:xj(t,{allowBare:!0})?{kind:"file",path:t}:null}function eCe(e,t,n){return e.startsWith(mv)?e:M4(e)}function mD(e){const t=[...SF(e).map(n=>({type:"path",...n})),...qEe(e).map(n=>({type:"web",...n}))].sort((n,r)=>n.start-r.start||(n.type==="path"?-1:1));return t.length===0?[{type:"text",value:e}]:CF(e,t)}function tCe(e){const t=SF(e).map(n=>({type:"path",...n}));return t.length>0?CF(e,t):null}function nCe(e){var n;if(((n=e.children)==null?void 0:n.length)!==1)return null;const t=e.children[0];return(t==null?void 0:t.type)==="text"&&typeof t.value=="string"?t.value:null}function rCe(e){if(e.type!=="link"||typeof e.url!="string"||!e.url.toLowerCase().startsWith("mailto:"))return null;const t=nCe(e);return t&&EF(e.url.slice(7)).toLowerCase()===t.toLowerCase()?t:null}function iCe(e){var r;const t=((r=e.match(KEe))==null?void 0:r[0])??"";if(!t)return null;const n=t.replace(/[)\].,;:!?,。;:!?、]+$/u,"");return GEe.test(n)?{suffix:n,rest:e.slice(n.length)}:null}function sCe(e,t){if((t==null?void 0:t.type)!=="text"||typeof t.value!="string")return null;const n=rCe(e);if(!n)return null;const r=iCe(t.value);return r?{remote:`${n}${r.suffix}`,rest:r.rest}:null}function CF(e,t){const n=[];let r=0;for(const i of t)i.start<r||(i.start>r&&n.push({type:"text",value:e.slice(r,i.start)}),i.type==="path"?n.push({type:"link",url:XEe(i.kind,i.path),title:null,children:[{type:"text",value:i.path}]}):n.push({type:"link",url:i.url,title:null,children:[{type:"text",value:i.text}]}),r=i.end);return r<e.length&&n.push({type:"text",value:e.slice(r)}),n}function kF(e,t=!1){if(!e.children)return;const n=[];for(let r=0;r<e.children.length;r+=1){const i=e.children[r],s=sCe(i,e.children[r+1]);if(s){n.push({type:"text",value:s.remote}),s.rest&&n.push(...mD(s.rest)),r+=1;continue}if(i.type==="text"&&typeof i.value=="string"){n.push(...mD(i.value));continue}if(i.type==="inlineCode"&&t&&typeof i.value=="string"){const o=tCe(i.value);if(o){n.push(...o);continue}}["link","linkReference","definition","inlineCode","code","html","yaml"].includes(i.type)||kF(i,t||i.type==="tableCell"),n.push(i)}e.children=n}function oCe(){return e=>{kF(e)}}function aCe({href:e,children:t,tone:n}){const r=ZEe(e)??JEe(e),{download:i}=VEe(),{openImagePreview:s}=N3();if(!r){const u=/^https?:\/\//i.test(e);return g.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer","data-slot":u?"inline-web-link":void 0,"data-wrap":u?"anywhere":void 0,title:"移动端点按打开;桌面端按 Cmd/Ctrl 点击打开",className:Ye("inline [overflow-wrap:anywhere]",u&&"break-words",n==="on-primary"&&"text-primary-foreground underline decoration-current/50 underline-offset-2 hover:bg-primary-foreground/10"),onClick:d=>{cCe(d)||d.preventDefault()},children:[u&&g.jsx(_8,{className:"mr-1 inline size-3 align-[-0.125em]","aria-hidden":"true"}),t]})}const o=r.kind==="image",l=o?Lf:NP;return g.jsxs("button",{type:"button","data-slot":o?"inline-image-preview-link":"inline-file-download-link",title:r.path,"aria-label":`${o?"预览":"下载"} ${r.path}`,className:Ye("inline cursor-pointer items-baseline rounded-sm border-0 bg-transparent p-0 font-mono text-[0.95em] underline decoration-dotted underline-offset-2 transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",n==="on-primary"?"text-primary-foreground hover:bg-primary-foreground/10":"text-[var(--color-status-working)] hover:bg-accent/70"),onClick:()=>{o?s(r.path):i(r.path)},children:[g.jsx(l,{className:"mr-1 inline size-3 align-[-0.125em]","aria-hidden":"true"}),t]})}function lCe(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(pointer: coarse), (hover: none)").matches}function cCe(e){return!/^https?:\/\//i.test(e.currentTarget.href)||e.metaKey||e.ctrlKey?!0:lCe()}function uCe({children:e,...t}){return g.jsx("div",{"data-slot":"markdown-code-block","data-overflow":"horizontal",className:"dev-render-scroll not-prose my-3 max-w-full overflow-x-auto rounded-md bg-popover",children:g.jsx("pre",{className:"p-3 text-[0.92em]",children:g.jsx("code",{...t,children:e})})})}function dCe(e){return b.Children.toArray(e).map(t=>typeof t=="string"||typeof t=="number"?String(t):"").join("")}const dx=b.memo(function({text:t,tone:n="default",trailingInline:r,preserveSoftBreaks:i=!1}){const s=r?`${t}${cx}`:t;return g.jsx("div",{"data-slot":"markdown-view","data-tone":n,className:Ye("dev-markdown prose prose-sm max-w-none",n==="on-primary"&&"dev-markdown-on-primary"),style:{fontSize:"inherit"},children:g.jsx($0e,{remarkPlugins:[Jxe,oCe],rehypePlugins:[[$Ee,{detect:!0,ignoreMissing:!0}]],urlTransform:eCe,skipHtml:!0,disallowedElements:["script","iframe","object","embed"],components:{pre:({children:o})=>g.jsx(g.Fragment,{children:o}),p:({children:o,className:l,...u})=>g.jsx("p",{className:Ye(l,i&&"whitespace-pre-wrap"),...u,children:pD(o,r)}),li:({children:o,className:l,...u})=>g.jsx("li",{className:Ye(l,i&&"whitespace-pre-wrap"),...u,children:pD(o,r)}),a:({href:o="",children:l})=>g.jsx(aCe,{href:o,tone:n,children:l}),code:({className:o,children:l,...u})=>{const d=dCe(l);return typeof o=="string"&&o.includes("language-")||d.includes(`
687
- `)?g.jsx(uCe,{...u,children:g.jsx("span",{className:o,children:l})}):g.jsx("code",{"data-slot":"markdown-inline-code","data-wrap":"break-all","data-tone":n,className:Ye("rounded px-1 py-0.5 text-[0.9em] break-all whitespace-normal",n==="on-primary"?"bg-primary-foreground/15 text-primary-foreground":"bg-muted"),...u,children:l})},table:({children:o,...l})=>g.jsx("div",{"data-slot":"markdown-table-wrapper","data-overflow":"horizontal",className:"dev-render-scroll not-prose my-3 w-fit max-w-full overflow-x-auto rounded-md border border-border/60",children:g.jsx("table",{className:"border-collapse text-[0.92em]",...l,children:o})}),thead:({children:o,...l})=>g.jsx("thead",{className:"bg-foreground/5",...l,children:o}),th:({children:o,style:l,...u})=>g.jsx("th",{className:"border border-border/60 px-3 py-1.5 text-left font-semibold whitespace-nowrap",style:l,...u,children:o}),td:({children:o,style:l,...u})=>g.jsx("td",{className:"border border-border/60 px-3 py-1.5 whitespace-nowrap align-top",style:l,...u,children:o})},children:s})})}),hCe=b.memo(function({message:t,contentFontSize:n,turnControl:r,findState:i}){var h,p,y;const s=t.role,o=n?{fontSize:n}:void 0,[l,u]=b.useState(!1),d=s==="user"&&t.isPartial?g.jsx("span",{className:"inline-block w-2 h-4 ml-1 bg-[var(--color-status-working)] dev-cursor-blink align-middle","aria-label":"streaming"}):null;if(s==="system")return g.jsx("article",{"data-slot":"message-bubble","data-role":"system",className:"dev-chat-rail-inset py-2",children:g.jsxs("div",{"data-slot":"message-row","data-align":"center","data-find-match":i?"true":void 0,"data-find-active":i==="active"?"true":void 0,className:"dev-message-rail mx-auto flex w-full items-center",children:[g.jsx("div",{className:"h-px flex-1 bg-border"}),g.jsx("div",{"data-slot":"message-system-marker",className:"mx-3 shrink-0 rounded-full border bg-background px-3 py-1 text-xs text-muted-foreground",children:t.text}),g.jsx("div",{className:"h-px flex-1 bg-border"})]})});if(s==="activity"){const v=((h=t.activity)==null?void 0:h.status)??(t.isPartial?"running":"done"),_=v==="running",w=v==="error"?"border-[var(--color-status-warning)]/40 bg-[var(--color-status-warning)]/10 text-[var(--color-status-warning)]":"border-border bg-muted/60 text-muted-foreground",x=((y=(p=t.activity)==null?void 0:p.details)==null?void 0:y.filter(k=>k.content.length))??[],E=`${t.id}-activity-details`;return g.jsx("article",{"data-slot":"message-bubble","data-role":"activity",className:"dev-chat-rail-inset py-1",children:g.jsx("div",{"data-slot":"message-row","data-align":"start","data-find-match":i?"true":void 0,"data-find-active":i==="active"?"true":void 0,className:"dev-message-rail mx-auto flex w-full justify-start",children:g.jsxs("div",{"data-slot":"activity-bubble","data-status":v,"data-tone":v==="error"?"warning":"neutral",className:`w-fit max-w-[88%] min-w-0 rounded-md border px-3 py-1.5 text-xs ${w}`,"aria-live":_?"polite":void 0,style:o,children:[g.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[_?g.jsxs("span",{"data-slot":"activity-spinner",className:"relative flex size-3 shrink-0 items-center justify-center text-current","aria-hidden":"true",children:[g.jsx("span",{className:"absolute size-2 rounded-full bg-current opacity-40 animate-ping"}),g.jsx("span",{className:"size-1.5 rounded-full bg-current opacity-80"})]}):g.jsx("span",{"data-slot":"activity-dot",className:"size-1.5 shrink-0 rounded-full bg-current opacity-60","aria-hidden":"true"}),g.jsx("span",{"data-slot":"activity-text","data-wrap":"anywhere",className:"min-w-0 whitespace-pre-wrap [overflow-wrap:anywhere]",children:t.text}),x.length>0?g.jsx("button",{type:"button",className:"-mr-1 flex size-6 shrink-0 items-center justify-center rounded text-current/80 hover:bg-current/10 hover:text-current focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":l?"收起工具详情":"展开工具详情","aria-expanded":l,"aria-controls":E,onClick:()=>u(k=>!k),children:g.jsx(pl,{className:`size-3.5 transition-transform ${l?"":"-rotate-90"}`,"aria-hidden":"true"})}):null,r?g.jsx("span",{"data-slot":"activity-turn-control",className:"ml-1 flex shrink-0 items-center border-l border-current/15 pl-1",children:r}):null]}),l&&x.length>0?g.jsx("div",{id:E,"data-slot":"activity-details",className:"mt-2 space-y-2 border-t border-current/15 pt-2",children:x.map((k,R)=>g.jsx(Gj,{detail:k},`${k.title}-${R}`))}):null]})})})}if(s==="user"){const v=t.deliveryStatus==="queued",_=t.isPartial?"min-w-0 max-w-[80%] rounded-md border border-dashed border-primary-foreground/40 bg-primary/60 text-primary-foreground/90 px-4 py-2":v?"min-w-0 max-w-[80%] rounded-md border border-dashed border-primary/50 bg-primary/70 text-primary-foreground/90 px-4 py-2":"min-w-0 max-w-[80%] rounded-md bg-primary text-primary-foreground px-4 py-2";return g.jsx("article",{"data-slot":"message-bubble","data-role":"user","data-partial":t.isPartial?"true":void 0,className:"dev-chat-rail-inset py-2",children:g.jsx("div",{"data-slot":"message-row","data-align":"end","data-find-match":i?"true":void 0,"data-find-active":i==="active"?"true":void 0,className:"dev-message-rail mx-auto flex w-full justify-end",children:g.jsxs("div",{"data-slot":"message-body","data-variant":t.isPartial?"partial":v?"queued":"sent",className:_,style:o,children:[g.jsx(dx,{text:t.text,tone:"on-primary",trailingInline:d,preserveSoftBreaks:!0}),v?g.jsxs("div",{"data-slot":"queued-message-status",className:"mt-1 flex items-center justify-end gap-1 text-[11px] text-primary-foreground/75",children:[g.jsx(l8,{className:"size-3","aria-hidden":"true"}),g.jsx("span",{children:"已排队"})]}):null]})})})}return g.jsx("article",{"data-slot":"message-bubble","data-role":s,className:"dev-chat-rail-inset py-2",children:g.jsx("div",{"data-slot":"message-row","data-align":"start","data-find-match":i?"true":void 0,"data-find-active":i==="active"?"true":void 0,className:"dev-message-rail mx-auto flex w-full justify-start",children:g.jsxs("div",{"data-slot":"message-body",className:"w-fit max-w-[88%] min-w-0 rounded-md bg-card text-foreground px-4 py-2",style:o,children:[g.jsx(dx,{text:t.text,trailingInline:d}),r?g.jsx("div",{"data-slot":"assistant-turn-control",className:"mt-2 flex justify-end",children:r}):null]})})})}),gD=80;function vD(e,t){return e.length>t?e.slice(0,t)+"...":e}function fCe(e,t){const n=e.toLowerCase();if(n==="edit"||n==="edit_file")return{type:"edit",summary:t.file_path||"unknown file",details:{old_string:t.old_string,new_string:t.new_string}};if(n==="bash"||n==="execute"){const i=String(t.command||"");return{type:"bash",summary:vD(i,gD),details:t}}if(n==="write"||n==="write_file")return{type:"write",summary:t.file_path||"unknown file",details:{content:String(t.content||"").slice(0,200)}};const r=JSON.stringify(t);return{type:"generic",summary:vD(r,gD),details:t}}const pCe={Write:wm,Edit:wm,MultiEdit:wm,NotebookEdit:wm,Read:oA,NotebookRead:oA,Bash:cf,BashOutput:cf,Grep:zg,Glob:zg,WebFetch:aA,WebSearch:aA};function mCe(e){return pCe[e]??T7}function gCe({approval:e,sessionId:t,container:n,queuePosition:r,queueSize:i}){const[s,o]=b.useState(!1),[l,u]=b.useState(!1),d=Ne(k=>k.connected&&k.proxyOnline),h=b.useRef(null),p=fCe(e.toolName,e.input),y=KL(e.toolName,e.input).filter(k=>k.content.length),v=e.status!=="pending",_=mCe(e.toolName),w=i&&i>1&&r?`${r}/${i}`:null;function x(k){return n==="floating"?k:g.jsx("div",{"data-slot":"tool-approval-row",className:"dev-message-rail mx-auto w-full min-w-0",children:k})}function E(k,R=!1){if(s||v)return;const A=Pt;if(!A)return;if(!d){nt.warning("连接恢复后再审批");return}if(!(k==="allow"?A.sendControl({type:"tool_approve",sessionId:t,payload:{toolId:e.requestId,whitelistTool:R}}):A.sendControl({type:"tool_deny",sessionId:t,payload:{toolId:e.requestId}}))){nt.warning("连接恢复后再审批");return}o(!0)}if(v){const k=e.status==="approved"?"text-[var(--color-status-success)]":"text-destructive";return x(g.jsxs("div",{"data-slot":"tool-approval-card","data-status":e.status,className:Ye("rounded-md border border-border bg-card px-3 py-2 text-xs",n==="inline"&&"w-full min-w-0 max-w-full",n==="floating"&&"fixed bottom-4 right-4 max-w-[360px] shadow-lg"),children:[g.jsx("span",{className:Ye("font-mono",k),children:e.toolName}),g.jsx("span",{className:"text-muted-foreground ml-2",children:e.status==="approved"?"已允许":"已拒绝"})]}))}return x(g.jsxs("div",{ref:h,tabIndex:-1,"data-slot":"tool-approval-card","data-status":"pending",className:Ye("rounded-md border border-border bg-card p-3 flex flex-col gap-3 ring-2 ring-[var(--color-status-warning)]/40",n==="inline"&&"w-full min-w-0 max-w-full",n==="floating"&&"fixed bottom-4 right-4 w-[360px] max-w-[90vw] shadow-lg z-20"),role:"region","aria-label":`工具审批: ${e.toolName}`,children:[g.jsxs("button",{type:"button",onClick:()=>u(k=>!k),"aria-expanded":l,"aria-label":l?"收起详情":"展开详情",className:"flex min-h-11 min-w-0 items-center gap-2 rounded p-2 text-left -m-2 hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring md:min-h-0 md:p-1 md:-m-1",children:[g.jsx(_,{className:"size-4 shrink-0 text-[var(--color-status-warning)]","aria-hidden":"true"}),g.jsx("span",{className:"shrink-0 font-semibold text-sm",children:e.toolName}),w&&g.jsx("span",{className:"shrink-0 rounded border border-[var(--color-status-warning)]/40 bg-[var(--color-status-warning)]/10 px-1.5 py-0.5 text-[10px] leading-none text-[var(--color-status-warning)]","aria-label":`第 ${r} 个审批,共 ${i} 个`,children:w}),g.jsx("span",{"data-slot":"tool-approval-summary",className:"min-w-0 text-xs text-muted-foreground flex-1 truncate font-mono",children:p.summary}),l?g.jsx(Nx,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):g.jsx(pl,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"})]}),l&&(y.length>0?g.jsx("div",{"data-slot":"tool-approval-preview",className:"min-w-0 space-y-2 border-t border-border pt-2 text-xs",children:y.map((k,R)=>g.jsx(Gj,{detail:k},`${k.title}-${R}`))}):g.jsx("pre",{"data-slot":"tool-approval-json",className:"text-xs bg-muted rounded p-2 overflow-auto font-mono max-h-[50vh] whitespace-pre-wrap break-words",children:JSON.stringify(e.input,null,2)})),g.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g.jsx(_t,{variant:"ghost",size:"sm",className:"h-11 text-muted-foreground md:h-8",disabled:s||!d,onClick:()=>E("allow",!0),"data-action":"always",children:"始终允许"}),g.jsxs("div",{className:"flex gap-2",children:[g.jsx(_t,{variant:"ghost",size:"sm",className:"h-11 text-destructive hover:bg-destructive/10 hover:text-destructive md:h-8",disabled:s||!d,onClick:()=>E("deny"),"data-action":"deny",children:"拒绝"}),g.jsx(_t,{size:"sm",className:"h-11 md:h-8",disabled:s||!d,onClick:()=>E("allow"),"data-action":"allow",children:"允许"})]})]})]}))}function vCe({turnControl:e}){return g.jsx("div",{className:"dev-chat-rail-inset py-2 animate-in fade-in-0 slide-in-from-bottom-1 duration-200 motion-reduce:animate-none","data-slot":"thinking-indicator",role:"status","aria-label":"Agent 正在思考",children:g.jsx("div",{className:"dev-message-rail mx-auto flex w-full justify-start",children:g.jsxs("div",{className:"flex w-fit items-center gap-2 rounded-[8px_24px_24px_24px] bg-foreground/8 px-4 py-2.5",children:[g.jsxs("span",{className:"flex items-center gap-1.5","aria-hidden":"true",children:[g.jsx("span",{className:"dev-thinking-dot"}),g.jsx("span",{className:"dev-thinking-dot"}),g.jsx("span",{className:"dev-thinking-dot"})]}),e?g.jsx("span",{"data-slot":"thinking-turn-control",className:"ml-1 flex items-center border-l border-foreground/10 pl-1",children:e}):null]})})})}function yCe({isWorking:e,canSend:t,canQueue:n=!1,onSend:r,onQueue:i}){const s=t||n;return g.jsx(_t,{type:"submit",size:"icon",className:"size-11 md:size-9",disabled:!s,onClick:o=>{if(o.preventDefault(),t){r();return}n&&(i==null||i())},"aria-label":"发送","data-slot":"send-button","data-variant":"send","data-busy-queue":e&&n?"true":void 0,children:g.jsx(l7,{"aria-hidden":"true"})})}function bCe({isStopping:e,onStop:t,className:n}){return g.jsxs(_t,{type:"button",size:"icon-sm",variant:"ghost",className:Ye("relative overflow-visible rounded-md border border-transparent text-destructive hover:bg-destructive/10 hover:text-destructive disabled:opacity-100",e?"bg-destructive/10 text-destructive":"",n),onClick:t,disabled:e,"aria-busy":e?"true":void 0,"aria-label":"停止响应","data-slot":"stop-button","data-variant":"stop",children:[e?g.jsx("span",{"data-testid":"stop-progress-ring",className:"pointer-events-none absolute -inset-1 rounded-md border border-transparent border-t-destructive border-r-destructive/70 animate-spin","aria-hidden":"true"}):null,g.jsx(f7,{"aria-hidden":"true"})]})}function _Ce(e,t={}){const[n,r]=b.useState(!0),i=b.useRef(!0),s=b.useRef(t.threshold??8);return b.useEffect(()=>{if(!e)return;const l=y=>{i.current=y,r(y)},u=()=>{const y=s.current;l(e.scrollTop+e.clientHeight>=e.scrollHeight-y)},d=()=>{if(!i.current){u();return}e.scrollTop=e.scrollHeight,l(!0)};u(),e.addEventListener("scroll",u,{passive:!0});const h=new ResizeObserver(d);h.observe(e);for(const y of Array.from(e.children))h.observe(y);const p=new MutationObserver(()=>{for(const y of Array.from(e.children))h.observe(y);d()});return p.observe(e,{childList:!0}),()=>{e.removeEventListener("scroll",u),h.disconnect(),p.disconnect()}},[e]),{isAtBottom:n,scrollToBottom:()=>{e&&(e.scrollTop=e.scrollHeight,i.current=!0,r(!0))}}}const wCe=16,SCe=16,xCe=56;function ECe(e,t){if((e==null?void 0:e.role)==="system")return 44;const n=Math.max(12,t.fontSize||16),r=(e==null?void 0:e.text)??"",i=CCe((e==null?void 0:e.role)??"assistant",t.touchEditingSurface),s=Math.max(12,i/n),o=kCe(r,s),l=RCe(r,n),u=((e==null?void 0:e.toolCalls.length)??0)*Math.max(56,n*3.5),d=e!=null&&e.isPartial?n*.5:0,h=n*1.55,p=wCe+SCe+o*h+l+u+d;return Math.max(xCe,Math.round(p))}function CCe(e,t){return t?e==="user"?280:310:e==="user"?720:900}function kCe(e,t){return(e.length>0?e.split(`
686
+ `,1;if(md>1e5&&md>At.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Fn+=rn,rn.length}const li=gt($e);if(!li)throw rt(re.replace("{}",$e)),new Error('Unknown language: "'+$e+'"');const ap=tn(li);let Mc="",qt=bn||ap;const lp={},Tr=new de.__emitter(de);hs();let Fn="",da=0,No=0,md=0,ha=!1;try{if(li.__emitTokens)li.__emitTokens(vt,Tr);else{for(qt.matcher.considerAll();;){md++,ha?ha=!1:qt.matcher.considerAll(),qt.matcher.lastIndex=No;const lt=qt.matcher.exec(vt);if(!lt)break;const At=vt.substring(No,lt.index),rn=Nc(At,lt);No=lt.index+rn}Nc(vt.substring(No))}return Tr.finalize(),Mc=Tr.toHTML(),{language:$e,value:Mc,relevance:da,illegal:!1,_emitter:Tr,_top:qt}}catch(lt){if(lt.message&&lt.message.includes("Illegal"))return{language:$e,value:Kt(vt),illegal:!0,relevance:0,_illegalBy:{message:lt.message,index:No,context:vt.slice(No-100,No+100),mode:lt.mode,resultSoFar:Mc},_emitter:Tr};if(jt)return{language:$e,value:Kt(vt),illegal:!1,relevance:0,errorRaised:lt,_emitter:Tr,_top:qt};throw lt}}function Te($e){const vt={value:Kt($e),illegal:!1,relevance:0,_top:ie,_emitter:new de.__emitter(de)};return vt._emitter.addText($e),vt}function je($e,vt){vt=vt||de.languages||Object.keys(_e);const Vt=Te($e),bn=vt.filter(gt).filter(Tt).map(Gt=>ae(Gt,$e,!1));bn.unshift(Vt);const Bn=bn.sort((Gt,nn)=>{if(Gt.relevance!==nn.relevance)return nn.relevance-Gt.relevance;if(Gt.language&&nn.language){if(gt(Gt.language).supersetOf===nn.language)return 1;if(gt(nn.language).supersetOf===Gt.language)return-1}return 0}),[zt,Tn]=Bn,vr=zt;return vr.secondBest=Tn,vr}function st($e,vt,Vt){const bn=vt&&Be[vt]||Vt;$e.classList.add("hljs"),$e.classList.add(`language-${bn}`)}function ue($e){let vt=null;const Vt=Z($e);if(pe(Vt))return;if(rr("before:highlightElement",{el:$e,language:Vt}),$e.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",$e);return}if($e.children.length>0&&(de.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn($e)),de.throwUnescapedHTML))throw new Xn("One of your code blocks includes unescaped HTML.",$e.innerHTML);vt=$e;const bn=vt.textContent,Bn=Vt?ne(bn,{language:Vt,ignoreIllegals:!0}):je(bn);$e.innerHTML=Bn.value,$e.dataset.highlighted="yes",st($e,Vt,Bn.language),$e.result={language:Bn.language,re:Bn.relevance,relevance:Bn.relevance},Bn.secondBest&&($e.secondBest={language:Bn.secondBest.language,relevance:Bn.secondBest.relevance}),rr("after:highlightElement",{el:$e,result:Bn,text:bn})}function xe($e){de=Zn(de,$e)}const ke=()=>{fe(),le("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function De(){fe(),le("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let se=!1;function fe(){function $e(){fe()}if(document.readyState==="loading"){se||window.addEventListener("DOMContentLoaded",$e,!1),se=!0;return}document.querySelectorAll(de.cssSelector).forEach(ue)}function Oe($e,vt){let Vt=null;try{Vt=vt(J)}catch(bn){if(rt("Language definition for '{}' could not be registered.".replace("{}",$e)),jt)rt(bn);else throw bn;Vt=ie}Vt.name||(Vt.name=$e),_e[$e]=Vt,Vt.rawDefinition=vt.bind(null,J),Vt.aliases&&kt(Vt.aliases,{languageName:$e})}function Ue($e){delete _e[$e];for(const vt of Object.keys(Be))Be[vt]===$e&&delete Be[vt]}function ft(){return Object.keys(_e)}function gt($e){return $e=($e||"").toLowerCase(),_e[$e]||_e[Be[$e]]}function kt($e,{languageName:vt}){typeof $e=="string"&&($e=[$e]),$e.forEach(Vt=>{Be[Vt.toLowerCase()]=vt})}function Tt($e){const vt=gt($e);return vt&&!vt.disableAutodetect}function Ht($e){$e["before:highlightBlock"]&&!$e["before:highlightElement"]&&($e["before:highlightElement"]=vt=>{$e["before:highlightBlock"](Object.assign({block:vt.el},vt))}),$e["after:highlightBlock"]&&!$e["after:highlightElement"]&&($e["after:highlightElement"]=vt=>{$e["after:highlightBlock"](Object.assign({block:vt.el},vt))})}function yn($e){Ht($e),ht.push($e)}function oi($e){const vt=ht.indexOf($e);vt!==-1&&ht.splice(vt,1)}function rr($e,vt){const Vt=$e;ht.forEach(function(bn){bn[Vt]&&bn[Vt](vt)})}function fn($e){return le("10.7.0","highlightBlock will be removed entirely in v12.0"),le("10.7.0","Please use highlightElement now."),ue($e)}Object.assign(J,{highlight:ne,highlightAuto:je,highlightAll:fe,highlightElement:ue,highlightBlock:fn,configure:xe,initHighlighting:ke,initHighlightingOnLoad:De,registerLanguage:Oe,unregisterLanguage:Ue,listLanguages:ft,getLanguage:gt,registerAliases:kt,autoDetection:Tt,inherit:Zn,addPlugin:yn,removePlugin:oi}),J.debugMode=function(){jt=!1},J.safeMode=function(){jt=!0},J.versionString=Zt,J.regex={concat:w,lookahead:y,either:E,optional:_,anyNumberOfTimes:v};for(const $e in Ce)typeof Ce[$e]=="object"&&e(Ce[$e]);return Object.assign(J,Ce),J},Bt=Et({});return Bt.newInstance=()=>Et({}),o0=Bt,Bt.HighlightJS=Bt,Bt.default=Bt,o0}var LEe=PEe();const IEe=Af(LEe),fD={},zEe="hljs-";function BEe(e){const t=IEe.newInstance();return e&&s(e),{highlight:n,highlightAuto:r,listLanguages:i,register:s,registerAlias:o,registered:l};function n(u,d,h){const p=h||fD,y=typeof p.prefix=="string"?p.prefix:zEe;if(!t.getLanguage(u))throw new Error("Unknown language: `"+u+"` is not registered");t.configure({__emitter:jEe,classPrefix:y});const v=t.highlight(d,{ignoreIllegals:!0,language:u});if(v.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:v.errorRaised});const _=v._emitter.root,w=_.data;return w.language=v.language,w.relevance=v.relevance,_}function r(u,d){const p=(d||fD).subset||i();let y=-1,v=0,_;for(;++y<p.length;){const w=p[y];if(!t.getLanguage(w))continue;const x=n(w,u,d);x.data&&x.data.relevance!==void 0&&x.data.relevance>v&&(v=x.data.relevance,_=x)}return _||{type:"root",children:[],data:{language:void 0,relevance:v}}}function i(){return t.listLanguages()}function s(u,d){if(typeof u=="string")t.registerLanguage(u,d);else{let h;for(h in u)Object.hasOwn(u,h)&&t.registerLanguage(h,u[h])}}function o(u,d){if(typeof u=="string")t.registerAliases(typeof d=="string"?d:[...d],{languageName:u});else{let h;for(h in u)if(Object.hasOwn(u,h)){const p=u[h];t.registerAliases(typeof p=="string"?p:[...p],{languageName:h})}}}function l(u){return!!t.getLanguage(u)}}class jEe{constructor(t){this.options=t,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(t){if(t==="")return;const n=this.stack[this.stack.length-1],r=n.children[n.children.length-1];r&&r.type==="text"?r.value+=t:n.children.push({type:"text",value:t})}startScope(t){this.openNode(String(t))}endScope(){this.closeNode()}__addSublanguage(t,n){const r=this.stack[this.stack.length-1],i=t.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:i}):r.children.push(...i)}openNode(t){const n=this,r=t.split(".").map(function(o,l){return l?o+"_".repeat(l):n.options.classPrefix+o}),i=this.stack[this.stack.length-1],s={type:"element",tagName:"span",properties:{className:r},children:[]};i.children.push(s),this.stack.push(s)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const FEe={};function $Ee(e){const t=e||FEe,n=t.aliases,r=t.detect||!1,i=t.languages||DEe,s=t.plainText,o=t.prefix,l=t.subset;let u="hljs";const d=BEe(i);if(n&&d.registerAlias(n),o){const h=o.indexOf("-");u=h===-1?o:o.slice(0,h)}return function(h,p){hy(h,"element",function(y,v,_){if(y.tagName!=="code"||!_||_.type!=="element"||_.tagName!=="pre")return;const w=HEe(y);if(w===!1||!w&&!r||w&&s&&s.includes(w))return;Array.isArray(y.properties.className)||(y.properties.className=[]),y.properties.className.includes(u)||y.properties.className.unshift(u);const x=o1e(y,{whitespace:"pre"});let E;try{E=w?d.highlight(w,x,{prefix:o}):d.highlightAuto(x,{prefix:o,subset:l})}catch(k){const R=k;if(w&&/Unknown language/.test(R.message)){p.message("Cannot highlight as `"+w+"`, it’s not registered",{ancestors:[_,y],cause:R,place:y.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw R}!w&&E.data&&E.data.language&&y.properties.className.push("language-"+E.data.language),E.children.length>0&&(y.children=E.children)})}}function HEe(e){const t=e.properties.className;let n=-1;if(!Array.isArray(t))return;let r;for(;++n<t.length;){const i=String(t[n]);if(i==="no-highlight"||i==="nohighlight")return!1;!r&&i.slice(0,5)==="lang-"&&(r=i.slice(5)),!r&&i.slice(0,9)==="language-"&&(r=i.slice(9))}return r}function SF(e){const t=y4(e).map(n=>({kind:"image",...n}));for(const n of E4(e)){const{start:r,end:i}=n;t.some(s=>r<s.end&&i>s.start)||t.push({kind:"file",...n})}return t.sort((n,r)=>n.start-r.start)}const UEe=new RegExp("(?<![A-Za-z0-9@:/])(?:[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?\\.)+[A-Za-z]{2,}(?:\\/[A-Za-z0-9._~:/?#[\\]@!$&'()*+,;=%-]*)?(?=[\\s`\"'<>),.;:!?,。;:!?、]|$)","gi");function WEe(e){return e.replace(/[)\].,;:!?,。;:!?、]+$/u,"")}function qEe(e){const t=[];for(const n of e.matchAll(UEe)){const r=n[0]??"",i=n.index??-1;if(i<0)continue;const s=WEe(r);gE(s)&&t.push({text:s,url:`https://${s}`,start:i,end:i+r.length})}return t}const xF=b.createContext(null);function VEe(){return b.useContext(xF)??{download:()=>{}}}function YEe({sessionId:e,children:t}){const n=b.useCallback(i=>{const s=Pt;if(!s){nt.error("请先连接开发机");return}const o=nt.loading(`下载 ${i} ...`);Y1({relay:s,sessionId:e,path:i}).then(l=>{l.ok?nt.success(`已开始下载 ${i}`,{id:o}):nt.error(l.error,{id:o})})},[e]),r=b.useMemo(()=>({download:n}),[n]);return g.jsx(xF.Provider,{value:r,children:t})}const cx="",mv="dev-anywhere-path:",KEe=/^:[^\s`"'<>),,。;:!?、]+/u,GEe=/^:[A-Za-z0-9._~%+-]+(?:\/[A-Za-z0-9._~%+-]+)+$/;function ux(e,t){if(typeof e=="string"){const n=e.indexOf(cx);return n===-1?e:g.jsxs(g.Fragment,{children:[e.slice(0,n),t,e.slice(n+cx.length)]})}return Array.isArray(e)?e.map(n=>ux(n,t)):b.isValidElement(e)&&e.props.children?b.cloneElement(e,void 0,ux(e.props.children,t)):e}function pD(e,t){return t?b.Children.map(e,n=>ux(n,t)):e}function XEe(e,t){return`${mv}${e}:${encodeURIComponent(t)}`}function ZEe(e){if(!e.startsWith(mv))return null;const t=e.slice(mv.length),n=t.indexOf(":");if(n===-1)return null;const r=t.slice(0,n);return r!=="file"&&r!=="image"?null:{kind:r,path:decodeURIComponent(t.slice(n+1))}}function EF(e){try{return decodeURIComponent(e)}catch{return e}}function QEe(e){return e.replace(/:\d+(?::\d+)?$/,"")}function JEe(e){if(!e||e.startsWith("#")||/^[a-z][a-z0-9+.-]*:/i.test(e))return null;const t=QEe(EF(e));return v4(t)?{kind:"image",path:t}:x4(t,{allowBare:!0})?{kind:"file",path:t}:null}function eCe(e,t,n){return e.startsWith(mv)?e:Mj(e)}function mD(e){const t=[...SF(e).map(n=>({type:"path",...n})),...qEe(e).map(n=>({type:"web",...n}))].sort((n,r)=>n.start-r.start||(n.type==="path"?-1:1));return t.length===0?[{type:"text",value:e}]:CF(e,t)}function tCe(e){const t=SF(e).map(n=>({type:"path",...n}));return t.length>0?CF(e,t):null}function nCe(e){var n;if(((n=e.children)==null?void 0:n.length)!==1)return null;const t=e.children[0];return(t==null?void 0:t.type)==="text"&&typeof t.value=="string"?t.value:null}function rCe(e){if(e.type!=="link"||typeof e.url!="string"||!e.url.toLowerCase().startsWith("mailto:"))return null;const t=nCe(e);return t&&EF(e.url.slice(7)).toLowerCase()===t.toLowerCase()?t:null}function iCe(e){var r;const t=((r=e.match(KEe))==null?void 0:r[0])??"";if(!t)return null;const n=t.replace(/[)\].,;:!?,。;:!?、]+$/u,"");return GEe.test(n)?{suffix:n,rest:e.slice(n.length)}:null}function sCe(e,t){if((t==null?void 0:t.type)!=="text"||typeof t.value!="string")return null;const n=rCe(e);if(!n)return null;const r=iCe(t.value);return r?{remote:`${n}${r.suffix}`,rest:r.rest}:null}function CF(e,t){const n=[];let r=0;for(const i of t)i.start<r||(i.start>r&&n.push({type:"text",value:e.slice(r,i.start)}),i.type==="path"?n.push({type:"link",url:XEe(i.kind,i.path),title:null,children:[{type:"text",value:i.path}]}):n.push({type:"link",url:i.url,title:null,children:[{type:"text",value:i.text}]}),r=i.end);return r<e.length&&n.push({type:"text",value:e.slice(r)}),n}function kF(e,t=!1){if(!e.children)return;const n=[];for(let r=0;r<e.children.length;r+=1){const i=e.children[r],s=sCe(i,e.children[r+1]);if(s){n.push({type:"text",value:s.remote}),s.rest&&n.push(...mD(s.rest)),r+=1;continue}if(i.type==="text"&&typeof i.value=="string"){n.push(...mD(i.value));continue}if(i.type==="inlineCode"&&t&&typeof i.value=="string"){const o=tCe(i.value);if(o){n.push(...o);continue}}["link","linkReference","definition","inlineCode","code","html","yaml"].includes(i.type)||kF(i,t||i.type==="tableCell"),n.push(i)}e.children=n}function oCe(){return e=>{kF(e)}}function aCe({href:e,children:t,tone:n}){const r=ZEe(e)??JEe(e),{download:i}=VEe(),{openImagePreview:s}=N3();if(!r){const u=/^https?:\/\//i.test(e);return g.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer","data-slot":u?"inline-web-link":void 0,"data-wrap":u?"anywhere":void 0,title:"移动端点按打开;桌面端按 Cmd/Ctrl 点击打开",className:Ye("inline [overflow-wrap:anywhere]",u&&"break-words",n==="on-primary"&&"text-primary-foreground underline decoration-current/50 underline-offset-2 hover:bg-primary-foreground/10"),onClick:d=>{cCe(d)||d.preventDefault()},children:[u&&g.jsx(_8,{className:"mr-1 inline size-3 align-[-0.125em]","aria-hidden":"true"}),t]})}const o=r.kind==="image",l=o?Lf:NP;return g.jsxs("button",{type:"button","data-slot":o?"inline-image-preview-link":"inline-file-download-link",title:r.path,"aria-label":`${o?"预览":"下载"} ${r.path}`,className:Ye("inline cursor-pointer items-baseline rounded-sm border-0 bg-transparent p-0 font-mono text-[0.95em] underline decoration-dotted underline-offset-2 transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",n==="on-primary"?"text-primary-foreground hover:bg-primary-foreground/10":"text-[var(--color-status-working)] hover:bg-accent/70"),onClick:()=>{o?s(r.path):i(r.path)},children:[g.jsx(l,{className:"mr-1 inline size-3 align-[-0.125em]","aria-hidden":"true"}),t]})}function lCe(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(pointer: coarse), (hover: none)").matches}function cCe(e){return!/^https?:\/\//i.test(e.currentTarget.href)||e.metaKey||e.ctrlKey?!0:lCe()}function uCe({children:e,...t}){return g.jsx("div",{"data-slot":"markdown-code-block","data-overflow":"horizontal",className:"dev-render-scroll not-prose my-3 max-w-full overflow-x-auto rounded-md bg-popover",children:g.jsx("pre",{className:"p-3 text-[0.92em]",children:g.jsx("code",{...t,children:e})})})}function dCe(e){return b.Children.toArray(e).map(t=>typeof t=="string"||typeof t=="number"?String(t):"").join("")}const dx=b.memo(function({text:t,tone:n="default",trailingInline:r,preserveSoftBreaks:i=!1}){const s=r?`${t}${cx}`:t;return g.jsx("div",{"data-slot":"markdown-view","data-tone":n,className:Ye("dev-markdown prose prose-sm max-w-none",n==="on-primary"&&"dev-markdown-on-primary"),style:{fontSize:"inherit"},children:g.jsx($0e,{remarkPlugins:[Jxe,oCe],rehypePlugins:[[$Ee,{detect:!0,ignoreMissing:!0}]],urlTransform:eCe,skipHtml:!0,disallowedElements:["script","iframe","object","embed"],components:{pre:({children:o})=>g.jsx(g.Fragment,{children:o}),p:({children:o,className:l,...u})=>g.jsx("p",{className:Ye(l,i&&"whitespace-pre-wrap"),...u,children:pD(o,r)}),li:({children:o,className:l,...u})=>g.jsx("li",{className:Ye(l,i&&"whitespace-pre-wrap"),...u,children:pD(o,r)}),a:({href:o="",children:l})=>g.jsx(aCe,{href:o,tone:n,children:l}),code:({className:o,children:l,...u})=>{const d=dCe(l);return typeof o=="string"&&o.includes("language-")||d.includes(`
687
+ `)?g.jsx(uCe,{...u,children:g.jsx("span",{className:o,children:l})}):g.jsx("code",{"data-slot":"markdown-inline-code","data-wrap":"break-all","data-tone":n,className:Ye("rounded px-1 py-0.5 text-[0.9em] break-all whitespace-normal",n==="on-primary"?"bg-primary-foreground/15 text-primary-foreground":"bg-muted"),...u,children:l})},table:({children:o,...l})=>g.jsx("div",{"data-slot":"markdown-table-wrapper","data-overflow":"horizontal",className:"dev-render-scroll not-prose my-3 w-fit max-w-full overflow-x-auto rounded-md border border-border/60",children:g.jsx("table",{className:"border-collapse text-[0.92em]",...l,children:o})}),thead:({children:o,...l})=>g.jsx("thead",{className:"bg-foreground/5",...l,children:o}),th:({children:o,style:l,...u})=>g.jsx("th",{className:"border border-border/60 px-3 py-1.5 text-left font-semibold whitespace-nowrap",style:l,...u,children:o}),td:({children:o,style:l,...u})=>g.jsx("td",{className:"border border-border/60 px-3 py-1.5 whitespace-nowrap align-top",style:l,...u,children:o})},children:s})})}),hCe=b.memo(function({message:t,contentFontSize:n,turnControl:r,findState:i}){var h,p,y;const s=t.role,o=n?{fontSize:n}:void 0,[l,u]=b.useState(!1),d=s==="user"&&t.isPartial?g.jsx("span",{className:"inline-block w-2 h-4 ml-1 bg-[var(--color-status-working)] dev-cursor-blink align-middle","aria-label":"streaming"}):null;if(s==="system")return g.jsx("article",{"data-slot":"message-bubble","data-role":"system",className:"dev-chat-rail-inset py-2",children:g.jsxs("div",{"data-slot":"message-row","data-align":"center","data-find-match":i?"true":void 0,"data-find-active":i==="active"?"true":void 0,className:"dev-message-rail mx-auto flex w-full min-w-0 max-w-full items-center",children:[g.jsx("div",{className:"h-px flex-1 bg-border"}),g.jsx("div",{"data-slot":"message-system-marker",className:"mx-3 min-w-0 max-w-[calc(100%_-_3rem)] whitespace-pre-wrap rounded-full border bg-background px-3 py-1 text-xs text-muted-foreground [overflow-wrap:anywhere]",children:t.text}),g.jsx("div",{className:"h-px flex-1 bg-border"})]})});if(s==="activity"){const v=((h=t.activity)==null?void 0:h.status)??(t.isPartial?"running":"done"),_=v==="running",w=v==="error"?"border-[var(--color-status-warning)]/40 bg-[var(--color-status-warning)]/10 text-[var(--color-status-warning)]":"border-border bg-muted/60 text-muted-foreground",x=((y=(p=t.activity)==null?void 0:p.details)==null?void 0:y.filter(k=>k.content.length))??[],E=`${t.id}-activity-details`;return g.jsx("article",{"data-slot":"message-bubble","data-role":"activity",className:"dev-chat-rail-inset py-1",children:g.jsx("div",{"data-slot":"message-row","data-align":"start","data-find-match":i?"true":void 0,"data-find-active":i==="active"?"true":void 0,className:"dev-message-rail mx-auto flex w-full min-w-0 max-w-full justify-start",children:g.jsxs("div",{"data-slot":"activity-bubble","data-status":v,"data-tone":v==="error"?"warning":"neutral",className:`w-fit max-w-[88%] min-w-0 rounded-md border px-3 py-1.5 text-xs ${w}`,"aria-live":_?"polite":void 0,style:o,children:[g.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[g.jsxs("span",{"data-slot":"activity-status-indicator","data-state":_?"running":"settled",className:"relative flex size-3 shrink-0 items-center justify-center text-current","aria-hidden":"true",children:[_?g.jsx("span",{className:"absolute size-2 rounded-full bg-current opacity-40 animate-ping"}):null,g.jsx("span",{"data-slot":"activity-dot",className:`size-1.5 rounded-full bg-current ${_?"opacity-80":"opacity-60"}`})]}),g.jsx("span",{"data-slot":"activity-text","data-wrap":"anywhere",className:"min-w-0 whitespace-pre-wrap [overflow-wrap:anywhere]",children:t.text}),x.length>0?g.jsx("button",{type:"button",className:"-mr-1 flex size-6 shrink-0 items-center justify-center rounded text-current/80 hover:bg-current/10 hover:text-current focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":l?"收起工具详情":"展开工具详情","aria-expanded":l,"aria-controls":E,onClick:()=>u(k=>!k),children:g.jsx(pl,{className:`size-3.5 transition-transform ${l?"":"-rotate-90"}`,"aria-hidden":"true"})}):null,r?g.jsx("span",{"data-slot":"activity-turn-control",className:"ml-1 flex shrink-0 items-center border-l border-current/15 pl-1",children:r}):null]}),l&&x.length>0?g.jsx("div",{id:E,"data-slot":"activity-details",className:"mt-2 space-y-2 border-t border-current/15 pt-2",children:x.map((k,R)=>g.jsx(G4,{detail:k},`${k.title}-${R}`))}):null]})})})}if(s==="user"){const v=t.deliveryStatus==="queued",_=t.isPartial?"min-w-0 max-w-[80%] rounded-md border border-dashed border-primary-foreground/40 bg-primary/60 text-primary-foreground/90 px-4 py-2":v?"min-w-0 max-w-[80%] rounded-md border border-dashed border-primary/50 bg-primary/70 text-primary-foreground/90 px-4 py-2":"min-w-0 max-w-[80%] rounded-md bg-primary text-primary-foreground px-4 py-2";return g.jsx("article",{"data-slot":"message-bubble","data-role":"user","data-partial":t.isPartial?"true":void 0,className:"dev-chat-rail-inset py-2",children:g.jsx("div",{"data-slot":"message-row","data-align":"end","data-find-match":i?"true":void 0,"data-find-active":i==="active"?"true":void 0,className:"dev-message-rail mx-auto flex w-full min-w-0 max-w-full justify-end",children:g.jsxs("div",{"data-slot":"message-body","data-variant":t.isPartial?"partial":v?"queued":"sent",className:`${_} w-fit [overflow-wrap:anywhere]`,style:o,children:[g.jsx(dx,{text:t.text,tone:"on-primary",trailingInline:d,preserveSoftBreaks:!0}),v?g.jsxs("div",{"data-slot":"queued-message-status",className:"mt-1 flex items-center justify-end gap-1 text-[11px] text-primary-foreground/75",children:[g.jsx(l8,{className:"size-3","aria-hidden":"true"}),g.jsx("span",{children:"已排队"})]}):null]})})})}return g.jsx("article",{"data-slot":"message-bubble","data-role":s,className:"dev-chat-rail-inset py-2",children:g.jsx("div",{"data-slot":"message-row","data-align":"start","data-find-match":i?"true":void 0,"data-find-active":i==="active"?"true":void 0,className:"dev-message-rail mx-auto flex w-full min-w-0 max-w-full justify-start",children:g.jsxs("div",{"data-slot":"message-body",className:"w-fit max-w-[88%] min-w-0 rounded-md bg-card text-foreground px-4 py-2 [overflow-wrap:anywhere]",style:o,children:[g.jsx(dx,{text:t.text,trailingInline:d}),r?g.jsx("div",{"data-slot":"assistant-turn-control",className:"mt-2 flex justify-end",children:r}):null]})})})}),gD=80;function vD(e,t){return e.length>t?e.slice(0,t)+"...":e}function fCe(e,t){const n=e.toLowerCase();if(n==="edit"||n==="edit_file")return{type:"edit",summary:t.file_path||"unknown file",details:{old_string:t.old_string,new_string:t.new_string}};if(n==="bash"||n==="execute"){const i=String(t.command||"");return{type:"bash",summary:vD(i,gD),details:t}}if(n==="write"||n==="write_file")return{type:"write",summary:t.file_path||"unknown file",details:{content:String(t.content||"").slice(0,200)}};const r=JSON.stringify(t);return{type:"generic",summary:vD(r,gD),details:t}}const pCe={Write:wm,Edit:wm,MultiEdit:wm,NotebookEdit:wm,Read:oA,NotebookRead:oA,Bash:cf,BashOutput:cf,Grep:zg,Glob:zg,WebFetch:aA,WebSearch:aA};function mCe(e){return pCe[e]??T7}function gCe({approval:e,sessionId:t,container:n,queuePosition:r,queueSize:i}){const[s,o]=b.useState(!1),[l,u]=b.useState(!1),d=Ne(k=>k.connected&&k.proxyOnline),h=b.useRef(null),p=fCe(e.toolName,e.input),y=KL(e.toolName,e.input).filter(k=>k.content.length),v=e.status!=="pending",_=mCe(e.toolName),w=i&&i>1&&r?`${r}/${i}`:null;function x(k){return n==="floating"?k:g.jsx("div",{"data-slot":"tool-approval-row",className:"dev-message-rail mx-auto w-full min-w-0",children:k})}function E(k,R=!1){if(s||v)return;const A=Pt;if(!A)return;if(!d){nt.warning("连接恢复后再审批");return}if(!(k==="allow"?A.sendControl({type:"tool_approve",sessionId:t,payload:{toolId:e.requestId,whitelistTool:R}}):A.sendControl({type:"tool_deny",sessionId:t,payload:{toolId:e.requestId}}))){nt.warning("连接恢复后再审批");return}o(!0)}if(v){const k=e.status==="approved"?"text-[var(--color-status-success)]":"text-destructive";return x(g.jsxs("div",{"data-slot":"tool-approval-card","data-status":e.status,className:Ye("rounded-md border border-border bg-card px-3 py-2 text-xs",n==="inline"&&"w-full min-w-0 max-w-full",n==="floating"&&"fixed bottom-4 right-4 max-w-[360px] shadow-lg"),children:[g.jsx("span",{className:Ye("font-mono",k),children:e.toolName}),g.jsx("span",{className:"text-muted-foreground ml-2",children:e.status==="approved"?"已允许":"已拒绝"})]}))}return x(g.jsxs("div",{ref:h,tabIndex:-1,"data-slot":"tool-approval-card","data-status":"pending",className:Ye("rounded-md border border-border bg-card p-3 flex flex-col gap-3 ring-2 ring-[var(--color-status-warning)]/40",n==="inline"&&"w-full min-w-0 max-w-full",n==="floating"&&"fixed bottom-4 right-4 w-[360px] max-w-[90vw] shadow-lg z-20"),role:"region","aria-label":`工具审批: ${e.toolName}`,children:[g.jsxs("button",{type:"button",onClick:()=>u(k=>!k),"aria-expanded":l,"aria-label":l?"收起详情":"展开详情",className:"flex min-h-11 min-w-0 items-center gap-2 rounded p-2 text-left -m-2 hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring md:min-h-0 md:p-1 md:-m-1",children:[g.jsx(_,{className:"size-4 shrink-0 text-[var(--color-status-warning)]","aria-hidden":"true"}),g.jsx("span",{className:"shrink-0 font-semibold text-sm",children:e.toolName}),w&&g.jsx("span",{className:"shrink-0 rounded border border-[var(--color-status-warning)]/40 bg-[var(--color-status-warning)]/10 px-1.5 py-0.5 text-[10px] leading-none text-[var(--color-status-warning)]","aria-label":`第 ${r} 个审批,共 ${i} 个`,children:w}),g.jsx("span",{"data-slot":"tool-approval-summary",className:"min-w-0 text-xs text-muted-foreground flex-1 truncate font-mono",children:p.summary}),l?g.jsx(Nx,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):g.jsx(pl,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"})]}),l&&(y.length>0?g.jsx("div",{"data-slot":"tool-approval-preview",className:"min-w-0 space-y-2 border-t border-border pt-2 text-xs",children:y.map((k,R)=>g.jsx(G4,{detail:k},`${k.title}-${R}`))}):g.jsx("pre",{"data-slot":"tool-approval-json",className:"text-xs bg-muted rounded p-2 overflow-auto font-mono max-h-[50vh] whitespace-pre-wrap break-words",children:JSON.stringify(e.input,null,2)})),g.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g.jsx(_t,{variant:"ghost",size:"sm",className:"h-11 text-muted-foreground md:h-8",disabled:s||!d,onClick:()=>E("allow",!0),"data-action":"always",children:"始终允许"}),g.jsxs("div",{className:"flex gap-2",children:[g.jsx(_t,{variant:"ghost",size:"sm",className:"h-11 text-destructive hover:bg-destructive/10 hover:text-destructive md:h-8",disabled:s||!d,onClick:()=>E("deny"),"data-action":"deny",children:"拒绝"}),g.jsx(_t,{size:"sm",className:"h-11 md:h-8",disabled:s||!d,onClick:()=>E("allow"),"data-action":"allow",children:"允许"})]})]})]}))}function vCe({turnControl:e}){return g.jsx("div",{className:"dev-chat-rail-inset py-2 animate-in fade-in-0 slide-in-from-bottom-1 duration-200 motion-reduce:animate-none","data-slot":"thinking-indicator",role:"status","aria-label":"Agent 正在思考",children:g.jsx("div",{className:"dev-message-rail mx-auto flex w-full justify-start",children:g.jsxs("div",{className:"flex w-fit items-center gap-2 rounded-[8px_24px_24px_24px] bg-foreground/8 px-4 py-2.5",children:[g.jsxs("span",{className:"flex items-center gap-1.5","aria-hidden":"true",children:[g.jsx("span",{className:"dev-thinking-dot"}),g.jsx("span",{className:"dev-thinking-dot"}),g.jsx("span",{className:"dev-thinking-dot"})]}),e?g.jsx("span",{"data-slot":"thinking-turn-control",className:"ml-1 flex items-center border-l border-foreground/10 pl-1",children:e}):null]})})})}function yCe({isWorking:e,canSend:t,canQueue:n=!1,onSend:r,onQueue:i}){const s=t||n;return g.jsx(_t,{type:"submit",size:"icon",className:"size-11 md:size-9",disabled:!s,onClick:o=>{if(o.preventDefault(),t){r();return}n&&(i==null||i())},"aria-label":"发送","data-slot":"send-button","data-variant":"send","data-busy-queue":e&&n?"true":void 0,children:g.jsx(l7,{"aria-hidden":"true"})})}function bCe({isStopping:e,onStop:t,className:n}){return g.jsxs(_t,{type:"button",size:"icon-sm",variant:"ghost",className:Ye("relative overflow-visible rounded-md border border-transparent text-destructive hover:bg-destructive/10 hover:text-destructive disabled:opacity-100",e?"bg-destructive/10 text-destructive":"",n),onClick:t,disabled:e,"aria-busy":e?"true":void 0,"aria-label":"停止响应","data-slot":"stop-button","data-variant":"stop",children:[e?g.jsx("span",{"data-testid":"stop-progress-ring",className:"pointer-events-none absolute -inset-1 rounded-md border border-transparent border-t-destructive border-r-destructive/70 animate-spin","aria-hidden":"true"}):null,g.jsx(f7,{"aria-hidden":"true"})]})}function _Ce(e,t={}){const[n,r]=b.useState(!0),i=b.useRef(!0),s=b.useRef(t.threshold??8);return b.useEffect(()=>{if(!e)return;const l=y=>{i.current=y,r(y)},u=()=>{const y=s.current;l(e.scrollTop+e.clientHeight>=e.scrollHeight-y)},d=()=>{if(!i.current){u();return}e.scrollTop=e.scrollHeight,l(!0)};u(),e.addEventListener("scroll",u,{passive:!0});const h=new ResizeObserver(d);h.observe(e);for(const y of Array.from(e.children))h.observe(y);const p=new MutationObserver(()=>{for(const y of Array.from(e.children))h.observe(y);d()});return p.observe(e,{childList:!0}),()=>{e.removeEventListener("scroll",u),h.disconnect(),p.disconnect()}},[e]),{isAtBottom:n,scrollToBottom:()=>{e&&(e.scrollTop=e.scrollHeight,i.current=!0,r(!0))}}}const wCe=16,SCe=16,xCe=56;function ECe(e,t){if((e==null?void 0:e.role)==="system")return 44;const n=Math.max(12,t.fontSize||16),r=(e==null?void 0:e.text)??"",i=CCe((e==null?void 0:e.role)??"assistant",t.touchEditingSurface),s=Math.max(12,i/n),o=kCe(r,s),l=RCe(r,n),u=((e==null?void 0:e.toolCalls.length)??0)*Math.max(56,n*3.5),d=e!=null&&e.isPartial?n*.5:0,h=n*1.55,p=wCe+SCe+o*h+l+u+d;return Math.max(xCe,Math.round(p))}function CCe(e,t){return t?e==="user"?280:310:e==="user"?720:900}function kCe(e,t){return(e.length>0?e.split(`
688
688
  `):[""]).reduce((r,i)=>{const s=TCe(i);return r+Math.max(1,Math.ceil(s/t))},0)}function TCe(e){let t=0;for(const n of e)/\s/u.test(n)?t+=.35:/[\u2E80-\u9FFF\uF900-\uFAFF\u3000-\u303F\uFF00-\uFFEF]/u.test(n)?t+=1:t+=.55;return t}function RCe(e,t){const n=e.split(`
689
689
  `);let r=0,i=!1;for(const s of n){if(s.trimStart().startsWith("```")){i=!i,r+=t*.9;continue}i&&(r+=t*.15),/^\s*\|.*\|\s*$/u.test(s)&&(r+=t*.35)}return r}function ACe(e){var n;return e.role!=="activity"?!1:(((n=e.activity)==null?void 0:n.status)??(e.isPartial?"running":"done"))==="running"}function NCe({messages:e,isWorking:t,hasPendingApprovals:n}){if(!t||n)return{messageId:null,showThinking:!1};for(let i=e.length-1;i>=0;i-=1){const s=e[i];if(s&&ACe(s))return{messageId:s.id,showThinking:!1}}const r=e[e.length-1];return(r==null?void 0:r.role)==="assistant"&&r.isPartial?{messageId:r.id,showThinking:!1}:{messageId:null,showThinking:!0}}function MCe(e){return!!((e==null?void 0:e.role)==="user"&&e.isPartial&&e.inputMethod==="voice")}function OCe(e,t){if(!t)return[];const n=t.toLowerCase(),r=[];for(let i=0;i<e.length;i+=1)e[i].text.toLowerCase().includes(n)&&r.push(i);return r}const $E=j1({windowKey:"__devAnywhereJsonScrollTrace",storageKey:"dev_anywhere_json_scroll_trace"}),a0=$E.isEnabled,DCe=$E.append;function PCe(){const e=$E.getAll(),t=e.slice(-180),n=t.map(d=>d.scrollTop),r=t.map(d=>d.totalSize),i=Mu(t.map(d=>d.clientHeight)),s=Mu(t.map(d=>d.visualViewportHeight)),o=[...new Set(t.map(d=>d.focus??"null"))].join(","),l=c3(n),u=t.map(d=>[An(d.t),d.event,An(d.scrollTop),d.scrollHeight,d.clientHeight,d.messageCount,An(d.totalSize),ICe(d.firstIndex,d.lastIndex),d.firstStart===void 0?"":An(d.firstStart),d.lastEnd===void 0?"":An(d.lastEnd),d.visualViewportHeight===void 0?"":An(d.visualViewportHeight),d.atBottom?"bottom":"",d.historyLoading||d.historyHasMore?LCe(d):"",d.preservePrepend?"preserve":"",d.scrollDelta===void 0?"":An(d.scrollDelta),d.scrollHeightDelta===void 0?"":An(d.scrollHeightDelta),d.focus??""].join(" "));return["DEV Anywhere JSON scroll trace",`events=${e.length}, included=${t.length}`,`scrollTop=${Va(n)}, totalSize=${Va(r)}, directionFlips=${l}`,`clientHeight=${i.join(",")}, visualViewportHeight=${s.join(",")}`,`focus=${o}`,"t event scrollTop scrollHeight clientHeight messages totalSize visible firstStart lastEnd vvHeight atBottom history preserve scrollDelta scrollHeightDelta focus",...u].join(`
690
- `)}function LCe(e){return e.historyLoading&&e.historyHasMore?"loading+more":e.historyLoading?"loading":e.historyHasMore?"more":""}function ICe(e,t){return e===void 0||t===void 0?"":`${e}..${t}`}const yD=50,zCe=96;function BCe({sessionId:e,findRequest:t}){const n=Qt(ze=>{var et;return((et=ze.bySessionId[e])==null?void 0:et.messages)??qs.messages}),r=Qt(ze=>{var et;return((et=ze.bySessionId[e])==null?void 0:et.historyHasMore)??qs.historyHasMore}),i=Qt(ze=>{var et;return((et=ze.bySessionId[e])==null?void 0:et.historyNextBefore)??qs.historyNextBefore}),s=Qt(ze=>{var et;return((et=ze.bySessionId[e])==null?void 0:et.historyLoading)??qs.historyLoading}),o=Qt(ze=>ze.setHistoryLoading),l=Qt(ze=>{var et;return((et=ze.bySessionId[e])==null?void 0:et.pendingApprovals)??qs.pendingApprovals}),u=$t(ze=>{var et;return((et=ze.sessions.find(Et=>Et.sessionId===e))==null?void 0:et.state)==="working"}),d=Ne(ze=>ze.connected),h=Ne(ze=>ze.proxyOnline),p=Ne(ze=>ze.chatContentFontSize),y=Ne(ze=>ze.inputModePreference==="hardware"),_=ul("(pointer: coarse), (hover: none)")&&!y,w=Ix(p,_),[x,E]=b.useState(null),{isAtBottom:k,scrollToBottom:R}=_Ce(x),[A,I]=b.useState(!1),[T,H]=b.useState(()=>a0()),[D,W]=b.useState(!1),[U,F]=b.useState(!1),[O,M]=b.useState(""),[B,L]=b.useState(null),[N,V]=b.useState(!1),[Y,$]=b.useState(!1),P=b.useRef(0),q=b.useRef(!1),K=b.useRef(null),z=b.useRef(null),X=b.useRef(()=>{}),ee=b.useRef({hasMore:r,nextBefore:i,loading:s});b.useEffect(()=>{ee.current={hasMore:r,nextBefore:i,loading:s}},[r,i,s]),b.useEffect(()=>{const ze=()=>{H(a0())};return ze(),window.addEventListener("hashchange",ze),window.addEventListener("popstate",ze),()=>{window.removeEventListener("hashchange",ze),window.removeEventListener("popstate",ze)}},[]);const te=age(),Q=y?0:te,me=b.useRef(k);b.useEffect(()=>{me.current=k},[k]),b.useEffect(()=>{if(!x||!me.current)return;const ze=requestAnimationFrame(()=>{x.scrollTop=x.scrollHeight});return()=>cancelAnimationFrame(ze)},[Q,x]),b.useEffect(()=>{const ze=Pt;if(!ze||!e||!d||!h)return;ze.sendControl({type:"session_subscribe",sessionId:e});const et=Qt.getState().bySessionId[e];et!=null&&et.historyLoading||et!=null&&et.historyInitialized||(X.current("history-initial:request"),o(e,!0),ze.requestSessionMessagesPage(e,{limit:yD}).then(Et=>{X.current("history-initial:response",{historyHasMore:Et.hasMore}),Qt.getState().loadHistoryPage(e,{mode:"replace",messages:Et.messages,hasMore:Et.hasMore,nextBefore:Et.nextBefore})}).catch(()=>Qt.getState().setHistoryLoading(e,!1)))},[e,d,h,o]);const ve=b.useCallback(()=>{const ze=Pt,et=ee.current;!ze||!e||!d||!h||!et.hasMore||!et.nextBefore||et.loading||(ee.current={...et,loading:!0},K.current={previousScrollHeight:(x==null?void 0:x.scrollHeight)??0},X.current("history-prepend:request"),o(e,!0),ze.requestSessionMessagesPage(e,{limit:yD,before:et.nextBefore}).then(Et=>{X.current("history-prepend:response",{historyHasMore:Et.hasMore}),Qt.getState().loadHistoryPage(e,{mode:"prepend",messages:Et.messages,hasMore:Et.hasMore,nextBefore:Et.nextBefore})}).catch(()=>{X.current("history-prepend:error"),K.current=null,ee.current={...ee.current,loading:!1},Qt.getState().setHistoryLoading(e,!1)}))},[d,h,x,e,o]),Ce=b.useCallback(async()=>{const ze=Pt,et=Qt.getState().bySessionId[e];if(!ze||!d||!h||!(et!=null&&et.historyHasMore)||!et.historyNextBefore||q.current)return;const Et=++P.current;q.current=!0,V(!0),$(!1),o(e,!0),ee.current={hasMore:et.historyHasMore,nextBefore:et.historyNextBefore,loading:!0};let Bt=et.historyNextBefore,J=et.historyHasMore;const _e=new Set,Be=[];try{for(;J&&Bt;){if(_e.has(Bt))throw new Error(`History pagination repeated cursor: ${Bt}`);_e.add(Bt);const jt=await ze.requestSessionMessagesPage(e,{limit:200,before:Bt});if(Et!==P.current)return;if(Be.push(jt.messages),J=jt.hasMore,J&&!jt.nextBefore)throw new Error("History pagination omitted nextBefore while hasMore is true");Bt=jt.nextBefore}if(Et!==P.current)return;const ht=Be.reverse().flat();ee.current={hasMore:J,nextBefore:Bt??null,loading:!1},Qt.getState().loadHistoryPage(e,{mode:"prepend",messages:ht,hasMore:J,...Bt!==void 0?{nextBefore:Bt}:{}})}catch(ht){if(Et!==P.current)return;console.error("[chat-find] failed to load complete history",{sessionId:e},ht),Qt.getState().setHistoryLoading(e,!1),ee.current={...ee.current,loading:!1},$(!0),nt.error("搜索历史消息失败")}finally{Et===P.current&&(q.current=!1,V(!1))}},[d,h,e,o]),Me=b.useCallback(()=>{P.current+=1,q.current&&(q.current=!1,V(!1),ee.current={...ee.current,loading:!1},Qt.getState().setHistoryLoading(e,!1))},[e]);b.useEffect(()=>{!U||!O||Y||!r||s||N||Ce()},[Y,N,U,O,r,s,Ce]),b.useEffect(()=>()=>{P.current+=1,q.current&&Qt.getState().setHistoryLoading(e,!1)},[e]);const Ve=b.useCallback(()=>{x&&(X.current("scroll"),x.scrollTop<=zCe&&(X.current("scroll:top-threshold"),ve()))},[ve,x]),Qe=b.useCallback(ze=>{var et;return((et=n[ze])==null?void 0:et.id)??ze},[n]),ct=b.useCallback(ze=>ECe(n[ze],{fontSize:w,touchEditingSurface:_}),[w,n,_]),Ot=Sye({count:n.length,getScrollElement:()=>x,estimateSize:ct,overscan:_?8:5,getItemKey:Qe}),he=b.useMemo(()=>OCe(n,O),[O,n]),Ke=b.useMemo(()=>he.map(ze=>n[ze].id),[he,n]),Rt=b.useMemo(()=>new Set(Ke),[Ke]),ye=B?Ke.indexOf(B):-1;b.useEffect(()=>{if(!U||!O||he.length===0){L(null);return}L(ze=>{var J,_e;if(ze&&Rt.has(ze))return ze;const et=((J=Ot.getVirtualItems()[0])==null?void 0:J.index)??0,Et=he.findIndex(Be=>Be>=et),Bt=Et>=0?Et:0;return((_e=n[he[Bt]])==null?void 0:_e.id)??null})},[Rt,he,U,O,n,Ot]),b.useLayoutEffect(()=>{if(!B)return;const ze=n.findIndex(et=>et.id===B);ze<0||Ot.scrollToIndex(ze,{align:"center",behavior:"auto"})},[B,n,Ot]),b.useEffect(()=>{if(!B||!x)return;let ze=null;const et=()=>{ze!==null&&cancelAnimationFrame(ze),ze=requestAnimationFrame(()=>{var Bt;ze=null,(Bt=x.querySelector('[data-slot="message-row"][data-find-active="true"]'))==null||Bt.scrollIntoView({block:"center",inline:"nearest",behavior:"auto"})})},Et=new ResizeObserver(et);return Et.observe(x),et(),()=>{Et.disconnect(),ze!==null&&cancelAnimationFrame(ze)}},[B,x]);const He=b.useCallback(ze=>{if(Ke.length===0)return;const et=B?Ke.indexOf(B):-1,Et=ze==="next"?(et+1+Ke.length)%Ke.length:(et-1+Ke.length)%Ke.length;L(Ke[Et])},[B,Ke]),Ge=b.useCallback(()=>{$(!1),F(!0)},[]),be=b.useCallback(()=>{Me(),F(!1),L(null)},[Me]),Xe=b.useCallback(()=>He("previous"),[He]),rt=b.useCallback(()=>He("next"),[He]),pt=L3({open:U,openRequest:t,onOpen:Ge,onClose:be,onPrevious:Xe,onNext:rt}),le=b.useCallback(ze=>{M(ze),$(!1),ze||(Me(),L(null))},[Me]),Ae=b.useCallback((ze,et={})=>{var ie,de;if(!a0())return;const Et=x,Bt=Ot.getVirtualItems(),J=Bt[0],_e=Bt[Bt.length-1],Be=z.current,ht=(Et==null?void 0:Et.scrollTop)??0,jt=(Et==null?void 0:Et.scrollHeight)??0,re=window.visualViewport;DCe({t:performance.now(),event:ze,scrollTop:ht,scrollHeight:jt,clientHeight:(Et==null?void 0:Et.clientHeight)??0,innerHeight:window.innerHeight,visualViewportHeight:re==null?void 0:re.height,visualViewportOffsetTop:re==null?void 0:re.offsetTop,messageCount:n.length,totalSize:Ot.getTotalSize(),firstIndex:J==null?void 0:J.index,lastIndex:_e==null?void 0:_e.index,firstStart:J==null?void 0:J.start,lastEnd:_e==null?void 0:_e.end,focus:((ie=document.activeElement)==null?void 0:ie.getAttribute("aria-label"))??((de=document.activeElement)==null?void 0:de.tagName)??null,atBottom:me.current,historyLoading:ee.current.loading,historyHasMore:ee.current.hasMore,preservePrepend:!!K.current,scrollDelta:Be?ht-Be.scrollTop:void 0,scrollHeightDelta:Be?jt-Be.scrollHeight:void 0,...et}),z.current={scrollTop:ht,scrollHeight:jt}},[n.length,x,Ot]);b.useEffect(()=>{X.current=Ae},[Ae]);const Ze=n[n.length-1],tt=b.useRef(n.length);b.useEffect(()=>{tt.current=n.length},[n.length]),b.useLayoutEffect(()=>{Ot.measure(),X.current("virtualizer:measure");const ze=tt.current;if(!x||!me.current||ze===0)return;let et=0;const Et=requestAnimationFrame(()=>{et=requestAnimationFrame(()=>{Ot.scrollToIndex(ze-1,{align:"end",behavior:"auto"})})});return()=>{cancelAnimationFrame(Et),cancelAnimationFrame(et)}},[w,x,Ot]),b.useLayoutEffect(()=>{const ze=K.current;if(!x||!ze)return;X.current("prepend-preserve:start");let et=0;const Et=requestAnimationFrame(()=>{Ot.measure(),et=requestAnimationFrame(()=>{const Bt=x.scrollHeight-ze.previousScrollHeight;X.current("prepend-preserve:apply",{scrollHeightDelta:Bt}),Bt>0&&(x.scrollTop+=Bt),X.current("prepend-preserve:after-scroll",{scrollHeightDelta:Bt}),K.current=null})});return()=>{cancelAnimationFrame(Et),cancelAnimationFrame(et)}},[n.length,x,Ot]);const dt=b.useRef(!1);b.useEffect(()=>{dt.current=!1,W(!1),F(!1),M(""),L(null),V(!1),$(!1),q.current=!1},[e]),b.useLayoutEffect(()=>{if(!x||n.length===0||dt.current)return;dt.current=!0;const ze=()=>{x.scrollTop=x.scrollHeight,X.current("initial-pin")};ze();const et=requestAnimationFrame(()=>{ze(),requestAnimationFrame(ze)});return I(!1),()=>cancelAnimationFrame(et)},[x,n.length]);const Dt=b.useRef(k);b.useEffect(()=>{Dt.current=k,k&&I(!1)},[k]),b.useEffect(()=>{if(!dt.current||n.length===0||U&&O||K.current)return;const ze=MCe(Ze);Dt.current||ze?(X.current(ze?"follow-voice-transcript":"follow-output"),Ot.scrollToIndex(n.length-1,{align:"end",behavior:"auto"})):(X.current("new-message-while-away"),I(!0))},[U,O,n.length,Ze==null?void 0:Ze.text]);const Wt=l.filter(ze=>ze.status==="pending"),tn=Wt.length>0;b.useEffect(()=>{u||W(!1)},[u]);const vn=b.useCallback(()=>{if(D)return;W(!0),((Pt==null?void 0:Pt.sendControl({type:"session_worker_abort",sessionId:e}))===!1||!Pt)&&W(!1)},[e,D]),un=NCe({messages:n,isWorking:u,hasPendingApprovals:tn}),Zt=u&&!tn?g.jsx(bCe,{isStopping:D,onStop:vn}):null,Xn=un.showThinking,Kt=n.some(ze=>ze.id.startsWith(`history-${e}-`)),Zn=!!O&&(N||s);return n.length===0&&!tn?g.jsxs("div",{className:"relative h-full",children:[g.jsx(tc,{variant:"no-messages"}),U?g.jsx(X0,{query:O,resultIndex:ye,resultCount:Ke.length,focusRequest:pt.focusRequest,loading:Zn,onQueryChange:le,onPrevious:Xe,onNext:rt,onClose:pt.closeFind}):null]}):g.jsxs("div",{className:"flex flex-col h-full",children:[g.jsxs("div",{className:"flex-1 relative min-h-0",children:[U?g.jsx(X0,{query:O,resultIndex:ye,resultCount:Ke.length,focusRequest:pt.focusRequest,loading:Zn,onQueryChange:le,onPrevious:Xe,onNext:rt,onClose:pt.closeFind}):null,g.jsx("div",{ref:E,className:"dev-render-scroll absolute inset-0 overflow-auto","data-slot":"message-list",onScroll:Ve,children:x&&g.jsxs("div",{className:"flex flex-col min-h-full",children:[g.jsx("div",{className:"flex-1","aria-hidden":!0}),(s||r||Kt)&&g.jsx("div",{className:"mx-auto flex min-h-10 w-full max-w-[var(--dev-message-rail-width)] items-center justify-center px-4 py-2 text-xs text-muted-foreground","data-slot":"history-scrollback-status",children:s?"正在加载更早消息...":r?"继续上滑加载更早消息":"已到最早记录"}),g.jsx("div",{style:{height:Ot.getTotalSize(),position:"relative",width:"100%"},children:Ot.getVirtualItems().map(ze=>{const et=n[ze.index];return g.jsx("div",{"data-index":ze.index,ref:Ot.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${ze.start}px)`},children:g.jsx(hCe,{message:et,contentFontSize:w,findState:(et==null?void 0:et.id)===B?"active":et&&Rt.has(et.id)?"match":void 0,turnControl:(et==null?void 0:et.id)===un.messageId?Zt:void 0})},ze.key)})}),Xn&&g.jsx(vCe,{turnControl:Zt})]})}),g.jsx(O3,{visible:!k,hasNewMessages:A,className:U?"top-14":void 0,onClick:()=>{Ot.scrollToIndex(Math.max(n.length-1,0),{align:"end",behavior:"smooth"}),R(),I(!1)}}),T?g.jsx(jCe,{}):null]}),tn&&g.jsxs("div",{className:"dev-render-scroll dev-chat-rail-inset flex flex-col gap-2 overflow-x-hidden overflow-y-auto py-2","aria-live":"polite",children:[Wt.length>1&&g.jsxs("div",{className:"dev-message-rail mx-auto w-full min-w-0 px-1 text-xs text-muted-foreground",children:[Wt.length," 个工具审批待处理"]}),Wt.map((ze,et)=>g.jsx(gCe,{approval:ze,sessionId:e,container:"inline",queuePosition:et+1,queueSize:Wt.length},ze.requestId))]})]})}function jCe(){const[e,t]=b.useState(!1);async function n(){const r=PCe();try{await navigator.clipboard.writeText(r),t(!0),window.setTimeout(()=>t(!1),1200)}catch{window.prompt("Copy JSON scroll trace",r)}}return g.jsx("button",{type:"button",className:"absolute left-3 bottom-3 z-30 rounded border border-[#4A4A4A] bg-[#1E1E1E]/90 px-2 py-1 text-[11px] text-[#C8C8C8]",onClick:n,"data-slot":"json-scroll-trace-copy",children:e?"Copied":"Trace"})}function FCe({className:e,...t}){return g.jsx("textarea",{"data-slot":"textarea",className:Ye("flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground 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 md:text-sm dark:bg-input/30 dark:aria-invalid:ring-destructive/40",e),...t})}function $Ce(e,t){return!!(e||t.some(n=>n.status==="pending"))}function HCe(e){const t=e.lastIndexOf("@");return t<0||t>0&&e[t-1]!==" "?!1:!e.slice(t+1).includes(" ")}function UCe(e){return e?HCe(e)?"file":e.startsWith("/")&&!e.slice(1).includes(" ")?"slash":"none":"none"}function WCe(e,t){return[e.trim(),...t.map(r=>`@${r.path}`)].filter(Boolean).join(" ")}function qCe(e,t,n){if(e.length>=t.length||n.length===0)return{cleaned:e,removedMention:null};for(const r of n)if(t.includes(r)&&!e.includes(r)){let i=e;for(let s=r.length-1;s>0;s--){const o=r.slice(0,s);if(i.endsWith(o)){i=i.slice(0,-o.length),i.endsWith(" ")&&(i=i.slice(0,-1));break}}return{cleaned:i,removedMention:r}}return{cleaned:e,removedMention:null}}var bD=1,VCe=.9,YCe=.8,KCe=.17,l0=.1,c0=.999,GCe=.9999,XCe=.99,ZCe=/[\\\/_+.#"@\[\(\{&]/,QCe=/[\\\/_+.#"@\[\(\{&]/g,JCe=/[\s-]/,TF=/[\s-]/g;function hx(e,t,n,r,i,s,o){if(s===t.length)return i===e.length?bD:XCe;var l=`${i},${s}`;if(o[l]!==void 0)return o[l];for(var u=r.charAt(s),d=n.indexOf(u,i),h=0,p,y,v,_;d>=0;)p=hx(e,t,n,r,d+1,s+1,o),p>h&&(d===i?p*=bD:ZCe.test(e.charAt(d-1))?(p*=YCe,v=e.slice(i,d-1).match(QCe),v&&i>0&&(p*=Math.pow(c0,v.length))):JCe.test(e.charAt(d-1))?(p*=VCe,_=e.slice(i,d-1).match(TF),_&&i>0&&(p*=Math.pow(c0,_.length))):(p*=KCe,i>0&&(p*=Math.pow(c0,d-i))),e.charAt(d)!==t.charAt(s)&&(p*=GCe)),(p<l0&&n.charAt(d-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(d-1)!==r.charAt(s))&&(y=hx(e,t,n,r,d+1,s+2,o),y*l0>p&&(p=y*l0)),p>h&&(h=p),d=n.indexOf(u,d+1);return o[l]=h,h}function _D(e){return e.toLowerCase().replace(TF," ")}function eke(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,hx(e,t,_D(e),_D(t),0,0,{})}var Ah='[cmdk-group=""]',u0='[cmdk-group-items=""]',tke='[cmdk-group-heading=""]',RF='[cmdk-item=""]',wD=`${RF}:not([aria-disabled="true"])`,fx="cmdk-item-select",ku="data-value",nke=(e,t,n)=>eke(e,t,n),AF=b.createContext(void 0),op=()=>b.useContext(AF),NF=b.createContext(void 0),HE=()=>b.useContext(NF),MF=b.createContext(void 0),OF=b.forwardRef((e,t)=>{let n=Tu(()=>{var K,z;return{search:"",value:(z=(K=e.value)!=null?K:e.defaultValue)!=null?z:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Tu(()=>new Set),i=Tu(()=>new Map),s=Tu(()=>new Map),o=Tu(()=>new Set),l=DF(e),{label:u,children:d,value:h,onValueChange:p,filter:y,shouldFilter:v,loop:_,disablePointerSelection:w=!1,vimBindings:x=!0,...E}=e,k=vi(),R=vi(),A=vi(),I=b.useRef(null),T=fke();pc(()=>{if(h!==void 0){let K=h.trim();n.current.value=K,H.emit()}},[h]),pc(()=>{T(6,M)},[]);let H=b.useMemo(()=>({subscribe:K=>(o.current.add(K),()=>o.current.delete(K)),snapshot:()=>n.current,setState:(K,z,X)=>{var ee,te,Q,me;if(!Object.is(n.current[K],z)){if(n.current[K]=z,K==="search")O(),U(),T(1,F);else if(K==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let ve=document.getElementById(A);ve?ve.focus():(ee=document.getElementById(k))==null||ee.focus()}if(T(7,()=>{var ve;n.current.selectedItemId=(ve=B())==null?void 0:ve.id,H.emit()}),X||T(5,M),((te=l.current)==null?void 0:te.value)!==void 0){let ve=z??"";(me=(Q=l.current).onValueChange)==null||me.call(Q,ve);return}}H.emit()}},emit:()=>{o.current.forEach(K=>K())}}),[]),D=b.useMemo(()=>({value:(K,z,X)=>{var ee;z!==((ee=s.current.get(K))==null?void 0:ee.value)&&(s.current.set(K,{value:z,keywords:X}),n.current.filtered.items.set(K,W(z,X)),T(2,()=>{U(),H.emit()}))},item:(K,z)=>(r.current.add(K),z&&(i.current.has(z)?i.current.get(z).add(K):i.current.set(z,new Set([K]))),T(3,()=>{O(),U(),n.current.value||F(),H.emit()}),()=>{s.current.delete(K),r.current.delete(K),n.current.filtered.items.delete(K);let X=B();T(4,()=>{O(),(X==null?void 0:X.getAttribute("id"))===K&&F(),H.emit()})}),group:K=>(i.current.has(K)||i.current.set(K,new Set),()=>{s.current.delete(K),i.current.delete(K)}),filter:()=>l.current.shouldFilter,label:u||e["aria-label"],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:k,inputId:A,labelId:R,listInnerRef:I}),[]);function W(K,z){var X,ee;let te=(ee=(X=l.current)==null?void 0:X.filter)!=null?ee:nke;return K?te(K,n.current.search,z):0}function U(){if(!n.current.search||l.current.shouldFilter===!1)return;let K=n.current.filtered.items,z=[];n.current.filtered.groups.forEach(ee=>{let te=i.current.get(ee),Q=0;te.forEach(me=>{let ve=K.get(me);Q=Math.max(ve,Q)}),z.push([ee,Q])});let X=I.current;L().sort((ee,te)=>{var Q,me;let ve=ee.getAttribute("id"),Ce=te.getAttribute("id");return((Q=K.get(Ce))!=null?Q:0)-((me=K.get(ve))!=null?me:0)}).forEach(ee=>{let te=ee.closest(u0);te?te.appendChild(ee.parentElement===te?ee:ee.closest(`${u0} > *`)):X.appendChild(ee.parentElement===X?ee:ee.closest(`${u0} > *`))}),z.sort((ee,te)=>te[1]-ee[1]).forEach(ee=>{var te;let Q=(te=I.current)==null?void 0:te.querySelector(`${Ah}[${ku}="${encodeURIComponent(ee[0])}"]`);Q==null||Q.parentElement.appendChild(Q)})}function F(){let K=L().find(X=>X.getAttribute("aria-disabled")!=="true"),z=K==null?void 0:K.getAttribute(ku);H.setState("value",z||void 0)}function O(){var K,z,X,ee;if(!n.current.search||l.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let te=0;for(let Q of r.current){let me=(z=(K=s.current.get(Q))==null?void 0:K.value)!=null?z:"",ve=(ee=(X=s.current.get(Q))==null?void 0:X.keywords)!=null?ee:[],Ce=W(me,ve);n.current.filtered.items.set(Q,Ce),Ce>0&&te++}for(let[Q,me]of i.current)for(let ve of me)if(n.current.filtered.items.get(ve)>0){n.current.filtered.groups.add(Q);break}n.current.filtered.count=te}function M(){var K,z,X;let ee=B();ee&&(((K=ee.parentElement)==null?void 0:K.firstChild)===ee&&((X=(z=ee.closest(Ah))==null?void 0:z.querySelector(tke))==null||X.scrollIntoView({block:"nearest"})),ee.scrollIntoView({block:"nearest"}))}function B(){var K;return(K=I.current)==null?void 0:K.querySelector(`${RF}[aria-selected="true"]`)}function L(){var K;return Array.from(((K=I.current)==null?void 0:K.querySelectorAll(wD))||[])}function N(K){let z=L()[K];z&&H.setState("value",z.getAttribute(ku))}function V(K){var z;let X=B(),ee=L(),te=ee.findIndex(me=>me===X),Q=ee[te+K];(z=l.current)!=null&&z.loop&&(Q=te+K<0?ee[ee.length-1]:te+K===ee.length?ee[0]:ee[te+K]),Q&&H.setState("value",Q.getAttribute(ku))}function Y(K){let z=B(),X=z==null?void 0:z.closest(Ah),ee;for(;X&&!ee;)X=K>0?dke(X,Ah):hke(X,Ah),ee=X==null?void 0:X.querySelector(wD);ee?H.setState("value",ee.getAttribute(ku)):V(K)}let $=()=>N(L().length-1),P=K=>{K.preventDefault(),K.metaKey?$():K.altKey?Y(1):V(1)},q=K=>{K.preventDefault(),K.metaKey?N(0):K.altKey?Y(-1):V(-1)};return b.createElement(Jt.div,{ref:t,tabIndex:-1,...E,"cmdk-root":"",onKeyDown:K=>{var z;(z=E.onKeyDown)==null||z.call(E,K);let X=K.nativeEvent.isComposing||K.keyCode===229;if(!(K.defaultPrevented||X))switch(K.key){case"n":case"j":{x&&K.ctrlKey&&P(K);break}case"ArrowDown":{P(K);break}case"p":case"k":{x&&K.ctrlKey&&q(K);break}case"ArrowUp":{q(K);break}case"Home":{K.preventDefault(),N(0);break}case"End":{K.preventDefault(),$();break}case"Enter":{K.preventDefault();let ee=B();if(ee){let te=new Event(fx);ee.dispatchEvent(te)}}}}},b.createElement("label",{"cmdk-label":"",htmlFor:D.inputId,id:D.labelId,style:mke},u),py(e,K=>b.createElement(NF.Provider,{value:H},b.createElement(AF.Provider,{value:D},K))))}),rke=b.forwardRef((e,t)=>{var n,r;let i=vi(),s=b.useRef(null),o=b.useContext(MF),l=op(),u=DF(e),d=(r=(n=u.current)==null?void 0:n.forceMount)!=null?r:o==null?void 0:o.forceMount;pc(()=>{if(!d)return l.item(i,o==null?void 0:o.id)},[d]);let h=PF(i,s,[e.value,e.children,s],e.keywords),p=HE(),y=fl(T=>T.value&&T.value===h.current),v=fl(T=>d||l.filter()===!1?!0:T.search?T.filtered.items.get(i)>0:!0);b.useEffect(()=>{let T=s.current;if(!(!T||e.disabled))return T.addEventListener(fx,_),()=>T.removeEventListener(fx,_)},[v,e.onSelect,e.disabled]);function _(){var T,H;w(),(H=(T=u.current).onSelect)==null||H.call(T,h.current)}function w(){p.setState("value",h.current,!0)}if(!v)return null;let{disabled:x,value:E,onSelect:k,forceMount:R,keywords:A,...I}=e;return b.createElement(Jt.div,{ref:na(s,t),...I,id:i,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!y,"data-disabled":!!x,"data-selected":!!y,onPointerMove:x||l.getDisablePointerSelection()?void 0:w,onClick:x?void 0:_},e.children)}),ike=b.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...s}=e,o=vi(),l=b.useRef(null),u=b.useRef(null),d=vi(),h=op(),p=fl(v=>i||h.filter()===!1?!0:v.search?v.filtered.groups.has(o):!0);pc(()=>h.group(o),[]),PF(o,l,[e.value,e.heading,u]);let y=b.useMemo(()=>({id:o,forceMount:i}),[i]);return b.createElement(Jt.div,{ref:na(l,t),...s,"cmdk-group":"",role:"presentation",hidden:p?void 0:!0},n&&b.createElement("div",{ref:u,"cmdk-group-heading":"","aria-hidden":!0,id:d},n),py(e,v=>b.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?d:void 0},b.createElement(MF.Provider,{value:y},v))))}),ske=b.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=b.useRef(null),s=fl(o=>!o.search);return!n&&!s?null:b.createElement(Jt.div,{ref:na(i,t),...r,"cmdk-separator":"",role:"separator"})}),oke=b.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,s=HE(),o=fl(d=>d.search),l=fl(d=>d.selectedItemId),u=op();return b.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),b.createElement(Jt.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":u.listId,"aria-labelledby":u.labelId,"aria-activedescendant":l,id:u.inputId,type:"text",value:i?e.value:o,onChange:d=>{i||s.setState("search",d.target.value),n==null||n(d.target.value)}})}),ake=b.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...i}=e,s=b.useRef(null),o=b.useRef(null),l=fl(d=>d.selectedItemId),u=op();return b.useEffect(()=>{if(o.current&&s.current){let d=o.current,h=s.current,p,y=new ResizeObserver(()=>{p=requestAnimationFrame(()=>{let v=d.offsetHeight;h.style.setProperty("--cmdk-list-height",v.toFixed(1)+"px")})});return y.observe(d),()=>{cancelAnimationFrame(p),y.unobserve(d)}}},[]),b.createElement(Jt.div,{ref:na(s,t),...i,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":r,id:u.listId},py(e,d=>b.createElement("div",{ref:na(o,u.listInnerRef),"cmdk-list-sizer":""},d)))}),lke=b.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:s,container:o,...l}=e;return b.createElement(s1,{open:n,onOpenChange:r},b.createElement(o1,{container:o},b.createElement(a1,{"cmdk-overlay":"",className:i}),b.createElement(l1,{"aria-label":e.label,"cmdk-dialog":"",className:s},b.createElement(OF,{ref:t,...l}))))}),cke=b.forwardRef((e,t)=>fl(n=>n.filtered.count===0)?b.createElement(Jt.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),uke=b.forwardRef((e,t)=>{let{progress:n,children:r,label:i="Loading...",...s}=e;return b.createElement(Jt.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},py(e,o=>b.createElement("div",{"aria-hidden":!0},o)))}),fy=Object.assign(OF,{List:ake,Item:rke,Input:oke,Group:ike,Separator:ske,Dialog:lke,Empty:cke,Loading:uke});function dke(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function hke(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function DF(e){let t=b.useRef(e);return pc(()=>{t.current=e}),t}var pc=typeof window>"u"?b.useEffect:b.useLayoutEffect;function Tu(e){let t=b.useRef();return t.current===void 0&&(t.current=e()),t}function fl(e){let t=HE(),n=()=>e(t.snapshot());return b.useSyncExternalStore(t.subscribe,n,n)}function PF(e,t,n,r=[]){let i=b.useRef(),s=op();return pc(()=>{var o;let l=(()=>{var d;for(let h of n){if(typeof h=="string")return h.trim();if(typeof h=="object"&&"current"in h)return h.current?(d=h.current.textContent)==null?void 0:d.trim():i.current}})(),u=r.map(d=>d.trim());s.value(e,l,u),(o=t.current)==null||o.setAttribute(ku,l),i.current=l}),i}var fke=()=>{let[e,t]=b.useState(),n=Tu(()=>new Map);return pc(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,i)=>{n.current.set(r,i),t({})}};function pke(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function py({asChild:e,children:t},n){return e&&b.isValidElement(t)?b.cloneElement(pke(t),{ref:t.ref},n(t.props.children)):n(t)}var mke={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function gke({className:e,...t}){return g.jsx(fy,{"data-slot":"command",className:Ye("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t})}function vke({className:e,...t}){return g.jsx(fy.List,{"data-slot":"command-list",className:Ye("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",e),...t})}function yke({...e}){return g.jsx(fy.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...e})}function bke({className:e,...t}){return g.jsx(fy.Item,{"data-slot":"command-item",className:Ye("relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",e),...t})}const _ke=b.forwardRef(function({filter:t,onSelect:n},r){var d;const i=Rv(h=>h.commands),s=b.useMemo(()=>{const h=t.toLowerCase().replace(/^\//,"");return h?i.filter(p=>p.name.toLowerCase().includes(h)):i},[i,t]),[o,l]=b.useState(0);b.useEffect(()=>l(0),[t]),b.useEffect(()=>{o>=s.length&&s.length>0&&l(s.length-1)},[s.length,o]),b.useImperativeHandle(r,()=>({handleKey(h){return s.length===0?!1:h.key==="ArrowDown"?(l(p=>Math.min(s.length-1,p+1)),!0):h.key==="ArrowUp"?(l(p=>Math.max(0,p-1)),!0):h.key==="Enter"&&!h.nativeEvent.isComposing?(n(s[o]),!0):!1}}),[s,o,n]);const u=(d=s[o])==null?void 0:d.name;return g.jsx("div",{className:"absolute bottom-full left-0 right-0 mb-2 bg-popover border border-border rounded-md shadow-lg z-10 overflow-hidden","data-slot":"slash-command-picker",children:g.jsx(gke,{shouldFilter:!1,value:u,children:g.jsxs(vke,{className:"max-h-60",children:[s.length===0&&g.jsx(yke,{children:"没有匹配的命令"}),s.map(h=>g.jsxs(bke,{value:h.name,onSelect:()=>n(h),className:"min-h-11 py-2 data-[selected=true]:bg-[color-mix(in_srgb,var(--primary)_15%,transparent)] md:min-h-0 md:py-1.5",children:[g.jsx("span",{className:"font-mono text-sm whitespace-nowrap shrink-0",children:h.name}),h.description&&g.jsx("span",{className:"ml-auto min-w-0 text-xs text-muted-foreground truncate",children:h.description})]},h.name))]})})})});function wke({attachments:e,onRemove:t}){return e.length===0?null:g.jsx("div",{className:"flex w-full gap-2 overflow-x-auto px-2.5 pt-2.5 pb-1","data-slot":"input-attachments","aria-label":"已上传附件",children:e.map(n=>n.kind==="image"?g.jsx(Ske,{attachment:n,onRemove:t},n.id):g.jsx(xke,{attachment:n,onRemove:t},n.id))})}function Ske({attachment:e,onRemove:t}){const[n,r]=b.useState(null);return b.useEffect(()=>{if(typeof URL.createObjectURL!="function")return;const i=URL.createObjectURL(e.file);return r(i),()=>URL.revokeObjectURL(i)},[e.file]),g.jsxs("div",{className:"group relative size-20 shrink-0 overflow-hidden rounded-md border bg-muted","data-slot":"input-image-attachment",title:e.file.name,children:[n?g.jsx("img",{src:n,alt:e.file.name,className:"size-full object-contain","data-slot":"input-image-attachment-preview"}):g.jsx("div",{className:"flex size-full items-center justify-center text-muted-foreground",children:g.jsx(Lf,{className:"size-5","aria-hidden":"true"})}),g.jsx(LF,{attachment:e,onRemove:t})]})}function xke({attachment:e,onRemove:t}){return g.jsxs("div",{className:"relative flex h-16 w-56 shrink-0 items-center gap-2.5 rounded-md border bg-muted/50 px-3 pr-9","data-slot":"input-file-attachment",title:e.file.name,children:[g.jsx("div",{className:"flex size-9 shrink-0 items-center justify-center rounded-sm bg-background text-muted-foreground",children:g.jsx(k8,{className:"size-4","aria-hidden":"true"})}),g.jsxs("div",{className:"min-w-0",children:[g.jsx("div",{className:"truncate text-sm font-medium","data-slot":"input-attachment-name",children:e.file.name}),g.jsx("div",{className:"mt-0.5 text-xs text-muted-foreground",children:Eke(e.file.size)})]}),g.jsx(LF,{attachment:e,onRemove:t})]})}function LF({attachment:e,onRemove:t}){return g.jsx(_t,{type:"button",variant:"secondary",size:"icon",className:"absolute right-1 top-1 size-7 border bg-background/90 shadow-xs hover:bg-background","aria-label":`移除附件 ${e.file.name}`,"data-slot":"input-attachment-remove",onClick:()=>t(e.id),children:g.jsx(vc,{className:"size-3.5","aria-hidden":"true"})})}function Eke(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/102.4)/10} KB`:`${Math.round(e/(1024*102.4))/10} MB`}let SD=0;function Cke({sessionId:e}){const t=Yj(),n=b.useRef(null),r=b.useRef(null),i=b.useRef(null),s=Qt(be=>be.bySessionId[e]??qs),o=Qt(be=>be.setInputDraft),l=Qt(be=>be.addDraftAttachment),u=Qt(be=>be.removeDraftAttachment),d=Qt(be=>be.clearDraftAttachments),h=Qt(be=>be.addUserMessage),p=Ne(be=>be.chatContentFontSize),y=Ne(be=>be.inputModePreference==="hardware"),_=ul("(pointer: coarse), (hover: none)")&&!y,w=Ix(p,_),x=$t(be=>{var Xe;return(Xe=be.sessions.find(rt=>rt.sessionId===e))==null?void 0:Xe.state}),E=$t(be=>be.updateSessionState),k=ul("(min-width: 768px)"),R=(k||y)&&!_,A=s.inputDraft,I=s.draftAttachments,T=WCe(A,I),H=x==="working",D=H||x==="compacting",W=s.pendingApprovals,U=W.some(be=>be.status==="pending"),F=UCe(A),M=!$Ce(D,W)&&T!=="",B=H&&!U&&T!==""&&!UA(T),[L,N]=b.useState([]),[V,Y]=b.useState(!1),[$,P]=b.useState(""),q=b.useRef(A),K=b.useRef(e);K.current=e,b.useEffect(()=>{N([]),P("")},[e]),b.useEffect(()=>{q.current=A},[A]);const z=b.useCallback(()=>{N([]),P("")},[]),X=b.useCallback(()=>{o(e,""),q.current="",d(e),z()},[d,z,e,o]),ee=b.useCallback(be=>{o(e,be),q.current=be},[e,o]),te=b.useCallback(()=>{if(!B)return;const be=Date.now(),Xe=`${e}-user-${be}`;h(e,{id:Xe,role:"user",text:T,isPartial:!1,timestamp:be,toolCalls:[],deliveryStatus:"queued"}),X()},[B,T,e,h,X]),Q=b.useCallback(()=>{if(!M||!T)return;const be=Pt;if(!be)return;const Xe=Date.now(),rt=`${e}-user-${Xe}`,pt=UA(T);pt||h(e,{id:rt,role:"user",text:T,isPartial:!1,timestamp:Xe,toolCalls:[]}),E(e,pt?"compacting":"working",Xe),pt&&zZ(e),be.sendEnvelope({type:"user_input",sessionId:e,payload:{text:T,messageId:rt},seq:0,timestamp:Xe,source:"client",version:"1"}),X()},[M,T,e,h,E,X]),me=b.useCallback(()=>{if(M){Q();return}B&&te()},[M,B,Q,te]),ve=be=>{const Xe=q.current,{cleaned:rt,removedMention:pt}=qCe(be,Xe,L);if(pt){N(le=>le.filter(Ae=>Ae!==pt)),pt.startsWith("/")&&P(""),ee(rt);return}ee(be)},Ce=be=>{if(F!=="none"){const Xe=F==="slash"?r.current:i.current;if(Xe!=null&&Xe.handleKey(be)){be.preventDefault();return}}if(be.key==="Enter"&&!be.shiftKey&&!be.metaKey&&!be.ctrlKey){if(be.nativeEvent.isComposing)return;F==="none"&&R&&(be.preventDefault(),me())}else if(be.key==="Escape"&&F!=="none"){be.preventDefault();const Xe=A.replace(/\/\S*$/,"").replace(/@\S*$/,"");ee(Xe)}},Me=b.useCallback(async be=>{const Xe=be.clipboardData,rt=yE(Xe),pt=rt?null:(()=>{if(!Xe.files||Xe.files.length===0)return null;for(const tt of Xe.files)if(!tt.type.startsWith("image/"))return tt;return null})(),le=rt??pt;if(!le)return;be.preventDefault();const Ae=Pt;if(!Ae){nt.error("请先连接开发机");return}const Ze=e;Y(!0);try{let tt=null;if(rt){const dt=nt.loading("图片上传中...");try{const Dt=await Lj({clipboardData:Xe,relay:Ae,sessionId:Ze});if(nt.dismiss(dt),!Dt)return;tt=Dt.path}catch(Dt){nt.error(Dt instanceof Error?Dt.message:String(Dt),{id:dt});return}}else if(pt&&(tt=await kf({relay:Ae,sessionId:Ze,file:pt,successLabel:null}),!tt))return;if(!tt)return;l(Ze,{id:ED(Ze),kind:CD(le)?"image":"file",file:le,path:tt}),K.current===Ze&&requestAnimationFrame(()=>{var dt;return(dt=n.current)==null?void 0:dt.focus()})}finally{Y(!1)}},[l,e]),Ve=b.useRef(null),Qe=b.useRef(null),[ct,Ot]=b.useState(!1),[he,Ke]=b.useState(!1),Rt=b.useCallback(async be=>{const Xe=Pt;if(!Xe){nt.error("请先连接开发机");return}const rt=e;Y(!0);try{const pt=await kf({relay:Xe,sessionId:rt,file:be,successLabel:null});if(!pt)return;l(rt,{id:ED(rt),kind:CD(be)?"image":"file",file:be,path:pt}),K.current===rt&&requestAnimationFrame(()=>{var le;return(le=n.current)==null?void 0:le.focus()})}finally{Y(!1)}},[l,e]),ye=b.useCallback(async be=>{var rt;const Xe=(rt=be.target.files)==null?void 0:rt[0];be.target.value="",Xe&&await Rt(Xe)},[Rt]),He=b.useCallback(async be=>{var rt,pt;const Xe=(pt=(rt=be.dataTransfer)==null?void 0:rt.files)==null?void 0:pt[0];Xe&&(be.preventDefault(),Ke(!1),await Rt(Xe))},[Rt]),Ge=R?"输入消息... (Enter 发送,Shift+Enter 换行)":"输入消息...";return g.jsxs("div",{className:"relative w-full","data-slot":"input-bar","data-mode":"json",children:[F==="slash"&&g.jsx(_ke,{ref:r,filter:A.slice(A.lastIndexOf("/")),onSelect:be=>{var pt;const Xe=be.name,rt=A.replace(/\/[^\s]*$/,`${Xe} `);ee(rt),N(le=>[...le,Xe]),P(be.argumentHint??""),(pt=n.current)==null||pt.focus()}}),F==="file"&&g.jsx(FB,{ref:i,mode:"insert",filter:A.slice(A.lastIndexOf("@")),onSelect:be=>{var le;const Xe=be.endsWith("/"),rt=`@${be}`,pt=A.replace(/@[^\s]*$/,Xe?rt:`${rt} `);ee(pt),Xe||N(Ae=>[...Ae,rt]),(le=n.current)==null||le.focus()}}),g.jsxs("form",{onSubmit:be=>{be.preventDefault(),me()},onDragOver:be=>{be.dataTransfer.types.includes("Files")&&(be.preventDefault(),he||Ke(!0))},onDragLeave:be=>{be.currentTarget.contains(be.relatedTarget)||Ke(!1)},onDrop:be=>{He(be)},"data-slot":"input-card","data-drag-over":he?"true":void 0,className:"flex flex-col w-full rounded-md border border-input bg-transparent shadow-xs transition-[color,box-shadow] focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/75 data-[drag-over=true]:border-primary data-[drag-over=true]:ring-[3px] data-[drag-over=true]:ring-primary/50 dark:bg-input/30",children:[$&&g.jsxs("div",{className:"px-3 pt-1.5 text-[11px] text-muted-foreground font-mono truncate","data-slot":"input-argument-hint",children:["参数: ",$]}),g.jsx(wke,{attachments:I,onRemove:be=>u(e,be)}),g.jsxs("div",{className:"flex items-center w-full",children:[g.jsx(FCe,{ref:n,value:A,onChange:be=>ve(be.target.value),onPaste:Me,onKeyDown:Ce,enterKeyHint:R?"send":"enter",autoCapitalize:"none",autoComplete:"off",autoCorrect:"off",spellCheck:!1,placeholder:Ge,className:"flex-1 resize-none rounded-none border-0 bg-transparent font-normal shadow-none max-h-60 min-h-11 focus-visible:border-0 focus-visible:ring-0 md:min-h-0 dark:bg-transparent",style:{fontSize:w},rows:1,"aria-label":"输入聊天消息","aria-busy":V}),g.jsxs("div",{className:"self-stretch relative flex items-center gap-1 p-1.5 md:p-1 before:absolute before:inset-y-2 before:left-0 before:w-px before:bg-gradient-to-b before:from-transparent before:via-border before:to-transparent","data-slot":"input-actions",children:[g.jsx(kke,{open:ct,onOpenChange:Ot,isDesktop:k,onPickImage:()=>{var be;Ot(!1),(be=Qe.current)==null||be.click()},onPickFile:()=>{var be;Ot(!1),(be=Ve.current)==null||be.click()}}),g.jsx(yCe,{isWorking:H,canSend:M,canQueue:B,onSend:me,onQueue:te})]})]})]}),g.jsx("input",{ref:Qe,type:"file",accept:t.mediaAccept,className:"hidden","data-slot":"input-attach-image-input",onChange:be=>{ye(be)}}),g.jsx("input",{ref:Ve,type:"file",accept:t.fileAccept,className:"hidden","data-slot":"input-attach-file-input",onChange:be=>{ye(be)}})]})}function kke({open:e,onOpenChange:t,isDesktop:n,onPickImage:r,onPickFile:i}){const s=g.jsx(_t,{type:"button",variant:"ghost",size:"icon",className:"size-11 md:size-9","aria-label":"附加","data-slot":"input-attach-button",children:g.jsx(Y8,{"aria-hidden":"true"})});return n?g.jsxs(R1,{open:e,onOpenChange:t,children:[g.jsx(A1,{asChild:!0,children:s}),g.jsx(N1,{align:"end",className:"w-44 p-1",children:g.jsx(xD,{variant:"popover",onPickImage:r,onPickFile:i})})]}):g.jsxs(Xv,{open:e,onOpenChange:t,children:[g.jsx(yie,{asChild:!0,children:s}),g.jsxs(Zv,{side:"bottom",showCloseButton:!1,className:"h-auto gap-0 rounded-t-xl bg-popover pt-2 pb-[max(theme(spacing.2),env(safe-area-inset-bottom))] border-t-0","data-slot":"attach-menu-sheet",focusSurfaceOnOpen:!0,children:[g.jsx(sI,{children:g.jsx(Qv,{children:"附加内容"})}),g.jsx("div",{"aria-hidden":"true",className:"mx-auto mb-1 h-1 w-10 rounded-full bg-border","data-slot":"sheet-drag-handle"}),g.jsx(xD,{variant:"sheet",onPickImage:r,onPickFile:i})]})]})}function xD({variant:e,onPickImage:t,onPickFile:n}){const s=`flex w-full items-center gap-2 rounded-sm text-left text-sm hover:bg-accent hover:text-accent-foreground ${e==="sheet"?"h-12":"h-9"} ${e==="sheet"?"px-4":"px-2"}`;return g.jsxs("div",{className:"flex flex-col","data-slot":"input-attach-menu",children:[g.jsxs("button",{type:"button",className:s,"data-slot":"input-attach-menu-image",onClick:t,children:[g.jsx(Lf,{"aria-hidden":"true",className:"size-4"}),"上传照片或视频"]}),g.jsxs("button",{type:"button",className:s,"data-slot":"input-attach-menu-file",onClick:n,children:[g.jsx(zP,{"aria-hidden":"true",className:"size-4"}),"上传文件"]})]})}function ED(e){return SD+=1,`${e}-attachment-${SD}`}function CD(e){return e.type.startsWith("image/")?!0:/\.(?:avif|bmp|gif|heic|heif|jpe?g|png|webp)$/i.test(e.name)}function Tke({sessionId:e}){const t=Qt(r=>{var i;return((i=r.bySessionId[e])==null?void 0:i.quotedMessage)??null}),n=Qt(r=>r.setQuotedMessage);return t?g.jsx("div",{className:"dev-render-scroll dev-chat-rail-inset overflow-x-hidden overflow-y-auto py-2 bg-muted border-t border-border","data-slot":"quote-preview-bar",children:g.jsxs("div",{className:"dev-message-rail mx-auto flex w-full items-start gap-2",children:[g.jsxs("div",{className:"flex-1 min-w-0",children:[g.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:t.from==="assistant"?"Agent:":"You:"}),g.jsx("div",{className:"text-xs line-clamp-2",children:t.text})]}),g.jsx(_t,{variant:"ghost",size:"icon-xs",onClick:()=>n(e,null),"aria-label":"取消引用",children:g.jsx(vc,{"aria-hidden":"true"})})]})}):null}const Rke={idle:"会话空闲",working:"正在响应",compacting:"正在压缩上下文",waiting_approval:"等待工具审批",error:"会话连接异常",terminated:"会话已终止",disconnected:"连接已断开"};function Ake({state:e}){return g.jsxs("div",{className:`dev-status-line dev-status-line-${e}`,"data-slot":"status-line","data-state":e,role:"status","aria-label":Rke[e],children:[e==="idle"&&g.jsx("div",{className:"dev-status-line-sweep dev-status-line-sweep-idle"}),e==="working"&&g.jsx("div",{className:"dev-status-line-sweep dev-status-line-sweep-working"}),e==="compacting"&&g.jsx("div",{className:"dev-status-line-sweep dev-status-line-sweep-compacting"}),e==="waiting_approval"&&g.jsx("div",{className:"dev-status-line-sweep dev-status-line-sweep-waiting"})]})}function Nke({autoYesEnabled:e,onAutoYesChange:t}){return g.jsxs("div",{role:"status","aria-live":"polite","aria-label":"等待审批","data-slot":"pty-approval-hint",className:"dev-pty-approval-hint",children:[g.jsx("span",{className:"dev-pty-approval-hint-label",children:"等待审批"}),g.jsx("button",{type:"button","aria-pressed":e,className:"dev-pty-approval-auto-yes",onClick:()=>t(!e),children:"Always yes"})]})}const Mke={code:"这条回复包含代码,我先概括:它给出了一段实现或配置,请查看屏幕确认细节。",table:"这条回复包含表格,我先概括主要结论,请查看屏幕确认具体行列。",diff:"这条回复包含代码变更,我先概括:请查看屏幕确认具体修改。",log:"这条回复包含日志,我先概括关键状态,请查看屏幕确认原始输出。",stack_trace:"这条回复包含错误堆栈,我先概括问题方向,请查看屏幕确认调用位置。",long_list:"这条回复包含较长列表,我先概括结构,请查看屏幕确认每一项。",long_text:"这条回复内容较长,我先概括重点,请查看屏幕确认完整细节。",mixed:"这条回复包含不适合直接朗读的内容,我先概括重点,请查看屏幕确认细节。",approval:"有一个工具操作正在等待审批,请查看屏幕确认细节。"};function kD(e){return Mke[e]}class Oke{constructor(t){yt(this,"options");yt(this,"state","armed");yt(this,"preRoll",[]);yt(this,"preRollBytes",0);yt(this,"pending",[]);yt(this,"pendingBytes",0);yt(this,"stream",null);yt(this,"speechEnded",!1);this.options=t}pushFrame(t){var n;if(this.state==="armed"){this.appendPreRoll(t);return}if(this.state==="opening"){this.appendPending(t);return}this.state==="streaming"&&((n=this.stream)==null||n.send(t))}speechStarted(){this.state==="armed"&&(this.state="opening",this.pending=this.preRoll,this.pendingBytes=this.preRollBytes,this.preRoll=[],this.preRollBytes=0,this.options.openStream().then(t=>{if(this.state==="cancelled"){t.abort();return}if(this.state!=="opening"){t.abort();return}this.stream=t;for(const n of this.pending)t.send(n);if(this.pending=[],this.pendingBytes=0,this.speechEnded){this.state="finishing",t.finish(),this.state="complete";return}this.state="streaming"}).catch(t=>{this.state!=="cancelled"&&(this.state="complete",this.pending=[],this.pendingBytes=0,this.options.onError(t))}))}speechFinished(){var t;this.state==="armed"||this.state==="complete"||this.state==="cancelled"||(this.speechEnded=!0,this.state==="streaming"&&(this.state="finishing",(t=this.stream)==null||t.finish(),this.state="complete"))}cancel(){var n;if(this.state==="cancelled")return;const t=this.state!=="complete";this.state="cancelled",this.preRoll=[],this.preRollBytes=0,this.pending=[],this.pendingBytes=0,t&&((n=this.stream)==null||n.abort()),this.stream=null}rearm(){return this.state!=="complete"?!1:(this.state="armed",this.preRoll=[],this.preRollBytes=0,this.pending=[],this.pendingBytes=0,this.stream=null,this.speechEnded=!1,!0)}snapshot(){return{state:this.state,preRollBytes:this.preRollBytes,pendingBytes:this.pendingBytes,speechEnded:this.speechEnded}}appendPreRoll(t){const n=t.slice();for(this.preRoll.push(n),this.preRollBytes+=n.byteLength;this.preRollBytes>this.options.preRollBytes&&this.preRoll.length>1;){const r=this.preRoll.shift();this.preRollBytes-=(r==null?void 0:r.byteLength)??0}}appendPending(t){const n=t.slice();this.pending.push(n),this.pendingBytes+=n.byteLength}}const Dke=1e4,Pke=5e3,Lke=32*1024;function Ike(e){if(typeof e!="string")return null;try{const t=aX.safeParse(JSON.parse(e));return t.success?t.data:null}catch{return null}}class zke{constructor(t){yt(this,"options");yt(this,"socket",null);yt(this,"connectionPromise",null);yt(this,"activeAttempt",null);yt(this,"disposed",!1);this.options={...t,readyTimeoutMs:t.readyTimeoutMs??Dke,completionTimeoutMs:t.completionTimeoutMs??Pke,inFlightWindowBytes:t.inFlightWindowBytes??Lke}}connect(){var r;if(this.disposed)return Promise.reject(new Error("语音识别连接已关闭"));if(((r=this.socket)==null?void 0:r.readyState)===WebSocket.OPEN)return Promise.resolve();if(this.connectionPromise)return this.connectionPromise;const t=(this.options.createSocket??(i=>new WebSocket(i)))(this.options.url);this.socket=t;const n=new Promise((i,s)=>{let o=!1;const l=()=>{o||(o=!0,s(new Error("语音识别连接不可用")))};t.addEventListener("open",()=>{if(this.socket!==t||this.disposed){l();return}o=!0,this.trace("socket-open",{}),i()}),t.addEventListener("message",u=>this.handleMessage(t,u.data)),t.addEventListener("close",u=>{if(this.socket!==t)return;this.socket=null,l();const d=this.activeAttempt!==null;this.failActiveAttempt("语音识别连接已断开"),!this.disposed&&!d&&this.options.onTransportError("语音识别连接已断开"),this.trace("socket-closed",{code:u.code,reason:u.reason,wasClean:u.wasClean})}),t.addEventListener("error",()=>{this.socket===t&&(l(),this.trace("socket-error",{}))})}).finally(()=>{this.connectionPromise===n&&(this.connectionPromise=null)});return this.connectionPromise=n,n}async startAttempt(t){var u;await this.connect();const n=this.socket;if(!n||n.readyState!==WebSocket.OPEN)throw new Error("语音识别连接不可用");(u=this.activeAttempt)==null||u.publicAttempt.abort();let r,i;const s=new Promise((d,h)=>{r=d,i=h}),o={},l={attemptId:t.attemptId,send:d=>this.enqueue(o,d),finish:()=>this.finish(o),abort:()=>this.abort(o),snapshot:()=>this.snapshot(o)};return Object.assign(o,{options:t,queue:[],queuedBytes:0,sentBytes:0,acknowledgedBytes:0,acknowledgedPcmBytes:0,acknowledgedChunks:0,ready:!1,finishRequested:!1,stopSent:!1,terminal:!1,completionTimeoutId:null,resolveReady:r,rejectReady:i,publicAttempt:l,readyTimeoutId:window.setTimeout(()=>{this.activeAttempt!==o||o.ready||o.terminal||this.failAttempt(o,"语音识别服务准备超时")},this.options.readyTimeoutMs)}),this.activeAttempt=o,n.send(JSON.stringify({type:"start",...t})),this.trace("attempt-start-sent",{attemptId:t.attemptId,encoding:t.encoding}),s}dispose(){var n;if(this.disposed)return;this.disposed=!0,(n=this.activeAttempt)==null||n.publicAttempt.abort(),this.activeAttempt=null;const t=this.socket;this.socket=null,t==null||t.close()}handleMessage(t,n){if(this.socket!==t)return;const r=Ike(n);if(!r){this.trace("invalid-message",{});return}const i=this.activeAttempt;if(!i||i.options.attemptId!==r.attemptId){this.trace("stale-message",{attemptId:r.attemptId,activeAttemptId:(i==null?void 0:i.options.attemptId)??null,messageType:r.type});return}switch(r.type){case"ready":if(i.ready||i.terminal)return;i.ready=!0,window.clearTimeout(i.readyTimeoutId),i.resolveReady(i.publicAttempt),this.trace("attempt-ready",{attemptId:r.attemptId}),this.pump(i);return;case"audio_ack":i.acknowledgedBytes=Math.max(i.acknowledgedBytes,Math.min(r.encodedBytes,i.sentBytes)),i.acknowledgedPcmBytes=Math.max(i.acknowledgedPcmBytes,r.pcmBytes),i.acknowledgedChunks=Math.max(i.acknowledgedChunks,r.chunks),this.pump(i);return;case"partial":this.options.onPartial(r.text,r.attemptId),this.refreshCompletionTimeout(i);return;case"final":this.options.onFinal(r.text,r.attemptId),this.refreshCompletionTimeout(i);return;case"closed":if(!i.ready){this.failAttempt(i,"语音识别连接已断开");return}if(!i.finishRequested){this.failAttempt(i,"语音识别连接已断开");return}this.completeAttempt(i,"closed");return;case"error":this.failAttempt(i,r.error??"语音识别失败");return}}enqueue(t,n){if(this.activeAttempt!==t||t.terminal||t.finishRequested)return;const r=n.slice();t.queue.push(r),t.queuedBytes+=r.byteLength,this.pump(t)}finish(t){this.activeAttempt!==t||t.terminal||t.finishRequested||(t.finishRequested=!0,this.pump(t))}abort(t){if(!t.terminal&&(t.terminal=!0,t.queue=[],t.queuedBytes=0,window.clearTimeout(t.readyTimeoutId),t.completionTimeoutId!==null&&(window.clearTimeout(t.completionTimeoutId),t.completionTimeoutId=null),t.ready||t.rejectReady(new Error("语音识别已取消")),this.activeAttempt===t)){const n=this.socket;(n==null?void 0:n.readyState)===WebSocket.OPEN&&n.send(JSON.stringify({type:"stop",attemptId:t.options.attemptId})),this.activeAttempt=null}}pump(t){if(this.activeAttempt!==t||!t.ready||t.terminal)return;const n=this.socket;if(!(!n||n.readyState!==WebSocket.OPEN)){for(;t.queue.length>0;){const r=t.queue[0];if(!r)break;const i=t.sentBytes-t.acknowledgedBytes;if(i>0&&i+r.byteLength>this.options.inFlightWindowBytes)break;t.queue.shift(),t.queuedBytes-=r.byteLength,t.sentBytes+=r.byteLength,n.send(r)}t.finishRequested&&t.queue.length===0&&!t.stopSent&&(t.stopSent=!0,n.send(JSON.stringify({type:"stop",attemptId:t.options.attemptId})),this.trace("attempt-stop-sent",{...this.snapshot(t)}),this.refreshCompletionTimeout(t))}}refreshCompletionTimeout(t){this.activeAttempt!==t||t.terminal||!t.finishRequested||!t.stopSent||(t.completionTimeoutId!==null&&window.clearTimeout(t.completionTimeoutId),t.completionTimeoutId=window.setTimeout(()=>{this.activeAttempt!==t||t.terminal||(this.trace("attempt-completion-timeout",{...this.snapshot(t)}),this.completeAttempt(t,"timeout"))},this.options.completionTimeoutMs))}completeAttempt(t,n){var r,i;t.terminal||(t.terminal=!0,window.clearTimeout(t.readyTimeoutId),t.completionTimeoutId!==null&&(window.clearTimeout(t.completionTimeoutId),t.completionTimeoutId=null),this.activeAttempt===t&&(this.activeAttempt=null),(i=(r=this.options).onAttemptComplete)==null||i.call(r,t.options.attemptId,n))}failActiveAttempt(t){const n=this.activeAttempt;n&&this.failAttempt(n,t)}failAttempt(t,n){t.terminal||(t.terminal=!0,window.clearTimeout(t.readyTimeoutId),t.completionTimeoutId!==null&&(window.clearTimeout(t.completionTimeoutId),t.completionTimeoutId=null),t.ready?this.options.onAttemptError(n,t.options.attemptId):t.rejectReady(new Error(n)),this.activeAttempt===t&&(this.activeAttempt=null))}snapshot(t){return{attemptId:t.options.attemptId,queuedBytes:t.queuedBytes,sentBytes:t.sentBytes,acknowledgedBytes:t.acknowledgedBytes,acknowledgedPcmBytes:t.acknowledgedPcmBytes,acknowledgedChunks:t.acknowledgedChunks,finishRequested:t.finishRequested,stopSent:t.stopSent}}trace(t,n){var r,i;(i=(r=this.options).onTrace)==null||i.call(r,t,n)}}const Bke=900;function jke(e){const t=e.split(`
690
+ `)}function LCe(e){return e.historyLoading&&e.historyHasMore?"loading+more":e.historyLoading?"loading":e.historyHasMore?"more":""}function ICe(e,t){return e===void 0||t===void 0?"":`${e}..${t}`}const yD=50,zCe=96;function BCe({sessionId:e,findRequest:t}){const n=Qt(ze=>{var et;return((et=ze.bySessionId[e])==null?void 0:et.messages)??qs.messages}),r=Qt(ze=>{var et;return((et=ze.bySessionId[e])==null?void 0:et.historyHasMore)??qs.historyHasMore}),i=Qt(ze=>{var et;return((et=ze.bySessionId[e])==null?void 0:et.historyNextBefore)??qs.historyNextBefore}),s=Qt(ze=>{var et;return((et=ze.bySessionId[e])==null?void 0:et.historyLoading)??qs.historyLoading}),o=Qt(ze=>ze.setHistoryLoading),l=Qt(ze=>{var et;return((et=ze.bySessionId[e])==null?void 0:et.pendingApprovals)??qs.pendingApprovals}),u=$t(ze=>{var et;return((et=ze.sessions.find(Et=>Et.sessionId===e))==null?void 0:et.state)==="working"}),d=Ne(ze=>ze.connected),h=Ne(ze=>ze.proxyOnline),p=Ne(ze=>ze.chatContentFontSize),y=Ne(ze=>ze.inputModePreference==="hardware"),_=ul("(pointer: coarse), (hover: none)")&&!y,w=Ix(p,_),[x,E]=b.useState(null),{isAtBottom:k,scrollToBottom:R}=_Ce(x),[A,I]=b.useState(!1),[T,H]=b.useState(()=>a0()),[D,W]=b.useState(!1),[U,F]=b.useState(!1),[O,M]=b.useState(""),[B,L]=b.useState(null),[N,V]=b.useState(!1),[Y,$]=b.useState(!1),P=b.useRef(0),q=b.useRef(!1),K=b.useRef(null),z=b.useRef(null),X=b.useRef(()=>{}),ee=b.useRef({hasMore:r,nextBefore:i,loading:s});b.useEffect(()=>{ee.current={hasMore:r,nextBefore:i,loading:s}},[r,i,s]),b.useEffect(()=>{const ze=()=>{H(a0())};return ze(),window.addEventListener("hashchange",ze),window.addEventListener("popstate",ze),()=>{window.removeEventListener("hashchange",ze),window.removeEventListener("popstate",ze)}},[]);const te=age(),Q=y?0:te,me=b.useRef(k);b.useEffect(()=>{me.current=k},[k]),b.useEffect(()=>{if(!x||!me.current)return;const ze=requestAnimationFrame(()=>{x.scrollTop=x.scrollHeight});return()=>cancelAnimationFrame(ze)},[Q,x]),b.useEffect(()=>{const ze=Pt;if(!ze||!e||!d||!h)return;ze.sendControl({type:"session_subscribe",sessionId:e});const et=Qt.getState().bySessionId[e];et!=null&&et.historyLoading||et!=null&&et.historyInitialized||(X.current("history-initial:request"),o(e,!0),ze.requestSessionMessagesPage(e,{limit:yD}).then(Et=>{X.current("history-initial:response",{historyHasMore:Et.hasMore}),Qt.getState().loadHistoryPage(e,{mode:"replace",messages:Et.messages,hasMore:Et.hasMore,nextBefore:Et.nextBefore})}).catch(()=>Qt.getState().setHistoryLoading(e,!1)))},[e,d,h,o]);const ve=b.useCallback(()=>{const ze=Pt,et=ee.current;!ze||!e||!d||!h||!et.hasMore||!et.nextBefore||et.loading||(ee.current={...et,loading:!0},K.current={previousScrollHeight:(x==null?void 0:x.scrollHeight)??0},X.current("history-prepend:request"),o(e,!0),ze.requestSessionMessagesPage(e,{limit:yD,before:et.nextBefore}).then(Et=>{X.current("history-prepend:response",{historyHasMore:Et.hasMore}),Qt.getState().loadHistoryPage(e,{mode:"prepend",messages:Et.messages,hasMore:Et.hasMore,nextBefore:Et.nextBefore})}).catch(()=>{X.current("history-prepend:error"),K.current=null,ee.current={...ee.current,loading:!1},Qt.getState().setHistoryLoading(e,!1)}))},[d,h,x,e,o]),Ce=b.useCallback(async()=>{const ze=Pt,et=Qt.getState().bySessionId[e];if(!ze||!d||!h||!(et!=null&&et.historyHasMore)||!et.historyNextBefore||q.current)return;const Et=++P.current;q.current=!0,V(!0),$(!1),o(e,!0),ee.current={hasMore:et.historyHasMore,nextBefore:et.historyNextBefore,loading:!0};let Bt=et.historyNextBefore,J=et.historyHasMore;const _e=new Set,Be=[];try{for(;J&&Bt;){if(_e.has(Bt))throw new Error(`History pagination repeated cursor: ${Bt}`);_e.add(Bt);const jt=await ze.requestSessionMessagesPage(e,{limit:200,before:Bt});if(Et!==P.current)return;if(Be.push(jt.messages),J=jt.hasMore,J&&!jt.nextBefore)throw new Error("History pagination omitted nextBefore while hasMore is true");Bt=jt.nextBefore}if(Et!==P.current)return;const ht=Be.reverse().flat();ee.current={hasMore:J,nextBefore:Bt??null,loading:!1},Qt.getState().loadHistoryPage(e,{mode:"prepend",messages:ht,hasMore:J,...Bt!==void 0?{nextBefore:Bt}:{}})}catch(ht){if(Et!==P.current)return;console.error("[chat-find] failed to load complete history",{sessionId:e},ht),Qt.getState().setHistoryLoading(e,!1),ee.current={...ee.current,loading:!1},$(!0),nt.error("搜索历史消息失败")}finally{Et===P.current&&(q.current=!1,V(!1))}},[d,h,e,o]),Me=b.useCallback(()=>{P.current+=1,q.current&&(q.current=!1,V(!1),ee.current={...ee.current,loading:!1},Qt.getState().setHistoryLoading(e,!1))},[e]);b.useEffect(()=>{!U||!O||Y||!r||s||N||Ce()},[Y,N,U,O,r,s,Ce]),b.useEffect(()=>()=>{P.current+=1,q.current&&Qt.getState().setHistoryLoading(e,!1)},[e]);const Ve=b.useCallback(()=>{x&&(X.current("scroll"),x.scrollTop<=zCe&&(X.current("scroll:top-threshold"),ve()))},[ve,x]),Qe=b.useCallback(ze=>{var et;return((et=n[ze])==null?void 0:et.id)??ze},[n]),ct=b.useCallback(ze=>ECe(n[ze],{fontSize:w,touchEditingSurface:_}),[w,n,_]),Ot=Sye({count:n.length,getScrollElement:()=>x,estimateSize:ct,overscan:_?8:5,getItemKey:Qe}),he=b.useMemo(()=>OCe(n,O),[O,n]),Ke=b.useMemo(()=>he.map(ze=>n[ze].id),[he,n]),Rt=b.useMemo(()=>new Set(Ke),[Ke]),ye=B?Ke.indexOf(B):-1;b.useEffect(()=>{if(!U||!O||he.length===0){L(null);return}L(ze=>{var J,_e;if(ze&&Rt.has(ze))return ze;const et=((J=Ot.getVirtualItems()[0])==null?void 0:J.index)??0,Et=he.findIndex(Be=>Be>=et),Bt=Et>=0?Et:0;return((_e=n[he[Bt]])==null?void 0:_e.id)??null})},[Rt,he,U,O,n,Ot]),b.useLayoutEffect(()=>{if(!B)return;const ze=n.findIndex(et=>et.id===B);ze<0||Ot.scrollToIndex(ze,{align:"center",behavior:"auto"})},[B,n,Ot]),b.useEffect(()=>{if(!B||!x)return;let ze=null;const et=()=>{ze!==null&&cancelAnimationFrame(ze),ze=requestAnimationFrame(()=>{var Bt;ze=null,(Bt=x.querySelector('[data-slot="message-row"][data-find-active="true"]'))==null||Bt.scrollIntoView({block:"center",inline:"nearest",behavior:"auto"})})},Et=new ResizeObserver(et);return Et.observe(x),et(),()=>{Et.disconnect(),ze!==null&&cancelAnimationFrame(ze)}},[B,x]);const He=b.useCallback(ze=>{if(Ke.length===0)return;const et=B?Ke.indexOf(B):-1,Et=ze==="next"?(et+1+Ke.length)%Ke.length:(et-1+Ke.length)%Ke.length;L(Ke[Et])},[B,Ke]),Ge=b.useCallback(()=>{$(!1),F(!0)},[]),be=b.useCallback(()=>{Me(),F(!1),L(null)},[Me]),Xe=b.useCallback(()=>He("previous"),[He]),rt=b.useCallback(()=>He("next"),[He]),pt=L3({open:U,openRequest:t,onOpen:Ge,onClose:be,onPrevious:Xe,onNext:rt}),le=b.useCallback(ze=>{M(ze),$(!1),ze||(Me(),L(null))},[Me]),Ae=b.useCallback((ze,et={})=>{var ie,de;if(!a0())return;const Et=x,Bt=Ot.getVirtualItems(),J=Bt[0],_e=Bt[Bt.length-1],Be=z.current,ht=(Et==null?void 0:Et.scrollTop)??0,jt=(Et==null?void 0:Et.scrollHeight)??0,re=window.visualViewport;DCe({t:performance.now(),event:ze,scrollTop:ht,scrollHeight:jt,clientHeight:(Et==null?void 0:Et.clientHeight)??0,innerHeight:window.innerHeight,visualViewportHeight:re==null?void 0:re.height,visualViewportOffsetTop:re==null?void 0:re.offsetTop,messageCount:n.length,totalSize:Ot.getTotalSize(),firstIndex:J==null?void 0:J.index,lastIndex:_e==null?void 0:_e.index,firstStart:J==null?void 0:J.start,lastEnd:_e==null?void 0:_e.end,focus:((ie=document.activeElement)==null?void 0:ie.getAttribute("aria-label"))??((de=document.activeElement)==null?void 0:de.tagName)??null,atBottom:me.current,historyLoading:ee.current.loading,historyHasMore:ee.current.hasMore,preservePrepend:!!K.current,scrollDelta:Be?ht-Be.scrollTop:void 0,scrollHeightDelta:Be?jt-Be.scrollHeight:void 0,...et}),z.current={scrollTop:ht,scrollHeight:jt}},[n.length,x,Ot]);b.useEffect(()=>{X.current=Ae},[Ae]);const Ze=n[n.length-1],tt=b.useRef(n.length);b.useEffect(()=>{tt.current=n.length},[n.length]),b.useLayoutEffect(()=>{Ot.measure(),X.current("virtualizer:measure");const ze=tt.current;if(!x||!me.current||ze===0)return;let et=0;const Et=requestAnimationFrame(()=>{et=requestAnimationFrame(()=>{Ot.scrollToIndex(ze-1,{align:"end",behavior:"auto"})})});return()=>{cancelAnimationFrame(Et),cancelAnimationFrame(et)}},[w,x,Ot]),b.useLayoutEffect(()=>{const ze=K.current;if(!x||!ze)return;X.current("prepend-preserve:start");let et=0;const Et=requestAnimationFrame(()=>{Ot.measure(),et=requestAnimationFrame(()=>{const Bt=x.scrollHeight-ze.previousScrollHeight;X.current("prepend-preserve:apply",{scrollHeightDelta:Bt}),Bt>0&&(x.scrollTop+=Bt),X.current("prepend-preserve:after-scroll",{scrollHeightDelta:Bt}),K.current=null})});return()=>{cancelAnimationFrame(Et),cancelAnimationFrame(et)}},[n.length,x,Ot]);const dt=b.useRef(!1);b.useEffect(()=>{dt.current=!1,W(!1),F(!1),M(""),L(null),V(!1),$(!1),q.current=!1},[e]),b.useLayoutEffect(()=>{if(!x||n.length===0||dt.current)return;dt.current=!0;const ze=()=>{x.scrollTop=x.scrollHeight,X.current("initial-pin")};ze();const et=requestAnimationFrame(()=>{ze(),requestAnimationFrame(ze)});return I(!1),()=>cancelAnimationFrame(et)},[x,n.length]);const Dt=b.useRef(k);b.useEffect(()=>{Dt.current=k,k&&I(!1)},[k]),b.useEffect(()=>{if(!dt.current||n.length===0||U&&O||K.current)return;const ze=MCe(Ze);Dt.current||ze?(X.current(ze?"follow-voice-transcript":"follow-output"),Ot.scrollToIndex(n.length-1,{align:"end",behavior:"auto"})):(X.current("new-message-while-away"),I(!0))},[U,O,n.length,Ze==null?void 0:Ze.text]);const Wt=l.filter(ze=>ze.status==="pending"),tn=Wt.length>0;b.useEffect(()=>{u||W(!1)},[u]);const vn=b.useCallback(()=>{if(D)return;W(!0),((Pt==null?void 0:Pt.sendControl({type:"session_worker_abort",sessionId:e}))===!1||!Pt)&&W(!1)},[e,D]),un=NCe({messages:n,isWorking:u,hasPendingApprovals:tn}),Zt=u&&!tn?g.jsx(bCe,{isStopping:D,onStop:vn}):null,Xn=un.showThinking,Kt=n.some(ze=>ze.id.startsWith(`history-${e}-`)),Zn=!!O&&(N||s);return n.length===0&&!tn?g.jsxs("div",{className:"relative h-full",children:[g.jsx(tc,{variant:"no-messages"}),U?g.jsx(X0,{query:O,resultIndex:ye,resultCount:Ke.length,focusRequest:pt.focusRequest,loading:Zn,onQueryChange:le,onPrevious:Xe,onNext:rt,onClose:pt.closeFind}):null]}):g.jsxs("div",{className:"flex flex-col h-full",children:[g.jsxs("div",{className:"flex-1 relative min-h-0",children:[U?g.jsx(X0,{query:O,resultIndex:ye,resultCount:Ke.length,focusRequest:pt.focusRequest,loading:Zn,onQueryChange:le,onPrevious:Xe,onNext:rt,onClose:pt.closeFind}):null,g.jsx("div",{ref:E,className:"dev-render-scroll absolute inset-0 overflow-auto","data-slot":"message-list",onScroll:Ve,children:x&&g.jsxs("div",{className:"flex flex-col min-h-full",children:[g.jsx("div",{className:"flex-1","aria-hidden":!0}),(s||r||Kt)&&g.jsx("div",{className:"mx-auto flex min-h-10 w-full max-w-[var(--dev-message-rail-width)] items-center justify-center px-4 py-2 text-xs text-muted-foreground","data-slot":"history-scrollback-status",children:s?"正在加载更早消息...":r?"继续上滑加载更早消息":"已到最早记录"}),g.jsx("div",{style:{height:Ot.getTotalSize(),position:"relative",width:"100%"},children:Ot.getVirtualItems().map(ze=>{const et=n[ze.index];return g.jsx("div",{"data-index":ze.index,ref:Ot.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${ze.start}px)`},children:g.jsx(hCe,{message:et,contentFontSize:w,findState:(et==null?void 0:et.id)===B?"active":et&&Rt.has(et.id)?"match":void 0,turnControl:(et==null?void 0:et.id)===un.messageId?Zt:void 0})},ze.key)})}),Xn&&g.jsx(vCe,{turnControl:Zt})]})}),g.jsx(O3,{visible:!k,hasNewMessages:A,className:U?"top-14":void 0,onClick:()=>{Ot.scrollToIndex(Math.max(n.length-1,0),{align:"end",behavior:"smooth"}),R(),I(!1)}}),T?g.jsx(jCe,{}):null]}),tn&&g.jsxs("div",{className:"dev-render-scroll dev-chat-rail-inset flex flex-col gap-2 overflow-x-hidden overflow-y-auto py-2","aria-live":"polite",children:[Wt.length>1&&g.jsxs("div",{className:"dev-message-rail mx-auto w-full min-w-0 px-1 text-xs text-muted-foreground",children:[Wt.length," 个工具审批待处理"]}),Wt.map((ze,et)=>g.jsx(gCe,{approval:ze,sessionId:e,container:"inline",queuePosition:et+1,queueSize:Wt.length},ze.requestId))]})]})}function jCe(){const[e,t]=b.useState(!1);async function n(){const r=PCe();try{await navigator.clipboard.writeText(r),t(!0),window.setTimeout(()=>t(!1),1200)}catch{window.prompt("Copy JSON scroll trace",r)}}return g.jsx("button",{type:"button",className:"absolute left-3 bottom-3 z-30 rounded border border-[#4A4A4A] bg-[#1E1E1E]/90 px-2 py-1 text-[11px] text-[#C8C8C8]",onClick:n,"data-slot":"json-scroll-trace-copy",children:e?"Copied":"Trace"})}function FCe({className:e,...t}){return g.jsx("textarea",{"data-slot":"textarea",className:Ye("flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground 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 md:text-sm dark:bg-input/30 dark:aria-invalid:ring-destructive/40",e),...t})}function $Ce(e,t){return!!(e||t.some(n=>n.status==="pending"))}function HCe(e){const t=e.lastIndexOf("@");return t<0||t>0&&e[t-1]!==" "?!1:!e.slice(t+1).includes(" ")}function UCe(e){return e?HCe(e)?"file":e.startsWith("/")&&!e.slice(1).includes(" ")?"slash":"none":"none"}function WCe(e,t){return[e.trim(),...t.map(r=>`@${r.path}`)].filter(Boolean).join(" ")}function qCe(e,t,n){if(e.length>=t.length||n.length===0)return{cleaned:e,removedMention:null};for(const r of n)if(t.includes(r)&&!e.includes(r)){let i=e;for(let s=r.length-1;s>0;s--){const o=r.slice(0,s);if(i.endsWith(o)){i=i.slice(0,-o.length),i.endsWith(" ")&&(i=i.slice(0,-1));break}}return{cleaned:i,removedMention:r}}return{cleaned:e,removedMention:null}}var bD=1,VCe=.9,YCe=.8,KCe=.17,l0=.1,c0=.999,GCe=.9999,XCe=.99,ZCe=/[\\\/_+.#"@\[\(\{&]/,QCe=/[\\\/_+.#"@\[\(\{&]/g,JCe=/[\s-]/,TF=/[\s-]/g;function hx(e,t,n,r,i,s,o){if(s===t.length)return i===e.length?bD:XCe;var l=`${i},${s}`;if(o[l]!==void 0)return o[l];for(var u=r.charAt(s),d=n.indexOf(u,i),h=0,p,y,v,_;d>=0;)p=hx(e,t,n,r,d+1,s+1,o),p>h&&(d===i?p*=bD:ZCe.test(e.charAt(d-1))?(p*=YCe,v=e.slice(i,d-1).match(QCe),v&&i>0&&(p*=Math.pow(c0,v.length))):JCe.test(e.charAt(d-1))?(p*=VCe,_=e.slice(i,d-1).match(TF),_&&i>0&&(p*=Math.pow(c0,_.length))):(p*=KCe,i>0&&(p*=Math.pow(c0,d-i))),e.charAt(d)!==t.charAt(s)&&(p*=GCe)),(p<l0&&n.charAt(d-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(d-1)!==r.charAt(s))&&(y=hx(e,t,n,r,d+1,s+2,o),y*l0>p&&(p=y*l0)),p>h&&(h=p),d=n.indexOf(u,d+1);return o[l]=h,h}function _D(e){return e.toLowerCase().replace(TF," ")}function eke(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,hx(e,t,_D(e),_D(t),0,0,{})}var Ah='[cmdk-group=""]',u0='[cmdk-group-items=""]',tke='[cmdk-group-heading=""]',RF='[cmdk-item=""]',wD=`${RF}:not([aria-disabled="true"])`,fx="cmdk-item-select",ku="data-value",nke=(e,t,n)=>eke(e,t,n),AF=b.createContext(void 0),op=()=>b.useContext(AF),NF=b.createContext(void 0),HE=()=>b.useContext(NF),MF=b.createContext(void 0),OF=b.forwardRef((e,t)=>{let n=Tu(()=>{var K,z;return{search:"",value:(z=(K=e.value)!=null?K:e.defaultValue)!=null?z:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Tu(()=>new Set),i=Tu(()=>new Map),s=Tu(()=>new Map),o=Tu(()=>new Set),l=DF(e),{label:u,children:d,value:h,onValueChange:p,filter:y,shouldFilter:v,loop:_,disablePointerSelection:w=!1,vimBindings:x=!0,...E}=e,k=vi(),R=vi(),A=vi(),I=b.useRef(null),T=fke();pc(()=>{if(h!==void 0){let K=h.trim();n.current.value=K,H.emit()}},[h]),pc(()=>{T(6,M)},[]);let H=b.useMemo(()=>({subscribe:K=>(o.current.add(K),()=>o.current.delete(K)),snapshot:()=>n.current,setState:(K,z,X)=>{var ee,te,Q,me;if(!Object.is(n.current[K],z)){if(n.current[K]=z,K==="search")O(),U(),T(1,F);else if(K==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let ve=document.getElementById(A);ve?ve.focus():(ee=document.getElementById(k))==null||ee.focus()}if(T(7,()=>{var ve;n.current.selectedItemId=(ve=B())==null?void 0:ve.id,H.emit()}),X||T(5,M),((te=l.current)==null?void 0:te.value)!==void 0){let ve=z??"";(me=(Q=l.current).onValueChange)==null||me.call(Q,ve);return}}H.emit()}},emit:()=>{o.current.forEach(K=>K())}}),[]),D=b.useMemo(()=>({value:(K,z,X)=>{var ee;z!==((ee=s.current.get(K))==null?void 0:ee.value)&&(s.current.set(K,{value:z,keywords:X}),n.current.filtered.items.set(K,W(z,X)),T(2,()=>{U(),H.emit()}))},item:(K,z)=>(r.current.add(K),z&&(i.current.has(z)?i.current.get(z).add(K):i.current.set(z,new Set([K]))),T(3,()=>{O(),U(),n.current.value||F(),H.emit()}),()=>{s.current.delete(K),r.current.delete(K),n.current.filtered.items.delete(K);let X=B();T(4,()=>{O(),(X==null?void 0:X.getAttribute("id"))===K&&F(),H.emit()})}),group:K=>(i.current.has(K)||i.current.set(K,new Set),()=>{s.current.delete(K),i.current.delete(K)}),filter:()=>l.current.shouldFilter,label:u||e["aria-label"],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:k,inputId:A,labelId:R,listInnerRef:I}),[]);function W(K,z){var X,ee;let te=(ee=(X=l.current)==null?void 0:X.filter)!=null?ee:nke;return K?te(K,n.current.search,z):0}function U(){if(!n.current.search||l.current.shouldFilter===!1)return;let K=n.current.filtered.items,z=[];n.current.filtered.groups.forEach(ee=>{let te=i.current.get(ee),Q=0;te.forEach(me=>{let ve=K.get(me);Q=Math.max(ve,Q)}),z.push([ee,Q])});let X=I.current;L().sort((ee,te)=>{var Q,me;let ve=ee.getAttribute("id"),Ce=te.getAttribute("id");return((Q=K.get(Ce))!=null?Q:0)-((me=K.get(ve))!=null?me:0)}).forEach(ee=>{let te=ee.closest(u0);te?te.appendChild(ee.parentElement===te?ee:ee.closest(`${u0} > *`)):X.appendChild(ee.parentElement===X?ee:ee.closest(`${u0} > *`))}),z.sort((ee,te)=>te[1]-ee[1]).forEach(ee=>{var te;let Q=(te=I.current)==null?void 0:te.querySelector(`${Ah}[${ku}="${encodeURIComponent(ee[0])}"]`);Q==null||Q.parentElement.appendChild(Q)})}function F(){let K=L().find(X=>X.getAttribute("aria-disabled")!=="true"),z=K==null?void 0:K.getAttribute(ku);H.setState("value",z||void 0)}function O(){var K,z,X,ee;if(!n.current.search||l.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let te=0;for(let Q of r.current){let me=(z=(K=s.current.get(Q))==null?void 0:K.value)!=null?z:"",ve=(ee=(X=s.current.get(Q))==null?void 0:X.keywords)!=null?ee:[],Ce=W(me,ve);n.current.filtered.items.set(Q,Ce),Ce>0&&te++}for(let[Q,me]of i.current)for(let ve of me)if(n.current.filtered.items.get(ve)>0){n.current.filtered.groups.add(Q);break}n.current.filtered.count=te}function M(){var K,z,X;let ee=B();ee&&(((K=ee.parentElement)==null?void 0:K.firstChild)===ee&&((X=(z=ee.closest(Ah))==null?void 0:z.querySelector(tke))==null||X.scrollIntoView({block:"nearest"})),ee.scrollIntoView({block:"nearest"}))}function B(){var K;return(K=I.current)==null?void 0:K.querySelector(`${RF}[aria-selected="true"]`)}function L(){var K;return Array.from(((K=I.current)==null?void 0:K.querySelectorAll(wD))||[])}function N(K){let z=L()[K];z&&H.setState("value",z.getAttribute(ku))}function V(K){var z;let X=B(),ee=L(),te=ee.findIndex(me=>me===X),Q=ee[te+K];(z=l.current)!=null&&z.loop&&(Q=te+K<0?ee[ee.length-1]:te+K===ee.length?ee[0]:ee[te+K]),Q&&H.setState("value",Q.getAttribute(ku))}function Y(K){let z=B(),X=z==null?void 0:z.closest(Ah),ee;for(;X&&!ee;)X=K>0?dke(X,Ah):hke(X,Ah),ee=X==null?void 0:X.querySelector(wD);ee?H.setState("value",ee.getAttribute(ku)):V(K)}let $=()=>N(L().length-1),P=K=>{K.preventDefault(),K.metaKey?$():K.altKey?Y(1):V(1)},q=K=>{K.preventDefault(),K.metaKey?N(0):K.altKey?Y(-1):V(-1)};return b.createElement(Jt.div,{ref:t,tabIndex:-1,...E,"cmdk-root":"",onKeyDown:K=>{var z;(z=E.onKeyDown)==null||z.call(E,K);let X=K.nativeEvent.isComposing||K.keyCode===229;if(!(K.defaultPrevented||X))switch(K.key){case"n":case"j":{x&&K.ctrlKey&&P(K);break}case"ArrowDown":{P(K);break}case"p":case"k":{x&&K.ctrlKey&&q(K);break}case"ArrowUp":{q(K);break}case"Home":{K.preventDefault(),N(0);break}case"End":{K.preventDefault(),$();break}case"Enter":{K.preventDefault();let ee=B();if(ee){let te=new Event(fx);ee.dispatchEvent(te)}}}}},b.createElement("label",{"cmdk-label":"",htmlFor:D.inputId,id:D.labelId,style:mke},u),py(e,K=>b.createElement(NF.Provider,{value:H},b.createElement(AF.Provider,{value:D},K))))}),rke=b.forwardRef((e,t)=>{var n,r;let i=vi(),s=b.useRef(null),o=b.useContext(MF),l=op(),u=DF(e),d=(r=(n=u.current)==null?void 0:n.forceMount)!=null?r:o==null?void 0:o.forceMount;pc(()=>{if(!d)return l.item(i,o==null?void 0:o.id)},[d]);let h=PF(i,s,[e.value,e.children,s],e.keywords),p=HE(),y=fl(T=>T.value&&T.value===h.current),v=fl(T=>d||l.filter()===!1?!0:T.search?T.filtered.items.get(i)>0:!0);b.useEffect(()=>{let T=s.current;if(!(!T||e.disabled))return T.addEventListener(fx,_),()=>T.removeEventListener(fx,_)},[v,e.onSelect,e.disabled]);function _(){var T,H;w(),(H=(T=u.current).onSelect)==null||H.call(T,h.current)}function w(){p.setState("value",h.current,!0)}if(!v)return null;let{disabled:x,value:E,onSelect:k,forceMount:R,keywords:A,...I}=e;return b.createElement(Jt.div,{ref:na(s,t),...I,id:i,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!y,"data-disabled":!!x,"data-selected":!!y,onPointerMove:x||l.getDisablePointerSelection()?void 0:w,onClick:x?void 0:_},e.children)}),ike=b.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...s}=e,o=vi(),l=b.useRef(null),u=b.useRef(null),d=vi(),h=op(),p=fl(v=>i||h.filter()===!1?!0:v.search?v.filtered.groups.has(o):!0);pc(()=>h.group(o),[]),PF(o,l,[e.value,e.heading,u]);let y=b.useMemo(()=>({id:o,forceMount:i}),[i]);return b.createElement(Jt.div,{ref:na(l,t),...s,"cmdk-group":"",role:"presentation",hidden:p?void 0:!0},n&&b.createElement("div",{ref:u,"cmdk-group-heading":"","aria-hidden":!0,id:d},n),py(e,v=>b.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?d:void 0},b.createElement(MF.Provider,{value:y},v))))}),ske=b.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=b.useRef(null),s=fl(o=>!o.search);return!n&&!s?null:b.createElement(Jt.div,{ref:na(i,t),...r,"cmdk-separator":"",role:"separator"})}),oke=b.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,s=HE(),o=fl(d=>d.search),l=fl(d=>d.selectedItemId),u=op();return b.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),b.createElement(Jt.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":u.listId,"aria-labelledby":u.labelId,"aria-activedescendant":l,id:u.inputId,type:"text",value:i?e.value:o,onChange:d=>{i||s.setState("search",d.target.value),n==null||n(d.target.value)}})}),ake=b.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...i}=e,s=b.useRef(null),o=b.useRef(null),l=fl(d=>d.selectedItemId),u=op();return b.useEffect(()=>{if(o.current&&s.current){let d=o.current,h=s.current,p,y=new ResizeObserver(()=>{p=requestAnimationFrame(()=>{let v=d.offsetHeight;h.style.setProperty("--cmdk-list-height",v.toFixed(1)+"px")})});return y.observe(d),()=>{cancelAnimationFrame(p),y.unobserve(d)}}},[]),b.createElement(Jt.div,{ref:na(s,t),...i,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":r,id:u.listId},py(e,d=>b.createElement("div",{ref:na(o,u.listInnerRef),"cmdk-list-sizer":""},d)))}),lke=b.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:s,container:o,...l}=e;return b.createElement(s1,{open:n,onOpenChange:r},b.createElement(o1,{container:o},b.createElement(a1,{"cmdk-overlay":"",className:i}),b.createElement(l1,{"aria-label":e.label,"cmdk-dialog":"",className:s},b.createElement(OF,{ref:t,...l}))))}),cke=b.forwardRef((e,t)=>fl(n=>n.filtered.count===0)?b.createElement(Jt.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),uke=b.forwardRef((e,t)=>{let{progress:n,children:r,label:i="Loading...",...s}=e;return b.createElement(Jt.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},py(e,o=>b.createElement("div",{"aria-hidden":!0},o)))}),fy=Object.assign(OF,{List:ake,Item:rke,Input:oke,Group:ike,Separator:ske,Dialog:lke,Empty:cke,Loading:uke});function dke(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function hke(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function DF(e){let t=b.useRef(e);return pc(()=>{t.current=e}),t}var pc=typeof window>"u"?b.useEffect:b.useLayoutEffect;function Tu(e){let t=b.useRef();return t.current===void 0&&(t.current=e()),t}function fl(e){let t=HE(),n=()=>e(t.snapshot());return b.useSyncExternalStore(t.subscribe,n,n)}function PF(e,t,n,r=[]){let i=b.useRef(),s=op();return pc(()=>{var o;let l=(()=>{var d;for(let h of n){if(typeof h=="string")return h.trim();if(typeof h=="object"&&"current"in h)return h.current?(d=h.current.textContent)==null?void 0:d.trim():i.current}})(),u=r.map(d=>d.trim());s.value(e,l,u),(o=t.current)==null||o.setAttribute(ku,l),i.current=l}),i}var fke=()=>{let[e,t]=b.useState(),n=Tu(()=>new Map);return pc(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,i)=>{n.current.set(r,i),t({})}};function pke(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function py({asChild:e,children:t},n){return e&&b.isValidElement(t)?b.cloneElement(pke(t),{ref:t.ref},n(t.props.children)):n(t)}var mke={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function gke({className:e,...t}){return g.jsx(fy,{"data-slot":"command",className:Ye("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t})}function vke({className:e,...t}){return g.jsx(fy.List,{"data-slot":"command-list",className:Ye("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",e),...t})}function yke({...e}){return g.jsx(fy.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...e})}function bke({className:e,...t}){return g.jsx(fy.Item,{"data-slot":"command-item",className:Ye("relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",e),...t})}const _ke=b.forwardRef(function({filter:t,onSelect:n},r){var d;const i=Rv(h=>h.commands),s=b.useMemo(()=>{const h=t.toLowerCase().replace(/^\//,"");return h?i.filter(p=>p.name.toLowerCase().includes(h)):i},[i,t]),[o,l]=b.useState(0);b.useEffect(()=>l(0),[t]),b.useEffect(()=>{o>=s.length&&s.length>0&&l(s.length-1)},[s.length,o]),b.useImperativeHandle(r,()=>({handleKey(h){return s.length===0?!1:h.key==="ArrowDown"?(l(p=>Math.min(s.length-1,p+1)),!0):h.key==="ArrowUp"?(l(p=>Math.max(0,p-1)),!0):h.key==="Enter"&&!h.nativeEvent.isComposing?(n(s[o]),!0):!1}}),[s,o,n]);const u=(d=s[o])==null?void 0:d.name;return g.jsx("div",{className:"absolute bottom-full left-0 right-0 mb-2 bg-popover border border-border rounded-md shadow-lg z-10 overflow-hidden","data-slot":"slash-command-picker",children:g.jsx(gke,{shouldFilter:!1,value:u,children:g.jsxs(vke,{className:"max-h-60",children:[s.length===0&&g.jsx(yke,{children:"没有匹配的命令"}),s.map(h=>g.jsxs(bke,{value:h.name,onSelect:()=>n(h),className:"min-h-11 py-2 data-[selected=true]:bg-[color-mix(in_srgb,var(--primary)_15%,transparent)] md:min-h-0 md:py-1.5",children:[g.jsx("span",{className:"font-mono text-sm whitespace-nowrap shrink-0",children:h.name}),h.description&&g.jsx("span",{className:"ml-auto min-w-0 text-xs text-muted-foreground truncate",children:h.description})]},h.name))]})})})});function wke({attachments:e,onRemove:t}){return e.length===0?null:g.jsx("div",{className:"flex w-full gap-2 overflow-x-auto px-2.5 pt-2.5 pb-1","data-slot":"input-attachments","aria-label":"已上传附件",children:e.map(n=>n.kind==="image"?g.jsx(Ske,{attachment:n,onRemove:t},n.id):g.jsx(xke,{attachment:n,onRemove:t},n.id))})}function Ske({attachment:e,onRemove:t}){const[n,r]=b.useState(null);return b.useEffect(()=>{if(typeof URL.createObjectURL!="function")return;const i=URL.createObjectURL(e.file);return r(i),()=>URL.revokeObjectURL(i)},[e.file]),g.jsxs("div",{className:"group relative size-20 shrink-0 overflow-hidden rounded-md border bg-muted","data-slot":"input-image-attachment",title:e.file.name,children:[n?g.jsx("img",{src:n,alt:e.file.name,className:"size-full object-contain","data-slot":"input-image-attachment-preview"}):g.jsx("div",{className:"flex size-full items-center justify-center text-muted-foreground",children:g.jsx(Lf,{className:"size-5","aria-hidden":"true"})}),g.jsx(LF,{attachment:e,onRemove:t})]})}function xke({attachment:e,onRemove:t}){return g.jsxs("div",{className:"relative flex h-16 w-56 shrink-0 items-center gap-2.5 rounded-md border bg-muted/50 px-3 pr-9","data-slot":"input-file-attachment",title:e.file.name,children:[g.jsx("div",{className:"flex size-9 shrink-0 items-center justify-center rounded-sm bg-background text-muted-foreground",children:g.jsx(k8,{className:"size-4","aria-hidden":"true"})}),g.jsxs("div",{className:"min-w-0",children:[g.jsx("div",{className:"truncate text-sm font-medium","data-slot":"input-attachment-name",children:e.file.name}),g.jsx("div",{className:"mt-0.5 text-xs text-muted-foreground",children:Eke(e.file.size)})]}),g.jsx(LF,{attachment:e,onRemove:t})]})}function LF({attachment:e,onRemove:t}){return g.jsx(_t,{type:"button",variant:"secondary",size:"icon",className:"absolute right-1 top-1 size-7 border bg-background/90 shadow-xs hover:bg-background","aria-label":`移除附件 ${e.file.name}`,"data-slot":"input-attachment-remove",onClick:()=>t(e.id),children:g.jsx(vc,{className:"size-3.5","aria-hidden":"true"})})}function Eke(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/102.4)/10} KB`:`${Math.round(e/(1024*102.4))/10} MB`}let SD=0;function Cke({sessionId:e}){const t=Y4(),n=b.useRef(null),r=b.useRef(null),i=b.useRef(null),s=Qt(be=>be.bySessionId[e]??qs),o=Qt(be=>be.setInputDraft),l=Qt(be=>be.addDraftAttachment),u=Qt(be=>be.removeDraftAttachment),d=Qt(be=>be.clearDraftAttachments),h=Qt(be=>be.addUserMessage),p=Ne(be=>be.chatContentFontSize),y=Ne(be=>be.inputModePreference==="hardware"),_=ul("(pointer: coarse), (hover: none)")&&!y,w=Ix(p,_),x=$t(be=>{var Xe;return(Xe=be.sessions.find(rt=>rt.sessionId===e))==null?void 0:Xe.state}),E=$t(be=>be.updateSessionState),k=ul("(min-width: 768px)"),R=(k||y)&&!_,A=s.inputDraft,I=s.draftAttachments,T=WCe(A,I),H=x==="working",D=H||x==="compacting",W=s.pendingApprovals,U=W.some(be=>be.status==="pending"),F=UCe(A),M=!$Ce(D,W)&&T!=="",B=H&&!U&&T!==""&&!UA(T),[L,N]=b.useState([]),[V,Y]=b.useState(!1),[$,P]=b.useState(""),q=b.useRef(A),K=b.useRef(e);K.current=e,b.useEffect(()=>{N([]),P("")},[e]),b.useEffect(()=>{q.current=A},[A]);const z=b.useCallback(()=>{N([]),P("")},[]),X=b.useCallback(()=>{o(e,""),q.current="",d(e),z()},[d,z,e,o]),ee=b.useCallback(be=>{o(e,be),q.current=be},[e,o]),te=b.useCallback(()=>{if(!B)return;const be=Date.now(),Xe=`${e}-user-${be}`;h(e,{id:Xe,role:"user",text:T,isPartial:!1,timestamp:be,toolCalls:[],deliveryStatus:"queued"}),X()},[B,T,e,h,X]),Q=b.useCallback(()=>{if(!M||!T)return;const be=Pt;if(!be)return;const Xe=Date.now(),rt=`${e}-user-${Xe}`,pt=UA(T);pt||h(e,{id:rt,role:"user",text:T,isPartial:!1,timestamp:Xe,toolCalls:[]}),E(e,pt?"compacting":"working",Xe),pt&&zZ(e),be.sendEnvelope({type:"user_input",sessionId:e,payload:{text:T,messageId:rt},seq:0,timestamp:Xe,source:"client",version:"1"}),X()},[M,T,e,h,E,X]),me=b.useCallback(()=>{if(M){Q();return}B&&te()},[M,B,Q,te]),ve=be=>{const Xe=q.current,{cleaned:rt,removedMention:pt}=qCe(be,Xe,L);if(pt){N(le=>le.filter(Ae=>Ae!==pt)),pt.startsWith("/")&&P(""),ee(rt);return}ee(be)},Ce=be=>{if(F!=="none"){const Xe=F==="slash"?r.current:i.current;if(Xe!=null&&Xe.handleKey(be)){be.preventDefault();return}}if(be.key==="Enter"&&!be.shiftKey&&!be.metaKey&&!be.ctrlKey){if(be.nativeEvent.isComposing)return;F==="none"&&R&&(be.preventDefault(),me())}else if(be.key==="Escape"&&F!=="none"){be.preventDefault();const Xe=A.replace(/\/\S*$/,"").replace(/@\S*$/,"");ee(Xe)}},Me=b.useCallback(async be=>{const Xe=be.clipboardData,rt=yE(Xe),pt=rt?null:(()=>{if(!Xe.files||Xe.files.length===0)return null;for(const tt of Xe.files)if(!tt.type.startsWith("image/"))return tt;return null})(),le=rt??pt;if(!le)return;be.preventDefault();const Ae=Pt;if(!Ae){nt.error("请先连接开发机");return}const Ze=e;Y(!0);try{let tt=null;if(rt){const dt=nt.loading("图片上传中...");try{const Dt=await L4({clipboardData:Xe,relay:Ae,sessionId:Ze});if(nt.dismiss(dt),!Dt)return;tt=Dt.path}catch(Dt){nt.error(Dt instanceof Error?Dt.message:String(Dt),{id:dt});return}}else if(pt&&(tt=await kf({relay:Ae,sessionId:Ze,file:pt,successLabel:null}),!tt))return;if(!tt)return;l(Ze,{id:ED(Ze),kind:CD(le)?"image":"file",file:le,path:tt}),K.current===Ze&&requestAnimationFrame(()=>{var dt;return(dt=n.current)==null?void 0:dt.focus()})}finally{Y(!1)}},[l,e]),Ve=b.useRef(null),Qe=b.useRef(null),[ct,Ot]=b.useState(!1),[he,Ke]=b.useState(!1),Rt=b.useCallback(async be=>{const Xe=Pt;if(!Xe){nt.error("请先连接开发机");return}const rt=e;Y(!0);try{const pt=await kf({relay:Xe,sessionId:rt,file:be,successLabel:null});if(!pt)return;l(rt,{id:ED(rt),kind:CD(be)?"image":"file",file:be,path:pt}),K.current===rt&&requestAnimationFrame(()=>{var le;return(le=n.current)==null?void 0:le.focus()})}finally{Y(!1)}},[l,e]),ye=b.useCallback(async be=>{var rt;const Xe=(rt=be.target.files)==null?void 0:rt[0];be.target.value="",Xe&&await Rt(Xe)},[Rt]),He=b.useCallback(async be=>{var rt,pt;const Xe=(pt=(rt=be.dataTransfer)==null?void 0:rt.files)==null?void 0:pt[0];Xe&&(be.preventDefault(),Ke(!1),await Rt(Xe))},[Rt]),Ge=R?"输入消息... (Enter 发送,Shift+Enter 换行)":"输入消息...";return g.jsxs("div",{className:"relative w-full","data-slot":"input-bar","data-mode":"json",children:[F==="slash"&&g.jsx(_ke,{ref:r,filter:A.slice(A.lastIndexOf("/")),onSelect:be=>{var pt;const Xe=be.name,rt=A.replace(/\/[^\s]*$/,`${Xe} `);ee(rt),N(le=>[...le,Xe]),P(be.argumentHint??""),(pt=n.current)==null||pt.focus()}}),F==="file"&&g.jsx(FB,{ref:i,mode:"insert",filter:A.slice(A.lastIndexOf("@")),onSelect:be=>{var le;const Xe=be.endsWith("/"),rt=`@${be}`,pt=A.replace(/@[^\s]*$/,Xe?rt:`${rt} `);ee(pt),Xe||N(Ae=>[...Ae,rt]),(le=n.current)==null||le.focus()}}),g.jsxs("form",{onSubmit:be=>{be.preventDefault(),me()},onDragOver:be=>{be.dataTransfer.types.includes("Files")&&(be.preventDefault(),he||Ke(!0))},onDragLeave:be=>{be.currentTarget.contains(be.relatedTarget)||Ke(!1)},onDrop:be=>{He(be)},"data-slot":"input-card","data-drag-over":he?"true":void 0,className:"flex flex-col w-full rounded-md border border-input bg-transparent shadow-xs transition-[color,box-shadow] focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/75 data-[drag-over=true]:border-primary data-[drag-over=true]:ring-[3px] data-[drag-over=true]:ring-primary/50 dark:bg-input/30",children:[$&&g.jsxs("div",{className:"px-3 pt-1.5 text-[11px] text-muted-foreground font-mono truncate","data-slot":"input-argument-hint",children:["参数: ",$]}),g.jsx(wke,{attachments:I,onRemove:be=>u(e,be)}),g.jsxs("div",{className:"flex items-center w-full",children:[g.jsx(FCe,{ref:n,value:A,onChange:be=>ve(be.target.value),onPaste:Me,onKeyDown:Ce,enterKeyHint:R?"send":"enter",autoCapitalize:"none",autoComplete:"off",autoCorrect:"off",spellCheck:!1,placeholder:Ge,className:"flex-1 resize-none rounded-none border-0 bg-transparent font-normal shadow-none max-h-60 min-h-11 focus-visible:border-0 focus-visible:ring-0 md:min-h-0 dark:bg-transparent",style:{fontSize:w},rows:1,"aria-label":"输入聊天消息","aria-busy":V}),g.jsxs("div",{className:"self-stretch relative flex items-center gap-1 p-1.5 md:p-1 before:absolute before:inset-y-2 before:left-0 before:w-px before:bg-gradient-to-b before:from-transparent before:via-border before:to-transparent","data-slot":"input-actions",children:[g.jsx(kke,{open:ct,onOpenChange:Ot,isDesktop:k,onPickImage:()=>{var be;Ot(!1),(be=Qe.current)==null||be.click()},onPickFile:()=>{var be;Ot(!1),(be=Ve.current)==null||be.click()}}),g.jsx(yCe,{isWorking:H,canSend:M,canQueue:B,onSend:me,onQueue:te})]})]})]}),g.jsx("input",{ref:Qe,type:"file",accept:t.mediaAccept,className:"hidden","data-slot":"input-attach-image-input",onChange:be=>{ye(be)}}),g.jsx("input",{ref:Ve,type:"file",accept:t.fileAccept,className:"hidden","data-slot":"input-attach-file-input",onChange:be=>{ye(be)}})]})}function kke({open:e,onOpenChange:t,isDesktop:n,onPickImage:r,onPickFile:i}){const s=g.jsx(_t,{type:"button",variant:"ghost",size:"icon",className:"size-11 md:size-9","aria-label":"附加","data-slot":"input-attach-button",children:g.jsx(Y8,{"aria-hidden":"true"})});return n?g.jsxs(R1,{open:e,onOpenChange:t,children:[g.jsx(A1,{asChild:!0,children:s}),g.jsx(N1,{align:"end",className:"w-44 p-1",children:g.jsx(xD,{variant:"popover",onPickImage:r,onPickFile:i})})]}):g.jsxs(Xv,{open:e,onOpenChange:t,children:[g.jsx(yie,{asChild:!0,children:s}),g.jsxs(Zv,{side:"bottom",showCloseButton:!1,className:"h-auto gap-0 rounded-t-xl bg-popover pt-2 pb-[max(theme(spacing.2),env(safe-area-inset-bottom))] border-t-0","data-slot":"attach-menu-sheet",focusSurfaceOnOpen:!0,children:[g.jsx(sI,{children:g.jsx(Qv,{children:"附加内容"})}),g.jsx("div",{"aria-hidden":"true",className:"mx-auto mb-1 h-1 w-10 rounded-full bg-border","data-slot":"sheet-drag-handle"}),g.jsx(xD,{variant:"sheet",onPickImage:r,onPickFile:i})]})]})}function xD({variant:e,onPickImage:t,onPickFile:n}){const s=`flex w-full items-center gap-2 rounded-sm text-left text-sm hover:bg-accent hover:text-accent-foreground ${e==="sheet"?"h-12":"h-9"} ${e==="sheet"?"px-4":"px-2"}`;return g.jsxs("div",{className:"flex flex-col","data-slot":"input-attach-menu",children:[g.jsxs("button",{type:"button",className:s,"data-slot":"input-attach-menu-image",onClick:t,children:[g.jsx(Lf,{"aria-hidden":"true",className:"size-4"}),"上传照片或视频"]}),g.jsxs("button",{type:"button",className:s,"data-slot":"input-attach-menu-file",onClick:n,children:[g.jsx(zP,{"aria-hidden":"true",className:"size-4"}),"上传文件"]})]})}function ED(e){return SD+=1,`${e}-attachment-${SD}`}function CD(e){return e.type.startsWith("image/")?!0:/\.(?:avif|bmp|gif|heic|heif|jpe?g|png|webp)$/i.test(e.name)}function Tke({sessionId:e}){const t=Qt(r=>{var i;return((i=r.bySessionId[e])==null?void 0:i.quotedMessage)??null}),n=Qt(r=>r.setQuotedMessage);return t?g.jsx("div",{className:"dev-render-scroll dev-chat-rail-inset overflow-x-hidden overflow-y-auto py-2 bg-muted border-t border-border","data-slot":"quote-preview-bar",children:g.jsxs("div",{className:"dev-message-rail mx-auto flex w-full items-start gap-2",children:[g.jsxs("div",{className:"flex-1 min-w-0",children:[g.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:t.from==="assistant"?"Agent:":"You:"}),g.jsx("div",{className:"text-xs line-clamp-2",children:t.text})]}),g.jsx(_t,{variant:"ghost",size:"icon-xs",onClick:()=>n(e,null),"aria-label":"取消引用",children:g.jsx(vc,{"aria-hidden":"true"})})]})}):null}const Rke={idle:"会话空闲",working:"正在响应",compacting:"正在压缩上下文",waiting_approval:"等待工具审批",error:"会话连接异常",terminated:"会话已终止",disconnected:"连接已断开"};function Ake({state:e}){return g.jsxs("div",{className:`dev-status-line dev-status-line-${e}`,"data-slot":"status-line","data-state":e,role:"status","aria-label":Rke[e],children:[e==="idle"&&g.jsx("div",{className:"dev-status-line-sweep dev-status-line-sweep-idle"}),e==="working"&&g.jsx("div",{className:"dev-status-line-sweep dev-status-line-sweep-working"}),e==="compacting"&&g.jsx("div",{className:"dev-status-line-sweep dev-status-line-sweep-compacting"}),e==="waiting_approval"&&g.jsx("div",{className:"dev-status-line-sweep dev-status-line-sweep-waiting"})]})}function Nke({autoYesEnabled:e,onAutoYesChange:t}){return g.jsxs("div",{role:"status","aria-live":"polite","aria-label":"等待审批","data-slot":"pty-approval-hint",className:"dev-pty-approval-hint",children:[g.jsx("span",{className:"dev-pty-approval-hint-label",children:"等待审批"}),g.jsx("button",{type:"button","aria-pressed":e,className:"dev-pty-approval-auto-yes",onClick:()=>t(!e),children:"Always yes"})]})}const Mke={code:"这条回复包含代码,我先概括:它给出了一段实现或配置,请查看屏幕确认细节。",table:"这条回复包含表格,我先概括主要结论,请查看屏幕确认具体行列。",diff:"这条回复包含代码变更,我先概括:请查看屏幕确认具体修改。",log:"这条回复包含日志,我先概括关键状态,请查看屏幕确认原始输出。",stack_trace:"这条回复包含错误堆栈,我先概括问题方向,请查看屏幕确认调用位置。",long_list:"这条回复包含较长列表,我先概括结构,请查看屏幕确认每一项。",long_text:"这条回复内容较长,我先概括重点,请查看屏幕确认完整细节。",mixed:"这条回复包含不适合直接朗读的内容,我先概括重点,请查看屏幕确认细节。",approval:"有一个工具操作正在等待审批,请查看屏幕确认细节。"};function kD(e){return Mke[e]}class Oke{constructor(t){yt(this,"options");yt(this,"state","armed");yt(this,"preRoll",[]);yt(this,"preRollBytes",0);yt(this,"pending",[]);yt(this,"pendingBytes",0);yt(this,"stream",null);yt(this,"speechEnded",!1);this.options=t}pushFrame(t){var n;if(this.state==="armed"){this.appendPreRoll(t);return}if(this.state==="opening"){this.appendPending(t);return}this.state==="streaming"&&((n=this.stream)==null||n.send(t))}speechStarted(){this.state==="armed"&&(this.state="opening",this.pending=this.preRoll,this.pendingBytes=this.preRollBytes,this.preRoll=[],this.preRollBytes=0,this.options.openStream().then(t=>{if(this.state==="cancelled"){t.abort();return}if(this.state!=="opening"){t.abort();return}this.stream=t;for(const n of this.pending)t.send(n);if(this.pending=[],this.pendingBytes=0,this.speechEnded){this.state="finishing",t.finish(),this.state="complete";return}this.state="streaming"}).catch(t=>{this.state!=="cancelled"&&(this.state="complete",this.pending=[],this.pendingBytes=0,this.options.onError(t))}))}speechFinished(){var t;this.state==="armed"||this.state==="complete"||this.state==="cancelled"||(this.speechEnded=!0,this.state==="streaming"&&(this.state="finishing",(t=this.stream)==null||t.finish(),this.state="complete"))}cancel(){var n;if(this.state==="cancelled")return;const t=this.state!=="complete";this.state="cancelled",this.preRoll=[],this.preRollBytes=0,this.pending=[],this.pendingBytes=0,t&&((n=this.stream)==null||n.abort()),this.stream=null}rearm(){return this.state!=="complete"?!1:(this.state="armed",this.preRoll=[],this.preRollBytes=0,this.pending=[],this.pendingBytes=0,this.stream=null,this.speechEnded=!1,!0)}snapshot(){return{state:this.state,preRollBytes:this.preRollBytes,pendingBytes:this.pendingBytes,speechEnded:this.speechEnded}}appendPreRoll(t){const n=t.slice();for(this.preRoll.push(n),this.preRollBytes+=n.byteLength;this.preRollBytes>this.options.preRollBytes&&this.preRoll.length>1;){const r=this.preRoll.shift();this.preRollBytes-=(r==null?void 0:r.byteLength)??0}}appendPending(t){const n=t.slice();this.pending.push(n),this.pendingBytes+=n.byteLength}}const Dke=1e4,Pke=5e3,Lke=32*1024;function Ike(e){if(typeof e!="string")return null;try{const t=aX.safeParse(JSON.parse(e));return t.success?t.data:null}catch{return null}}class zke{constructor(t){yt(this,"options");yt(this,"socket",null);yt(this,"connectionPromise",null);yt(this,"activeAttempt",null);yt(this,"disposed",!1);this.options={...t,readyTimeoutMs:t.readyTimeoutMs??Dke,completionTimeoutMs:t.completionTimeoutMs??Pke,inFlightWindowBytes:t.inFlightWindowBytes??Lke}}connect(){var r;if(this.disposed)return Promise.reject(new Error("语音识别连接已关闭"));if(((r=this.socket)==null?void 0:r.readyState)===WebSocket.OPEN)return Promise.resolve();if(this.connectionPromise)return this.connectionPromise;const t=(this.options.createSocket??(i=>new WebSocket(i)))(this.options.url);this.socket=t;const n=new Promise((i,s)=>{let o=!1;const l=()=>{o||(o=!0,s(new Error("语音识别连接不可用")))};t.addEventListener("open",()=>{if(this.socket!==t||this.disposed){l();return}o=!0,this.trace("socket-open",{}),i()}),t.addEventListener("message",u=>this.handleMessage(t,u.data)),t.addEventListener("close",u=>{if(this.socket!==t)return;this.socket=null,l();const d=this.activeAttempt!==null;this.failActiveAttempt("语音识别连接已断开"),!this.disposed&&!d&&this.options.onTransportError("语音识别连接已断开"),this.trace("socket-closed",{code:u.code,reason:u.reason,wasClean:u.wasClean})}),t.addEventListener("error",()=>{this.socket===t&&(l(),this.trace("socket-error",{}))})}).finally(()=>{this.connectionPromise===n&&(this.connectionPromise=null)});return this.connectionPromise=n,n}async startAttempt(t){var u;await this.connect();const n=this.socket;if(!n||n.readyState!==WebSocket.OPEN)throw new Error("语音识别连接不可用");(u=this.activeAttempt)==null||u.publicAttempt.abort();let r,i;const s=new Promise((d,h)=>{r=d,i=h}),o={},l={attemptId:t.attemptId,send:d=>this.enqueue(o,d),finish:()=>this.finish(o),abort:()=>this.abort(o),snapshot:()=>this.snapshot(o)};return Object.assign(o,{options:t,queue:[],queuedBytes:0,sentBytes:0,acknowledgedBytes:0,acknowledgedPcmBytes:0,acknowledgedChunks:0,ready:!1,finishRequested:!1,stopSent:!1,terminal:!1,completionTimeoutId:null,resolveReady:r,rejectReady:i,publicAttempt:l,readyTimeoutId:window.setTimeout(()=>{this.activeAttempt!==o||o.ready||o.terminal||this.failAttempt(o,"语音识别服务准备超时")},this.options.readyTimeoutMs)}),this.activeAttempt=o,n.send(JSON.stringify({type:"start",...t})),this.trace("attempt-start-sent",{attemptId:t.attemptId,encoding:t.encoding}),s}dispose(){var n;if(this.disposed)return;this.disposed=!0,(n=this.activeAttempt)==null||n.publicAttempt.abort(),this.activeAttempt=null;const t=this.socket;this.socket=null,t==null||t.close()}handleMessage(t,n){if(this.socket!==t)return;const r=Ike(n);if(!r){this.trace("invalid-message",{});return}const i=this.activeAttempt;if(!i||i.options.attemptId!==r.attemptId){this.trace("stale-message",{attemptId:r.attemptId,activeAttemptId:(i==null?void 0:i.options.attemptId)??null,messageType:r.type});return}switch(r.type){case"ready":if(i.ready||i.terminal)return;i.ready=!0,window.clearTimeout(i.readyTimeoutId),i.resolveReady(i.publicAttempt),this.trace("attempt-ready",{attemptId:r.attemptId}),this.pump(i);return;case"audio_ack":i.acknowledgedBytes=Math.max(i.acknowledgedBytes,Math.min(r.encodedBytes,i.sentBytes)),i.acknowledgedPcmBytes=Math.max(i.acknowledgedPcmBytes,r.pcmBytes),i.acknowledgedChunks=Math.max(i.acknowledgedChunks,r.chunks),this.pump(i);return;case"partial":this.options.onPartial(r.text,r.attemptId),this.refreshCompletionTimeout(i);return;case"final":this.options.onFinal(r.text,r.attemptId),this.refreshCompletionTimeout(i);return;case"closed":if(!i.ready){this.failAttempt(i,"语音识别连接已断开");return}if(!i.finishRequested){this.failAttempt(i,"语音识别连接已断开");return}this.completeAttempt(i,"closed");return;case"error":this.failAttempt(i,r.error??"语音识别失败");return}}enqueue(t,n){if(this.activeAttempt!==t||t.terminal||t.finishRequested)return;const r=n.slice();t.queue.push(r),t.queuedBytes+=r.byteLength,this.pump(t)}finish(t){this.activeAttempt!==t||t.terminal||t.finishRequested||(t.finishRequested=!0,this.pump(t))}abort(t){if(!t.terminal&&(t.terminal=!0,t.queue=[],t.queuedBytes=0,window.clearTimeout(t.readyTimeoutId),t.completionTimeoutId!==null&&(window.clearTimeout(t.completionTimeoutId),t.completionTimeoutId=null),t.ready||t.rejectReady(new Error("语音识别已取消")),this.activeAttempt===t)){const n=this.socket;(n==null?void 0:n.readyState)===WebSocket.OPEN&&n.send(JSON.stringify({type:"stop",attemptId:t.options.attemptId})),this.activeAttempt=null}}pump(t){if(this.activeAttempt!==t||!t.ready||t.terminal)return;const n=this.socket;if(!(!n||n.readyState!==WebSocket.OPEN)){for(;t.queue.length>0;){const r=t.queue[0];if(!r)break;const i=t.sentBytes-t.acknowledgedBytes;if(i>0&&i+r.byteLength>this.options.inFlightWindowBytes)break;t.queue.shift(),t.queuedBytes-=r.byteLength,t.sentBytes+=r.byteLength,n.send(r)}t.finishRequested&&t.queue.length===0&&!t.stopSent&&(t.stopSent=!0,n.send(JSON.stringify({type:"stop",attemptId:t.options.attemptId})),this.trace("attempt-stop-sent",{...this.snapshot(t)}),this.refreshCompletionTimeout(t))}}refreshCompletionTimeout(t){this.activeAttempt!==t||t.terminal||!t.finishRequested||!t.stopSent||(t.completionTimeoutId!==null&&window.clearTimeout(t.completionTimeoutId),t.completionTimeoutId=window.setTimeout(()=>{this.activeAttempt!==t||t.terminal||(this.trace("attempt-completion-timeout",{...this.snapshot(t)}),this.completeAttempt(t,"timeout"))},this.options.completionTimeoutMs))}completeAttempt(t,n){var r,i;t.terminal||(t.terminal=!0,window.clearTimeout(t.readyTimeoutId),t.completionTimeoutId!==null&&(window.clearTimeout(t.completionTimeoutId),t.completionTimeoutId=null),this.activeAttempt===t&&(this.activeAttempt=null),(i=(r=this.options).onAttemptComplete)==null||i.call(r,t.options.attemptId,n))}failActiveAttempt(t){const n=this.activeAttempt;n&&this.failAttempt(n,t)}failAttempt(t,n){t.terminal||(t.terminal=!0,window.clearTimeout(t.readyTimeoutId),t.completionTimeoutId!==null&&(window.clearTimeout(t.completionTimeoutId),t.completionTimeoutId=null),t.ready?this.options.onAttemptError(n,t.options.attemptId):t.rejectReady(new Error(n)),this.activeAttempt===t&&(this.activeAttempt=null))}snapshot(t){return{attemptId:t.options.attemptId,queuedBytes:t.queuedBytes,sentBytes:t.sentBytes,acknowledgedBytes:t.acknowledgedBytes,acknowledgedPcmBytes:t.acknowledgedPcmBytes,acknowledgedChunks:t.acknowledgedChunks,finishRequested:t.finishRequested,stopSent:t.stopSent}}trace(t,n){var r,i;(i=(r=this.options).onTrace)==null||i.call(r,t,n)}}const Bke=900;function jke(e){const t=e.split(`
691
691
  `);return t.some((n,r)=>{const i=t[r+1];return n.includes("|")&&typeof i=="string"&&/^\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)+\|?\s*$/.test(i)})}function Fke(e){const t=e.split(`
692
692
  `);return t.some(n=>/^\+[^+]/.test(n))&&t.some(n=>/^-[^-]/.test(n))}function $ke(e){return/\n\s+at\s+.+:\d+:\d+/.test(e)||/Traceback \(most recent call last\):/.test(e)}function Hke(e){return/\b(ERROR|WARN|INFO|DEBUG)\b[:\s]/.test(e)||/\[\d{2}:\d{2}:\d{2}]/.test(e)}function Uke(e){return e.split(`
693
693
  `).filter(t=>/^\s*(?:[-*]|\d+\.)\s+/.test(t)).length>=8}function Wke(e,t={}){const n=e.trim();return/```/.test(n)?{mode:"summary_required",reason:"code"}:jke(n)?{mode:"summary_required",reason:"table"}:$ke(n)?{mode:"summary_required",reason:"stack_trace"}:Fke(n)?{mode:"summary_required",reason:"diff"}:Hke(n)?{mode:"summary_required",reason:"log"}:Uke(n)?{mode:"summary_required",reason:"long_list"}:n.length>(t.maxDirectChars??Bke)?{mode:"summary_required",reason:"long_text"}:{mode:"direct"}}const qke=/\bhttps?:\/\/[^\s<>"',。;:!?、)】》」』]+/giu,Vke=/<https?:\/\/[^>]+>/giu,Yke=/^\s{0,3}\[[^\]]+\]:\s*https?:\/\/\S+(?:\s+(?:"[^"]*"|'[^']*'|\([^)]*\)))?\s*$/gimu,Kke=/[),.;:!?,。;:!?、)】》」』]+$/u;function Gke(e,t){for(let n=t;n<e.length;n+=1){if(e[n]==="\\"){n+=1;continue}if(e[n]==="]")return n}return-1}function Xke(e,t){if(e[t]!=="(")return null;let n=0;for(let r=t;r<e.length;r+=1){const i=e[r];if(i==="\\"){r+=1;continue}if(i==="("){n+=1;continue}if(i===")"&&(n-=1,n===0))return{end:r+1}}return null}function Zke(e){let t="",n=0;for(;n<e.length;){const r=e.startsWith("![",n),i=r?n+2:e[n]==="["?n+1:-1;if(i<0){t+=e[n],n+=1;continue}const s=Gke(e,i),o=s>=0?Xke(e,s+1):null;if(!o){t+=e[n],n+=1;continue}const l=e.slice(i,s).replace(/\\(\[|\])/gu,"$1").trim();t+=r?l?`图片:${l}`:"图片":l||"链接",n=o.end}return t}function Qke(e){var n;return`链接${((n=e.match(Kke))==null?void 0:n[0])??""}`}function TD(e){return Zke(e).replace(Yke,"").replace(Vke,"链接").replace(qke,Qke).replace(/`([^`\n]+)`/gu,"$1").replace(/(^|\s)(?:#{1,6}|>|[-*+])\s+/gmu,"$1").replace(/(\*\*|__|~~)(.*?)\1/gu,"$2").replace(/[*_]/gu,"").replace(/[ \t]+/gu," ").replace(/\s*\n\s*/gu,",").replace(/,{2,}/gu,",").replace(/^[,\s]+|[,\s]+$/gu,"").trim()}const IF=["file_path","path","filename","cwd"],zF=["command","cmd","script"],BF=["query","queries","search"];function d0(e,t){for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}return null}function Jke(e){const t=new Set([...IF,...zF,...BF]);return Object.keys(e).filter(n=>!t.has(n)).slice(0,3)}function eTe(e){return e.split(/[\\/]+/u).filter(Boolean).slice(-2).join("/")||e}function tTe(e,t=56){const n=e.replace(/\s+/g," ").trim();return n.length>t?`${n.slice(0,t)}...`:n}function nTe(e){const t=e.num??e.count??e.limit??e.max_results;return typeof t=="number"&&Number.isFinite(t)&&t>0?`,最多返回 ${t} 条`:typeof t=="string"&&t.trim()?`,最多返回 ${t.trim()} 条`:null}function rTe(e){const t=d0(e.input,zF),n=d0(e.input,IF),r=d0(e.input,BF);return r?`工具 ${e.toolName} 请求搜索:${tTe(r)}${nTe(e.input)??""}。`:/search/i.test(e.toolName)?`工具 ${e.toolName} 请求搜索资料。`:t?`工具 ${e.toolName} 请求执行命令。`:n?`工具 ${e.toolName} 请求操作 ${eTe(n)}。`:Jke(e.input).length>0?`工具 ${e.toolName} 请求执行操作。`:`工具 ${e.toolName} 请求执行操作。`}const iTe=new Map([["复述",{type:"repeat"}],["再说一遍",{type:"repeat"}]]),sTe=["退出语音助手","关闭语音助手","停止语音助手"],oTe=/(?:退出|关闭|停止)\s*voice\s*pilot/iu,aTe=[{phrases:["不同意","不允许","不要同意","不要允许","别同意","别允许","拒绝"],command:{type:"deny_once"}},{phrases:["始终允许"],command:{type:"approve_always"}},{phrases:["同意","允许"],command:{type:"approve_once"}}];function jF(e){return e.trim().replace(/[。!?!?,,\s]+$/u,"")}function lTe(e){const t=jF(e);return t.split(/[。!?!?,,;;\s]+/u).map(r=>r.trim()).filter(Boolean).at(-1)??t}function cTe(e){var n;const t=lTe(e);return(n=aTe.find(({phrases:r})=>r.some(i=>t.includes(i))))==null?void 0:n.command}function uTe(e,t){const n=e.trim(),r=jF(n),i=t.approvalPromptActive===!0?cTe(n):void 0;if(i)return{kind:"command",command:i};if(sTe.some(o=>r.includes(o))||oTe.test(r))return{kind:"command",command:{type:"exit"}};const s=iTe.get(r);return s?{kind:"command",command:s}:{kind:"agentText",text:n}}function dTe({sessionState:e,agentPhase:t,ptyState:n}){return e==="working"||e==="compacting"||t==="thinking"||t==="tool_use"||t==="outputting"||n==="working"}const RD=[784,1047],hTe=70,fTe=20,pTe=.16,mTe=6,gTe={frequency:660,durationMs:110,gain:.09};function FF(e,t){const n=Math.max(1,Math.ceil(e*t.durationMs/1e3)),r=Math.max(1,Math.floor(e*mTe/1e3)),i=new Int16Array(n);for(let s=0;s<n;s+=1){const o=Math.min(1,s/r),l=Math.min(1,(n-s-1)/r),u=Math.max(0,Math.min(o,l)),d=Math.sin(2*Math.PI*t.frequency*s/e);i[s]=Math.round(d*u*t.gain*32767)}return new Uint8Array(i.buffer)}function vTe(e,t){const n=Math.max(0,Math.ceil(e*t/1e3));return new Uint8Array(n*Int16Array.BYTES_PER_ELEMENT)}function yTe(e){const t=new Uint8Array(e.reduce((r,i)=>r+i.byteLength,0));let n=0;for(const r of e)t.set(r,n),n+=r.byteLength;return t}function bTe(e,t){const r=(e==="listening-start"?RD:[...RD].reverse()).map(i=>FF(t,{frequency:i,durationMs:hTe,gain:pTe}));return yTe([r[0]??new Uint8Array,vTe(t,fTe),r[1]??new Uint8Array])}function _Te(e,t){const n=e==="assistant-end"?FF(t,gTe):bTe(e,t);return{pcm:n,durationMs:n.byteLength/Int16Array.BYTES_PER_ELEMENT/t*1e3}}const AD={idle:["starting"],starting:["suspended","listening","speaking","summarizing","error","idle"],suspended:["starting","idle"],listening:["suspended","submitting","waiting","speaking","summarizing","approval","error","idle"],submitting:["suspended","waiting","speaking","approval","error","idle"],waiting:["suspended","listening","speaking","summarizing","approval","error","idle"],summarizing:["suspended","speaking","approval","error","idle"],speaking:["suspended","waiting","listening","approval","error","idle"],approval:["suspended","waiting","speaking","error","idle"],error:["suspended","idle"]};function wTe(){let e=XA({initial:"idle",transitions:AD}),t={config:!1,mic:!1,asr:!1,tts:!1};function n(s=[]){return{phase:e.current(),effects:s}}function r(s){e.is(s)||e.transitionTo(s)}function i(){return!e.is("starting")||!t.config||!t.mic||!t.asr||!t.tts?n():(r("listening"),n([{type:"beginListening"}]))}return{getPhase:()=>e.current(),hydrateReadyForTest(s){e=XA({initial:s,transitions:AD}),t={config:!0,mic:!0,asr:!0,tts:!0}},send(s){if(s.type==="disableRequested")return r("idle"),t={config:!1,mic:!1,asr:!1,tts:!1},n([{type:"stopCapture"},{type:"releaseWakeLock"},{type:"cleanup"}]);if(s.type==="suspendRequested"&&!e.isIn(["idle","suspended"]))return r("suspended"),t={config:!1,mic:!1,asr:!1,tts:!1},n([{type:"releaseWakeLock"},{type:"cancelTurnBuffer"},{type:"suspendRuntime"}]);if(s.type==="resumeRequested"&&e.is("suspended"))return r("starting"),t={config:!1,mic:!1,asr:!1,tts:!1},n([{type:"loadConfig"},{type:"requestMicPermission"},{type:"requestWakeLock"}]);if(s.type==="providerError")return r("error"),n([{type:"stopCapture"},{type:"setError",error:s.error}]);if(s.type==="enableRequested"&&e.is("idle"))return r("starting"),t={config:!1,mic:!1,asr:!1,tts:!1},n([{type:"loadConfig"},{type:"requestMicPermission"},{type:"requestWakeLock"}]);if(e.is("starting")){if(s.type==="configReady")return t.config=!0,i();if(s.type==="micPermissionGranted")return t.mic=!0,i();if(s.type==="asrReady")return t.asr=!0,i();if(s.type==="ttsReady")return t.tts=!0,i();if(s.type==="micPermissionDenied")return r("error"),n([{type:"setError",error:s.error}])}return s.type==="asrFinal"&&(e.is("listening")||e.is("approval"))?n([{type:"appendFinalToTurnBuffer",text:s.text}]):s.type==="turnIdleElapsed"&&e.is("listening")?(r("submitting"),n([{type:"stopCapture"},{type:"playCue",cue:"user-end"}])):s.type==="userEndCueDone"&&e.is("submitting")?(r("waiting"),n([{type:"submitText",text:s.text,messageId:s.messageId}])):s.type==="agentSubmitFailed"?(r("error"),n([{type:"setError",error:s.error}])):s.type==="assistantTextReady"&&e.is("waiting")?(r("speaking"),n([{type:"stopCapture"},{type:"speakText",text:s.text,messageId:s.messageId}])):s.type==="ttsFinished"&&e.isIn(["speaking","approval"])?n([{type:"playCue",cue:"assistant-end"}]):s.type==="assistantEndCueDone"&&e.is("speaking")?(r("waiting"),n([])):s.type==="assistantEndCueDone"&&e.is("approval")?n([{type:"beginListening"}]):s.type==="agentBecameBusy"&&e.is("listening")?(r("waiting"),n([{type:"stopCapture"},{type:"cancelTurnBuffer"}])):s.type==="agentBecameIdle"&&e.is("waiting")?(r("listening"),n([{type:"beginListening"}])):s.type==="approvalArrived"&&e.isIn(["listening","submitting","waiting","speaking","summarizing"])?(r("approval"),n([{type:"stopCapture"},{type:"cancelTurnBuffer"}])):s.type==="approvalCleared"&&e.is("approval")?(r("waiting"),n([{type:"stopCapture"},{type:"cancelTurnBuffer"}])):s.type==="approvalResolved"&&e.is("approval")?(r("waiting"),n([{type:"stopCapture"},{type:"cancelTurnBuffer"},s.action==="approve"?{type:"approveTool",requestId:s.requestId,whitelistTool:!1}:s.action==="approve_always"?{type:"approveTool",requestId:s.requestId,whitelistTool:!0}:{type:"denyTool",requestId:s.requestId},{type:"playCue",cue:"user-end"}])):s.type==="summaryRequested"&&e.isIn(["waiting","listening","starting"])?(r("summarizing"),n([{type:"stopCapture"},{type:"requestSummary",text:s.text,messageId:s.messageId,reason:s.reason}])):s.type==="summaryReady"&&e.is("summarizing")?(r("speaking"),n([{type:"speakText",text:s.text,messageId:s.messageId}])):s.type==="summaryFailed"&&e.is("summarizing")?(r("speaking"),n([{type:"speakText",text:s.fallbackText,messageId:s.messageId}])):s.type==="userTextRecognized"&&e.is("submitting")?(r("waiting"),n([{type:"submitText",text:s.text,messageId:s.messageId}])):s.type==="assistantTextReady"&&e.is("approval")?n([{type:"stopCapture"},{type:"speakText",text:s.text,messageId:s.messageId}]):s.type==="assistantTextReady"&&e.isIn(["starting","listening","submitting","summarizing"])?(r("speaking"),n([{type:"stopCapture"},{type:"speakText",text:s.text,messageId:s.messageId}])):n()}}}class STe{constructor(t){yt(this,"idleTimeoutMs");yt(this,"onTurnReady");yt(this,"setTimeoutFn");yt(this,"clearTimeoutFn");yt(this,"finalSegments",[]);yt(this,"partialText","");yt(this,"idleTimer",null);this.idleTimeoutMs=t.idleTimeoutMs,this.onTurnReady=t.onTurnReady,this.setTimeoutFn=t.setTimeoutFn??((n,r)=>setTimeout(n,r)),this.clearTimeoutFn=t.clearTimeoutFn??(n=>clearTimeout(n))}appendPartial(t){const n=t.trim();if(this.partialText=n,n){this.restartIdleTimer();return}this.finalSegments.length===0&&this.clearIdleTimer()}appendFinal(t){const n=t.trim();if(this.partialText="",!n){this.clearIdleTimer();return}this.finalSegments.push(n),this.restartIdleTimer()}cancel(){this.finalSegments=[],this.partialText="",this.clearIdleTimer()}flushNow(){return this.clearIdleTimer(),this.emitIfReady()}dispose(){this.cancel()}getSnapshot(){return{draft:this.finalSegments.join(`
694
694
  `),partial:this.partialText,hasDraft:this.finalSegments.length>0}}restartIdleTimer(){this.clearIdleTimer(),this.idleTimer=this.setTimeoutFn(()=>this.emitIfReady(),this.idleTimeoutMs)}clearIdleTimer(){this.idleTimer!==null&&(this.clearTimeoutFn(this.idleTimer),this.idleTimer=null)}emitIfReady(){this.clearIdleTimer();const t=[...this.finalSegments];this.partialText&&t.push(this.partialText);const n=t.join(`
695
695
  `).trim();return this.finalSegments=[],this.partialText="",n?(this.onTurnReady(n),!0):!1}}const px=16e3,ND=24e3,MD=3e3,OD=180,DD=8,xTe=1200,ETe=px,CTe="当前正在等待审批,请说允许、始终允许或拒绝。";function kTe(e){const t={};for(const[n,r]of Object.entries(e))(r===null||typeof r=="string"||typeof r=="number"||typeof r=="boolean")&&(t[n]=r);return t}function Nh(){var e;return((e=navigator.audioSession)==null?void 0:e.type)??null}function PD(e){const t=new URL(e,window.location.origin);t.protocol=t.protocol==="https:"?"wss:":"ws:";const n=Qx();return n&&t.searchParams.set("token",n),t.toString()}function TTe(e){if(typeof e!="string")return null;try{const t=JSON.parse(e);return typeof t.type!="string"?null:t}catch{return null}}function co(e){return e.find(t=>t.status==="pending")??null}function RTe(e){return e.filter(t=>t.status==="pending")}function ATe(e,t){const n=RTe(e),r=n.findIndex(i=>i.requestId===t);return{position:r>=0?r+1:1,total:Math.max(1,n.length)}}function LD(e){return e<=0?Promise.resolve():new Promise(t=>window.setTimeout(t,e))}function Yr(e,t){return e instanceof Error?e.message:typeof e=="string"?e:t}function NTe(e){if(!e)return"";const{draft:t,partial:n}=e;return t&&n?`${t}
696
696
  ${n}`:t||n}function MTe(e){return[`toolName: ${e.toolName}`,`input: ${JSON.stringify(e.input,null,2)}`].join(`
697
- `)}function OTe(e,t){const r=`需要审批:${e.trim().replace(/[。.!?!?\s]+$/u,"")||"有一个工具操作正在等待审批"}`;return t&&t.total>1?`有 ${t.total} 个工具审批待处理。第 ${t.position} 个,共 ${t.total} 个。${r}。请说允许、始终允许或拒绝。`:`${r}。请说允许、始终允许或拒绝。`}function DTe(e){let t=0;for(let n=0;n<e.length;n+=1)t=t*31+e.charCodeAt(n)|0;return`${e.length}:${Math.abs(t)}`}function PTe(){if(typeof window>"u")return MD;const e=window.__devAnywhereVoicePilotTurnIdleMs;return typeof e=="number"&&Number.isFinite(e)&&e>0?e:MD}function LTe(e,t){if(typeof e!="number"||!Number.isSafeInteger(e)||e<=0)return t;const n=e*1e3;return Number.isSafeInteger(n)&&n>0?n:t}function uo(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e}),b.useCallback(((...n)=>t.current(...n)),[])}function ITe({sessionId:e,turnIdleMs:t=PTe()}){const n=cn(re=>re.bySessionId[e]??ay),r=n.enabled,i=Qt(re=>{var ie;return((ie=re.bySessionId[e])==null?void 0:ie.messages)??qs.messages}),s=Qt(re=>{var ie;return((ie=re.bySessionId[e])==null?void 0:ie.pendingApprovals)??qs.pendingApprovals}),o=Qt(re=>{var ie;return((ie=re.bySessionId[e])==null?void 0:ie.turnCompletionVersion)??qs.turnCompletionVersion}),l=$t(re=>{const ie=re.sessions.find(Z=>Z.sessionId===e),de=re.agentStatusBySessionId[e],pe=re.ptyStateBySessionId[e];return dTe({sessionState:ie==null?void 0:ie.state,agentPhase:de==null?void 0:de.phase,ptyState:pe==null?void 0:pe.state})}),u=Hj(Wj(e)),d=b.useRef(null),h=b.useRef(null),p=b.useRef(null),y=b.useRef(null),v=b.useRef(null),_=b.useRef(null),w=b.useRef(Promise.resolve()),x=b.useRef(!1),E=b.useRef(null),k=b.useRef(null),R=b.useRef(n),A=b.useRef(i),I=b.useRef(s),T=b.useRef(l),H=b.useRef([]),D=b.useRef([]),W=b.useRef(null),U=b.useRef(null),F=b.useRef(t),O=b.useRef(new Map),M=b.useRef(!1),B=b.useRef(null),L=b.useRef(new Set),N=b.useRef(0),V=b.useRef(0),Y=b.useRef(0),$=b.useRef(null),P=b.useRef(new Map),q=b.useRef(null),K=b.useRef(null),z=b.useRef(!1),X=b.useRef(o),ee=b.useRef(new Set),te=b.useRef(n.resumeRequestSeq);T.current=l;const Q=b.useCallback((re,ie,de={})=>{Gh({sessionId:e,scope:re,event:ie,...de})},[e]),me=b.useCallback(re=>{const ie=Nh();try{k.current?k.current.setMode(re):k.current=I1.acquire(re),Q("audio-session","mode-applied",{details:{mode:re,previousType:ie,currentType:Nh()}})}catch(de){throw Q("audio-session","mode-failed",{details:{mode:re,previousType:ie,currentType:Nh(),error:de instanceof Error?de.message:String(de)}}),de}},[Q]),ve=b.useCallback(()=>{var ie;const re=Nh();(ie=k.current)==null||ie.release(),k.current=null,Q("audio-session","released",{details:{previousType:re,currentType:Nh()}})},[Q]);function Ce(){return K.current||(K.current=wTe()),K.current}async function Me(re){var ie,de;for(const pe of re)switch(pe.type){case"loadConfig":rt();break;case"requestMicPermission":he({type:"micPermissionGranted"});break;case"requestWakeLock":u.enable().catch(Z=>{Xe(Yr(Z,"无法保持屏幕常亮"))});break;case"releaseWakeLock":u.disable().catch(()=>{});break;case"stopCapture":await pt();break;case"beginListening":ye()?await Dt(!0):(await pt(),Ge());break;case"playCue":await le(),await Wt(pe.cue);break;case"appendFinalToTurnBuffer":(ie=U.current)==null||ie.appendFinal(pe.text),dt();break;case"cancelTurnBuffer":(de=U.current)==null||de.cancel();break;case"speakText":case"speakStatic":{await le();const Z=h.current;if(!Z||Z.readyState!==WebSocket.OPEN){H.current.push(pe.text);break}vn(Z,pe.text);break}case"submitText":{const Z=Pt;if(!Z){cn.getState().setError(e,"开发机连接不可用");break}z.current=!0,Z.sendEnvelope({type:"user_input",sessionId:e,payload:{text:pe.text,messageId:pe.messageId},seq:0,timestamp:Date.now(),source:"client",version:"1"}),Q("runtime","user-text-submitted",{details:{chars:pe.text.length,messageId:pe.messageId}});break}case"approveTool":z.current=!0,Pt==null||Pt.sendControl({type:"tool_approve",sessionId:e,payload:{toolId:pe.requestId,whitelistTool:pe.whitelistTool}});break;case"denyTool":z.current=!0,Pt==null||Pt.sendControl({type:"tool_deny",sessionId:e,payload:{toolId:pe.requestId}});break;case"requestSummary":Ve(pe.text,pe.messageId,pe.reason);break;case"cleanup":tn();break;case"suspendRuntime":tn(!1);break;case"setError":ve(),cn.getState().setError(e,pe.error);break;default:{const Z=pe;throw new Error(`Unhandled Voice Pilot effect: ${JSON.stringify(Z)}`)}}}async function Ve(re,ie,de){var ne;const pe=Pt,Z=kD(de);if(!pe){await he({type:"summaryFailed",fallbackText:Z,messageId:ie});return}try{const ae=await pe.requestVoiceSummary(e,ie,re,de);if(ae.success&&((ne=ae.summary)!=null&&ne.trim())){const Te=`下面是摘要:${ae.summary.trim()}`;await he({type:"summaryReady",text:Te,messageId:ie});return}}catch{}await he({type:"summaryFailed",fallbackText:Z,messageId:ie})}async function Qe(re){var pe;const ie=rTe(re),de=Pt;if(!de)return ie;try{const Z=await de.requestVoiceSummary(e,re.requestId,MTe(re),"approval");if(Z.success&&((pe=Z.summary)!=null&&pe.trim()))return Z.summary.trim()}catch{}return ie}function ct(){const re=[...A.current].reverse().find(ie=>ie.role==="assistant"&&ie.text.trim());re&&jt(re)}const Ot=uo(re=>{Ke()&&(L.current.has(re.requestId)||(L.current.add(re.requestId),ct(),(async()=>{try{const ie=await Qe(re);if(!Ke())return;const de=co(I.current);if((de==null?void 0:de.requestId)!==re.requestId)return;Zn(re,OTe(ie,ATe(I.current,re.requestId)))}catch(ie){L.current.delete(re.requestId),cn.getState().setError(e,Yr(ie,"审批播报失败"))}})()))}),he=uo(async re=>{const ie=Ce(),de=ie.getPhase(),pe=ie.send(re),Z=ie.getPhase();Q("state-machine","transition",{details:{input:re.type,previousPhase:de,nextPhase:Z,effectCount:pe.effects.length}});const ne=pe.effects.some(ae=>ae.type==="beginListening");ne||cn.getState().setPhase(e,Z),await Me(pe.effects),ne&&Ke()&&ie.getPhase()===Z&&cn.getState().setPhase(e,Z)}),Ke=uo(()=>{var re;return!!((re=cn.getState().bySessionId[e])!=null&&re.enabled)}),Rt=uo(()=>{var re,ie;return((re=K.current)==null?void 0:re.getPhase())??((ie=cn.getState().bySessionId[e])==null?void 0:ie.phase)??R.current.phase}),ye=uo(()=>{const re=Rt();return re==="approval"?!!co(I.current):re==="listening"?!T.current&&!co(I.current):!1});function He(){return ee.current.size>0||!!W.current||D.current.length>0}const Ge=uo(()=>{if(!Ke()||!K.current)return;const re=Rt(),ie=!!co(I.current);if(re==="listening"&&T.current&&!ie){z.current=!0,he({type:"agentBecameBusy"});return}re==="waiting"&&!z.current&&!T.current&&!ie&&!He()&&he({type:"agentBecameIdle"})}),be=b.useCallback(()=>{const re=Rt();return re==="approval"?!!co(I.current):re==="listening"?!T.current&&!co(I.current):!1},[Rt]);function Xe(re){!Ke()||!K.current||he({type:"providerError",error:re}).catch(ie=>{Ke()&&cn.getState().setError(e,Yr(ie,re))})}async function rt(){var ie;if(!Ke())return;const re=Pt;if(!re){await he({type:"providerError",error:"开发机连接不可用"});return}try{const de=await re.requestVoiceConfig();if(!Ke())return;if(!((ie=de.config)!=null&&ie.configured)){await he({type:"providerError",error:"请先在设置里配置 Voice Pilot。"});return}if(F.current=LTe(de.config.turnIdleSeconds,t),await he({type:"configReady"}),!Ke()||Rt()!=="starting")return;ht()}catch(de){if(!Ke())return;await he({type:"providerError",error:Yr(de,"读取语音设置失败")})}}b.useEffect(()=>{R.current=n},[n]),b.useEffect(()=>{A.current=i},[i]),b.useEffect(()=>{I.current=s},[s]);const pt=b.useCallback(async re=>{const ie=v.current,de=N.current+1;N.current=de;const pe=y.current;y.current=null,pe==null||pe.cancel(),ie&&Q("capture","stopped",{attemptId:ie,details:pe?{...pe.snapshot()}:void 0}),v.current=null;const Z=cn.getState();Z.setActivityLevel(e,0),Z.clearWaveform(e);const ne=_.current;ne&&ne.generation!==re&&(Q("capture","startup-cancelled",{details:{generation:ne.generation}}),await ne.promise.catch(()=>{}),Q("capture","startup-settled",{details:{generation:ne.generation}}));const ae=p.current;if(p.current=null,ae){Q("capture","release-started",{attemptId:ie});const Te=w.current,je=(async()=>{await Te.catch(()=>{}),await ae.stop()})();w.current=je;try{await je,Q("capture","release-finished",{attemptId:ie})}catch(st){throw Q("capture","release-failed",{attemptId:ie,details:{error:st instanceof Error?st.message:String(st)}}),st}}else await w.current;k.current&&N.current===de&&!p.current&&me("playback")},[e,me,Q]),le=b.useCallback(async()=>{var ie,de;await w.current,me("playback");const re=x.current;Q("playback","prepare-started",{details:{refreshAfterCapture:re,...(ie=E.current)==null?void 0:ie.snapshot()}}),re?(await Pg.reactivateAfterCapture(),x.current=!1):await Pg.prepare(),Q("playback","prepare-finished",{details:{refreshedAfterCapture:re,...(de=E.current)==null?void 0:de.snapshot()}})},[me,Q]),Ae=b.useCallback(re=>{!Number.isFinite(re)||re<=0||(V.current=Math.max(V.current,performance.now()+re))},[]),Ze=b.useCallback(()=>performance.now()<V.current,[]),tt=b.useCallback(()=>{const re=q.current;q.current=null,re&&Qt.getState().removeMessage(e,re)},[e]),dt=b.useCallback(()=>{var ie;const re=NTe((ie=U.current)==null?void 0:ie.getSnapshot());if(!re){tt();return}q.current||(q.current=`${e}-voice-user-${Date.now()}`),Qt.getState().upsertUserMessage(e,{id:q.current,role:"user",text:re,isPartial:!0,inputMethod:"voice",timestamp:Date.now(),toolCalls:[]})},[tt,e]),Dt=uo(re=>{if(p.current)return Promise.resolve();const ie=_.current;if(ie)return ie.generation===N.current?ie.promise:ie.promise.catch(()=>{}).then(()=>{if(!(!Ke()||!ye()))return Dt(re)});const de=N.current+1;N.current=de,Q("capture","preparing",{details:{generation:de,playStartCue:re}});const pe=cn.getState();pe.setActivityLevel(e,0),pe.clearWaveform(e);const ne=(async()=>{if(await w.current,N.current!==de||!ye())return;const ae=d.current;if(!ae)throw new Error("语音识别连接不可用");me("capture"),x.current=!0;const Te=new Oke({preRollBytes:Math.ceil(xTe*ETe/1e3),openStream:async()=>{if(N.current!==de||!ye())throw new Error("语音识别已取消");const ue=`${e}-asr-${Date.now()}-${de}`;v.current=ue,Q("asr","speech-attempt-starting",{attemptId:ue});const xe=await ae.startAttempt({sessionId:e,attemptId:ue,sampleRate:px,encoding:"mulaw"});if(N.current!==de||!ye())throw xe.abort(),new Error("语音识别已取消");return Q("asr","provider-ready",{attemptId:ue}),xe},onError:ue=>{Q("asr","speech-attempt-failed",{attemptId:v.current,details:{error:Yr(ue,"语音识别失败")}}),Xe(Yr(ue,"语音识别失败"))}});y.current=Te;const je=Vj(),st=await iye({source:je,onFrame:({pcm:ue,activityLevel:xe})=>{if(N.current!==de||!be())return;if(Ze()){cn.getState().setActivityLevel(e,0);return}const ke=cn.getState();ke.setActivityLevel(e,xe),ke.appendWaveform(e,YN(ue,DD)),Te.pushFrame(SX(ue))},onSpeechStart:()=>{Q("capture","speech-start",{details:{...Te.snapshot()}}),Te.speechStarted()},onSpeechEnd:()=>{Q("capture","speech-end",{attemptId:v.current,details:{...Te.snapshot()}}),Te.speechFinished()}});if(N.current!==de||!ye()){Te.cancel(),y.current===Te&&(y.current=null),await st.stop();return}if(p.current=st,Q("capture","source-ready",{details:{source:st.source,sampleRate:px}}),re&&(await le(),await Wt("listening-start")),N.current!==de||p.current!==st||!ye()){N.current===de&&await pt(de);return}re&&(me("capture"),x.current=!0),await st.start(),Q("capture","listening",{details:{source:st.source}})})().catch(async ae=>{throw Q("capture","start-failed",{attemptId:v.current,details:{error:ae instanceof Error?ae.message:String(ae)}}),N.current===de&&await pt(de),ae}).finally(()=>{var ae;((ae=_.current)==null?void 0:ae.promise)===ne&&(_.current=null)});return _.current={generation:de,promise:ne},ne});b.useEffect(()=>{if(!(!r||!d.current)){if(!ye()){pt().then(()=>Ge()).catch(re=>{Ke()&&cn.getState().setError(e,Yr(re,"停止语音采集失败"))});return}Dt(!1).catch(re=>{Ke()&&cn.getState().setError(e,Yr(re,"语音识别连接不可用"))})}},[l,Dt,r,e,ye,pt,Ge,Ke]);const Wt=b.useCallback(async re=>{const ie=E.current;if(!ie)throw new Error("Voice Pilot 音频尚未准备好");const de=_Te(re,ND);Q("playback","earcon-starting",{details:{kind:re,durationMs:de.durationMs,...ie.snapshot()}}),await ie.resume();const pe=ie.enqueue(de.pcm),Z=Number.isFinite(pe)?pe:de.durationMs,ne=Math.max(0,Z)+OD;Ae(ne),await LD(ne),Q("playback","earcon-finished",{details:{kind:re,...ie.snapshot()}})},[Ae,Q]),tn=b.useCallback((re=!0)=>{var Z,ne;Q("runtime","cleanup-started");const ie=pt();(Z=U.current)==null||Z.dispose(),(ne=E.current)==null||ne.stop(),V.current=0,Y.current=0;const de=d.current,pe=h.current;d.current=null,h.current=null,de==null||de.dispose(),pe==null||pe.close(),U.current=null,E.current=null,H.current=[],D.current=[],W.current=null,$.current=null,P.current.clear(),L.current.clear(),z.current=!1,ee.current.clear(),tt(),re&&(K.current=null),ie.finally(ve),Q("runtime","cleanup-finished")},[tt,ve,pt,Q]),vn=b.useCallback((re,ie)=>{const de=`${e}-tts-${Date.now()}`;P.current.set(de,{requestId:de,requestedAt:performance.now(),startedAt:null,firstPcmAt:null,pcmBytes:0,pcmChunks:0}),Q("tts","request-sent",{requestId:de,details:{textChars:ie.length,socketState:re.readyState}}),re.send(JSON.stringify({type:"speak",requestId:de,text:ie}))},[e,Q]),un=b.useCallback(async()=>{const re=h.current;if(!re||re.readyState!==WebSocket.OPEN||H.current.length===0||(await le(),!Ke()||h.current!==re))return;const ie=H.current.splice(0);for(const de of ie)vn(re,de)},[le,vn,Ke]);function Zt(re){var ie;Ke()&&((ie=W.current)==null?void 0:ie.key)!==re.key&&(D.current.some(de=>de.key===re.key)||(D.current.push(re),Xn()))}async function Xn(){if(!Ke()||W.current)return;const re=D.current.shift();if(re){W.current=re;try{if(re.kind==="approval"){if(B.current=re.requestId,await he({type:"approvalArrived",requestId:re.requestId}),!Ke()){W.current=null;return}const ie=co(I.current);if((ie==null?void 0:ie.requestId)!==re.requestId){W.current=null,Xn();return}cn.getState().setApproval(e,re.requestId)}cn.getState().setLastSpokenText(e,re.text),await he({type:"assistantTextReady",text:re.text,messageId:re.messageId})}catch(ie){W.current=null,cn.getState().setError(e,Yr(ie,"语音播报排队失败"))}}}const Kt=uo((re,ie="")=>{const de=TD(re);if(!de)return;Q("runtime","assistant-text-queued",{details:{chars:de.length,sourceChars:re.trim().length,messageId:ie||null}});const pe=ie?`assistant:${ie}:${DTe(de)}`:`assistant:${Date.now()}:${Math.random().toString(36).slice(2)}`;Zt({kind:"assistant",key:pe,text:de,messageId:ie})});function Zn(re,ie){const de=TD(ie);de&&Zt({kind:"approval",key:`approval:${re.requestId}`,text:de,messageId:re.requestId,requestId:re.requestId})}const ze=b.useCallback((re,ie="")=>{Kt(re,ie)},[Kt]),et=b.useCallback(re=>{const ie=Date.now(),de=q.current??`${e}-voice-user-${ie}`;return q.current=null,Qt.getState().upsertUserMessage(e,{id:de,role:"user",text:re,isPartial:!1,inputMethod:"voice",timestamp:ie,toolCalls:[]}),$t.getState().updateSessionState(e,"working",ie),de},[e]),Et=b.useCallback(re=>{const ie=cn.getState();if(tt(),re.type==="repeat")return ze(R.current.lastSpokenText||"还没有可以复述的内容。"),!0;if(re.type==="exit")return ie.disable(e),!0;const de=co(I.current);return de&&(re.type==="approve_once"||re.type==="approve_always"||re.type==="deny_once")&&he({type:"approvalResolved",action:re.type==="approve_once"?"approve":re.type==="approve_always"?"approve_always":"deny",requestId:de.requestId}),!0},[tt,he,e,ze]),Bt=b.useCallback(async re=>{var ne,ae;const ie=re.trim();if(!ie)return;const de=co(I.current),pe=uTe(ie,{phase:((ne=cn.getState().bySessionId[e])==null?void 0:ne.phase)??"listening",approvalPromptActive:!!de});if(pe.kind==="command"){Q("runtime","voice-command-routed",{details:{command:pe.command.type}}),Et(pe.command);return}if(Q("runtime","voice-text-routed",{details:{chars:pe.text.length,approvalPromptActive:!!de}}),await he({type:"turnIdleElapsed"}),!((ae=cn.getState().bySessionId[e])!=null&&ae.enabled))return;if(de){Q("runtime","approval-guidance-requested",{details:{chars:pe.text.length}}),tt(),ze(CTe);return}const Z=et(pe.text);await he({type:"userEndCueDone",text:pe.text,messageId:Z})},[et,tt,Et,he,e,ze,Q]),J=b.useCallback(re=>{const ie=re.trim();ie&&he({type:"asrFinal",text:ie})},[he]),_e=uo((re,ie)=>{var pe;const de=((pe=U.current)==null?void 0:pe.flushNow())??!1;Q("asr","attempt-error",{attemptId:ie,details:{error:re,preservedRecognizedText:de}}),de||Xe(re)}),Be=uo((re,ie)=>{var pe,Z;if(Q("asr","attempt-complete",{attemptId:re,details:{reason:ie}}),!be()||v.current!==re)return;const de=(pe=U.current)==null?void 0:pe.getSnapshot();if(!(de!=null&&de.draft||de!=null&&de.partial)){if((Z=y.current)!=null&&Z.rearm()){v.current=null,Q("capture","rearmed-after-empty-attempt",{attemptId:re,details:{reason:ie}});return}Q("capture","restarting-after-empty-attempt",{attemptId:re,details:{reason:ie}}),pt().then(()=>{if(!(!Ke()||!ye()))return Dt(!1)}).catch(ne=>{Ke()&&Xe(Yr(ne,"重新开始语音采集失败"))})}});function ht(){if(U.current||d.current||h.current||E.current)return;Q("runtime","creating"),U.current=new STe({idleTimeoutMs:F.current,onTurnReady:pe=>{Bt(pe)}});const re=new zke({url:PD("/voice/asr"),onPartial:(pe,Z)=>{var ne;be()&&(Q("asr","partial-received",{attemptId:Z,details:{chars:pe.length}}),(ne=U.current)==null||ne.appendPartial(pe),dt())},onFinal:(pe,Z)=>{Q("asr","final-received",{attemptId:Z,details:{chars:pe.length}}),be()&&J(pe)},onAttemptError:(pe,Z)=>{_e(pe,Z)},onAttemptComplete:(pe,Z)=>{Be(pe,Z)},onTransportError:pe=>{Q("asr","transport-error",{attemptId:v.current,details:{error:pe}}),Xe(pe)},onTrace:(pe,Z)=>{Q("asr",pe,{attemptId:v.current,details:kTe(Z)})}}),ie=new WebSocket(PD("/voice/tts"));ie.binaryType="arraybuffer",d.current=re,h.current=ie;const de=new VB(Pg.get(),ND,{onActivityLevel:pe=>{E.current===de&&cn.getState().setActivityLevel(e,pe)},onPlaybackChunk:pe=>{E.current===de&&cn.getState().appendWaveform(e,YN(pe,DD))},onPlaybackEvent:pe=>{const Z={contextState:pe.contextState,contextTime:pe.contextTime,nextStartTime:pe.nextStartTime,queuedMs:pe.queuedMs,...typeof pe.bytes=="number"?{bytes:pe.bytes}:{},...typeof pe.durationMs=="number"?{durationMs:pe.durationMs}:{},...pe.error?{error:pe.error}:{}};Q("playback",pe.event,{requestId:$.current,details:Z})}});E.current=de,re.connect().then(()=>{if(!(d.current!==re||!Ke()))return Q("asr","websocket-open"),he({type:"asrReady"})}).catch(pe=>{d.current!==re||!Ke()||Xe(Yr(pe,"语音识别连接不可用"))}),ie.addEventListener("message",pe=>{var ne;if(pe.data instanceof ArrayBuffer){const ae=new Uint8Array(pe.data),Te=$.current,je=Te?P.current.get(Te):null;je&&(je.firstPcmAt===null&&(je.firstPcmAt=performance.now(),Q("tts","first-pcm-received",{requestId:Te,details:{firstPcmMs:je.firstPcmAt-je.requestedAt,bytes:ae.byteLength,...de.snapshot()}})),je.pcmBytes+=ae.byteLength,je.pcmChunks+=1);const st=((ne=E.current)==null?void 0:ne.enqueue(ae))??0;Number.isFinite(st)&&st>0&&(Y.current=Math.max(Y.current,performance.now()+st),Ae(st+OD));return}const Z=TTe(pe.data);if(Z){if(Z.type==="started"){const ae=Z.requestId??null;$.current=ae;const Te=ae?P.current.get(ae):null;Te&&(Te.startedAt=performance.now()),Q("tts","provider-started",{requestId:ae,details:{startedMs:Te?performance.now()-Te.requestedAt:0}});return}if(Z.type==="finished"){const ae=Z.requestId??$.current,Te=ae?P.current.get(ae):null;Q("tts","provider-finished",{requestId:ae,details:{durationMs:Te?performance.now()-Te.requestedAt:0,pcmBytes:(Te==null?void 0:Te.pcmBytes)??0,pcmChunks:(Te==null?void 0:Te.pcmChunks)??0,...de.snapshot()}}),(async()=>{var ue;const je=Math.max(0,Y.current-performance.now());je>0&&await LD(je),Y.current=0;const st=cn.getState();if(st.setActivityLevel(e,0),st.clearWaveform(e),await he({type:"ttsFinished"}),ae&&P.current.delete(ae),$.current===ae&&($.current=null),W.current=null,!!((ue=cn.getState().bySessionId[e])!=null&&ue.enabled)){if(D.current.length>0){await Xn();return}await he({type:"assistantEndCueDone"}),Ge()}})().catch(je=>{cn.getState().setError(e,Yr(je,"语音播报状态更新失败"))})}Z.type==="error"&&(Q("tts","provider-error",{requestId:Z.requestId??$.current,details:{errorCode:Z.errorCode??null,error:Z.error??"语音播报失败",...de.snapshot()}}),Xe(Z.error??"语音播报失败"))}}),ie.addEventListener("close",pe=>{h.current!==ie||!Ke()||(Q("tts","websocket-closed",{requestId:$.current,details:{code:pe.code,reason:pe.reason,wasClean:pe.wasClean}}),Xe("语音播报连接已断开"))}),ie.addEventListener("error",()=>{h.current!==ie||!Ke()||(Q("tts","websocket-error",{requestId:$.current}),Xe("语音播报连接不可用"))}),ie.addEventListener("open",()=>{h.current!==ie||Rt()==="suspended"||(Q("tts","websocket-open"),he({type:"ttsReady"}).catch(pe=>{cn.getState().setError(e,Yr(pe,"语音播报连接不可用"))}),un().catch(pe=>{Ke()&&cn.getState().setError(e,Yr(pe,"准备语音播报失败"))}))}),Q("runtime","created",{details:{playbackContextState:de.snapshot().contextState}})}const jt=b.useCallback(re=>{const ie=re.text.trim();if(!ie||O.current.get(re.id)===ie)return!1;O.current.set(re.id,ie);const pe=Wke(ie);if(pe.mode==="direct")return Kt(ie,re.id),!0;const Z=kD(pe.reason),ne=Symbol(re.id);return ee.current.add(ne),(async()=>{var ae;try{const Te=Pt;if(!Te){Kt(Z,re.id);return}try{const je=await Te.requestVoiceSummary(e,re.id,ie,pe.reason);if(je.success&&((ae=je.summary)!=null&&ae.trim())){Kt(`下面是摘要:${je.summary.trim()}`,re.id);return}}catch{}Kt(Z,re.id)}finally{ee.current.delete(ne),Ge()}})(),!0},[Kt,e,Ge]);return b.useEffect(()=>{if(!r){K.current?he({type:"disableRequested"}).catch(re=>{cn.getState().setError(e,Yr(re,"停止语音助手失败"))}):(tn(),u.disable().catch(()=>{}));return}return he({type:"enableRequested"}).catch(re=>{cn.getState().setError(e,Yr(re,"启动语音助手失败"))}),()=>{tn(),u.disable().catch(()=>{})}},[tn,r,e]),b.useEffect(()=>{if(!r)return;const re=()=>{Q("runtime","page-hidden"),he({type:"suspendRequested"}).catch(de=>{Ke()&&cn.getState().setError(e,Yr(de,"暂停 Voice Pilot 失败"))})},ie=()=>{document.visibilityState==="hidden"&&re()};return document.addEventListener("visibilitychange",ie),window.addEventListener("pagehide",re),()=>{document.removeEventListener("visibilitychange",ie),window.removeEventListener("pagehide",re)}},[r,he,e,Q,Ke]),b.useEffect(()=>{if(!r){te.current=n.resumeRequestSeq;return}n.resumeRequestSeq!==te.current&&(te.current=n.resumeRequestSeq,Rt()==="suspended"&&(Q("runtime","resume-requested"),he({type:"resumeRequested"}).catch(re=>{Ke()&&cn.getState().setError(e,Yr(re,"继续 Voice Pilot 失败"))})))},[Rt,r,n.resumeRequestSeq,he,e,Q,Ke]),b.useEffect(()=>{if(!r){M.current=!1,O.current.clear();return}const re=[...i].reverse().find(ie=>ie.role==="assistant"&&!ie.isPartial);if(!M.current){re!=null&&re.text.trim()&&O.current.set(re.id,re.text.trim()),M.current=!0;return}!re||re.isPartial||jt(re)},[r,i,jt]),b.useEffect(()=>{if(!r){X.current=o,z.current=!1;return}X.current!==o&&(X.current=o,z.current=!1,Ge())},[r,Ge,o]),b.useEffect(()=>{if(!r)return;const re=co(s);if(!re){B.current=null,L.current.clear(),n.approvalRequestId&&(cn.getState().setApproval(e,null),he({type:"approvalCleared",requestId:n.approvalRequestId}).then(()=>Ge()));return}B.current!==re.requestId&&!L.current.has(re.requestId)?(cn.getState().setApproval(e,re.requestId),he({type:"approvalArrived",requestId:re.requestId}),Ot(re)):cn.getState().setApproval(e,re.requestId)},[r,i,s,n.approvalRequestId,n.phase,Ot,he,e,jt,Ge]),null}const zTe={idle:"离线",starting:"准备中",suspended:"已暂停",listening:"聆听",submitting:"发送",waiting:"等待",summarizing:"摘要",speaking:"播报",approval:"审批",error:"异常"},BTe={idle:"quiet",starting:"active",suspended:"quiet",listening:"live",submitting:"active",waiting:"active",summarizing:"active",speaking:"speak",approval:"approval",error:"error"},Lu={width:120,height:28};function jTe(e){const t=Lu.width,n=Lu.height;if(e.length===0)return"";const r=q0-e.length;return e.map((i,s)=>{const o=(r+s+.5)/q0*t,l=VN(i.max),u=VN(i.min),d=(1-l)*n/2,h=(1-u)*n/2;return`M ${o.toFixed(2)} ${d.toFixed(2)} L ${o.toFixed(2)} ${h.toFixed(2)}`}).join(" ")}function FTe({sessionId:e}){var p;const t=cn(y=>y.bySessionId[e]??ay),n=cn(y=>y.disable),r=cn(y=>y.requestResume),i=t.enabled,s=t.phase,o=t.activityLevel;if(!i)return null;const l=BTe[s],u=s!=="error"&&s!=="suspended",d=jTe(t.waveform),h=((p=t.error)==null?void 0:p.trim())||(s==="suspended"?"页面曾进入后台,继续后才会重新使用麦克风。":null);return g.jsxs("div",{"data-slot":"voice-pilot-status","data-phase":s,"data-tone":l,role:"status","aria-live":"polite",className:Ye("dev-voice-pilot-panel mb-2 min-h-[4.5rem] overflow-hidden rounded-md border px-3 py-2.5 text-sm shadow-sm",u&&"dev-voice-pilot-panel-active"),children:[g.jsxs("div",{className:"min-w-0 pr-8",children:[g.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[g.jsx("span",{className:"truncate font-semibold text-foreground",children:"Voice Pilot"}),g.jsx("span",{"data-slot":"voice-pilot-live-chip",className:"dev-voice-pilot-chip rounded-[3px] border px-1.5 py-0.5 text-[10px] font-medium leading-none tracking-normal",children:zTe[s]})]}),h?g.jsx("div",{className:"mt-1 min-w-0 break-words text-xs leading-5 text-muted-foreground",children:h}):null,s==="suspended"?g.jsxs(_t,{type:"button",size:"xs","data-slot":"voice-pilot-resume",className:"mt-2",onClick:()=>r(e),children:[g.jsx(PP,{"aria-hidden":"true"}),"继续"]}):null]}),g.jsxs(qf,{children:[g.jsx(Vf,{asChild:!0,children:g.jsx(_t,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"停止 Voice Pilot","data-slot":"voice-pilot-stop",className:"dev-voice-pilot-stop absolute right-2 top-2 size-7 rounded-[5px] p-0",onClick:()=>n(e),children:g.jsx(vc,{"aria-hidden":"true",className:"size-4"})})}),g.jsx(Yf,{side:"top",children:"停止 Voice Pilot"})]}),g.jsx("div",{"data-slot":"voice-pilot-waveform","data-activity-level":Math.round(o*100),"data-waveform-bins":t.waveform.length,className:"dev-voice-waveform mt-2",children:g.jsxs("svg",{"aria-hidden":"true","data-slot":"voice-pilot-waveform-svg",className:"dev-voice-waveform-svg",viewBox:`0 0 ${Lu.width} ${Lu.height}`,preserveAspectRatio:"none",style:{width:"calc(100% - 1rem)",height:"calc(100% - 0.7rem)"},children:[g.jsx("path",{className:"dev-voice-waveform-baseline",d:`M 0 ${Lu.height/2} H ${Lu.width}`}),g.jsx("path",{"data-slot":"voice-pilot-waveform-curve",className:"dev-voice-waveform-curve",d})]})})]})}function $Te({isIpad:e,isLandscape:t,isPty:n,keyboardOpen:r,shownForCurrentKeyboardOpen:i,dismissed:s}){return e&&t&&n&&r&&!i&&!s}function HTe(){return Ei("local",dn.ipadFloatingKeyboardHintDismissed)==="1"}function UTe(){hr("local",dn.ipadFloatingKeyboardHintDismissed,"1")}function WTe(e,t){return t&&!e}function qTe(e){return HB(e)}function VTe(e){return e.connected?e.proxyOnline?e.routeSessionEnded?"session-ended":e.sessionState==="error"?"session-error":"ok":"proxy-offline":"relay-disconnected"}function YTe(e){return e.ptyWaitingApproval&&!e.ptyAutoYesEnabled}function KTe(){const{id:e}=EU(),[t]=k9(),n=t.get("mode")??"json";return e?g.jsx(GTe,{id:e,mode:n}):g.jsx(tc,{variant:"no-session"})}function GTe({id:e,mode:t}){const n=b.useRef(0),[r,i]=b.useState(null),s=Ne(z=>z.connected),o=Ne(z=>z.proxyOnline),l=Ne(z=>z.selectedProxyId),u=$t(z=>z.sessions.find(X=>X.sessionId===e)),d=(u==null?void 0:u.kind)==="terminal",h=$t(z=>z.sessionListLoaded),p=$t(z=>z.agentStatusBySessionId[e]),y=$t(z=>z.ptyStateBySessionId[e]),v=Bx(l,e),_=$t(z=>v?!!z.ptyAutoYesBySessionKey[v]:!1),w=$t(z=>z.setPtyAutoYes),x=Qt(z=>{var X;return((X=z.bySessionId[e])==null?void 0:X.pendingApprovals)??qs.pendingApprovals}),E=WTe(u,h),k=VTe({connected:s,proxyOnline:o,routeSessionEnded:E,sessionState:u==null?void 0:u.state}),R=Qs(),A=Pi(),{bottomOffset:I,layoutBottomInset:T}=vE(),H=Ne(z=>z.inputModePreference),D=Ne(z=>z.adaptiveInputModality),W=Ne(z=>z.setAdaptiveInputModality),U=I>0,F=H==="hardware"||H==="auto"&&D==="hardware"&&!U;b.useEffect(()=>{H==="auto"&&D==="hardware"&&U&&W("touch")},[D,H,W,U]);const O=ul("(orientation: landscape)"),[M]=b.useState(()=>kv().osName==="iPad"),B=b.useRef(!1),L=F?0:I,N=F?0:T;b.useEffect(()=>{const z=L>0;if(!z){B.current=!1;return}$Te({isIpad:M,isLandscape:O,isPty:t==="pty",keyboardOpen:z,shownForCurrentKeyboardOpen:B.current,dismissed:HTe()})&&(B.current=!0,nt.info("可以缩小软键盘",{id:"ipad-floating-keyboard-hint",testId:"ipad-floating-keyboard-hint",description:"在键盘上双指向内捏合,即可切换为浮动键盘并扩大终端显示区域。",duration:8e3,classNames:{actionButton:"!h-11 !px-3"},action:{label:"不再显示",onClick:()=>UTe()}}))},[L,M,O,t]);const V=b.useRef(!1);b.useEffect(()=>{const z=Cve();z&&z===`${A.pathname}${A.search}`&&(V.current=!0)},[]),b.useEffect(()=>{if(d||!s||!o||E)return;const z=Pt;z&&(z.requestSessionResources(e).then(X=>{Rv.getState().setCommands(X.commands);const ee=ii.getState();if(ee.clearTree(),X.groups.length!==0){ee.setCwd(X.groups[0].path);for(const te of X.groups)ee.setDirEntries(te.path,te.entries)}}).catch(X=>{console.error("[chat] requestSessionResources failed",{sessionId:e},X)}),z.requestAgentStatuses(e).then(X=>{const ee=$t.getState();for(const te of X)ee.setAgentStatus(te.sessionId,te.payload)}).catch(X=>{console.error("[chat] requestAgentStatuses failed",{sessionId:e},X)}))},[e,s,o,E,d]),b.useEffect(()=>{E&&Bj()},[E]),b.useEffect(()=>{V.current&&E&&(nt.info("上次会话已结束"),R("/sessions",{replace:!0}))},[E,R]);const Y=qTe({connected:s,proxyOnline:o,routeSessionEnded:E,session:u,agentStatus:p,ptyState:y,hasPendingApproval:t==="json"&&x.some(z=>z.status==="pending")}),P=YTe({ptyWaitingApproval:!d&&t==="pty"&&k==="ok"&&Y==="waiting_approval",ptyAutoYesEnabled:_}),q=(r==null?void 0:r.sessionId)===e?r.sequence:void 0;function K(){n.current+=1,i({sessionId:e,sequence:n.current})}return g.jsx(M3,{sessionId:e,children:g.jsx(YEe,{sessionId:e,children:g.jsxs("div",{className:"flex flex-col h-full transition-[padding-bottom] duration-200 ease-out motion-reduce:transition-none",style:N?{paddingBottom:N}:void 0,"data-keyboard-offset":L,"data-keyboard-layout-inset":N,children:[g.jsx(uye,{sessionId:e,mode:t,onFind:K}),t==="json"&&k==="ok"&&g.jsx(ITe,{sessionId:e}),!d&&!P&&g.jsx(Ake,{state:Y}),P&&g.jsx(Nke,{autoYesEnabled:_,onAutoYesChange:z=>{v&&w(v,z)}}),g.jsxs("div",{className:"flex-1 min-h-0 relative",children:[k==="session-ended"?V.current?null:g.jsx(ZTe,{mode:t}):k==="session-error"?g.jsx(XTe,{mode:t,onBack:()=>R("/sessions")}):t==="pty"?g.jsx(gve,{sessionId:e,sessionKind:u==null?void 0:u.kind,provider:u==null?void 0:u.provider,findRequest:q}):g.jsx(BCe,{sessionId:e,findRequest:q}),(k==="relay-disconnected"||k==="proxy-offline")&&g.jsx(QTe,{variant:k==="relay-disconnected"?"relay":"proxy"})]}),t==="json"&&k==="ok"&&g.jsxs(g.Fragment,{children:[g.jsx(Tke,{sessionId:e}),g.jsx("div",{className:`dev-chat-input-rail-inset relative z-20 overflow-visible bg-background pt-2 transition-[padding-bottom] duration-200 ease-out motion-reduce:transition-none ${N>0?"pb-2":"pb-[max(env(safe-area-inset-bottom),0.5rem)]"}`,"data-slot":"input-bar-region",children:g.jsxs("div",{className:"dev-message-rail mx-auto w-full",children:[g.jsx(FTe,{sessionId:e}),g.jsx(Cke,{sessionId:e})]})})]})]})})})}function XTe({mode:e,onBack:t}){return g.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 bg-background px-6 text-center","data-slot":"failed-session-panel",role:"alert",children:[g.jsxs("div",{className:"space-y-1",children:[g.jsx("h2",{className:"text-lg font-semibold",children:e==="pty"?"终端连接异常":"会话连接异常"}),g.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:"与开发机上的进程通道已中断。请返回会话列表,终止后重新创建。"})]}),g.jsxs(_t,{type:"button",variant:"outline",onClick:t,children:[g.jsx(_v,{"aria-hidden":"true"}),"返回会话列表"]})]})}function ZTe({mode:e}){return g.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 px-6 text-center bg-background","data-slot":"terminated-session-panel",role:"status","aria-live":"polite",children:[g.jsx("h2",{className:"text-lg font-semibold",children:e==="pty"?"终端连接已断开":"会话已终止"}),g.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:e==="pty"?"页面已停止接收终端画面和输入。":"当前会话已经结束,输入已停止。"})]})}function QTe({variant:e}){const t=e==="relay"?"中继连接可能遇到问题":"开发机连接可能遇到问题",n=e==="relay"?"正在继续尝试连接中继服务器,网络恢复后会自动返回当前会话。":"正在继续尝试连接开发机。若长时间没有恢复,请确认 DEV Anywhere 正在开发机上运行。";return g.jsxs("div",{className:"absolute inset-0 z-30 flex flex-col items-center justify-center gap-2 px-6 text-center bg-background","data-slot":"connection-lost-panel","data-variant":e,role:"status","aria-live":"polite",children:[g.jsx("h2",{className:"text-lg font-semibold",children:t}),g.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:n})]})}function JTe(){const e=Ne(w=>w.connected),t=Ne(w=>w.phase),n=Ne(w=>w.proxyOnline),r=Ne(w=>w.relayUrl),[i,s]=b.useState(""),[o,l]=b.useState(!1),u=b.useRef(null),d=b.useRef(null),h=b.useRef(null);b.useEffect(()=>{let w=null,x=!1;return(async()=>{const k=d.current;if(!k)return;const R=await sj(k);if(x){R.dispose();return}u.current=R.terminal,w=R.dispose,window.__xterm=R.terminal})(),document.title="PTY Test -- DEV Anywhere",()=>{x=!0,w==null||w(),u.current=null,delete window.__xterm}},[]),b.useEffect(()=>()=>{var w;(w=h.current)==null||w.call(h)},[]);const p=b.useCallback(()=>{var k;if(o){(k=h.current)==null||k.call(h),h.current=null,l(!1);return}if(!i.trim()||!ec||!Pt)return;let w=!1;const x=ec.subscribeBinary(i,R=>{var A;w&&((A=u.current)==null||A.write(R))});h.current=x;const E=Pt.onMessage(R=>{const A=R;A.type==="session_snapshot"&&A.sessionId===i&&(E(),u.current&&typeof A.data=="string"&&(u.current.reset(),u.current.resize(A.cols,A.rows),u.current.write(A.data,()=>{var T;const I=(T=d.current)==null?void 0:T.querySelector(".xterm");I&&d.current&&(d.current.style.width=`${I.scrollWidth}px`)})),w=!0)});ec.send(JSON.stringify({type:"session_subscribe",sessionId:i})),l(!0)},[o,i]),y=b.useCallback(w=>{w.key==="Enter"&&p()},[p]),v=e?"bg-[var(--color-status-success)]":"bg-[var(--muted-foreground)]",_=[e?"WS Connected":"WS Disconnected",`Phase: ${t}`,n?"Proxy Online":"Proxy Offline",o?`Subscribed: ${i}`:"Not subscribed"].join(" | ");return g.jsxs("div",{className:"flex flex-col h-screen bg-[var(--background)]",children:[g.jsxs("div",{className:"sticky top-0 z-10 flex items-center gap-2 px-4 h-12 bg-[var(--card)] border-b border-[var(--border)]",children:[g.jsx("div",{className:`w-2 h-2 rounded-full ${v}`}),g.jsx("span",{className:"text-sm text-[var(--foreground)] truncate",style:{fontFamily:"var(--font-sans)"},children:_}),g.jsx("div",{className:"flex-1"}),g.jsx("span",{className:"text-xs text-[var(--muted-foreground)] hidden sm:inline",style:{fontFamily:"var(--font-mono)"},children:r}),g.jsx("input",{type:"text",value:i,onChange:w=>s(w.target.value),onKeyDown:y,readOnly:o,placeholder:"session-id",className:"w-[200px] h-8 px-2 rounded text-[13px] bg-[var(--input)] text-[var(--foreground)] border border-[var(--border)] focus:border-[var(--ring)] focus:outline-none",style:{fontFamily:"var(--font-mono)",opacity:o?.7:1}}),g.jsx(_t,{onClick:p,disabled:!e||!i.trim(),size:"sm",children:o?"Unsubscribe":"Subscribe"})]}),g.jsx("div",{className:"flex-1 overflow-auto",style:{backgroundColor:"#1E1E1E"},children:g.jsx("div",{ref:d,style:{minHeight:"100%"}})})]})}const $F=[{name:"background",cssVar:"--background",className:"bg-background"},{name:"card",cssVar:"--card",className:"bg-card"},{name:"popover",cssVar:"--popover",className:"bg-popover"},{name:"input",cssVar:"--input",className:"bg-input"},{name:"border",cssVar:"--border",className:"bg-background border border-border"}],HF=[{name:"primary",cssVar:"--primary",className:"bg-primary"},{name:"focus ring",cssVar:"--ring",className:"bg-ring"},{name:"primary-foreground",cssVar:"--primary-foreground",className:"bg-primary-foreground text-primary"},{name:"destructive",cssVar:"--destructive",className:"bg-destructive"},{name:"muted",cssVar:"--muted",className:"bg-muted"}],UF=[{name:"working",cssVar:"--color-status-working"},{name:"compacting",cssVar:"--color-status-compacting"},{name:"success",cssVar:"--color-status-success"},{name:"warning",cssVar:"--color-status-warning"},{name:"error",cssVar:"--color-status-error"}];function eRe(e){const[t,n]=b.useState({});return b.useEffect(()=>{const r=getComputedStyle(document.documentElement),i={};for(const s of e)i[s]=r.getPropertyValue(s).trim().toUpperCase()||s;n(i)},[e]),t}const tRe=[{className:"text-3xl font-bold",label:"Heading 3XL (30px) -- font-sans"},{className:"text-2xl font-semibold",label:"Heading 2XL (24px) -- font-sans"},{className:"text-xl font-medium",label:"Heading XL (20px) -- font-sans"},{className:"text-base",label:"Body text (16px) -- The quick brown fox jumps over the lazy dog. -- font-sans"},{className:"text-sm text-muted-foreground",label:"Small muted text (14px) -- font-sans"}],nRe=[{className:"w-1",label:"w-1 (4px)"},{className:"w-2",label:"w-2 (8px)"},{className:"w-3",label:"w-3 (12px)"},{className:"w-4",label:"w-4 (16px)"},{className:"w-6",label:"w-6 (24px)"},{className:"w-8",label:"w-8 (32px)"},{className:"w-12",label:"w-12 (48px)"},{className:"w-16",label:"w-16 (64px)"}],rRe=[{className:"rounded-sm",label:"sm (2px)"},{className:"rounded-md",label:"md (4px)"},{className:"rounded-lg",label:"lg (6px)"},{className:"rounded-xl",label:"xl (8px)"}];function Mh({children:e}){return g.jsx("h2",{className:"text-xl font-semibold border-b border-border pb-2",children:e})}function ID({className:e,label:t}){return g.jsxs("div",{children:[g.jsx("div",{className:`h-20 rounded-md border border-border ${e}`}),g.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t})]})}const iRe=[...$F.map(e=>e.cssVar),...HF.map(e=>e.cssVar),"--muted-foreground",...UF.map(e=>e.cssVar)];function sRe(){const e=eRe(iRe);return g.jsx("div",{className:"min-h-screen p-3 sm:p-4 lg:p-6",children:g.jsxs("div",{className:"max-w-4xl mx-auto space-y-8",children:[g.jsx("h1",{className:"text-3xl font-bold text-primary",children:"Token Showcase"}),g.jsxs("section",{className:"space-y-4",children:[g.jsx(Mh,{children:"Color Palette"}),g.jsx("h3",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wide",children:"Surface Hierarchy"}),g.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3",children:$F.map(t=>g.jsx(ID,{className:t.className,label:`${e[t.cssVar]??t.cssVar} / ${t.name}`},t.name))}),g.jsx("h3",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wide mt-6",children:"Accent & Semantic"}),g.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3",children:[HF.map(t=>g.jsx(ID,{className:t.className,label:`${e[t.cssVar]??t.cssVar} / ${t.name}`},t.name)),g.jsxs("div",{children:[g.jsx("div",{className:"h-20 rounded-md border border-border bg-background flex items-center justify-center",children:g.jsx("span",{className:"text-muted-foreground",children:e["--muted-foreground"]??"—"})}),g.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[e["--muted-foreground"]??"—"," / muted-foreground"]})]})]}),g.jsx("h3",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wide mt-6",children:"Status Colors"}),g.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-5 gap-3",children:UF.map(t=>g.jsxs("div",{children:[g.jsx("div",{className:"h-20 rounded-md border border-border",style:{backgroundColor:`var(${t.cssVar})`}}),g.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[e[t.cssVar]??t.cssVar," / ",t.name]})]},t.name))})]}),g.jsxs("section",{className:"space-y-4",children:[g.jsx(Mh,{children:"Typography"}),g.jsx("div",{className:"space-y-3",children:tRe.map(t=>g.jsx("div",{children:g.jsx("p",{className:t.className,children:t.label})},t.label))}),g.jsx("h3",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wide mt-6",children:"Monospace (Sarasa Fixed SC)"}),g.jsxs("div",{className:"space-y-2 bg-card p-3 rounded-md border border-border",children:[g.jsx("p",{className:"text-base font-mono",children:"const greeting = 'Hello'; // Sarasa Fixed SC"}),g.jsx("p",{className:"text-base font-mono",children:"const msg = '----'; // CJK alignment test"})]})]}),g.jsxs("section",{className:"space-y-4",children:[g.jsx(Mh,{children:"Spacing"}),g.jsx("div",{className:"space-y-2",children:nRe.map(t=>g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsx("div",{className:`${t.className} h-3 bg-primary rounded-sm`}),g.jsx("span",{className:"text-xs text-muted-foreground",children:t.label})]},t.label))})]}),g.jsxs("section",{className:"space-y-4",children:[g.jsx(Mh,{children:"Border Radius"}),g.jsx("div",{className:"flex flex-wrap gap-4",children:rRe.map(t=>g.jsxs("div",{className:"text-center",children:[g.jsx("div",{className:`w-16 h-16 bg-card border border-border ${t.className}`}),g.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t.label})]},t.label))})]}),g.jsxs("section",{className:"space-y-4",children:[g.jsx(Mh,{children:"Button Variants"}),g.jsx("h3",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wide",children:"Variants"}),g.jsxs("div",{className:"flex flex-wrap gap-3",children:[g.jsx(_t,{children:"Default"}),g.jsx(_t,{variant:"destructive",children:"Destructive"}),g.jsx(_t,{variant:"outline",children:"Outline"}),g.jsx(_t,{variant:"secondary",children:"Secondary"}),g.jsx(_t,{variant:"ghost",children:"Ghost"}),g.jsx(_t,{variant:"link",children:"Link"})]}),g.jsx("h3",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wide mt-4",children:"Sizes"}),g.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[g.jsx(_t,{size:"sm",children:"Small"}),g.jsx(_t,{size:"default",children:"Default"}),g.jsx(_t,{size:"lg",children:"Large"}),g.jsx(_t,{size:"icon",children:g.jsx("span",{children:"+"})})]})]})]})})}const oRe=`# Heading 1
697
+ `)}function OTe(e,t){const r=`需要审批:${e.trim().replace(/[。.!?!?\s]+$/u,"")||"有一个工具操作正在等待审批"}`;return t&&t.total>1?`有 ${t.total} 个工具审批待处理。第 ${t.position} 个,共 ${t.total} 个。${r}。请说允许、始终允许或拒绝。`:`${r}。请说允许、始终允许或拒绝。`}function DTe(e){let t=0;for(let n=0;n<e.length;n+=1)t=t*31+e.charCodeAt(n)|0;return`${e.length}:${Math.abs(t)}`}function PTe(){if(typeof window>"u")return MD;const e=window.__devAnywhereVoicePilotTurnIdleMs;return typeof e=="number"&&Number.isFinite(e)&&e>0?e:MD}function LTe(e,t){if(typeof e!="number"||!Number.isSafeInteger(e)||e<=0)return t;const n=e*1e3;return Number.isSafeInteger(n)&&n>0?n:t}function uo(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e}),b.useCallback(((...n)=>t.current(...n)),[])}function ITe({sessionId:e,turnIdleMs:t=PTe()}){const n=cn(re=>re.bySessionId[e]??ay),r=n.enabled,i=Qt(re=>{var ie;return((ie=re.bySessionId[e])==null?void 0:ie.messages)??qs.messages}),s=Qt(re=>{var ie;return((ie=re.bySessionId[e])==null?void 0:ie.pendingApprovals)??qs.pendingApprovals}),o=Qt(re=>{var ie;return((ie=re.bySessionId[e])==null?void 0:ie.turnCompletionVersion)??qs.turnCompletionVersion}),l=$t(re=>{const ie=re.sessions.find(Z=>Z.sessionId===e),de=re.agentStatusBySessionId[e],pe=re.ptyStateBySessionId[e];return dTe({sessionState:ie==null?void 0:ie.state,agentPhase:de==null?void 0:de.phase,ptyState:pe==null?void 0:pe.state})}),u=H4(W4(e)),d=b.useRef(null),h=b.useRef(null),p=b.useRef(null),y=b.useRef(null),v=b.useRef(null),_=b.useRef(null),w=b.useRef(Promise.resolve()),x=b.useRef(!1),E=b.useRef(null),k=b.useRef(null),R=b.useRef(n),A=b.useRef(i),I=b.useRef(s),T=b.useRef(l),H=b.useRef([]),D=b.useRef([]),W=b.useRef(null),U=b.useRef(null),F=b.useRef(t),O=b.useRef(new Map),M=b.useRef(!1),B=b.useRef(null),L=b.useRef(new Set),N=b.useRef(0),V=b.useRef(0),Y=b.useRef(0),$=b.useRef(null),P=b.useRef(new Map),q=b.useRef(null),K=b.useRef(null),z=b.useRef(!1),X=b.useRef(o),ee=b.useRef(new Set),te=b.useRef(n.resumeRequestSeq);T.current=l;const Q=b.useCallback((re,ie,de={})=>{Gh({sessionId:e,scope:re,event:ie,...de})},[e]),me=b.useCallback(re=>{const ie=Nh();try{k.current?k.current.setMode(re):k.current=I1.acquire(re),Q("audio-session","mode-applied",{details:{mode:re,previousType:ie,currentType:Nh()}})}catch(de){throw Q("audio-session","mode-failed",{details:{mode:re,previousType:ie,currentType:Nh(),error:de instanceof Error?de.message:String(de)}}),de}},[Q]),ve=b.useCallback(()=>{var ie;const re=Nh();(ie=k.current)==null||ie.release(),k.current=null,Q("audio-session","released",{details:{previousType:re,currentType:Nh()}})},[Q]);function Ce(){return K.current||(K.current=wTe()),K.current}async function Me(re){var ie,de;for(const pe of re)switch(pe.type){case"loadConfig":rt();break;case"requestMicPermission":he({type:"micPermissionGranted"});break;case"requestWakeLock":u.enable().catch(Z=>{Xe(Yr(Z,"无法保持屏幕常亮"))});break;case"releaseWakeLock":u.disable().catch(()=>{});break;case"stopCapture":await pt();break;case"beginListening":ye()?await Dt(!0):(await pt(),Ge());break;case"playCue":await le(),await Wt(pe.cue);break;case"appendFinalToTurnBuffer":(ie=U.current)==null||ie.appendFinal(pe.text),dt();break;case"cancelTurnBuffer":(de=U.current)==null||de.cancel();break;case"speakText":case"speakStatic":{await le();const Z=h.current;if(!Z||Z.readyState!==WebSocket.OPEN){H.current.push(pe.text);break}vn(Z,pe.text);break}case"submitText":{const Z=Pt;if(!Z){cn.getState().setError(e,"开发机连接不可用");break}z.current=!0,Z.sendEnvelope({type:"user_input",sessionId:e,payload:{text:pe.text,messageId:pe.messageId},seq:0,timestamp:Date.now(),source:"client",version:"1"}),Q("runtime","user-text-submitted",{details:{chars:pe.text.length,messageId:pe.messageId}});break}case"approveTool":z.current=!0,Pt==null||Pt.sendControl({type:"tool_approve",sessionId:e,payload:{toolId:pe.requestId,whitelistTool:pe.whitelistTool}});break;case"denyTool":z.current=!0,Pt==null||Pt.sendControl({type:"tool_deny",sessionId:e,payload:{toolId:pe.requestId}});break;case"requestSummary":Ve(pe.text,pe.messageId,pe.reason);break;case"cleanup":tn();break;case"suspendRuntime":tn(!1);break;case"setError":ve(),cn.getState().setError(e,pe.error);break;default:{const Z=pe;throw new Error(`Unhandled Voice Pilot effect: ${JSON.stringify(Z)}`)}}}async function Ve(re,ie,de){var ne;const pe=Pt,Z=kD(de);if(!pe){await he({type:"summaryFailed",fallbackText:Z,messageId:ie});return}try{const ae=await pe.requestVoiceSummary(e,ie,re,de);if(ae.success&&((ne=ae.summary)!=null&&ne.trim())){const Te=`下面是摘要:${ae.summary.trim()}`;await he({type:"summaryReady",text:Te,messageId:ie});return}}catch{}await he({type:"summaryFailed",fallbackText:Z,messageId:ie})}async function Qe(re){var pe;const ie=rTe(re),de=Pt;if(!de)return ie;try{const Z=await de.requestVoiceSummary(e,re.requestId,MTe(re),"approval");if(Z.success&&((pe=Z.summary)!=null&&pe.trim()))return Z.summary.trim()}catch{}return ie}function ct(){const re=[...A.current].reverse().find(ie=>ie.role==="assistant"&&ie.text.trim());re&&jt(re)}const Ot=uo(re=>{Ke()&&(L.current.has(re.requestId)||(L.current.add(re.requestId),ct(),(async()=>{try{const ie=await Qe(re);if(!Ke())return;const de=co(I.current);if((de==null?void 0:de.requestId)!==re.requestId)return;Zn(re,OTe(ie,ATe(I.current,re.requestId)))}catch(ie){L.current.delete(re.requestId),cn.getState().setError(e,Yr(ie,"审批播报失败"))}})()))}),he=uo(async re=>{const ie=Ce(),de=ie.getPhase(),pe=ie.send(re),Z=ie.getPhase();Q("state-machine","transition",{details:{input:re.type,previousPhase:de,nextPhase:Z,effectCount:pe.effects.length}});const ne=pe.effects.some(ae=>ae.type==="beginListening");ne||cn.getState().setPhase(e,Z),await Me(pe.effects),ne&&Ke()&&ie.getPhase()===Z&&cn.getState().setPhase(e,Z)}),Ke=uo(()=>{var re;return!!((re=cn.getState().bySessionId[e])!=null&&re.enabled)}),Rt=uo(()=>{var re,ie;return((re=K.current)==null?void 0:re.getPhase())??((ie=cn.getState().bySessionId[e])==null?void 0:ie.phase)??R.current.phase}),ye=uo(()=>{const re=Rt();return re==="approval"?!!co(I.current):re==="listening"?!T.current&&!co(I.current):!1});function He(){return ee.current.size>0||!!W.current||D.current.length>0}const Ge=uo(()=>{if(!Ke()||!K.current)return;const re=Rt(),ie=!!co(I.current);if(re==="listening"&&T.current&&!ie){z.current=!0,he({type:"agentBecameBusy"});return}re==="waiting"&&!z.current&&!T.current&&!ie&&!He()&&he({type:"agentBecameIdle"})}),be=b.useCallback(()=>{const re=Rt();return re==="approval"?!!co(I.current):re==="listening"?!T.current&&!co(I.current):!1},[Rt]);function Xe(re){!Ke()||!K.current||he({type:"providerError",error:re}).catch(ie=>{Ke()&&cn.getState().setError(e,Yr(ie,re))})}async function rt(){var ie;if(!Ke())return;const re=Pt;if(!re){await he({type:"providerError",error:"开发机连接不可用"});return}try{const de=await re.requestVoiceConfig();if(!Ke())return;if(!((ie=de.config)!=null&&ie.configured)){await he({type:"providerError",error:"请先在设置里配置 Voice Pilot。"});return}if(F.current=LTe(de.config.turnIdleSeconds,t),await he({type:"configReady"}),!Ke()||Rt()!=="starting")return;ht()}catch(de){if(!Ke())return;await he({type:"providerError",error:Yr(de,"读取语音设置失败")})}}b.useEffect(()=>{R.current=n},[n]),b.useEffect(()=>{A.current=i},[i]),b.useEffect(()=>{I.current=s},[s]);const pt=b.useCallback(async re=>{const ie=v.current,de=N.current+1;N.current=de;const pe=y.current;y.current=null,pe==null||pe.cancel(),ie&&Q("capture","stopped",{attemptId:ie,details:pe?{...pe.snapshot()}:void 0}),v.current=null;const Z=cn.getState();Z.setActivityLevel(e,0),Z.clearWaveform(e);const ne=_.current;ne&&ne.generation!==re&&(Q("capture","startup-cancelled",{details:{generation:ne.generation}}),await ne.promise.catch(()=>{}),Q("capture","startup-settled",{details:{generation:ne.generation}}));const ae=p.current;if(p.current=null,ae){Q("capture","release-started",{attemptId:ie});const Te=w.current,je=(async()=>{await Te.catch(()=>{}),await ae.stop()})();w.current=je;try{await je,Q("capture","release-finished",{attemptId:ie})}catch(st){throw Q("capture","release-failed",{attemptId:ie,details:{error:st instanceof Error?st.message:String(st)}}),st}}else await w.current;k.current&&N.current===de&&!p.current&&me("playback")},[e,me,Q]),le=b.useCallback(async()=>{var ie,de;await w.current,me("playback");const re=x.current;Q("playback","prepare-started",{details:{refreshAfterCapture:re,...(ie=E.current)==null?void 0:ie.snapshot()}}),re?(await Pg.reactivateAfterCapture(),x.current=!1):await Pg.prepare(),Q("playback","prepare-finished",{details:{refreshedAfterCapture:re,...(de=E.current)==null?void 0:de.snapshot()}})},[me,Q]),Ae=b.useCallback(re=>{!Number.isFinite(re)||re<=0||(V.current=Math.max(V.current,performance.now()+re))},[]),Ze=b.useCallback(()=>performance.now()<V.current,[]),tt=b.useCallback(()=>{const re=q.current;q.current=null,re&&Qt.getState().removeMessage(e,re)},[e]),dt=b.useCallback(()=>{var ie;const re=NTe((ie=U.current)==null?void 0:ie.getSnapshot());if(!re){tt();return}q.current||(q.current=`${e}-voice-user-${Date.now()}`),Qt.getState().upsertUserMessage(e,{id:q.current,role:"user",text:re,isPartial:!0,inputMethod:"voice",timestamp:Date.now(),toolCalls:[]})},[tt,e]),Dt=uo(re=>{if(p.current)return Promise.resolve();const ie=_.current;if(ie)return ie.generation===N.current?ie.promise:ie.promise.catch(()=>{}).then(()=>{if(!(!Ke()||!ye()))return Dt(re)});const de=N.current+1;N.current=de,Q("capture","preparing",{details:{generation:de,playStartCue:re}});const pe=cn.getState();pe.setActivityLevel(e,0),pe.clearWaveform(e);const ne=(async()=>{if(await w.current,N.current!==de||!ye())return;const ae=d.current;if(!ae)throw new Error("语音识别连接不可用");me("capture"),x.current=!0;const Te=new Oke({preRollBytes:Math.ceil(xTe*ETe/1e3),openStream:async()=>{if(N.current!==de||!ye())throw new Error("语音识别已取消");const ue=`${e}-asr-${Date.now()}-${de}`;v.current=ue,Q("asr","speech-attempt-starting",{attemptId:ue});const xe=await ae.startAttempt({sessionId:e,attemptId:ue,sampleRate:px,encoding:"mulaw"});if(N.current!==de||!ye())throw xe.abort(),new Error("语音识别已取消");return Q("asr","provider-ready",{attemptId:ue}),xe},onError:ue=>{Q("asr","speech-attempt-failed",{attemptId:v.current,details:{error:Yr(ue,"语音识别失败")}}),Xe(Yr(ue,"语音识别失败"))}});y.current=Te;const je=V4(),st=await iye({source:je,onFrame:({pcm:ue,activityLevel:xe})=>{if(N.current!==de||!be())return;if(Ze()){cn.getState().setActivityLevel(e,0);return}const ke=cn.getState();ke.setActivityLevel(e,xe),ke.appendWaveform(e,YN(ue,DD)),Te.pushFrame(SX(ue))},onSpeechStart:()=>{Q("capture","speech-start",{details:{...Te.snapshot()}}),Te.speechStarted()},onSpeechEnd:()=>{Q("capture","speech-end",{attemptId:v.current,details:{...Te.snapshot()}}),Te.speechFinished()}});if(N.current!==de||!ye()){Te.cancel(),y.current===Te&&(y.current=null),await st.stop();return}if(p.current=st,Q("capture","source-ready",{details:{source:st.source,sampleRate:px}}),re&&(await le(),await Wt("listening-start")),N.current!==de||p.current!==st||!ye()){N.current===de&&await pt(de);return}re&&(me("capture"),x.current=!0),await st.start(),Q("capture","listening",{details:{source:st.source}})})().catch(async ae=>{throw Q("capture","start-failed",{attemptId:v.current,details:{error:ae instanceof Error?ae.message:String(ae)}}),N.current===de&&await pt(de),ae}).finally(()=>{var ae;((ae=_.current)==null?void 0:ae.promise)===ne&&(_.current=null)});return _.current={generation:de,promise:ne},ne});b.useEffect(()=>{if(!(!r||!d.current)){if(!ye()){pt().then(()=>Ge()).catch(re=>{Ke()&&cn.getState().setError(e,Yr(re,"停止语音采集失败"))});return}Dt(!1).catch(re=>{Ke()&&cn.getState().setError(e,Yr(re,"语音识别连接不可用"))})}},[l,Dt,r,e,ye,pt,Ge,Ke]);const Wt=b.useCallback(async re=>{const ie=E.current;if(!ie)throw new Error("Voice Pilot 音频尚未准备好");const de=_Te(re,ND);Q("playback","earcon-starting",{details:{kind:re,durationMs:de.durationMs,...ie.snapshot()}}),await ie.resume();const pe=ie.enqueue(de.pcm),Z=Number.isFinite(pe)?pe:de.durationMs,ne=Math.max(0,Z)+OD;Ae(ne),await LD(ne),Q("playback","earcon-finished",{details:{kind:re,...ie.snapshot()}})},[Ae,Q]),tn=b.useCallback((re=!0)=>{var Z,ne;Q("runtime","cleanup-started");const ie=pt();(Z=U.current)==null||Z.dispose(),(ne=E.current)==null||ne.stop(),V.current=0,Y.current=0;const de=d.current,pe=h.current;d.current=null,h.current=null,de==null||de.dispose(),pe==null||pe.close(),U.current=null,E.current=null,H.current=[],D.current=[],W.current=null,$.current=null,P.current.clear(),L.current.clear(),z.current=!1,ee.current.clear(),tt(),re&&(K.current=null),ie.finally(ve),Q("runtime","cleanup-finished")},[tt,ve,pt,Q]),vn=b.useCallback((re,ie)=>{const de=`${e}-tts-${Date.now()}`;P.current.set(de,{requestId:de,requestedAt:performance.now(),startedAt:null,firstPcmAt:null,pcmBytes:0,pcmChunks:0}),Q("tts","request-sent",{requestId:de,details:{textChars:ie.length,socketState:re.readyState}}),re.send(JSON.stringify({type:"speak",requestId:de,text:ie}))},[e,Q]),un=b.useCallback(async()=>{const re=h.current;if(!re||re.readyState!==WebSocket.OPEN||H.current.length===0||(await le(),!Ke()||h.current!==re))return;const ie=H.current.splice(0);for(const de of ie)vn(re,de)},[le,vn,Ke]);function Zt(re){var ie;Ke()&&((ie=W.current)==null?void 0:ie.key)!==re.key&&(D.current.some(de=>de.key===re.key)||(D.current.push(re),Xn()))}async function Xn(){if(!Ke()||W.current)return;const re=D.current.shift();if(re){W.current=re;try{if(re.kind==="approval"){if(B.current=re.requestId,await he({type:"approvalArrived",requestId:re.requestId}),!Ke()){W.current=null;return}const ie=co(I.current);if((ie==null?void 0:ie.requestId)!==re.requestId){W.current=null,Xn();return}cn.getState().setApproval(e,re.requestId)}cn.getState().setLastSpokenText(e,re.text),await he({type:"assistantTextReady",text:re.text,messageId:re.messageId})}catch(ie){W.current=null,cn.getState().setError(e,Yr(ie,"语音播报排队失败"))}}}const Kt=uo((re,ie="")=>{const de=TD(re);if(!de)return;Q("runtime","assistant-text-queued",{details:{chars:de.length,sourceChars:re.trim().length,messageId:ie||null}});const pe=ie?`assistant:${ie}:${DTe(de)}`:`assistant:${Date.now()}:${Math.random().toString(36).slice(2)}`;Zt({kind:"assistant",key:pe,text:de,messageId:ie})});function Zn(re,ie){const de=TD(ie);de&&Zt({kind:"approval",key:`approval:${re.requestId}`,text:de,messageId:re.requestId,requestId:re.requestId})}const ze=b.useCallback((re,ie="")=>{Kt(re,ie)},[Kt]),et=b.useCallback(re=>{const ie=Date.now(),de=q.current??`${e}-voice-user-${ie}`;return q.current=null,Qt.getState().upsertUserMessage(e,{id:de,role:"user",text:re,isPartial:!1,inputMethod:"voice",timestamp:ie,toolCalls:[]}),$t.getState().updateSessionState(e,"working",ie),de},[e]),Et=b.useCallback(re=>{const ie=cn.getState();if(tt(),re.type==="repeat")return ze(R.current.lastSpokenText||"还没有可以复述的内容。"),!0;if(re.type==="exit")return ie.disable(e),!0;const de=co(I.current);return de&&(re.type==="approve_once"||re.type==="approve_always"||re.type==="deny_once")&&he({type:"approvalResolved",action:re.type==="approve_once"?"approve":re.type==="approve_always"?"approve_always":"deny",requestId:de.requestId}),!0},[tt,he,e,ze]),Bt=b.useCallback(async re=>{var ne,ae;const ie=re.trim();if(!ie)return;const de=co(I.current),pe=uTe(ie,{phase:((ne=cn.getState().bySessionId[e])==null?void 0:ne.phase)??"listening",approvalPromptActive:!!de});if(pe.kind==="command"){Q("runtime","voice-command-routed",{details:{command:pe.command.type}}),Et(pe.command);return}if(Q("runtime","voice-text-routed",{details:{chars:pe.text.length,approvalPromptActive:!!de}}),await he({type:"turnIdleElapsed"}),!((ae=cn.getState().bySessionId[e])!=null&&ae.enabled))return;if(de){Q("runtime","approval-guidance-requested",{details:{chars:pe.text.length}}),tt(),ze(CTe);return}const Z=et(pe.text);await he({type:"userEndCueDone",text:pe.text,messageId:Z})},[et,tt,Et,he,e,ze,Q]),J=b.useCallback(re=>{const ie=re.trim();ie&&he({type:"asrFinal",text:ie})},[he]),_e=uo((re,ie)=>{var pe;const de=((pe=U.current)==null?void 0:pe.flushNow())??!1;Q("asr","attempt-error",{attemptId:ie,details:{error:re,preservedRecognizedText:de}}),de||Xe(re)}),Be=uo((re,ie)=>{var pe,Z;if(Q("asr","attempt-complete",{attemptId:re,details:{reason:ie}}),!be()||v.current!==re)return;const de=(pe=U.current)==null?void 0:pe.getSnapshot();if(!(de!=null&&de.draft||de!=null&&de.partial)){if((Z=y.current)!=null&&Z.rearm()){v.current=null,Q("capture","rearmed-after-empty-attempt",{attemptId:re,details:{reason:ie}});return}Q("capture","restarting-after-empty-attempt",{attemptId:re,details:{reason:ie}}),pt().then(()=>{if(!(!Ke()||!ye()))return Dt(!1)}).catch(ne=>{Ke()&&Xe(Yr(ne,"重新开始语音采集失败"))})}});function ht(){if(U.current||d.current||h.current||E.current)return;Q("runtime","creating"),U.current=new STe({idleTimeoutMs:F.current,onTurnReady:pe=>{Bt(pe)}});const re=new zke({url:PD("/voice/asr"),onPartial:(pe,Z)=>{var ne;be()&&(Q("asr","partial-received",{attemptId:Z,details:{chars:pe.length}}),(ne=U.current)==null||ne.appendPartial(pe),dt())},onFinal:(pe,Z)=>{Q("asr","final-received",{attemptId:Z,details:{chars:pe.length}}),be()&&J(pe)},onAttemptError:(pe,Z)=>{_e(pe,Z)},onAttemptComplete:(pe,Z)=>{Be(pe,Z)},onTransportError:pe=>{Q("asr","transport-error",{attemptId:v.current,details:{error:pe}}),Xe(pe)},onTrace:(pe,Z)=>{Q("asr",pe,{attemptId:v.current,details:kTe(Z)})}}),ie=new WebSocket(PD("/voice/tts"));ie.binaryType="arraybuffer",d.current=re,h.current=ie;const de=new VB(Pg.get(),ND,{onActivityLevel:pe=>{E.current===de&&cn.getState().setActivityLevel(e,pe)},onPlaybackChunk:pe=>{E.current===de&&cn.getState().appendWaveform(e,YN(pe,DD))},onPlaybackEvent:pe=>{const Z={contextState:pe.contextState,contextTime:pe.contextTime,nextStartTime:pe.nextStartTime,queuedMs:pe.queuedMs,...typeof pe.bytes=="number"?{bytes:pe.bytes}:{},...typeof pe.durationMs=="number"?{durationMs:pe.durationMs}:{},...pe.error?{error:pe.error}:{}};Q("playback",pe.event,{requestId:$.current,details:Z})}});E.current=de,re.connect().then(()=>{if(!(d.current!==re||!Ke()))return Q("asr","websocket-open"),he({type:"asrReady"})}).catch(pe=>{d.current!==re||!Ke()||Xe(Yr(pe,"语音识别连接不可用"))}),ie.addEventListener("message",pe=>{var ne;if(pe.data instanceof ArrayBuffer){const ae=new Uint8Array(pe.data),Te=$.current,je=Te?P.current.get(Te):null;je&&(je.firstPcmAt===null&&(je.firstPcmAt=performance.now(),Q("tts","first-pcm-received",{requestId:Te,details:{firstPcmMs:je.firstPcmAt-je.requestedAt,bytes:ae.byteLength,...de.snapshot()}})),je.pcmBytes+=ae.byteLength,je.pcmChunks+=1);const st=((ne=E.current)==null?void 0:ne.enqueue(ae))??0;Number.isFinite(st)&&st>0&&(Y.current=Math.max(Y.current,performance.now()+st),Ae(st+OD));return}const Z=TTe(pe.data);if(Z){if(Z.type==="started"){const ae=Z.requestId??null;$.current=ae;const Te=ae?P.current.get(ae):null;Te&&(Te.startedAt=performance.now()),Q("tts","provider-started",{requestId:ae,details:{startedMs:Te?performance.now()-Te.requestedAt:0}});return}if(Z.type==="finished"){const ae=Z.requestId??$.current,Te=ae?P.current.get(ae):null;Q("tts","provider-finished",{requestId:ae,details:{durationMs:Te?performance.now()-Te.requestedAt:0,pcmBytes:(Te==null?void 0:Te.pcmBytes)??0,pcmChunks:(Te==null?void 0:Te.pcmChunks)??0,...de.snapshot()}}),(async()=>{var ue;const je=Math.max(0,Y.current-performance.now());je>0&&await LD(je),Y.current=0;const st=cn.getState();if(st.setActivityLevel(e,0),st.clearWaveform(e),await he({type:"ttsFinished"}),ae&&P.current.delete(ae),$.current===ae&&($.current=null),W.current=null,!!((ue=cn.getState().bySessionId[e])!=null&&ue.enabled)){if(D.current.length>0){await Xn();return}await he({type:"assistantEndCueDone"}),Ge()}})().catch(je=>{cn.getState().setError(e,Yr(je,"语音播报状态更新失败"))})}Z.type==="error"&&(Q("tts","provider-error",{requestId:Z.requestId??$.current,details:{errorCode:Z.errorCode??null,error:Z.error??"语音播报失败",...de.snapshot()}}),Xe(Z.error??"语音播报失败"))}}),ie.addEventListener("close",pe=>{h.current!==ie||!Ke()||(Q("tts","websocket-closed",{requestId:$.current,details:{code:pe.code,reason:pe.reason,wasClean:pe.wasClean}}),Xe("语音播报连接已断开"))}),ie.addEventListener("error",()=>{h.current!==ie||!Ke()||(Q("tts","websocket-error",{requestId:$.current}),Xe("语音播报连接不可用"))}),ie.addEventListener("open",()=>{h.current!==ie||Rt()==="suspended"||(Q("tts","websocket-open"),he({type:"ttsReady"}).catch(pe=>{cn.getState().setError(e,Yr(pe,"语音播报连接不可用"))}),un().catch(pe=>{Ke()&&cn.getState().setError(e,Yr(pe,"准备语音播报失败"))}))}),Q("runtime","created",{details:{playbackContextState:de.snapshot().contextState}})}const jt=b.useCallback(re=>{const ie=re.text.trim();if(!ie||O.current.get(re.id)===ie)return!1;O.current.set(re.id,ie);const pe=Wke(ie);if(pe.mode==="direct")return Kt(ie,re.id),!0;const Z=kD(pe.reason),ne=Symbol(re.id);return ee.current.add(ne),(async()=>{var ae;try{const Te=Pt;if(!Te){Kt(Z,re.id);return}try{const je=await Te.requestVoiceSummary(e,re.id,ie,pe.reason);if(je.success&&((ae=je.summary)!=null&&ae.trim())){Kt(`下面是摘要:${je.summary.trim()}`,re.id);return}}catch{}Kt(Z,re.id)}finally{ee.current.delete(ne),Ge()}})(),!0},[Kt,e,Ge]);return b.useEffect(()=>{if(!r){K.current?he({type:"disableRequested"}).catch(re=>{cn.getState().setError(e,Yr(re,"停止语音助手失败"))}):(tn(),u.disable().catch(()=>{}));return}return he({type:"enableRequested"}).catch(re=>{cn.getState().setError(e,Yr(re,"启动语音助手失败"))}),()=>{tn(),u.disable().catch(()=>{})}},[tn,r,e]),b.useEffect(()=>{if(!r)return;const re=()=>{Q("runtime","page-hidden"),he({type:"suspendRequested"}).catch(de=>{Ke()&&cn.getState().setError(e,Yr(de,"暂停 Voice Pilot 失败"))})},ie=()=>{document.visibilityState==="hidden"&&re()};return document.addEventListener("visibilitychange",ie),window.addEventListener("pagehide",re),()=>{document.removeEventListener("visibilitychange",ie),window.removeEventListener("pagehide",re)}},[r,he,e,Q,Ke]),b.useEffect(()=>{if(!r){te.current=n.resumeRequestSeq;return}n.resumeRequestSeq!==te.current&&(te.current=n.resumeRequestSeq,Rt()==="suspended"&&(Q("runtime","resume-requested"),he({type:"resumeRequested"}).catch(re=>{Ke()&&cn.getState().setError(e,Yr(re,"继续 Voice Pilot 失败"))})))},[Rt,r,n.resumeRequestSeq,he,e,Q,Ke]),b.useEffect(()=>{if(!r){M.current=!1,O.current.clear();return}const re=[...i].reverse().find(ie=>ie.role==="assistant"&&!ie.isPartial);if(!M.current){re!=null&&re.text.trim()&&O.current.set(re.id,re.text.trim()),M.current=!0;return}!re||re.isPartial||jt(re)},[r,i,jt]),b.useEffect(()=>{if(!r){X.current=o,z.current=!1;return}X.current!==o&&(X.current=o,z.current=!1,Ge())},[r,Ge,o]),b.useEffect(()=>{if(!r)return;const re=co(s);if(!re){B.current=null,L.current.clear(),n.approvalRequestId&&(cn.getState().setApproval(e,null),he({type:"approvalCleared",requestId:n.approvalRequestId}).then(()=>Ge()));return}B.current!==re.requestId&&!L.current.has(re.requestId)?(cn.getState().setApproval(e,re.requestId),he({type:"approvalArrived",requestId:re.requestId}),Ot(re)):cn.getState().setApproval(e,re.requestId)},[r,i,s,n.approvalRequestId,n.phase,Ot,he,e,jt,Ge]),null}const zTe={idle:"离线",starting:"准备中",suspended:"已暂停",listening:"聆听",submitting:"发送",waiting:"等待",summarizing:"摘要",speaking:"播报",approval:"审批",error:"异常"},BTe={idle:"quiet",starting:"active",suspended:"quiet",listening:"live",submitting:"active",waiting:"active",summarizing:"active",speaking:"speak",approval:"approval",error:"error"},Lu={width:120,height:28};function jTe(e){const t=Lu.width,n=Lu.height;if(e.length===0)return"";const r=q0-e.length;return e.map((i,s)=>{const o=(r+s+.5)/q0*t,l=VN(i.max),u=VN(i.min),d=(1-l)*n/2,h=(1-u)*n/2;return`M ${o.toFixed(2)} ${d.toFixed(2)} L ${o.toFixed(2)} ${h.toFixed(2)}`}).join(" ")}function FTe({sessionId:e}){var p;const t=cn(y=>y.bySessionId[e]??ay),n=cn(y=>y.disable),r=cn(y=>y.requestResume),i=t.enabled,s=t.phase,o=t.activityLevel;if(!i)return null;const l=BTe[s],u=s!=="error"&&s!=="suspended",d=jTe(t.waveform),h=((p=t.error)==null?void 0:p.trim())||(s==="suspended"?"页面曾进入后台,继续后才会重新使用麦克风。":null);return g.jsxs("div",{"data-slot":"voice-pilot-status","data-phase":s,"data-tone":l,role:"status","aria-live":"polite",className:Ye("dev-voice-pilot-panel mb-2 min-h-[4.5rem] overflow-hidden rounded-md border px-3 py-2.5 text-sm shadow-sm",u&&"dev-voice-pilot-panel-active"),children:[g.jsxs("div",{className:"min-w-0 pr-8",children:[g.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[g.jsx("span",{className:"truncate font-semibold text-foreground",children:"Voice Pilot"}),g.jsx("span",{"data-slot":"voice-pilot-live-chip",className:"dev-voice-pilot-chip rounded-[3px] border px-1.5 py-0.5 text-[10px] font-medium leading-none tracking-normal",children:zTe[s]})]}),h?g.jsx("div",{className:"mt-1 min-w-0 break-words text-xs leading-5 text-muted-foreground",children:h}):null,s==="suspended"?g.jsxs(_t,{type:"button",size:"xs","data-slot":"voice-pilot-resume",className:"mt-2",onClick:()=>r(e),children:[g.jsx(PP,{"aria-hidden":"true"}),"继续"]}):null]}),g.jsxs(qf,{children:[g.jsx(Vf,{asChild:!0,children:g.jsx(_t,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"停止 Voice Pilot","data-slot":"voice-pilot-stop",className:"dev-voice-pilot-stop absolute right-2 top-2 size-7 rounded-[5px] p-0",onClick:()=>n(e),children:g.jsx(vc,{"aria-hidden":"true",className:"size-4"})})}),g.jsx(Yf,{side:"top",children:"停止 Voice Pilot"})]}),g.jsx("div",{"data-slot":"voice-pilot-waveform","data-activity-level":Math.round(o*100),"data-waveform-bins":t.waveform.length,className:"dev-voice-waveform mt-2",children:g.jsxs("svg",{"aria-hidden":"true","data-slot":"voice-pilot-waveform-svg",className:"dev-voice-waveform-svg",viewBox:`0 0 ${Lu.width} ${Lu.height}`,preserveAspectRatio:"none",style:{width:"calc(100% - 1rem)",height:"calc(100% - 0.7rem)"},children:[g.jsx("path",{className:"dev-voice-waveform-baseline",d:`M 0 ${Lu.height/2} H ${Lu.width}`}),g.jsx("path",{"data-slot":"voice-pilot-waveform-curve",className:"dev-voice-waveform-curve",d})]})})]})}function $Te({isIpad:e,isLandscape:t,isPty:n,keyboardOpen:r,shownForCurrentKeyboardOpen:i,dismissed:s}){return e&&t&&n&&r&&!i&&!s}function HTe(){return Ei("local",dn.ipadFloatingKeyboardHintDismissed)==="1"}function UTe(){hr("local",dn.ipadFloatingKeyboardHintDismissed,"1")}function WTe(e,t){return t&&!e}function qTe(e){return HB(e)}function VTe(e){return e.connected?e.proxyOnline?e.routeSessionEnded?"session-ended":e.sessionState==="error"?"session-error":"ok":"proxy-offline":"relay-disconnected"}function YTe(e){return e.ptyWaitingApproval&&!e.ptyAutoYesEnabled}function KTe(){const{id:e}=EU(),[t]=k9(),n=t.get("mode")??"json";return e?g.jsx(GTe,{id:e,mode:n}):g.jsx(tc,{variant:"no-session"})}function GTe({id:e,mode:t}){const n=b.useRef(0),[r,i]=b.useState(null),s=Ne(z=>z.connected),o=Ne(z=>z.proxyOnline),l=Ne(z=>z.selectedProxyId),u=$t(z=>z.sessions.find(X=>X.sessionId===e)),d=(u==null?void 0:u.kind)==="terminal",h=$t(z=>z.sessionListLoaded),p=$t(z=>z.agentStatusBySessionId[e]),y=$t(z=>z.ptyStateBySessionId[e]),v=Bx(l,e),_=$t(z=>v?!!z.ptyAutoYesBySessionKey[v]:!1),w=$t(z=>z.setPtyAutoYes),x=Qt(z=>{var X;return((X=z.bySessionId[e])==null?void 0:X.pendingApprovals)??qs.pendingApprovals}),E=WTe(u,h),k=VTe({connected:s,proxyOnline:o,routeSessionEnded:E,sessionState:u==null?void 0:u.state}),R=Qs(),A=Pi(),{bottomOffset:I,layoutBottomInset:T}=vE(),H=Ne(z=>z.inputModePreference),D=Ne(z=>z.adaptiveInputModality),W=Ne(z=>z.setAdaptiveInputModality),U=I>0,F=H==="hardware"||H==="auto"&&D==="hardware"&&!U;b.useEffect(()=>{H==="auto"&&D==="hardware"&&U&&W("touch")},[D,H,W,U]);const O=ul("(orientation: landscape)"),[M]=b.useState(()=>kv().osName==="iPad"),B=b.useRef(!1),L=F?0:I,N=F?0:T;b.useEffect(()=>{const z=L>0;if(!z){B.current=!1;return}$Te({isIpad:M,isLandscape:O,isPty:t==="pty",keyboardOpen:z,shownForCurrentKeyboardOpen:B.current,dismissed:HTe()})&&(B.current=!0,nt.info("可以缩小软键盘",{id:"ipad-floating-keyboard-hint",testId:"ipad-floating-keyboard-hint",description:"在键盘上双指向内捏合,即可切换为浮动键盘并扩大终端显示区域。",duration:8e3,classNames:{actionButton:"!h-11 !px-3"},action:{label:"不再显示",onClick:()=>UTe()}}))},[L,M,O,t]);const V=b.useRef(!1);b.useEffect(()=>{const z=Cve();z&&z===`${A.pathname}${A.search}`&&(V.current=!0)},[]),b.useEffect(()=>{if(d||!s||!o||E)return;const z=Pt;z&&(z.requestSessionResources(e).then(X=>{Rv.getState().setCommands(X.commands);const ee=ii.getState();if(ee.clearTree(),X.groups.length!==0){ee.setCwd(X.groups[0].path);for(const te of X.groups)ee.setDirEntries(te.path,te.entries)}}).catch(X=>{console.error("[chat] requestSessionResources failed",{sessionId:e},X)}),z.requestAgentStatuses(e).then(X=>{const ee=$t.getState();for(const te of X)ee.setAgentStatus(te.sessionId,te.payload)}).catch(X=>{console.error("[chat] requestAgentStatuses failed",{sessionId:e},X)}))},[e,s,o,E,d]),b.useEffect(()=>{E&&B4()},[E]),b.useEffect(()=>{V.current&&E&&(nt.info("上次会话已结束"),R("/sessions",{replace:!0}))},[E,R]);const Y=qTe({connected:s,proxyOnline:o,routeSessionEnded:E,session:u,agentStatus:p,ptyState:y,hasPendingApproval:t==="json"&&x.some(z=>z.status==="pending")}),P=YTe({ptyWaitingApproval:!d&&t==="pty"&&k==="ok"&&Y==="waiting_approval",ptyAutoYesEnabled:_}),q=(r==null?void 0:r.sessionId)===e?r.sequence:void 0;function K(){n.current+=1,i({sessionId:e,sequence:n.current})}return g.jsx(M3,{sessionId:e,children:g.jsx(YEe,{sessionId:e,children:g.jsxs("div",{className:"flex flex-col h-full transition-[padding-bottom] duration-200 ease-out motion-reduce:transition-none",style:N?{paddingBottom:N}:void 0,"data-keyboard-offset":L,"data-keyboard-layout-inset":N,children:[g.jsx(uye,{sessionId:e,mode:t,onFind:K}),t==="json"&&k==="ok"&&g.jsx(ITe,{sessionId:e}),!d&&!P&&g.jsx(Ake,{state:Y}),P&&g.jsx(Nke,{autoYesEnabled:_,onAutoYesChange:z=>{v&&w(v,z)}}),g.jsxs("div",{className:"flex-1 min-h-0 relative",children:[k==="session-ended"?V.current?null:g.jsx(ZTe,{mode:t}):k==="session-error"?g.jsx(XTe,{mode:t,onBack:()=>R("/sessions")}):t==="pty"?g.jsx(gve,{sessionId:e,sessionKind:u==null?void 0:u.kind,provider:u==null?void 0:u.provider,findRequest:q}):g.jsx(BCe,{sessionId:e,findRequest:q}),(k==="relay-disconnected"||k==="proxy-offline")&&g.jsx(QTe,{variant:k==="relay-disconnected"?"relay":"proxy"})]}),t==="json"&&k==="ok"&&g.jsxs(g.Fragment,{children:[g.jsx(Tke,{sessionId:e}),g.jsx("div",{className:`dev-chat-input-rail-inset relative z-20 overflow-visible bg-background pt-2 transition-[padding-bottom] duration-200 ease-out motion-reduce:transition-none ${N>0?"pb-2":"pb-[max(env(safe-area-inset-bottom),0.5rem)]"}`,"data-slot":"input-bar-region","data-keyboard-edge-guard":L>0&&N===0?"true":void 0,children:g.jsxs("div",{className:"dev-message-rail mx-auto w-full",children:[g.jsx(FTe,{sessionId:e}),g.jsx(Cke,{sessionId:e})]})})]})]})})})}function XTe({mode:e,onBack:t}){return g.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 bg-background px-6 text-center","data-slot":"failed-session-panel",role:"alert",children:[g.jsxs("div",{className:"space-y-1",children:[g.jsx("h2",{className:"text-lg font-semibold",children:e==="pty"?"终端连接异常":"会话连接异常"}),g.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:"与开发机上的进程通道已中断。请返回会话列表,终止后重新创建。"})]}),g.jsxs(_t,{type:"button",variant:"outline",onClick:t,children:[g.jsx(_v,{"aria-hidden":"true"}),"返回会话列表"]})]})}function ZTe({mode:e}){return g.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 px-6 text-center bg-background","data-slot":"terminated-session-panel",role:"status","aria-live":"polite",children:[g.jsx("h2",{className:"text-lg font-semibold",children:e==="pty"?"终端连接已断开":"会话已终止"}),g.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:e==="pty"?"页面已停止接收终端画面和输入。":"当前会话已经结束,输入已停止。"})]})}function QTe({variant:e}){const t=e==="relay"?"中继连接可能遇到问题":"开发机连接可能遇到问题",n=e==="relay"?"正在继续尝试连接中继服务器,网络恢复后会自动返回当前会话。":"正在继续尝试连接开发机。若长时间没有恢复,请确认 DEV Anywhere 正在开发机上运行。";return g.jsxs("div",{className:"absolute inset-0 z-30 flex flex-col items-center justify-center gap-2 px-6 text-center bg-background","data-slot":"connection-lost-panel","data-variant":e,role:"status","aria-live":"polite",children:[g.jsx("h2",{className:"text-lg font-semibold",children:t}),g.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:n})]})}function JTe(){const e=Ne(w=>w.connected),t=Ne(w=>w.phase),n=Ne(w=>w.proxyOnline),r=Ne(w=>w.relayUrl),[i,s]=b.useState(""),[o,l]=b.useState(!1),u=b.useRef(null),d=b.useRef(null),h=b.useRef(null);b.useEffect(()=>{let w=null,x=!1;return(async()=>{const k=d.current;if(!k)return;const R=await s4(k);if(x){R.dispose();return}u.current=R.terminal,w=R.dispose,window.__xterm=R.terminal})(),document.title="PTY Test -- DEV Anywhere",()=>{x=!0,w==null||w(),u.current=null,delete window.__xterm}},[]),b.useEffect(()=>()=>{var w;(w=h.current)==null||w.call(h)},[]);const p=b.useCallback(()=>{var k;if(o){(k=h.current)==null||k.call(h),h.current=null,l(!1);return}if(!i.trim()||!ec||!Pt)return;let w=!1;const x=ec.subscribeBinary(i,R=>{var A;w&&((A=u.current)==null||A.write(R))});h.current=x;const E=Pt.onMessage(R=>{const A=R;A.type==="session_snapshot"&&A.sessionId===i&&(E(),u.current&&typeof A.data=="string"&&(u.current.reset(),u.current.resize(A.cols,A.rows),u.current.write(A.data,()=>{var T;const I=(T=d.current)==null?void 0:T.querySelector(".xterm");I&&d.current&&(d.current.style.width=`${I.scrollWidth}px`)})),w=!0)});ec.send(JSON.stringify({type:"session_subscribe",sessionId:i})),l(!0)},[o,i]),y=b.useCallback(w=>{w.key==="Enter"&&p()},[p]),v=e?"bg-[var(--color-status-success)]":"bg-[var(--muted-foreground)]",_=[e?"WS Connected":"WS Disconnected",`Phase: ${t}`,n?"Proxy Online":"Proxy Offline",o?`Subscribed: ${i}`:"Not subscribed"].join(" | ");return g.jsxs("div",{className:"flex flex-col h-screen bg-[var(--background)]",children:[g.jsxs("div",{className:"sticky top-0 z-10 flex items-center gap-2 px-4 h-12 bg-[var(--card)] border-b border-[var(--border)]",children:[g.jsx("div",{className:`w-2 h-2 rounded-full ${v}`}),g.jsx("span",{className:"text-sm text-[var(--foreground)] truncate",style:{fontFamily:"var(--font-sans)"},children:_}),g.jsx("div",{className:"flex-1"}),g.jsx("span",{className:"text-xs text-[var(--muted-foreground)] hidden sm:inline",style:{fontFamily:"var(--font-mono)"},children:r}),g.jsx("input",{type:"text",value:i,onChange:w=>s(w.target.value),onKeyDown:y,readOnly:o,placeholder:"session-id",className:"w-[200px] h-8 px-2 rounded text-[13px] bg-[var(--input)] text-[var(--foreground)] border border-[var(--border)] focus:border-[var(--ring)] focus:outline-none",style:{fontFamily:"var(--font-mono)",opacity:o?.7:1}}),g.jsx(_t,{onClick:p,disabled:!e||!i.trim(),size:"sm",children:o?"Unsubscribe":"Subscribe"})]}),g.jsx("div",{className:"flex-1 overflow-auto",style:{backgroundColor:"#1E1E1E"},children:g.jsx("div",{ref:d,style:{minHeight:"100%"}})})]})}const $F=[{name:"background",cssVar:"--background",className:"bg-background"},{name:"card",cssVar:"--card",className:"bg-card"},{name:"popover",cssVar:"--popover",className:"bg-popover"},{name:"input",cssVar:"--input",className:"bg-input"},{name:"border",cssVar:"--border",className:"bg-background border border-border"}],HF=[{name:"primary",cssVar:"--primary",className:"bg-primary"},{name:"focus ring",cssVar:"--ring",className:"bg-ring"},{name:"primary-foreground",cssVar:"--primary-foreground",className:"bg-primary-foreground text-primary"},{name:"destructive",cssVar:"--destructive",className:"bg-destructive"},{name:"muted",cssVar:"--muted",className:"bg-muted"}],UF=[{name:"working",cssVar:"--color-status-working"},{name:"compacting",cssVar:"--color-status-compacting"},{name:"success",cssVar:"--color-status-success"},{name:"warning",cssVar:"--color-status-warning"},{name:"error",cssVar:"--color-status-error"}];function eRe(e){const[t,n]=b.useState({});return b.useEffect(()=>{const r=getComputedStyle(document.documentElement),i={};for(const s of e)i[s]=r.getPropertyValue(s).trim().toUpperCase()||s;n(i)},[e]),t}const tRe=[{className:"text-3xl font-bold",label:"Heading 3XL (30px) -- font-sans"},{className:"text-2xl font-semibold",label:"Heading 2XL (24px) -- font-sans"},{className:"text-xl font-medium",label:"Heading XL (20px) -- font-sans"},{className:"text-base",label:"Body text (16px) -- The quick brown fox jumps over the lazy dog. -- font-sans"},{className:"text-sm text-muted-foreground",label:"Small muted text (14px) -- font-sans"}],nRe=[{className:"w-1",label:"w-1 (4px)"},{className:"w-2",label:"w-2 (8px)"},{className:"w-3",label:"w-3 (12px)"},{className:"w-4",label:"w-4 (16px)"},{className:"w-6",label:"w-6 (24px)"},{className:"w-8",label:"w-8 (32px)"},{className:"w-12",label:"w-12 (48px)"},{className:"w-16",label:"w-16 (64px)"}],rRe=[{className:"rounded-sm",label:"sm (2px)"},{className:"rounded-md",label:"md (4px)"},{className:"rounded-lg",label:"lg (6px)"},{className:"rounded-xl",label:"xl (8px)"}];function Mh({children:e}){return g.jsx("h2",{className:"text-xl font-semibold border-b border-border pb-2",children:e})}function ID({className:e,label:t}){return g.jsxs("div",{children:[g.jsx("div",{className:`h-20 rounded-md border border-border ${e}`}),g.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t})]})}const iRe=[...$F.map(e=>e.cssVar),...HF.map(e=>e.cssVar),"--muted-foreground",...UF.map(e=>e.cssVar)];function sRe(){const e=eRe(iRe);return g.jsx("div",{className:"min-h-screen p-3 sm:p-4 lg:p-6",children:g.jsxs("div",{className:"max-w-4xl mx-auto space-y-8",children:[g.jsx("h1",{className:"text-3xl font-bold text-primary",children:"Token Showcase"}),g.jsxs("section",{className:"space-y-4",children:[g.jsx(Mh,{children:"Color Palette"}),g.jsx("h3",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wide",children:"Surface Hierarchy"}),g.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3",children:$F.map(t=>g.jsx(ID,{className:t.className,label:`${e[t.cssVar]??t.cssVar} / ${t.name}`},t.name))}),g.jsx("h3",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wide mt-6",children:"Accent & Semantic"}),g.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3",children:[HF.map(t=>g.jsx(ID,{className:t.className,label:`${e[t.cssVar]??t.cssVar} / ${t.name}`},t.name)),g.jsxs("div",{children:[g.jsx("div",{className:"h-20 rounded-md border border-border bg-background flex items-center justify-center",children:g.jsx("span",{className:"text-muted-foreground",children:e["--muted-foreground"]??"—"})}),g.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[e["--muted-foreground"]??"—"," / muted-foreground"]})]})]}),g.jsx("h3",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wide mt-6",children:"Status Colors"}),g.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-5 gap-3",children:UF.map(t=>g.jsxs("div",{children:[g.jsx("div",{className:"h-20 rounded-md border border-border",style:{backgroundColor:`var(${t.cssVar})`}}),g.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[e[t.cssVar]??t.cssVar," / ",t.name]})]},t.name))})]}),g.jsxs("section",{className:"space-y-4",children:[g.jsx(Mh,{children:"Typography"}),g.jsx("div",{className:"space-y-3",children:tRe.map(t=>g.jsx("div",{children:g.jsx("p",{className:t.className,children:t.label})},t.label))}),g.jsx("h3",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wide mt-6",children:"Monospace (Sarasa Fixed SC)"}),g.jsxs("div",{className:"space-y-2 bg-card p-3 rounded-md border border-border",children:[g.jsx("p",{className:"text-base font-mono",children:"const greeting = 'Hello'; // Sarasa Fixed SC"}),g.jsx("p",{className:"text-base font-mono",children:"const msg = '----'; // CJK alignment test"})]})]}),g.jsxs("section",{className:"space-y-4",children:[g.jsx(Mh,{children:"Spacing"}),g.jsx("div",{className:"space-y-2",children:nRe.map(t=>g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsx("div",{className:`${t.className} h-3 bg-primary rounded-sm`}),g.jsx("span",{className:"text-xs text-muted-foreground",children:t.label})]},t.label))})]}),g.jsxs("section",{className:"space-y-4",children:[g.jsx(Mh,{children:"Border Radius"}),g.jsx("div",{className:"flex flex-wrap gap-4",children:rRe.map(t=>g.jsxs("div",{className:"text-center",children:[g.jsx("div",{className:`w-16 h-16 bg-card border border-border ${t.className}`}),g.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t.label})]},t.label))})]}),g.jsxs("section",{className:"space-y-4",children:[g.jsx(Mh,{children:"Button Variants"}),g.jsx("h3",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wide",children:"Variants"}),g.jsxs("div",{className:"flex flex-wrap gap-3",children:[g.jsx(_t,{children:"Default"}),g.jsx(_t,{variant:"destructive",children:"Destructive"}),g.jsx(_t,{variant:"outline",children:"Outline"}),g.jsx(_t,{variant:"secondary",children:"Secondary"}),g.jsx(_t,{variant:"ghost",children:"Ghost"}),g.jsx(_t,{variant:"link",children:"Link"})]}),g.jsx("h3",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wide mt-4",children:"Sizes"}),g.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[g.jsx(_t,{size:"sm",children:"Small"}),g.jsx(_t,{size:"default",children:"Default"}),g.jsx(_t,{size:"lg",children:"Large"}),g.jsx(_t,{size:"icon",children:g.jsx("span",{children:"+"})})]})]})]})})}const oRe=`# Heading 1
698
698
  ## Heading 2
699
699
  ### Heading 3
700
700
 
@@ -769,4 +769,4 @@ fn main() {
769
769
  ---
770
770
 
771
771
  _End of sample._
772
- `;function aRe(){return g.jsx("div",{className:"min-h-dvh bg-background text-foreground p-6",children:g.jsxs("div",{className:"mx-auto max-w-[720px] space-y-6",children:[g.jsxs("header",{children:[g.jsx("h1",{className:"text-lg font-semibold",children:"Markdown 渲染走查"}),g.jsx("p",{className:"text-sm text-muted-foreground",children:"下方模拟 assistant 气泡容器 (max-w 约束), 验证所有 markdown 元素在气泡内的实际渲染。"})]}),g.jsx("article",{className:"flex justify-start",children:g.jsx("div",{className:"max-w-[80%] rounded-md bg-card text-foreground px-4 py-2 text-sm",children:g.jsx(dx,{text:oRe})})})]})})}const gv=b9([{path:"/",element:g.jsx(Rve,{}),children:[{index:!0,element:g.jsx(Ave,{})},{path:"sessions",element:g.jsx(Nve,{})},{path:"chat/:id",element:g.jsx(KTe,{})}]},{path:"/pty-test",element:g.jsx(JTe,{})},{path:"/tokens",element:g.jsx(sRe,{})},{path:"/markdown-test",element:g.jsx(aRe,{})}]);function lRe({browserName:e}){const[t,n]=b.useState("idle"),r=async()=>{const i=await Mj(window.location.href,{allowLegacyFallback:!0});n(i==="failed"?"failed":"copied")};return g.jsxs("div",{className:"flex min-h-[100dvh] flex-col overflow-hidden bg-background text-foreground","data-slot":"unsupported-ipad-browser",children:[g.jsx("header",{className:"mx-auto flex w-full max-w-5xl items-center px-6 py-5 sm:px-10",children:g.jsx(eL,{className:"text-sm",slot:"unsupported-browser-brand"})}),g.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:g.jsxs("section",{className:"max-w-xl","aria-labelledby":"unsupported-browser-title",children:[g.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[g.jsx(u8,{className:"size-4 text-primary","aria-hidden":"true"}),g.jsx("span",{children:"iPad 浏览器支持"})]}),g.jsx("h1",{id:"unsupported-browser-title",className:"mt-4 text-3xl font-semibold tracking-normal sm:text-4xl",children:"请使用 Safari 打开"}),g.jsxs("p",{className:"mt-4 max-w-lg text-base leading-7 text-muted-foreground",children:["DEV Anywhere 暂不支持 iPad 上的 ",e,"。当前版本仅支持 Safari,以保证终端输入和实体键盘行为稳定。"]}),g.jsxs("div",{className:"mt-7 flex flex-wrap items-center gap-3",children:[g.jsxs(_t,{className:"h-11 px-4",onClick:r,children:[t==="copied"?g.jsx(ta,{className:"size-4","aria-hidden":"true"}):g.jsx(AP,{className:"size-4","aria-hidden":"true"}),t==="copied"?"链接已复制":"复制当前链接"]}),g.jsx("span",{className:"text-sm text-muted-foreground","aria-live":"polite",children:t==="copied"?"请切换到 Safari 后粘贴打开":t==="failed"?"复制失败,请从地址栏复制":"复制后在 Safari 中打开"})]})]})})]})}function cRe({children:e}){const t=Tve();return t.supported?e:g.jsx(lRe,{browserName:t.browserName})}function uRe(){return g.jsx(cRe,{children:g.jsx(dRe,{})})}function dRe(){return AQ(),g.jsx(vie,{delayDuration:200,children:g.jsx(UU,{router:gv})})}function hRe(e=window.history){e.scrollRestoration="manual"}hRe();LW();Roe();rH.createRoot(document.getElementById("root")).render(g.jsx(b.StrictMode,{children:g.jsx(uRe,{})}));export{Wve as _};
772
+ `;function aRe(){return g.jsx("div",{className:"min-h-dvh bg-background text-foreground p-6",children:g.jsxs("div",{className:"mx-auto max-w-[720px] space-y-6",children:[g.jsxs("header",{children:[g.jsx("h1",{className:"text-lg font-semibold",children:"Markdown 渲染走查"}),g.jsx("p",{className:"text-sm text-muted-foreground",children:"下方模拟 assistant 气泡容器 (max-w 约束), 验证所有 markdown 元素在气泡内的实际渲染。"})]}),g.jsx("article",{className:"flex justify-start",children:g.jsx("div",{className:"max-w-[80%] rounded-md bg-card text-foreground px-4 py-2 text-sm",children:g.jsx(dx,{text:oRe})})})]})})}const gv=b9([{path:"/",element:g.jsx(Rve,{}),children:[{index:!0,element:g.jsx(Ave,{})},{path:"sessions",element:g.jsx(Nve,{})},{path:"chat/:id",element:g.jsx(KTe,{})}]},{path:"/pty-test",element:g.jsx(JTe,{})},{path:"/tokens",element:g.jsx(sRe,{})},{path:"/markdown-test",element:g.jsx(aRe,{})}]);function lRe({browserName:e}){const[t,n]=b.useState("idle"),r=async()=>{const i=await M4(window.location.href,{allowLegacyFallback:!0});n(i==="failed"?"failed":"copied")};return g.jsxs("div",{className:"flex min-h-[100dvh] flex-col overflow-hidden bg-background text-foreground","data-slot":"unsupported-ipad-browser",children:[g.jsx("header",{className:"mx-auto flex w-full max-w-5xl items-center px-6 py-5 sm:px-10",children:g.jsx(eL,{className:"text-sm",slot:"unsupported-browser-brand"})}),g.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:g.jsxs("section",{className:"max-w-xl","aria-labelledby":"unsupported-browser-title",children:[g.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[g.jsx(u8,{className:"size-4 text-primary","aria-hidden":"true"}),g.jsx("span",{children:"iPad 浏览器支持"})]}),g.jsx("h1",{id:"unsupported-browser-title",className:"mt-4 text-3xl font-semibold tracking-normal sm:text-4xl",children:"请使用 Safari 打开"}),g.jsxs("p",{className:"mt-4 max-w-lg text-base leading-7 text-muted-foreground",children:["DEV Anywhere 暂不支持 iPad 上的 ",e,"。当前版本仅支持 Safari,以保证终端输入和实体键盘行为稳定。"]}),g.jsxs("div",{className:"mt-7 flex flex-wrap items-center gap-3",children:[g.jsxs(_t,{className:"h-11 px-4",onClick:r,children:[t==="copied"?g.jsx(ta,{className:"size-4","aria-hidden":"true"}):g.jsx(AP,{className:"size-4","aria-hidden":"true"}),t==="copied"?"链接已复制":"复制当前链接"]}),g.jsx("span",{className:"text-sm text-muted-foreground","aria-live":"polite",children:t==="copied"?"请切换到 Safari 后粘贴打开":t==="failed"?"复制失败,请从地址栏复制":"复制后在 Safari 中打开"})]})]})})]})}function cRe({children:e}){const t=Tve();return t.supported?e:g.jsx(lRe,{browserName:t.browserName})}function uRe(){return g.jsx(cRe,{children:g.jsx(dRe,{})})}function dRe(){return AQ(),g.jsx(vie,{delayDuration:200,children:g.jsx(UU,{router:gv})})}function hRe(e=window.history){e.scrollRestoration="manual"}hRe();LW();Roe();rH.createRoot(document.getElementById("root")).render(g.jsx(b.StrictMode,{children:g.jsx(uRe,{})}));export{Wve as _};