nterminal 1.2.21 → 1.2.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{g as Zt,j as nn}from"./index-D9dhxxB2.js";function pi(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const mi=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,gi=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,di={};function ct(e,t){return(di.jsx?gi:mi).test(e)}const yi=/[ \t\n\f\r]/g;function ki(e){return typeof e=="object"?e.type==="text"?ft(e.value):!1:ft(e)}function ft(e){return e.replace(yi,"")===""}class Ye{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Ye.prototype.normal={};Ye.prototype.property={};Ye.prototype.space=void 0;function er(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Ye(n,r,t)}function zn(e){return e.toLowerCase()}class ee{constructor(t,n){this.attribute=n,this.property=t}}ee.prototype.attribute="";ee.prototype.booleanish=!1;ee.prototype.boolean=!1;ee.prototype.commaOrSpaceSeparated=!1;ee.prototype.commaSeparated=!1;ee.prototype.defined=!1;ee.prototype.mustUseProperty=!1;ee.prototype.number=!1;ee.prototype.overloadedBoolean=!1;ee.prototype.property="";ee.prototype.spaceSeparated=!1;ee.prototype.space=void 0;let xi=0;const _=Ee(),Y=Ee(),Dn=Ee(),E=Ee(),W=Ee(),De=Ee(),te=Ee();function Ee(){return 2**++xi}const Ln=Object.freeze(Object.defineProperty({__proto__:null,boolean:_,booleanish:Y,commaOrSpaceSeparated:te,commaSeparated:De,number:E,overloadedBoolean:Dn,spaceSeparated:W},Symbol.toStringTag,{value:"Module"})),pn=Object.keys(Ln);class Hn extends ee{constructor(t,n,r,i){let o=-1;if(super(t,n),ht(this,"space",i),typeof r=="number")for(;++o<pn.length;){const l=pn[o];ht(this,pn[o],(r&Ln[l])===Ln[l])}}}Hn.prototype.defined=!0;function ht(e,t,n){n&&(e[t]=n)}function Fe(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const o=new Hn(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[zn(r)]=r,n[zn(o.attribute)]=r}return new Ye(t,n,e.space)}const nr=Fe({properties:{ariaActiveDescendant:null,ariaAtomic:Y,ariaAutoComplete:null,ariaBusy:Y,ariaChecked:Y,ariaColCount:E,ariaColIndex:E,ariaColSpan:E,ariaControls:W,ariaCurrent:null,ariaDescribedBy:W,ariaDetails:null,ariaDisabled:Y,ariaDropEffect:W,ariaErrorMessage:null,ariaExpanded:Y,ariaFlowTo:W,ariaGrabbed:Y,ariaHasPopup:null,ariaHidden:Y,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:W,ariaLevel:E,ariaLive:null,ariaModal:Y,ariaMultiLine:Y,ariaMultiSelectable:Y,ariaOrientation:null,ariaOwns:W,ariaPlaceholder:null,ariaPosInSet:E,ariaPressed:Y,ariaReadOnly:Y,ariaRelevant:null,ariaRequired:Y,ariaRoleDescription:W,ariaRowCount:E,ariaRowIndex:E,ariaRowSpan:E,ariaSelected:Y,ariaSetSize:E,ariaSort:null,ariaValueMax:E,ariaValueMin:E,ariaValueNow:E,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function tr(e,t){return t in e?e[t]:t}function rr(e,t){return tr(e,t.toLowerCase())}const bi=Fe({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:De,acceptCharset:W,accessKey:W,action:null,allow:null,allowFullScreen:_,allowPaymentRequest:_,allowUserMedia:_,alt:null,as:null,async:_,autoCapitalize:null,autoComplete:W,autoFocus:_,autoPlay:_,blocking:W,capture:null,charSet:null,checked:_,cite:null,className:W,cols:E,colSpan:null,content:null,contentEditable:Y,controls:_,controlsList:W,coords:E|De,crossOrigin:null,data:null,dateTime:null,decoding:null,default:_,defer:_,dir:null,dirName:null,disabled:_,download:Dn,draggable:Y,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:_,formTarget:null,headers:W,height:E,hidden:Dn,high:E,href:null,hrefLang:null,htmlFor:W,httpEquiv:W,id:null,imageSizes:null,imageSrcSet:null,inert:_,inputMode:null,integrity:null,is:null,isMap:_,itemId:null,itemProp:W,itemRef:W,itemScope:_,itemType:W,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:_,low:E,manifest:null,max:null,maxLength:E,media:null,method:null,min:null,minLength:E,multiple:_,muted:_,name:null,nonce:null,noModule:_,noValidate:_,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:_,optimum:E,pattern:null,ping:W,placeholder:null,playsInline:_,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:_,referrerPolicy:null,rel:W,required:_,reversed:_,rows:E,rowSpan:E,sandbox:W,scope:null,scoped:_,seamless:_,selected:_,shadowRootClonable:_,shadowRootDelegatesFocus:_,shadowRootMode:null,shape:null,size:E,sizes:null,slot:null,span:E,spellCheck:Y,src:null,srcDoc:null,srcLang:null,srcSet:null,start:E,step:null,style:null,tabIndex:E,target:null,title:null,translate:null,type:null,typeMustMatch:_,useMap:null,value:Y,width:E,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:W,axis:null,background:null,bgColor:null,border:E,borderColor:null,bottomMargin:E,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:_,declare:_,event:null,face:null,frame:null,frameBorder:null,hSpace:E,leftMargin:E,link:null,longDesc:null,lowSrc:null,marginHeight:E,marginWidth:E,noResize:_,noHref:_,noShade:_,noWrap:_,object:null,profile:null,prompt:null,rev:null,rightMargin:E,rules:null,scheme:null,scrolling:Y,standby:null,summary:null,text:null,topMargin:E,valueType:null,version:null,vAlign:null,vLink:null,vSpace:E,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:_,disableRemotePlayback:_,prefix:null,property:null,results:E,security:null,unselectable:null},space:"html",transform:rr}),wi=Fe({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:te,accentHeight:E,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:E,amplitude:E,arabicForm:null,ascent:E,attributeName:null,attributeType:null,azimuth:E,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:E,by:null,calcMode:null,capHeight:E,className:W,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:E,diffuseConstant:E,direction:null,display:null,dur:null,divisor:E,dominantBaseline:null,download:_,dx:null,dy:null,edgeMode:null,editable:null,elevation:E,enableBackground:null,end:null,event:null,exponent:E,externalResourcesRequired:null,fill:null,fillOpacity:E,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:De,g2:De,glyphName:De,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:E,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:E,horizOriginX:E,horizOriginY:E,id:null,ideographic:E,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:E,k:E,k1:E,k2:E,k3:E,k4:E,kernelMatrix:te,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:E,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:E,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:E,overlineThickness:E,paintOrder:null,panose1:null,path:null,pathLength:E,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:W,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:E,pointsAtY:E,pointsAtZ:E,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:te,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:te,rev:te,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:te,requiredFeatures:te,requiredFonts:te,requiredFormats:te,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:E,specularExponent:E,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:E,strikethroughThickness:E,string:null,stroke:null,strokeDashArray:te,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:E,strokeOpacity:E,strokeWidth:null,style:null,surfaceScale:E,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:te,tabIndex:E,tableValues:null,target:null,targetX:E,targetY:E,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:te,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:E,underlineThickness:E,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:E,values:null,vAlphabetic:E,vMathematical:E,vectorEffect:null,vHanging:E,vIdeographic:E,version:null,vertAdvY:E,vertOriginX:E,vertOriginY:E,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:E,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:tr}),ir=Fe({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()}}),lr=Fe({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:rr}),or=Fe({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Si={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"},Ci=/[A-Z]/g,pt=/-[a-z]/g,Ei=/^data[-\w.:]+$/i;function Ii(e,t){const n=zn(t);let r=t,i=ee;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Ei.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(pt,Ti);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!pt.test(o)){let l=o.replace(Ci,Ai);l.charAt(0)!=="-"&&(l="-"+l),t="data"+l}}i=Hn}return new i(r,t)}function Ai(e){return"-"+e.toLowerCase()}function Ti(e){return e.charAt(1).toUpperCase()}const Pi=er([nr,bi,ir,lr,or],"html"),Un=er([nr,wi,ir,lr,or],"svg");function vi(e){return e.join(" ").trim()}var Pe={},mn,mt;function zi(){if(mt)return mn;mt=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,l=/^[;\s]*/,a=/^\s+|\s+$/g,u=`
1
+ import{g as Zt,j as nn}from"./index-CXBkB4aI.js";function pi(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const mi=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,gi=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,di={};function ct(e,t){return(di.jsx?gi:mi).test(e)}const yi=/[ \t\n\f\r]/g;function ki(e){return typeof e=="object"?e.type==="text"?ft(e.value):!1:ft(e)}function ft(e){return e.replace(yi,"")===""}class Ye{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Ye.prototype.normal={};Ye.prototype.property={};Ye.prototype.space=void 0;function er(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Ye(n,r,t)}function zn(e){return e.toLowerCase()}class ee{constructor(t,n){this.attribute=n,this.property=t}}ee.prototype.attribute="";ee.prototype.booleanish=!1;ee.prototype.boolean=!1;ee.prototype.commaOrSpaceSeparated=!1;ee.prototype.commaSeparated=!1;ee.prototype.defined=!1;ee.prototype.mustUseProperty=!1;ee.prototype.number=!1;ee.prototype.overloadedBoolean=!1;ee.prototype.property="";ee.prototype.spaceSeparated=!1;ee.prototype.space=void 0;let xi=0;const _=Ee(),Y=Ee(),Dn=Ee(),E=Ee(),W=Ee(),De=Ee(),te=Ee();function Ee(){return 2**++xi}const Ln=Object.freeze(Object.defineProperty({__proto__:null,boolean:_,booleanish:Y,commaOrSpaceSeparated:te,commaSeparated:De,number:E,overloadedBoolean:Dn,spaceSeparated:W},Symbol.toStringTag,{value:"Module"})),pn=Object.keys(Ln);class Hn extends ee{constructor(t,n,r,i){let o=-1;if(super(t,n),ht(this,"space",i),typeof r=="number")for(;++o<pn.length;){const l=pn[o];ht(this,pn[o],(r&Ln[l])===Ln[l])}}}Hn.prototype.defined=!0;function ht(e,t,n){n&&(e[t]=n)}function Fe(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const o=new Hn(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[zn(r)]=r,n[zn(o.attribute)]=r}return new Ye(t,n,e.space)}const nr=Fe({properties:{ariaActiveDescendant:null,ariaAtomic:Y,ariaAutoComplete:null,ariaBusy:Y,ariaChecked:Y,ariaColCount:E,ariaColIndex:E,ariaColSpan:E,ariaControls:W,ariaCurrent:null,ariaDescribedBy:W,ariaDetails:null,ariaDisabled:Y,ariaDropEffect:W,ariaErrorMessage:null,ariaExpanded:Y,ariaFlowTo:W,ariaGrabbed:Y,ariaHasPopup:null,ariaHidden:Y,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:W,ariaLevel:E,ariaLive:null,ariaModal:Y,ariaMultiLine:Y,ariaMultiSelectable:Y,ariaOrientation:null,ariaOwns:W,ariaPlaceholder:null,ariaPosInSet:E,ariaPressed:Y,ariaReadOnly:Y,ariaRelevant:null,ariaRequired:Y,ariaRoleDescription:W,ariaRowCount:E,ariaRowIndex:E,ariaRowSpan:E,ariaSelected:Y,ariaSetSize:E,ariaSort:null,ariaValueMax:E,ariaValueMin:E,ariaValueNow:E,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function tr(e,t){return t in e?e[t]:t}function rr(e,t){return tr(e,t.toLowerCase())}const bi=Fe({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:De,acceptCharset:W,accessKey:W,action:null,allow:null,allowFullScreen:_,allowPaymentRequest:_,allowUserMedia:_,alt:null,as:null,async:_,autoCapitalize:null,autoComplete:W,autoFocus:_,autoPlay:_,blocking:W,capture:null,charSet:null,checked:_,cite:null,className:W,cols:E,colSpan:null,content:null,contentEditable:Y,controls:_,controlsList:W,coords:E|De,crossOrigin:null,data:null,dateTime:null,decoding:null,default:_,defer:_,dir:null,dirName:null,disabled:_,download:Dn,draggable:Y,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:_,formTarget:null,headers:W,height:E,hidden:Dn,high:E,href:null,hrefLang:null,htmlFor:W,httpEquiv:W,id:null,imageSizes:null,imageSrcSet:null,inert:_,inputMode:null,integrity:null,is:null,isMap:_,itemId:null,itemProp:W,itemRef:W,itemScope:_,itemType:W,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:_,low:E,manifest:null,max:null,maxLength:E,media:null,method:null,min:null,minLength:E,multiple:_,muted:_,name:null,nonce:null,noModule:_,noValidate:_,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:_,optimum:E,pattern:null,ping:W,placeholder:null,playsInline:_,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:_,referrerPolicy:null,rel:W,required:_,reversed:_,rows:E,rowSpan:E,sandbox:W,scope:null,scoped:_,seamless:_,selected:_,shadowRootClonable:_,shadowRootDelegatesFocus:_,shadowRootMode:null,shape:null,size:E,sizes:null,slot:null,span:E,spellCheck:Y,src:null,srcDoc:null,srcLang:null,srcSet:null,start:E,step:null,style:null,tabIndex:E,target:null,title:null,translate:null,type:null,typeMustMatch:_,useMap:null,value:Y,width:E,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:W,axis:null,background:null,bgColor:null,border:E,borderColor:null,bottomMargin:E,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:_,declare:_,event:null,face:null,frame:null,frameBorder:null,hSpace:E,leftMargin:E,link:null,longDesc:null,lowSrc:null,marginHeight:E,marginWidth:E,noResize:_,noHref:_,noShade:_,noWrap:_,object:null,profile:null,prompt:null,rev:null,rightMargin:E,rules:null,scheme:null,scrolling:Y,standby:null,summary:null,text:null,topMargin:E,valueType:null,version:null,vAlign:null,vLink:null,vSpace:E,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:_,disableRemotePlayback:_,prefix:null,property:null,results:E,security:null,unselectable:null},space:"html",transform:rr}),wi=Fe({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:te,accentHeight:E,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:E,amplitude:E,arabicForm:null,ascent:E,attributeName:null,attributeType:null,azimuth:E,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:E,by:null,calcMode:null,capHeight:E,className:W,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:E,diffuseConstant:E,direction:null,display:null,dur:null,divisor:E,dominantBaseline:null,download:_,dx:null,dy:null,edgeMode:null,editable:null,elevation:E,enableBackground:null,end:null,event:null,exponent:E,externalResourcesRequired:null,fill:null,fillOpacity:E,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:De,g2:De,glyphName:De,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:E,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:E,horizOriginX:E,horizOriginY:E,id:null,ideographic:E,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:E,k:E,k1:E,k2:E,k3:E,k4:E,kernelMatrix:te,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:E,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:E,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:E,overlineThickness:E,paintOrder:null,panose1:null,path:null,pathLength:E,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:W,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:E,pointsAtY:E,pointsAtZ:E,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:te,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:te,rev:te,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:te,requiredFeatures:te,requiredFonts:te,requiredFormats:te,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:E,specularExponent:E,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:E,strikethroughThickness:E,string:null,stroke:null,strokeDashArray:te,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:E,strokeOpacity:E,strokeWidth:null,style:null,surfaceScale:E,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:te,tabIndex:E,tableValues:null,target:null,targetX:E,targetY:E,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:te,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:E,underlineThickness:E,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:E,values:null,vAlphabetic:E,vMathematical:E,vectorEffect:null,vHanging:E,vIdeographic:E,version:null,vertAdvY:E,vertOriginX:E,vertOriginY:E,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:E,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:tr}),ir=Fe({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()}}),lr=Fe({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:rr}),or=Fe({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Si={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"},Ci=/[A-Z]/g,pt=/-[a-z]/g,Ei=/^data[-\w.:]+$/i;function Ii(e,t){const n=zn(t);let r=t,i=ee;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Ei.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(pt,Ti);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!pt.test(o)){let l=o.replace(Ci,Ai);l.charAt(0)!=="-"&&(l="-"+l),t="data"+l}}i=Hn}return new i(r,t)}function Ai(e){return"-"+e.toLowerCase()}function Ti(e){return e.charAt(1).toUpperCase()}const Pi=er([nr,bi,ir,lr,or],"html"),Un=er([nr,wi,ir,lr,or],"svg");function vi(e){return e.join(" ").trim()}var Pe={},mn,mt;function zi(){if(mt)return mn;mt=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,l=/^[;\s]*/,a=/^\s+|\s+$/g,u=`
2
2
  `,s="/",f="*",c="",p="comment",h="declaration";function d(S,y){if(typeof S!="string")throw new TypeError("First argument must be a string");if(!S)return[];y=y||{};var I=1,C=1;function F(D){var T=D.match(t);T&&(I+=T.length);var q=D.lastIndexOf(u);C=~q?D.length-q:C+D.length}function R(){var D={line:I,column:C};return function(T){return T.position=new b(D),j(),T}}function b(D){this.start=D,this.end={line:I,column:C},this.source=y.source}b.prototype.content=S;function M(D){var T=new Error(y.source+":"+I+":"+C+": "+D);if(T.reason=D,T.filename=y.source,T.line=I,T.column=C,T.source=S,!y.silent)throw T}function H(D){var T=D.exec(S);if(T){var q=T[0];return F(q),S=S.slice(q.length),T}}function j(){H(n)}function k(D){var T;for(D=D||[];T=P();)T!==!1&&D.push(T);return D}function P(){var D=R();if(!(s!=S.charAt(0)||f!=S.charAt(1))){for(var T=2;c!=S.charAt(T)&&(f!=S.charAt(T)||s!=S.charAt(T+1));)++T;if(T+=2,c===S.charAt(T-1))return M("End of comment missing");var q=S.slice(2,T-2);return C+=2,F(q),S=S.slice(T),C+=2,D({type:p,comment:q})}}function v(){var D=R(),T=H(r);if(T){if(P(),!H(i))return M("property missing ':'");var q=H(o),X=D({type:h,property:w(T[0].replace(e,c)),value:q?w(q[0].replace(e,c)):c});return H(l),X}}function U(){var D=[];k(D);for(var T;T=v();)T!==!1&&(D.push(T),k(D));return D}return j(),U()}function w(S){return S?S.replace(a,c):c}return mn=d,mn}var gt;function Di(){if(gt)return Pe;gt=1;var e=Pe&&Pe.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Pe,"__esModule",{value:!0}),Pe.default=n;const t=e(zi());function n(r,i){let o=null;if(!r||typeof r!="string")return o;const l=(0,t.default)(r),a=typeof i=="function";return l.forEach(u=>{if(u.type!=="declaration")return;const{property:s,value:f}=u;a?i(s,f,u):f&&(o=o||{},o[s]=f)}),o}return Pe}var Ne={},dt;function Li(){if(dt)return Ne;dt=1,Object.defineProperty(Ne,"__esModule",{value:!0}),Ne.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,o=function(s){return!s||n.test(s)||e.test(s)},l=function(s,f){return f.toUpperCase()},a=function(s,f){return"".concat(f,"-")},u=function(s,f){return f===void 0&&(f={}),o(s)?s:(s=s.toLowerCase(),f.reactCompat?s=s.replace(i,a):s=s.replace(r,a),s.replace(t,l))};return Ne.camelCase=u,Ne}var Be,yt;function Fi(){if(yt)return Be;yt=1;var e=Be&&Be.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(Di()),n=Li();function r(i,o){var l={};return!i||typeof i!="string"||(0,t.default)(i,function(a,u){a&&u&&(l[(0,n.camelCase)(a,o)]=u)}),l}return r.default=r,Be=r,Be}var Ri=Fi();const _i=Zt(Ri),ar=ur("end"),qn=ur("start");function ur(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 Oi(e){const t=qn(e),n=ar(e);if(t&&n)return{start:t,end:n}}function Ue(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?kt(e.position):"start"in e||"end"in e?kt(e):"line"in e||"column"in e?Fn(e):""}function Fn(e){return xt(e&&e.line)+":"+xt(e&&e.column)}function kt(e){return Fn(e&&e.start)+"-"+Fn(e&&e.end)}function xt(e){return e&&typeof e=="number"?e:1}class K extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",o={},l=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?i=t:!o.cause&&t&&(l=!0,i=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof r=="string"){const u=r.indexOf(":");u===-1?o.ruleId=r:(o.source=r.slice(0,u),o.ruleId=r.slice(u+1))}if(!o.place&&o.ancestors&&o.ancestors){const u=o.ancestors[o.ancestors.length-1];u&&(o.place=u.position)}const a=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=a?a.line:void 0,this.name=Ue(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=l&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}K.prototype.file="";K.prototype.name="";K.prototype.reason="";K.prototype.message="";K.prototype.stack="";K.prototype.column=void 0;K.prototype.line=void 0;K.prototype.ancestors=void 0;K.prototype.cause=void 0;K.prototype.fatal=void 0;K.prototype.place=void 0;K.prototype.ruleId=void 0;K.prototype.source=void 0;const Vn={}.hasOwnProperty,Mi=new Map,Ni=/[A-Z]/g,Bi=new Set(["table","tbody","thead","tfoot","tr"]),ji=new Set(["td","th"]),sr="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Hi(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=Qi(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=Xi(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"?Un:Pi,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=cr(i,e,void 0);return o&&typeof o!="string"?o:i.create(e,i.Fragment,{children:o||void 0},void 0)}function cr(e,t,n){if(t.type==="element")return Ui(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return qi(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return $i(e,t,n);if(t.type==="mdxjsEsm")return Vi(e,t);if(t.type==="root")return Wi(e,t,n);if(t.type==="text")return Yi(e,t)}function Ui(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Un,e.schema=i),e.ancestors.push(t);const o=hr(e,t.tagName,!1),l=Gi(e,t);let a=Wn(e,t);return Bi.has(t.tagName)&&(a=a.filter(function(u){return typeof u=="string"?!ki(u):!0})),fr(e,l,o,t),$n(l,a),e.ancestors.pop(),e.schema=r,e.create(t,o,l,n)}function qi(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)}$e(e,t.position)}function Vi(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);$e(e,t.position)}function $i(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=Un,e.schema=i),e.ancestors.push(t);const o=t.name===null?e.Fragment:hr(e,t.name,!0),l=Ki(e,t),a=Wn(e,t);return fr(e,l,o,t),$n(l,a),e.ancestors.pop(),e.schema=r,e.create(t,o,l,n)}function Wi(e,t,n){const r={};return $n(r,Wn(e,t)),e.create(t,e.Fragment,r,n)}function Yi(e,t){return t.value}function fr(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function $n(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Xi(e,t,n){return r;function r(i,o,l,a){const s=Array.isArray(l.children)?n:t;return a?s(o,l,a):s(o,l)}}function Qi(e,t){return n;function n(r,i,o,l){const a=Array.isArray(o.children),u=qn(r);return t(i,o,l,a,{columnNumber:u?u.column-1:void 0,fileName:e,lineNumber:u?u.line:void 0},void 0)}}function Gi(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&Vn.call(t.properties,i)){const o=Ji(e,i,t.properties[i]);if(o){const[l,a]=o;e.tableCellAlignToStyle&&l==="align"&&typeof a=="string"&&ji.has(t.tagName)?r=a:n[l]=a}}if(r){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function Ki(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const o=r.data.estree.body[0];o.type;const l=o.expression;l.type;const a=l.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else $e(e,t.position);else{const i=r.name;let o;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const a=r.value.data.estree.body[0];a.type,o=e.evaluater.evaluateExpression(a.expression)}else $e(e,t.position);else o=r.value===null?!0:r.value;n[i]=o}return n}function Wn(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:Mi;for(;++r<t.children.length;){const o=t.children[r];let l;if(e.passKeys){const u=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(u){const s=i.get(u)||0;l=u+"-"+s,i.set(u,s+1)}}const a=cr(e,o,l);a!==void 0&&n.push(a)}return n}function Ji(e,t,n){const r=Ii(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?pi(n):vi(n)),r.property==="style"){let i=typeof n=="object"?n:Zi(e,String(n));return e.stylePropertyNameCase==="css"&&(i=el(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?Si[r.property]||r.property:r.attribute,n]}}function Zi(e,t){try{return _i(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new K("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=sr+"#cannot-parse-style-attribute",i}}function hr(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let o=-1,l;for(;++o<i.length;){const a=ct(i[o])?{type:"Identifier",name:i[o]}:{type:"Literal",value:i[o]};l=l?{type:"MemberExpression",object:l,property:a,computed:!!(o&&a.type==="Literal"),optional:!1}:a}r=l}else r=ct(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return Vn.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);$e(e)}function $e(e,t){const n=new K("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=sr+"#cannot-handle-mdx-estrees-without-createevaluater",n}function el(e){const t={};let n;for(n in e)Vn.call(e,n)&&(t[nl(n)]=e[n]);return t}function nl(e){let t=e.replace(Ni,tl);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function tl(e){return"-"+e.toLowerCase()}const gn={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"]},rl={};function Yn(e,t){const n=rl,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return pr(e,r,i)}function pr(e,t,n){if(il(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 bt(e.children,t,n)}return Array.isArray(e)?bt(e,t,n):""}function bt(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=pr(e[i],t,n);return r.join("")}function il(e){return!!(e&&typeof e=="object")}const wt=document.createElement("i");function Xn(e){const t="&"+e+";";wt.innerHTML=t;const n=wt.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function re(e,t,n,r){const i=e.length;let o=0,l;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)l=Array.from(r),l.unshift(t,n),e.splice(...l);else for(n&&e.splice(t,n);o<r.length;)l=r.slice(o,o+1e4),l.unshift(t,0),e.splice(...l),o+=1e4,t+=1e4}function ie(e,t){return e.length>0?(re(e,e.length,0,t),e):t}const St={}.hasOwnProperty;function mr(e){const t={};let n=-1;for(;++n<e.length;)ll(t,e[n]);return t}function ll(e,t){let n;for(n in t){const i=(St.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let l;if(o)for(l in o){St.call(i,l)||(i[l]=[]);const a=o[l];ol(i[l],Array.isArray(a)?a:a?[a]:[])}}}function ol(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);re(e,0,0,r)}function gr(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 se(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const J=xe(/[A-Za-z]/),G=xe(/[\dA-Za-z]/),al=xe(/[#-'*+\--9=?A-Z^-~]/);function rn(e){return e!==null&&(e<32||e===127)}const Rn=xe(/\d/),ul=xe(/[\dA-Fa-f]/),sl=xe(/[!-/:-@[-`{-~]/);function z(e){return e!==null&&e<-2}function $(e){return e!==null&&(e<0||e===32)}function O(e){return e===-2||e===-1||e===32}const un=xe(new RegExp("\\p{P}|\\p{S}","u")),Ce=xe(/\s/);function xe(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Re(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const o=e.charCodeAt(n);let l="";if(o===37&&G(e.charCodeAt(n+1))&&G(e.charCodeAt(n+2)))i=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(l=String.fromCharCode(o));else if(o>55295&&o<57344){const a=e.charCodeAt(n+1);o<56320&&a>56319&&a<57344?(l=String.fromCharCode(o,a),i=1):l="�"}else l=String.fromCharCode(o);l&&(t.push(e.slice(r,n),encodeURIComponent(l)),r=n+i+1,l=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function B(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let o=0;return l;function l(u){return O(u)?(e.enter(n),a(u)):t(u)}function a(u){return O(u)&&o++<i?(e.consume(u),a):(e.exit(n),t(u))}}const cl={tokenize:fl};function fl(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),B(e,t,"linePrefix")}function i(a){return e.enter("paragraph"),o(a)}function o(a){const u=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=u),n=u,l(a)}function l(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return z(a)?(e.consume(a),e.exit("chunkText"),o):(e.consume(a),l)}}const hl={tokenize:pl},Ct={tokenize:ml};function pl(e){const t=this,n=[];let r=0,i,o,l;return a;function a(C){if(r<n.length){const F=n[r];return t.containerState=F[1],e.attempt(F[0].continuation,u,s)(C)}return s(C)}function u(C){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&I();const F=t.events.length;let R=F,b;for(;R--;)if(t.events[R][0]==="exit"&&t.events[R][1].type==="chunkFlow"){b=t.events[R][1].end;break}y(r);let M=F;for(;M<t.events.length;)t.events[M][1].end={...b},M++;return re(t.events,R+1,0,t.events.slice(F)),t.events.length=M,s(C)}return a(C)}function s(C){if(r===n.length){if(!i)return p(C);if(i.currentConstruct&&i.currentConstruct.concrete)return d(C);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Ct,f,c)(C)}function f(C){return i&&I(),y(r),p(C)}function c(C){return t.parser.lazy[t.now().line]=r!==n.length,l=t.now().offset,d(C)}function p(C){return t.containerState={},e.attempt(Ct,h,d)(C)}function h(C){return r++,n.push([t.currentConstruct,t.containerState]),p(C)}function d(C){if(C===null){i&&I(),y(0),e.consume(C);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:o}),w(C)}function w(C){if(C===null){S(e.exit("chunkFlow"),!0),y(0),e.consume(C);return}return z(C)?(e.consume(C),S(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(C),w)}function S(C,F){const R=t.sliceStream(C);if(F&&R.push(null),C.previous=o,o&&(o.next=C),o=C,i.defineSkip(C.start),i.write(R),t.parser.lazy[C.start.line]){let b=i.events.length;for(;b--;)if(i.events[b][1].start.offset<l&&(!i.events[b][1].end||i.events[b][1].end.offset>l))return;const M=t.events.length;let H=M,j,k;for(;H--;)if(t.events[H][0]==="exit"&&t.events[H][1].type==="chunkFlow"){if(j){k=t.events[H][1].end;break}j=!0}for(y(r),b=M;b<t.events.length;)t.events[b][1].end={...k},b++;re(t.events,H+1,0,t.events.slice(M)),t.events.length=b}}function y(C){let F=n.length;for(;F-- >C;){const R=n[F];t.containerState=R[1],R[0].exit.call(t,e)}n.length=C}function I(){i.write([null]),o=void 0,i=void 0,t.containerState._closeFlow=void 0}}function ml(e,t,n){return B(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Le(e){if(e===null||$(e)||Ce(e))return 1;if(un(e))return 2}function sn(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const o=e[i].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}const _n={name:"attention",resolveAll:gl,tokenize:dl};function gl(e,t){let n=-1,r,i,o,l,a,u,s,f;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 c={...e[r][1].end},p={...e[n][1].start};Et(c,-u),Et(p,u),l={type:u>1?"strongSequence":"emphasisSequence",start:c,end:{...e[r][1].end}},a={type:u>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:p},o={type:u>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:u>1?"strong":"emphasis",start:{...l.start},end:{...a.end}},e[r][1].end={...l.start},e[n][1].start={...a.end},s=[],e[r][1].end.offset-e[r][1].start.offset&&(s=ie(s,[["enter",e[r][1],t],["exit",e[r][1],t]])),s=ie(s,[["enter",i,t],["enter",l,t],["exit",l,t],["enter",o,t]]),s=ie(s,sn(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),s=ie(s,[["exit",o,t],["enter",a,t],["exit",a,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(f=2,s=ie(s,[["enter",e[n][1],t],["exit",e[n][1],t]])):f=0,re(e,r-1,n-r+3,s),n=r+s.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function dl(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Le(r);let o;return l;function l(u){return o=u,e.enter("attentionSequence"),a(u)}function a(u){if(u===o)return e.consume(u),a;const s=e.exit("attentionSequence"),f=Le(u),c=!f||f===2&&i||n.includes(u),p=!i||i===2&&f||n.includes(r);return s._open=!!(o===42?c:c&&(i||!p)),s._close=!!(o===42?p:p&&(f||!c)),t(u)}}function Et(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const yl={name:"autolink",tokenize:kl};function kl(e,t,n){let r=0;return i;function i(h){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(h){return J(h)?(e.consume(h),l):h===64?n(h):s(h)}function l(h){return h===43||h===45||h===46||G(h)?(r=1,a(h)):s(h)}function a(h){return h===58?(e.consume(h),r=0,u):(h===43||h===45||h===46||G(h))&&r++<32?(e.consume(h),a):(r=0,s(h))}function u(h){return h===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):h===null||h===32||h===60||rn(h)?n(h):(e.consume(h),u)}function s(h){return h===64?(e.consume(h),f):al(h)?(e.consume(h),s):n(h)}function f(h){return G(h)?c(h):n(h)}function c(h){return h===46?(e.consume(h),r=0,f):h===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):p(h)}function p(h){if((h===45||G(h))&&r++<63){const d=h===45?p:c;return e.consume(h),d}return n(h)}}const Xe={partial:!0,tokenize:xl};function xl(e,t,n){return r;function r(o){return O(o)?B(e,i,"linePrefix")(o):i(o)}function i(o){return o===null||z(o)?t(o):n(o)}}const dr={continuation:{tokenize:wl},exit:Sl,name:"blockQuote",tokenize:bl};function bl(e,t,n){const r=this;return i;function i(l){if(l===62){const a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(l),e.exit("blockQuoteMarker"),o}return n(l)}function o(l){return O(l)?(e.enter("blockQuotePrefixWhitespace"),e.consume(l),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(l))}}function wl(e,t,n){const r=this;return i;function i(l){return O(l)?B(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l):o(l)}function o(l){return e.attempt(dr,t,n)(l)}}function Sl(e){e.exit("blockQuote")}const yr={name:"characterEscape",tokenize:Cl};function Cl(e,t,n){return r;function r(o){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(o),e.exit("escapeMarker"),i}function i(o){return sl(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}const kr={name:"characterReference",tokenize:El};function El(e,t,n){const r=this;let i=0,o,l;return a;function a(c){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(c),e.exit("characterReferenceMarker"),u}function u(c){return c===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(c),e.exit("characterReferenceMarkerNumeric"),s):(e.enter("characterReferenceValue"),o=31,l=G,f(c))}function s(c){return c===88||c===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(c),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,l=ul,f):(e.enter("characterReferenceValue"),o=7,l=Rn,f(c))}function f(c){if(c===59&&i){const p=e.exit("characterReferenceValue");return l===G&&!Xn(r.sliceSerialize(p))?n(c):(e.enter("characterReferenceMarker"),e.consume(c),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return l(c)&&i++<o?(e.consume(c),f):n(c)}}const It={partial:!0,tokenize:Al},At={concrete:!0,name:"codeFenced",tokenize:Il};function Il(e,t,n){const r=this,i={partial:!0,tokenize:R};let o=0,l=0,a;return u;function u(b){return s(b)}function s(b){const M=r.events[r.events.length-1];return o=M&&M[1].type==="linePrefix"?M[2].sliceSerialize(M[1],!0).length:0,a=b,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),f(b)}function f(b){return b===a?(l++,e.consume(b),f):l<3?n(b):(e.exit("codeFencedFenceSequence"),O(b)?B(e,c,"whitespace")(b):c(b))}function c(b){return b===null||z(b)?(e.exit("codeFencedFence"),r.interrupt?t(b):e.check(It,w,F)(b)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(b))}function p(b){return b===null||z(b)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(b)):O(b)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),B(e,h,"whitespace")(b)):b===96&&b===a?n(b):(e.consume(b),p)}function h(b){return b===null||z(b)?c(b):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),d(b))}function d(b){return b===null||z(b)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),c(b)):b===96&&b===a?n(b):(e.consume(b),d)}function w(b){return e.attempt(i,F,S)(b)}function S(b){return e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),y}function y(b){return o>0&&O(b)?B(e,I,"linePrefix",o+1)(b):I(b)}function I(b){return b===null||z(b)?e.check(It,w,F)(b):(e.enter("codeFlowValue"),C(b))}function C(b){return b===null||z(b)?(e.exit("codeFlowValue"),I(b)):(e.consume(b),C)}function F(b){return e.exit("codeFenced"),t(b)}function R(b,M,H){let j=0;return k;function k(T){return b.enter("lineEnding"),b.consume(T),b.exit("lineEnding"),P}function P(T){return b.enter("codeFencedFence"),O(T)?B(b,v,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(T):v(T)}function v(T){return T===a?(b.enter("codeFencedFenceSequence"),U(T)):H(T)}function U(T){return T===a?(j++,b.consume(T),U):j>=l?(b.exit("codeFencedFenceSequence"),O(T)?B(b,D,"whitespace")(T):D(T)):H(T)}function D(T){return T===null||z(T)?(b.exit("codeFencedFence"),M(T)):H(T)}}}function Al(e,t,n){const r=this;return i;function i(l){return l===null?n(l):(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),o)}function o(l){return r.parser.lazy[r.now().line]?n(l):t(l)}}const dn={name:"codeIndented",tokenize:Pl},Tl={partial:!0,tokenize:vl};function Pl(e,t,n){const r=this;return i;function i(s){return e.enter("codeIndented"),B(e,o,"linePrefix",5)(s)}function o(s){const f=r.events[r.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?l(s):n(s)}function l(s){return s===null?u(s):z(s)?e.attempt(Tl,l,u)(s):(e.enter("codeFlowValue"),a(s))}function a(s){return s===null||z(s)?(e.exit("codeFlowValue"),l(s)):(e.consume(s),a)}function u(s){return e.exit("codeIndented"),t(s)}}function vl(e,t,n){const r=this;return i;function i(l){return r.parser.lazy[r.now().line]?n(l):z(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),i):B(e,o,"linePrefix",5)(l)}function o(l){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(l):z(l)?i(l):n(l)}}const zl={name:"codeText",previous:Ll,resolve:Dl,tokenize:Fl};function Dl(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 Ll(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Fl(e,t,n){let r=0,i,o;return l;function l(c){return e.enter("codeText"),e.enter("codeTextSequence"),a(c)}function a(c){return c===96?(e.consume(c),r++,a):(e.exit("codeTextSequence"),u(c))}function u(c){return c===null?n(c):c===32?(e.enter("space"),e.consume(c),e.exit("space"),u):c===96?(o=e.enter("codeTextSequence"),i=0,f(c)):z(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),u):(e.enter("codeTextData"),s(c))}function s(c){return c===null||c===32||c===96||z(c)?(e.exit("codeTextData"),u(c)):(e.consume(c),s)}function f(c){return c===96?(e.consume(c),i++,f):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(c)):(o.type="codeTextData",s(c))}}class Rl{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 o=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&je(this.left,r),o.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),je(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),je(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);je(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);je(this.left,n.reverse())}}}function je(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 xr(e){const t={};let n=-1,r,i,o,l,a,u,s;const f=new Rl(e);for(;++n<f.length;){for(;n in t;)n=t[n];if(r=f.get(n),n&&r[1].type==="chunkFlow"&&f.get(n-1)[1].type==="listItemPrefix"&&(u=r[1]._tokenizer.events,o=0,o<u.length&&u[o][1].type==="lineEndingBlank"&&(o+=2),o<u.length&&u[o][1].type==="content"))for(;++o<u.length&&u[o][1].type!=="content";)u[o][1].type==="chunkText"&&(u[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,_l(f,n)),n=t[n],s=!0);else if(r[1]._container){for(o=n,i=void 0;o--;)if(l=f.get(o),l[1].type==="lineEnding"||l[1].type==="lineEndingBlank")l[0]==="enter"&&(i&&(f.get(i)[1].type="lineEndingBlank"),l[1].type="lineEnding",i=o);else if(!(l[1].type==="linePrefix"||l[1].type==="listItemIndent"))break;i&&(r[1].end={...f.get(i)[1].start},a=f.slice(i,n),a.unshift(r),f.splice(i,n-i+1,a))}}return re(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!s}function _l(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const o=[];let l=n._tokenizer;l||(l=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(l._contentTypeTextTrailing=!0));const a=l.events,u=[],s={};let f,c,p=-1,h=n,d=0,w=0;const S=[w];for(;h;){for(;e.get(++i)[1]!==h;);o.push(i),h._tokenizer||(f=r.sliceStream(h),h.next||f.push(null),c&&l.defineSkip(h.start),h._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=!0),l.write(f),h._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=void 0)),c=h,h=h.next}for(h=n;++p<a.length;)a[p][0]==="exit"&&a[p-1][0]==="enter"&&a[p][1].type===a[p-1][1].type&&a[p][1].start.line!==a[p][1].end.line&&(w=p+1,S.push(w),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(l.events=[],h?(h._tokenizer=void 0,h.previous=void 0):S.pop(),p=S.length;p--;){const y=a.slice(S[p],S[p+1]),I=o.pop();u.push([I,I+y.length-1]),e.splice(I,2,y)}for(u.reverse(),p=-1;++p<u.length;)s[d+u[p][0]]=d+u[p][1],d+=u[p][1]-u[p][0]-1;return s}const Ol={resolve:Nl,tokenize:Bl},Ml={partial:!0,tokenize:jl};function Nl(e){return xr(e),e}function Bl(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(a)}function i(a){return a===null?o(a):z(a)?e.check(Ml,l,o)(a):(e.consume(a),i)}function o(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function l(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function jl(e,t,n){const r=this;return i;function i(l){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),B(e,o,"linePrefix")}function o(l){if(l===null||z(l))return n(l);const a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(l):e.interrupt(r.parser.constructs.flow,n,t)(l)}}function br(e,t,n,r,i,o,l,a,u){const s=u||Number.POSITIVE_INFINITY;let f=0;return c;function c(y){return y===60?(e.enter(r),e.enter(i),e.enter(o),e.consume(y),e.exit(o),p):y===null||y===32||y===41||rn(y)?n(y):(e.enter(r),e.enter(l),e.enter(a),e.enter("chunkString",{contentType:"string"}),w(y))}function p(y){return y===62?(e.enter(o),e.consume(y),e.exit(o),e.exit(i),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),h(y))}function h(y){return y===62?(e.exit("chunkString"),e.exit(a),p(y)):y===null||y===60||z(y)?n(y):(e.consume(y),y===92?d:h)}function d(y){return y===60||y===62||y===92?(e.consume(y),h):h(y)}function w(y){return!f&&(y===null||y===41||$(y))?(e.exit("chunkString"),e.exit(a),e.exit(l),e.exit(r),t(y)):f<s&&y===40?(e.consume(y),f++,w):y===41?(e.consume(y),f--,w):y===null||y===32||y===40||rn(y)?n(y):(e.consume(y),y===92?S:w)}function S(y){return y===40||y===41||y===92?(e.consume(y),w):w(y)}}function wr(e,t,n,r,i,o){const l=this;let a=0,u;return s;function s(h){return e.enter(r),e.enter(i),e.consume(h),e.exit(i),e.enter(o),f}function f(h){return a>999||h===null||h===91||h===93&&!u||h===94&&!a&&"_hiddenFootnoteSupport"in l.parser.constructs?n(h):h===93?(e.exit(o),e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):z(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),f):(e.enter("chunkString",{contentType:"string"}),c(h))}function c(h){return h===null||h===91||h===93||z(h)||a++>999?(e.exit("chunkString"),f(h)):(e.consume(h),u||(u=!O(h)),h===92?p:c)}function p(h){return h===91||h===92||h===93?(e.consume(h),a++,c):c(h)}}function Sr(e,t,n,r,i,o){let l;return a;function a(p){return p===34||p===39||p===40?(e.enter(r),e.enter(i),e.consume(p),e.exit(i),l=p===40?41:p,u):n(p)}function u(p){return p===l?(e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):(e.enter(o),s(p))}function s(p){return p===l?(e.exit(o),u(l)):p===null?n(p):z(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),B(e,s,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),f(p))}function f(p){return p===l||p===null||z(p)?(e.exit("chunkString"),s(p)):(e.consume(p),p===92?c:f)}function c(p){return p===l||p===92?(e.consume(p),f):f(p)}}function qe(e,t){let n;return r;function r(i){return z(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):O(i)?B(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const Hl={name:"definition",tokenize:ql},Ul={partial:!0,tokenize:Vl};function ql(e,t,n){const r=this;let i;return o;function o(h){return e.enter("definition"),l(h)}function l(h){return wr.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function a(h){return i=se(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),u):n(h)}function u(h){return $(h)?qe(e,s)(h):s(h)}function s(h){return br(e,f,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function f(h){return e.attempt(Ul,c,c)(h)}function c(h){return O(h)?B(e,p,"whitespace")(h):p(h)}function p(h){return h===null||z(h)?(e.exit("definition"),r.parser.defined.push(i),t(h)):n(h)}}function Vl(e,t,n){return r;function r(a){return $(a)?qe(e,i)(a):n(a)}function i(a){return Sr(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function o(a){return O(a)?B(e,l,"whitespace")(a):l(a)}function l(a){return a===null||z(a)?t(a):n(a)}}const $l={name:"hardBreakEscape",tokenize:Wl};function Wl(e,t,n){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),i}function i(o){return z(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const Yl={name:"headingAtx",resolve:Xl,tokenize:Ql};function Xl(e,t){let n=e.length-2,r=3,i,o;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},o={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},re(e,r,n-r+1,[["enter",i,t],["enter",o,t],["exit",o,t],["exit",i,t]])),e}function Ql(e,t,n){let r=0;return i;function i(f){return e.enter("atxHeading"),o(f)}function o(f){return e.enter("atxHeadingSequence"),l(f)}function l(f){return f===35&&r++<6?(e.consume(f),l):f===null||$(f)?(e.exit("atxHeadingSequence"),a(f)):n(f)}function a(f){return f===35?(e.enter("atxHeadingSequence"),u(f)):f===null||z(f)?(e.exit("atxHeading"),t(f)):O(f)?B(e,a,"whitespace")(f):(e.enter("atxHeadingText"),s(f))}function u(f){return f===35?(e.consume(f),u):(e.exit("atxHeadingSequence"),a(f))}function s(f){return f===null||f===35||$(f)?(e.exit("atxHeadingText"),a(f)):(e.consume(f),s)}}const Gl=["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"],Tt=["pre","script","style","textarea"],Kl={concrete:!0,name:"htmlFlow",resolveTo:eo,tokenize:no},Jl={partial:!0,tokenize:ro},Zl={partial:!0,tokenize:to};function eo(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 no(e,t,n){const r=this;let i,o,l,a,u;return s;function s(g){return f(g)}function f(g){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(g),c}function c(g){return g===33?(e.consume(g),p):g===47?(e.consume(g),o=!0,w):g===63?(e.consume(g),i=3,r.interrupt?t:m):J(g)?(e.consume(g),l=String.fromCharCode(g),S):n(g)}function p(g){return g===45?(e.consume(g),i=2,h):g===91?(e.consume(g),i=5,a=0,d):J(g)?(e.consume(g),i=4,r.interrupt?t:m):n(g)}function h(g){return g===45?(e.consume(g),r.interrupt?t:m):n(g)}function d(g){const ae="CDATA[";return g===ae.charCodeAt(a++)?(e.consume(g),a===ae.length?r.interrupt?t:v:d):n(g)}function w(g){return J(g)?(e.consume(g),l=String.fromCharCode(g),S):n(g)}function S(g){if(g===null||g===47||g===62||$(g)){const ae=g===47,be=l.toLowerCase();return!ae&&!o&&Tt.includes(be)?(i=1,r.interrupt?t(g):v(g)):Gl.includes(l.toLowerCase())?(i=6,ae?(e.consume(g),y):r.interrupt?t(g):v(g)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(g):o?I(g):C(g))}return g===45||G(g)?(e.consume(g),l+=String.fromCharCode(g),S):n(g)}function y(g){return g===62?(e.consume(g),r.interrupt?t:v):n(g)}function I(g){return O(g)?(e.consume(g),I):k(g)}function C(g){return g===47?(e.consume(g),k):g===58||g===95||J(g)?(e.consume(g),F):O(g)?(e.consume(g),C):k(g)}function F(g){return g===45||g===46||g===58||g===95||G(g)?(e.consume(g),F):R(g)}function R(g){return g===61?(e.consume(g),b):O(g)?(e.consume(g),R):C(g)}function b(g){return g===null||g===60||g===61||g===62||g===96?n(g):g===34||g===39?(e.consume(g),u=g,M):O(g)?(e.consume(g),b):H(g)}function M(g){return g===u?(e.consume(g),u=null,j):g===null||z(g)?n(g):(e.consume(g),M)}function H(g){return g===null||g===34||g===39||g===47||g===60||g===61||g===62||g===96||$(g)?R(g):(e.consume(g),H)}function j(g){return g===47||g===62||O(g)?C(g):n(g)}function k(g){return g===62?(e.consume(g),P):n(g)}function P(g){return g===null||z(g)?v(g):O(g)?(e.consume(g),P):n(g)}function v(g){return g===45&&i===2?(e.consume(g),q):g===60&&i===1?(e.consume(g),X):g===62&&i===4?(e.consume(g),oe):g===63&&i===3?(e.consume(g),m):g===93&&i===5?(e.consume(g),he):z(g)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(Jl,pe,U)(g)):g===null||z(g)?(e.exit("htmlFlowData"),U(g)):(e.consume(g),v)}function U(g){return e.check(Zl,D,pe)(g)}function D(g){return e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),T}function T(g){return g===null||z(g)?U(g):(e.enter("htmlFlowData"),v(g))}function q(g){return g===45?(e.consume(g),m):v(g)}function X(g){return g===47?(e.consume(g),l="",le):v(g)}function le(g){if(g===62){const ae=l.toLowerCase();return Tt.includes(ae)?(e.consume(g),oe):v(g)}return J(g)&&l.length<8?(e.consume(g),l+=String.fromCharCode(g),le):v(g)}function he(g){return g===93?(e.consume(g),m):v(g)}function m(g){return g===62?(e.consume(g),oe):g===45&&i===2?(e.consume(g),m):v(g)}function oe(g){return g===null||z(g)?(e.exit("htmlFlowData"),pe(g)):(e.consume(g),oe)}function pe(g){return e.exit("htmlFlow"),t(g)}}function to(e,t,n){const r=this;return i;function i(l){return z(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),o):n(l)}function o(l){return r.parser.lazy[r.now().line]?n(l):t(l)}}function ro(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Xe,t,n)}}const io={name:"htmlText",tokenize:lo};function lo(e,t,n){const r=this;let i,o,l;return a;function a(m){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(m),u}function u(m){return m===33?(e.consume(m),s):m===47?(e.consume(m),R):m===63?(e.consume(m),C):J(m)?(e.consume(m),H):n(m)}function s(m){return m===45?(e.consume(m),f):m===91?(e.consume(m),o=0,d):J(m)?(e.consume(m),I):n(m)}function f(m){return m===45?(e.consume(m),h):n(m)}function c(m){return m===null?n(m):m===45?(e.consume(m),p):z(m)?(l=c,X(m)):(e.consume(m),c)}function p(m){return m===45?(e.consume(m),h):c(m)}function h(m){return m===62?q(m):m===45?p(m):c(m)}function d(m){const oe="CDATA[";return m===oe.charCodeAt(o++)?(e.consume(m),o===oe.length?w:d):n(m)}function w(m){return m===null?n(m):m===93?(e.consume(m),S):z(m)?(l=w,X(m)):(e.consume(m),w)}function S(m){return m===93?(e.consume(m),y):w(m)}function y(m){return m===62?q(m):m===93?(e.consume(m),y):w(m)}function I(m){return m===null||m===62?q(m):z(m)?(l=I,X(m)):(e.consume(m),I)}function C(m){return m===null?n(m):m===63?(e.consume(m),F):z(m)?(l=C,X(m)):(e.consume(m),C)}function F(m){return m===62?q(m):C(m)}function R(m){return J(m)?(e.consume(m),b):n(m)}function b(m){return m===45||G(m)?(e.consume(m),b):M(m)}function M(m){return z(m)?(l=M,X(m)):O(m)?(e.consume(m),M):q(m)}function H(m){return m===45||G(m)?(e.consume(m),H):m===47||m===62||$(m)?j(m):n(m)}function j(m){return m===47?(e.consume(m),q):m===58||m===95||J(m)?(e.consume(m),k):z(m)?(l=j,X(m)):O(m)?(e.consume(m),j):q(m)}function k(m){return m===45||m===46||m===58||m===95||G(m)?(e.consume(m),k):P(m)}function P(m){return m===61?(e.consume(m),v):z(m)?(l=P,X(m)):O(m)?(e.consume(m),P):j(m)}function v(m){return m===null||m===60||m===61||m===62||m===96?n(m):m===34||m===39?(e.consume(m),i=m,U):z(m)?(l=v,X(m)):O(m)?(e.consume(m),v):(e.consume(m),D)}function U(m){return m===i?(e.consume(m),i=void 0,T):m===null?n(m):z(m)?(l=U,X(m)):(e.consume(m),U)}function D(m){return m===null||m===34||m===39||m===60||m===61||m===96?n(m):m===47||m===62||$(m)?j(m):(e.consume(m),D)}function T(m){return m===47||m===62||$(m)?j(m):n(m)}function q(m){return m===62?(e.consume(m),e.exit("htmlTextData"),e.exit("htmlText"),t):n(m)}function X(m){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),le}function le(m){return O(m)?B(e,he,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(m):he(m)}function he(m){return e.enter("htmlTextData"),l(m)}}const Qn={name:"labelEnd",resolveAll:so,resolveTo:co,tokenize:fo},oo={tokenize:ho},ao={tokenize:po},uo={tokenize:mo};function so(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&&re(e,0,e.length,n),e}function co(e,t){let n=e.length,r=0,i,o,l,a;for(;n--;)if(i=e[n][1],o){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(l){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(o=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(l=n);const u={type:e[o][1].type==="labelLink"?"link":"image",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},s={type:"label",start:{...e[o][1].start},end:{...e[l][1].end}},f={type:"labelText",start:{...e[o+r+2][1].end},end:{...e[l-2][1].start}};return a=[["enter",u,t],["enter",s,t]],a=ie(a,e.slice(o+1,o+r+3)),a=ie(a,[["enter",f,t]]),a=ie(a,sn(t.parser.constructs.insideSpan.null,e.slice(o+r+4,l-3),t)),a=ie(a,[["exit",f,t],e[l-2],e[l-1],["exit",s,t]]),a=ie(a,e.slice(l+1)),a=ie(a,[["exit",u,t]]),re(e,o,e.length,a),e}function fo(e,t,n){const r=this;let i=r.events.length,o,l;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){o=r.events[i][1];break}return a;function a(p){return o?o._inactive?c(p):(l=r.parser.defined.includes(se(r.sliceSerialize({start:o.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelEnd"),u):n(p)}function u(p){return p===40?e.attempt(oo,f,l?f:c)(p):p===91?e.attempt(ao,f,l?s:c)(p):l?f(p):c(p)}function s(p){return e.attempt(uo,f,c)(p)}function f(p){return t(p)}function c(p){return o._balanced=!0,n(p)}}function ho(e,t,n){return r;function r(c){return e.enter("resource"),e.enter("resourceMarker"),e.consume(c),e.exit("resourceMarker"),i}function i(c){return $(c)?qe(e,o)(c):o(c)}function o(c){return c===41?f(c):br(e,l,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(c)}function l(c){return $(c)?qe(e,u)(c):f(c)}function a(c){return n(c)}function u(c){return c===34||c===39||c===40?Sr(e,s,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(c):f(c)}function s(c){return $(c)?qe(e,f)(c):f(c)}function f(c){return c===41?(e.enter("resourceMarker"),e.consume(c),e.exit("resourceMarker"),e.exit("resource"),t):n(c)}}function po(e,t,n){const r=this;return i;function i(a){return wr.call(r,e,o,l,"reference","referenceMarker","referenceString")(a)}function o(a){return r.parser.defined.includes(se(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function l(a){return n(a)}}function mo(e,t,n){return r;function r(o){return e.enter("reference"),e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),i}function i(o){return o===93?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),t):n(o)}}const go={name:"labelStartImage",resolveAll:Qn.resolveAll,tokenize:yo};function yo(e,t,n){const r=this;return i;function i(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),o}function o(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),l):n(a)}function l(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const ko={name:"labelStartLink",resolveAll:Qn.resolveAll,tokenize:xo};function xo(e,t,n){const r=this;return i;function i(l){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelLink"),o}function o(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(l):t(l)}}const yn={name:"lineEnding",tokenize:bo};function bo(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),B(e,t,"linePrefix")}}const tn={name:"thematicBreak",tokenize:wo};function wo(e,t,n){let r=0,i;return o;function o(s){return e.enter("thematicBreak"),l(s)}function l(s){return i=s,a(s)}function a(s){return s===i?(e.enter("thematicBreakSequence"),u(s)):r>=3&&(s===null||z(s))?(e.exit("thematicBreak"),t(s)):n(s)}function u(s){return s===i?(e.consume(s),r++,u):(e.exit("thematicBreakSequence"),O(s)?B(e,a,"whitespace")(s):a(s))}}const Z={continuation:{tokenize:Io},exit:To,name:"list",tokenize:Eo},So={partial:!0,tokenize:Po},Co={partial:!0,tokenize:Ao};function Eo(e,t,n){const r=this,i=r.events[r.events.length-1];let o=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,l=0;return a;function a(h){const d=r.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(d==="listUnordered"?!r.containerState.marker||h===r.containerState.marker:Rn(h)){if(r.containerState.type||(r.containerState.type=d,e.enter(d,{_container:!0})),d==="listUnordered")return e.enter("listItemPrefix"),h===42||h===45?e.check(tn,n,s)(h):s(h);if(!r.interrupt||h===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),u(h)}return n(h)}function u(h){return Rn(h)&&++l<10?(e.consume(h),u):(!r.interrupt||l<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(e.exit("listItemValue"),s(h)):n(h)}function s(h){return e.enter("listItemMarker"),e.consume(h),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||h,e.check(Xe,r.interrupt?n:f,e.attempt(So,p,c))}function f(h){return r.containerState.initialBlankLine=!0,o++,p(h)}function c(h){return O(h)?(e.enter("listItemPrefixWhitespace"),e.consume(h),e.exit("listItemPrefixWhitespace"),p):n(h)}function p(h){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(h)}}function Io(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Xe,i,o);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,B(e,t,"listItemIndent",r.containerState.size+1)(a)}function o(a){return r.containerState.furtherBlankLines||!O(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,l(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Co,t,l)(a))}function l(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,B(e,e.attempt(Z,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function Ao(e,t,n){const r=this;return B(e,i,"listItemIndent",r.containerState.size+1);function i(o){const l=r.events[r.events.length-1];return l&&l[1].type==="listItemIndent"&&l[2].sliceSerialize(l[1],!0).length===r.containerState.size?t(o):n(o)}}function To(e){e.exit(this.containerState.type)}function Po(e,t,n){const r=this;return B(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(o){const l=r.events[r.events.length-1];return!O(o)&&l&&l[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const Pt={name:"setextUnderline",resolveTo:vo,tokenize:zo};function vo(e,t){let n=e.length,r,i,o;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),!o&&e[n][1].type==="definition"&&(o=n);const l={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",o?(e.splice(i,0,["enter",l,t]),e.splice(o+1,0,["exit",e[r][1],t]),e[r][1].end={...e[o][1].end}):e[r][1]=l,e.push(["exit",l,t]),e}function zo(e,t,n){const r=this;let i;return o;function o(s){let f=r.events.length,c;for(;f--;)if(r.events[f][1].type!=="lineEnding"&&r.events[f][1].type!=="linePrefix"&&r.events[f][1].type!=="content"){c=r.events[f][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||c)?(e.enter("setextHeadingLine"),i=s,l(s)):n(s)}function l(s){return e.enter("setextHeadingLineSequence"),a(s)}function a(s){return s===i?(e.consume(s),a):(e.exit("setextHeadingLineSequence"),O(s)?B(e,u,"lineSuffix")(s):u(s))}function u(s){return s===null||z(s)?(e.exit("setextHeadingLine"),t(s)):n(s)}}const Do={tokenize:Lo};function Lo(e){const t=this,n=e.attempt(Xe,r,e.attempt(this.parser.constructs.flowInitial,i,B(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Ol,i)),"linePrefix")));return n;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const Fo={resolveAll:Er()},Ro=Cr("string"),_o=Cr("text");function Cr(e){return{resolveAll:Er(e==="text"?Oo:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],o=n.attempt(i,l,a);return l;function l(f){return s(f)?o(f):a(f)}function a(f){if(f===null){n.consume(f);return}return n.enter("data"),n.consume(f),u}function u(f){return s(f)?(n.exit("data"),o(f)):(n.consume(f),u)}function s(f){if(f===null)return!0;const c=i[f];let p=-1;if(c)for(;++p<c.length;){const h=c[p];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function Er(e){return t;function t(n,r){let i=-1,o;for(;++i<=n.length;)o===void 0?n[i]&&n[i][1].type==="data"&&(o=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==o+2&&(n[o][1].end=n[i-1][1].end,n.splice(o+2,i-o-2),i=o+2),o=void 0);return e?e(n,r):n}}function Oo(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 o=i.length,l=-1,a=0,u;for(;o--;){const s=i[o];if(typeof s=="string"){for(l=s.length;s.charCodeAt(l-1)===32;)a++,l--;if(l)break;l=-1}else if(s===-2)u=!0,a++;else if(s!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){const s={type:n===e.length||u||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?l:r.start._bufferIndex+l,_index:r.start._index+o,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...s.start},r.start.offset===r.end.offset?Object.assign(r,s):(e.splice(n,0,["enter",s,t],["exit",s,t]),n+=2)}n++}return e}const Mo={42:Z,43:Z,45:Z,48:Z,49:Z,50:Z,51:Z,52:Z,53:Z,54:Z,55:Z,56:Z,57:Z,62:dr},No={91:Hl},Bo={[-2]:dn,[-1]:dn,32:dn},jo={35:Yl,42:tn,45:[Pt,tn],60:Kl,61:Pt,95:tn,96:At,126:At},Ho={38:kr,92:yr},Uo={[-5]:yn,[-4]:yn,[-3]:yn,33:go,38:kr,42:_n,60:[yl,io],91:ko,92:[$l,yr],93:Qn,95:_n,96:zl},qo={null:[_n,Fo]},Vo={null:[42,95]},$o={null:[]},Wo=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Vo,contentInitial:No,disable:$o,document:Mo,flow:jo,flowInitial:Bo,insideSpan:qo,string:Ho,text:Uo},Symbol.toStringTag,{value:"Module"}));function Yo(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={},o=[];let l=[],a=[];const u={attempt:M(R),check:M(b),consume:I,enter:C,exit:F,interrupt:M(b,{interrupt:!0})},s={code:null,containerState:{},defineSkip:w,events:[],now:d,parser:e,previous:null,sliceSerialize:p,sliceStream:h,write:c};let f=t.tokenize.call(s,u);return t.resolveAll&&o.push(t),s;function c(P){return l=ie(l,P),S(),l[l.length-1]!==null?[]:(H(t,0),s.events=sn(o,s.events,s),s.events)}function p(P,v){return Qo(h(P),v)}function h(P){return Xo(l,P)}function d(){const{_bufferIndex:P,_index:v,line:U,column:D,offset:T}=r;return{_bufferIndex:P,_index:v,line:U,column:D,offset:T}}function w(P){i[P.line]=P.column,k()}function S(){let P;for(;r._index<l.length;){const v=l[r._index];if(typeof v=="string")for(P=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===P&&r._bufferIndex<v.length;)y(v.charCodeAt(r._bufferIndex));else y(v)}}function y(P){f=f(P)}function I(P){z(P)?(r.line++,r.column=1,r.offset+=P===-3?2:1,k()):P!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===l[r._index].length&&(r._bufferIndex=-1,r._index++)),s.previous=P}function C(P,v){const U=v||{};return U.type=P,U.start=d(),s.events.push(["enter",U,s]),a.push(U),U}function F(P){const v=a.pop();return v.end=d(),s.events.push(["exit",v,s]),v}function R(P,v){H(P,v.from)}function b(P,v){v.restore()}function M(P,v){return U;function U(D,T,q){let X,le,he,m;return Array.isArray(D)?pe(D):"tokenize"in D?pe([D]):oe(D);function oe(Q){return _e;function _e(ye){const Ie=ye!==null&&Q[ye],Ae=ye!==null&&Q.null,Ge=[...Array.isArray(Ie)?Ie:Ie?[Ie]:[],...Array.isArray(Ae)?Ae:Ae?[Ae]:[]];return pe(Ge)(ye)}}function pe(Q){return X=Q,le=0,Q.length===0?q:g(Q[le])}function g(Q){return _e;function _e(ye){return m=j(),he=Q,Q.partial||(s.currentConstruct=Q),Q.name&&s.parser.constructs.disable.null.includes(Q.name)?be():Q.tokenize.call(v?Object.assign(Object.create(s),v):s,u,ae,be)(ye)}}function ae(Q){return P(he,m),T}function be(Q){return m.restore(),++le<X.length?g(X[le]):q}}}function H(P,v){P.resolveAll&&!o.includes(P)&&o.push(P),P.resolve&&re(s.events,v,s.events.length-v,P.resolve(s.events.slice(v),s)),P.resolveTo&&(s.events=P.resolveTo(s.events,s))}function j(){const P=d(),v=s.previous,U=s.currentConstruct,D=s.events.length,T=Array.from(a);return{from:D,restore:q};function q(){r=P,s.previous=v,s.currentConstruct=U,s.events.length=D,a=T,k()}}function k(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Xo(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,o=t.end._bufferIndex;let l;if(n===i)l=[e[n].slice(r,o)];else{if(l=e.slice(n,i),r>-1){const a=l[0];typeof a=="string"?l[0]=a.slice(r):l.shift()}o>0&&l.push(e[i].slice(0,o))}return l}function Qo(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const o=e[n];let l;if(typeof o=="string")l=o;else switch(o){case-5:{l="\r";break}case-4:{l=`
3
3
  `;break}case-3:{l=`\r
4
4
  `;break}case-2:{l=t?" ":" ";break}case-1:{if(!t&&i)continue;l=" ";break}default:l=String.fromCharCode(o)}i=o===-2,r.push(l)}return r.join("")}function Go(e){const r={constructs:mr([Wo,...(e||{}).extensions||[]]),content:i(cl),defined:[],document:i(hl),flow:i(Do),lazy:{},string:i(Ro),text:i(_o)};return r;function i(o){return l;function l(a){return Yo(r,o,a)}}}function Ko(e){for(;!xr(e););return e}const vt=/[\0\t\n\r]/g;function Jo(){let e=1,t="",n=!0,r;return i;function i(o,l,a){const u=[];let s,f,c,p,h;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(l||void 0).decode(o)),c=0,t="",n&&(o.charCodeAt(0)===65279&&c++,n=void 0);c<o.length;){if(vt.lastIndex=c,s=vt.exec(o),p=s&&s.index!==void 0?s.index:o.length,h=o.charCodeAt(p),!s){t=o.slice(c);break}if(h===10&&c===p&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),c<p&&(u.push(o.slice(c,p)),e+=p-c),h){case 0:{u.push(65533),e++;break}case 9:{for(f=Math.ceil(e/4)*4,u.push(-2);e++<f;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}c=p+1}return a&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}const Zo=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function ea(e){return e.replace(Zo,na)}function na(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),o=i===120||i===88;return gr(n.slice(o?2:1),o?16:10)}return Xn(n)||e}const Ir={}.hasOwnProperty;function ta(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),ra(n)(Ko(Go(n).document().write(Jo()(e,t,!0))))}function ra(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(ut),autolinkProtocol:j,autolinkEmail:j,atxHeading:o(lt),blockQuote:o(Ae),characterEscape:j,characterReference:j,codeFenced:o(Ge),codeFencedFenceInfo:l,codeFencedFenceMeta:l,codeIndented:o(Ge,l),codeText:o(ii,l),codeTextData:j,data:j,codeFlowValue:j,definition:o(li),definitionDestinationString:l,definitionLabelString:l,definitionTitleString:l,emphasis:o(oi),hardBreakEscape:o(ot),hardBreakTrailing:o(ot),htmlFlow:o(at,l),htmlFlowData:j,htmlText:o(at,l),htmlTextData:j,image:o(ai),label:l,link:o(ut),listItem:o(ui),listItemValue:p,listOrdered:o(st,c),listUnordered:o(st),paragraph:o(si),reference:g,referenceString:l,resourceDestinationString:l,resourceTitleString:l,setextHeading:o(lt),strong:o(ci),thematicBreak:o(hi)},exit:{atxHeading:u(),atxHeadingSequence:R,autolink:u(),autolinkEmail:Ie,autolinkProtocol:ye,blockQuote:u(),characterEscapeValue:k,characterReferenceMarkerHexadecimal:be,characterReferenceMarkerNumeric:be,characterReferenceValue:Q,characterReference:_e,codeFenced:u(S),codeFencedFence:w,codeFencedFenceInfo:h,codeFencedFenceMeta:d,codeFlowValue:k,codeIndented:u(y),codeText:u(T),codeTextData:k,data:k,definition:u(),definitionDestinationString:F,definitionLabelString:I,definitionTitleString:C,emphasis:u(),hardBreakEscape:u(v),hardBreakTrailing:u(v),htmlFlow:u(U),htmlFlowData:k,htmlText:u(D),htmlTextData:k,image:u(X),label:he,labelText:le,lineEnding:P,link:u(q),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:ae,resourceDestinationString:m,resourceTitleString:oe,resource:pe,setextHeading:u(H),setextHeadingLineSequence:M,setextHeadingText:b,strong:u(),thematicBreak:u()}};Ar(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(x){let A={type:"root",children:[]};const L={stack:[A],tokenStack:[],config:t,enter:a,exit:s,buffer:l,resume:f,data:n},N=[];let V=-1;for(;++V<x.length;)if(x[V][1].type==="listOrdered"||x[V][1].type==="listUnordered")if(x[V][0]==="enter")N.push(V);else{const ue=N.pop();V=i(x,ue,V)}for(V=-1;++V<x.length;){const ue=t[x[V][0]];Ir.call(ue,x[V][1].type)&&ue[x[V][1].type].call(Object.assign({sliceSerialize:x[V][2].sliceSerialize},L),x[V][1])}if(L.tokenStack.length>0){const ue=L.tokenStack[L.tokenStack.length-1];(ue[1]||zt).call(L,void 0,ue[0])}for(A.position={start:ke(x.length>0?x[0][1].start:{line:1,column:1,offset:0}),end:ke(x.length>0?x[x.length-2][1].end:{line:1,column:1,offset:0})},V=-1;++V<t.transforms.length;)A=t.transforms[V](A)||A;return A}function i(x,A,L){let N=A-1,V=-1,ue=!1,we,me,Oe,Me;for(;++N<=L;){const ne=x[N];switch(ne[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ne[0]==="enter"?V++:V--,Me=void 0;break}case"lineEndingBlank":{ne[0]==="enter"&&(we&&!Me&&!V&&!Oe&&(Oe=N),Me=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Me=void 0}if(!V&&ne[0]==="enter"&&ne[1].type==="listItemPrefix"||V===-1&&ne[0]==="exit"&&(ne[1].type==="listUnordered"||ne[1].type==="listOrdered")){if(we){let Te=N;for(me=void 0;Te--;){const ge=x[Te];if(ge[1].type==="lineEnding"||ge[1].type==="lineEndingBlank"){if(ge[0]==="exit")continue;me&&(x[me][1].type="lineEndingBlank",ue=!0),ge[1].type="lineEnding",me=Te}else if(!(ge[1].type==="linePrefix"||ge[1].type==="blockQuotePrefix"||ge[1].type==="blockQuotePrefixWhitespace"||ge[1].type==="blockQuoteMarker"||ge[1].type==="listItemIndent"))break}Oe&&(!me||Oe<me)&&(we._spread=!0),we.end=Object.assign({},me?x[me][1].start:ne[1].end),x.splice(me||N,0,["exit",we,ne[2]]),N++,L++}if(ne[1].type==="listItemPrefix"){const Te={type:"listItem",_spread:!1,start:Object.assign({},ne[1].start),end:void 0};we=Te,x.splice(N,0,["enter",Te,ne[2]]),N++,L++,Oe=void 0,Me=!0}}}return x[A][1]._spread=ue,L}function o(x,A){return L;function L(N){a.call(this,x(N),N),A&&A.call(this,N)}}function l(){this.stack.push({type:"fragment",children:[]})}function a(x,A,L){this.stack[this.stack.length-1].children.push(x),this.stack.push(x),this.tokenStack.push([A,L||void 0]),x.position={start:ke(A.start),end:void 0}}function u(x){return A;function A(L){x&&x.call(this,L),s.call(this,L)}}function s(x,A){const L=this.stack.pop(),N=this.tokenStack.pop();if(N)N[0].type!==x.type&&(A?A.call(this,x,N[0]):(N[1]||zt).call(this,x,N[0]));else throw new Error("Cannot close `"+x.type+"` ("+Ue({start:x.start,end:x.end})+"): it’s not open");L.position.end=ke(x.end)}function f(){return Yn(this.stack.pop())}function c(){this.data.expectingFirstListItemValue=!0}function p(x){if(this.data.expectingFirstListItemValue){const A=this.stack[this.stack.length-2];A.start=Number.parseInt(this.sliceSerialize(x),10),this.data.expectingFirstListItemValue=void 0}}function h(){const x=this.resume(),A=this.stack[this.stack.length-1];A.lang=x}function d(){const x=this.resume(),A=this.stack[this.stack.length-1];A.meta=x}function w(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function S(){const x=this.resume(),A=this.stack[this.stack.length-1];A.value=x.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const x=this.resume(),A=this.stack[this.stack.length-1];A.value=x.replace(/(\r?\n|\r)$/g,"")}function I(x){const A=this.resume(),L=this.stack[this.stack.length-1];L.label=A,L.identifier=se(this.sliceSerialize(x)).toLowerCase()}function C(){const x=this.resume(),A=this.stack[this.stack.length-1];A.title=x}function F(){const x=this.resume(),A=this.stack[this.stack.length-1];A.url=x}function R(x){const A=this.stack[this.stack.length-1];if(!A.depth){const L=this.sliceSerialize(x).length;A.depth=L}}function b(){this.data.setextHeadingSlurpLineEnding=!0}function M(x){const A=this.stack[this.stack.length-1];A.depth=this.sliceSerialize(x).codePointAt(0)===61?1:2}function H(){this.data.setextHeadingSlurpLineEnding=void 0}function j(x){const L=this.stack[this.stack.length-1].children;let N=L[L.length-1];(!N||N.type!=="text")&&(N=fi(),N.position={start:ke(x.start),end:void 0},L.push(N)),this.stack.push(N)}function k(x){const A=this.stack.pop();A.value+=this.sliceSerialize(x),A.position.end=ke(x.end)}function P(x){const A=this.stack[this.stack.length-1];if(this.data.atHardBreak){const L=A.children[A.children.length-1];L.position.end=ke(x.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(A.type)&&(j.call(this,x),k.call(this,x))}function v(){this.data.atHardBreak=!0}function U(){const x=this.resume(),A=this.stack[this.stack.length-1];A.value=x}function D(){const x=this.resume(),A=this.stack[this.stack.length-1];A.value=x}function T(){const x=this.resume(),A=this.stack[this.stack.length-1];A.value=x}function q(){const x=this.stack[this.stack.length-1];if(this.data.inReference){const A=this.data.referenceType||"shortcut";x.type+="Reference",x.referenceType=A,delete x.url,delete x.title}else delete x.identifier,delete x.label;this.data.referenceType=void 0}function X(){const x=this.stack[this.stack.length-1];if(this.data.inReference){const A=this.data.referenceType||"shortcut";x.type+="Reference",x.referenceType=A,delete x.url,delete x.title}else delete x.identifier,delete x.label;this.data.referenceType=void 0}function le(x){const A=this.sliceSerialize(x),L=this.stack[this.stack.length-2];L.label=ea(A),L.identifier=se(A).toLowerCase()}function he(){const x=this.stack[this.stack.length-1],A=this.resume(),L=this.stack[this.stack.length-1];if(this.data.inReference=!0,L.type==="link"){const N=x.children;L.children=N}else L.alt=A}function m(){const x=this.resume(),A=this.stack[this.stack.length-1];A.url=x}function oe(){const x=this.resume(),A=this.stack[this.stack.length-1];A.title=x}function pe(){this.data.inReference=void 0}function g(){this.data.referenceType="collapsed"}function ae(x){const A=this.resume(),L=this.stack[this.stack.length-1];L.label=A,L.identifier=se(this.sliceSerialize(x)).toLowerCase(),this.data.referenceType="full"}function be(x){this.data.characterReferenceType=x.type}function Q(x){const A=this.sliceSerialize(x),L=this.data.characterReferenceType;let N;L?(N=gr(A,L==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):N=Xn(A);const V=this.stack[this.stack.length-1];V.value+=N}function _e(x){const A=this.stack.pop();A.position.end=ke(x.end)}function ye(x){k.call(this,x);const A=this.stack[this.stack.length-1];A.url=this.sliceSerialize(x)}function Ie(x){k.call(this,x);const A=this.stack[this.stack.length-1];A.url="mailto:"+this.sliceSerialize(x)}function Ae(){return{type:"blockquote",children:[]}}function Ge(){return{type:"code",lang:null,meta:null,value:""}}function ii(){return{type:"inlineCode",value:""}}function li(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function oi(){return{type:"emphasis",children:[]}}function lt(){return{type:"heading",depth:0,children:[]}}function ot(){return{type:"break"}}function at(){return{type:"html",value:""}}function ai(){return{type:"image",title:null,url:"",alt:null}}function ut(){return{type:"link",title:null,url:"",children:[]}}function st(x){return{type:"list",ordered:x.type==="listOrdered",start:null,spread:x._spread,children:[]}}function ui(x){return{type:"listItem",spread:x._spread,checked:null,children:[]}}function si(){return{type:"paragraph",children:[]}}function ci(){return{type:"strong",children:[]}}function fi(){return{type:"text",value:""}}function hi(){return{type:"thematicBreak"}}}function ke(e){return{line:e.line,column:e.column,offset:e.offset}}function Ar(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Ar(e,r):ia(e,r)}}function ia(e,t){let n;for(n in t)if(Ir.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 zt(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Ue({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Ue({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Ue({start:t.start,end:t.end})+") is still open")}function la(e){const t=this;t.parser=n;function n(r){return ta(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function oa(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 aa(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
@@ -11,7 +11,7 @@ Error generating stack: `+l.message+`
11
11
  While dragging, use the arrow keys to move the item.
12
12
  Press space again to drop the item in its new position, or press escape to cancel.
13
13
  `},ux={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function hx(e){let{announcements:t=ux,container:n,hiddenTextDescribedById:a,screenReaderInstructions:o=cx}=e;const{announce:c,announcement:d}=ax(),p=ku("DndLiveRegion"),[m,f]=g.useState(!1);if(g.useEffect(()=>{f(!0)},[]),lx(g.useMemo(()=>({onDragStart(y){let{active:b}=y;c(t.onDragStart({active:b}))},onDragMove(y){let{active:b,over:x}=y;t.onDragMove&&c(t.onDragMove({active:b,over:x}))},onDragOver(y){let{active:b,over:x}=y;c(t.onDragOver({active:b,over:x}))},onDragEnd(y){let{active:b,over:x}=y;c(t.onDragEnd({active:b,over:x}))},onDragCancel(y){let{active:b,over:x}=y;c(t.onDragCancel({active:b,over:x}))}}),[c,t])),!m)return null;const S=xi.createElement(xi.Fragment,null,xi.createElement(nx,{id:a,value:o.draggable}),xi.createElement(rx,{id:p,announcement:d}));return n?Il.createPortal(S,n):S}var ni;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(ni||(ni={}));function cu(){}function ky(e,t){return g.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function dx(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return g.useMemo(()=>[...t].filter(a=>a!=null),[...t])}const Ns=Object.freeze({x:0,y:0});function fx(e,t){let{data:{value:n}}=e,{data:{value:a}}=t;return a-n}function px(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function mx(e,t){const n=Math.max(t.top,e.top),a=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),c=Math.min(t.top+t.height,e.top+e.height),d=o-a,p=c-n;if(a<o&&n<c){const m=t.width*t.height,f=e.width*e.height,S=d*p,y=S/(m+f-S);return Number(y.toFixed(4))}return 0}const _x=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:a}=e;const o=[];for(const c of a){const{id:d}=c,p=n.get(d);if(p){const m=mx(p,t);m>0&&o.push({id:d,data:{droppableContainer:c,value:m}})}}return o.sort(fx)};function vx(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Db(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Ns}function gx(e){return function(n){for(var a=arguments.length,o=new Array(a>1?a-1:0),c=1;c<a;c++)o[c-1]=arguments[c];return o.reduce((d,p)=>({...d,top:d.top+e*p.y,bottom:d.bottom+e*p.y,left:d.left+e*p.x,right:d.right+e*p.x}),{...n})}}const yx=gx(1);function Sx(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function bx(e,t,n){const a=Sx(t);if(!a)return e;const{scaleX:o,scaleY:c,x:d,y:p}=a,m=e.left-d-(1-o)*parseFloat(n),f=e.top-p-(1-c)*parseFloat(n.slice(n.indexOf(" ")+1)),S=o?e.width/o:e.width,y=c?e.height/c:e.height;return{width:S,height:y,top:f,right:m+S,bottom:f+y,left:m}}const wx={ignoreTransform:!1};function bo(e,t){t===void 0&&(t=wx);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:f,transformOrigin:S}=$i(e).getComputedStyle(e);f&&(n=bx(n,f,S))}const{top:a,left:o,width:c,height:d,bottom:p,right:m}=n;return{top:a,left:o,width:c,height:d,bottom:p,right:m}}function Dy(e){return bo(e,{ignoreTransform:!0})}function Cx(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function xx(e,t){return t===void 0&&(t=$i(e).getComputedStyle(e)),t.position==="fixed"}function Ex(e,t){t===void 0&&(t=$i(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const c=t[o];return typeof c=="string"?n.test(c):!1})}function Zp(e,t){const n=[];function a(o){if(t!=null&&n.length>=t||!o)return n;if(Xp(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!yo(o)||xb(o)||n.includes(o))return n;const c=$i(e).getComputedStyle(o);return o!==e&&Ex(o,c)&&n.push(o),xx(o,c)?n:a(o.parentNode)}return e?a(e):n}function Rb(e){const[t]=Zp(e,1);return t??null}function Gd(e){return!Tu||!e?null:za(e)?e:Vp(e)?Xp(e)||e===ja(e).scrollingElement?window:yo(e)?e:null:null}function Mb(e){return za(e)?e.scrollX:e.scrollLeft}function Ab(e){return za(e)?e.scrollY:e.scrollTop}function kf(e){return{x:Mb(e),y:Ab(e)}}var ui;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(ui||(ui={}));function Nb(e){return!Tu||!e?!1:e===document.scrollingElement}function Bb(e){const t={x:0,y:0},n=Nb(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},a={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,c=e.scrollLeft<=t.x,d=e.scrollTop>=a.y,p=e.scrollLeft>=a.x;return{isTop:o,isLeft:c,isBottom:d,isRight:p,maxScroll:a,minScroll:t}}const Tx={x:.2,y:.2};function kx(e,t,n,a,o){let{top:c,left:d,right:p,bottom:m}=n;a===void 0&&(a=10),o===void 0&&(o=Tx);const{isTop:f,isBottom:S,isLeft:y,isRight:b}=Bb(e),x={x:0,y:0},C={x:0,y:0},k={height:t.height*o.y,width:t.width*o.x};return!f&&c<=t.top+k.height?(x.y=ui.Backward,C.y=a*Math.abs((t.top+k.height-c)/k.height)):!S&&m>=t.bottom-k.height&&(x.y=ui.Forward,C.y=a*Math.abs((t.bottom-k.height-m)/k.height)),!b&&p>=t.right-k.width?(x.x=ui.Forward,C.x=a*Math.abs((t.right-k.width-p)/k.width)):!y&&d<=t.left+k.width&&(x.x=ui.Backward,C.x=a*Math.abs((t.left+k.width-d)/k.width)),{direction:x,speed:C}}function Dx(e){if(e===document.scrollingElement){const{innerWidth:c,innerHeight:d}=window;return{top:0,left:0,right:c,bottom:d,width:c,height:d}}const{top:t,left:n,right:a,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:a,bottom:o,width:e.clientWidth,height:e.clientHeight}}function Lb(e){return e.reduce((t,n)=>Aa(t,kf(n)),Ns)}function Rx(e){return e.reduce((t,n)=>t+Mb(n),0)}function Mx(e){return e.reduce((t,n)=>t+Ab(n),0)}function Ax(e,t){if(t===void 0&&(t=bo),!e)return;const{top:n,left:a,bottom:o,right:c}=t(e);Rb(e)&&(o<=0||c<=0||n>=window.innerHeight||a>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Nx=[["x",["left","right"],Rx],["y",["top","bottom"],Mx]];class Qp{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const a=Zp(n),o=Lb(a);this.rect={...t},this.width=t.width,this.height=t.height;for(const[c,d,p]of Nx)for(const m of d)Object.defineProperty(this,m,{get:()=>{const f=p(a),S=o[c]-f;return this.rect[m]+S},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Gl{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var a;return(a=this.target)==null?void 0:a.removeEventListener(...n)})},this.target=t}add(t,n,a){var o;(o=this.target)==null||o.addEventListener(t,n,a),this.listeners.push([t,n,a])}}function Bx(e){const{EventTarget:t}=$i(e);return e instanceof t?e:ja(e)}function Zd(e,t){const n=Math.abs(e.x),a=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+a**2)>t:"x"in t&&"y"in t?n>t.x&&a>t.y:"x"in t?n>t.x:"y"in t?a>t.y:!1}var bs;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(bs||(bs={}));function Ry(e){e.preventDefault()}function Lx(e){e.stopPropagation()}var vt;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(vt||(vt={}));const Ob={start:[vt.Space,vt.Enter],cancel:[vt.Esc],end:[vt.Space,vt.Enter,vt.Tab]},Ox=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case vt.Right:return{...n,x:n.x+25};case vt.Left:return{...n,x:n.x-25};case vt.Down:return{...n,y:n.y+25};case vt.Up:return{...n,y:n.y-25}}};class zb{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new Gl(ja(n)),this.windowListeners=new Gl($i(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(bs.Resize,this.handleCancel),this.windowListeners.add(bs.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(bs.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,a=t.node.current;a&&Ax(a),n(Ns)}handleKeyDown(t){if(Tb(t)){const{active:n,context:a,options:o}=this.props,{keyboardCodes:c=Ob,coordinateGetter:d=Ox,scrollBehavior:p="smooth"}=o,{code:m}=t;if(c.end.includes(m)){this.handleEnd(t);return}if(c.cancel.includes(m)){this.handleCancel(t);return}const{collisionRect:f}=a.current,S=f?{x:f.left,y:f.top}:Ns;this.referenceCoordinates||(this.referenceCoordinates=S);const y=d(t,{active:n,context:a.current,currentCoordinates:S});if(y){const b=ou(y,S),x={x:0,y:0},{scrollableAncestors:C}=a.current;for(const k of C){const B=t.code,{isTop:R,isRight:re,isLeft:F,isBottom:J,maxScroll:ce,minScroll:q}=Bb(k),I=Dx(k),ie={x:Math.min(B===vt.Right?I.right-I.width/2:I.right,Math.max(B===vt.Right?I.left:I.left+I.width/2,y.x)),y:Math.min(B===vt.Down?I.bottom-I.height/2:I.bottom,Math.max(B===vt.Down?I.top:I.top+I.height/2,y.y))},de=B===vt.Right&&!re||B===vt.Left&&!F,j=B===vt.Down&&!J||B===vt.Up&&!R;if(de&&ie.x!==y.x){const $=k.scrollLeft+b.x,H=B===vt.Right&&$<=ce.x||B===vt.Left&&$>=q.x;if(H&&!b.y){k.scrollTo({left:$,behavior:p});return}H?x.x=k.scrollLeft-$:x.x=B===vt.Right?k.scrollLeft-ce.x:k.scrollLeft-q.x,x.x&&k.scrollBy({left:-x.x,behavior:p});break}else if(j&&ie.y!==y.y){const $=k.scrollTop+b.y,H=B===vt.Down&&$<=ce.y||B===vt.Up&&$>=q.y;if(H&&!b.x){k.scrollTo({top:$,behavior:p});return}H?x.y=k.scrollTop-$:x.y=B===vt.Down?k.scrollTop-ce.y:k.scrollTop-q.y,x.y&&k.scrollBy({top:-x.y,behavior:p});break}}this.handleMove(t,Aa(ou(y,this.referenceCoordinates),x))}}}handleMove(t,n){const{onMove:a}=this.props;t.preventDefault(),a(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}zb.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:a=Ob,onActivation:o}=t,{active:c}=n;const{code:d}=e.nativeEvent;if(a.start.includes(d)){const p=c.activatorNode.current;return p&&e.target!==p?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function My(e){return!!(e&&"distance"in e)}function Ay(e){return!!(e&&"delay"in e)}class Jp{constructor(t,n,a){var o;a===void 0&&(a=Bx(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:c}=t,{target:d}=c;this.props=t,this.events=n,this.document=ja(d),this.documentListeners=new Gl(this.document),this.listeners=new Gl(a),this.windowListeners=new Gl($i(d)),this.initialCoordinates=(o=Ef(c))!=null?o:Ns,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:a}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(bs.Resize,this.handleCancel),this.windowListeners.add(bs.DragStart,Ry),this.windowListeners.add(bs.VisibilityChange,this.handleCancel),this.windowListeners.add(bs.ContextMenu,Ry),this.documentListeners.add(bs.Keydown,this.handleKeydown),n){if(a!=null&&a({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Ay(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(My(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:a,onPending:o}=this.props;o(a,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(bs.Click,Lx,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(bs.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:a,initialCoordinates:o,props:c}=this,{onMove:d,options:{activationConstraint:p}}=c;if(!o)return;const m=(n=Ef(t))!=null?n:Ns,f=ou(o,m);if(!a&&p){if(My(p)){if(p.tolerance!=null&&Zd(f,p.tolerance))return this.handleCancel();if(Zd(f,p.distance))return this.handleStart()}if(Ay(p)&&Zd(f,p.tolerance))return this.handleCancel();this.handlePending(p,f);return}t.cancelable&&t.preventDefault(),d(m)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===vt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const zx={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class jb extends Jp{constructor(t){const{event:n}=t,a=ja(n.target);super(t,zx,a)}}jb.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:a}=t;return!n.isPrimary||n.button!==0?!1:(a?.({event:n}),!0)}}];const jx={move:{name:"mousemove"},end:{name:"mouseup"}};var Df;(function(e){e[e.RightClick=2]="RightClick"})(Df||(Df={}));class Hb extends Jp{constructor(t){super(t,jx,ja(t.event.target))}}Hb.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:a}=t;return n.button===Df.RightClick?!1:(a?.({event:n}),!0)}}];const Qd={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Ub extends Jp{constructor(t){super(t,Qd)}static setup(){return window.addEventListener(Qd.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Qd.move.name,t)};function t(){}}}Ub.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:a}=t;const{touches:o}=n;return o.length>1?!1:(a?.({event:n}),!0)}}];var Zl;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Zl||(Zl={}));var uu;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(uu||(uu={}));function Hx(e){let{acceleration:t,activator:n=Zl.Pointer,canScroll:a,draggingRect:o,enabled:c,interval:d=5,order:p=uu.TreeOrder,pointerCoordinates:m,scrollableAncestors:f,scrollableAncestorRects:S,delta:y,threshold:b}=e;const x=Px({delta:y,disabled:!c}),[C,k]=JC(),B=g.useRef({x:0,y:0}),R=g.useRef({x:0,y:0}),re=g.useMemo(()=>{switch(n){case Zl.Pointer:return m?{top:m.y,bottom:m.y,left:m.x,right:m.x}:null;case Zl.DraggableRect:return o}},[n,o,m]),F=g.useRef(null),J=g.useCallback(()=>{const q=F.current;if(!q)return;const I=B.current.x*R.current.x,ie=B.current.y*R.current.y;q.scrollBy(I,ie)},[]),ce=g.useMemo(()=>p===uu.TreeOrder?[...f].reverse():f,[p,f]);g.useEffect(()=>{if(!c||!f.length||!re){k();return}for(const q of ce){if(a?.(q)===!1)continue;const I=f.indexOf(q),ie=S[I];if(!ie)continue;const{direction:de,speed:j}=kx(q,ie,re,t,b);for(const $ of["x","y"])x[$][de[$]]||(j[$]=0,de[$]=0);if(j.x>0||j.y>0){k(),F.current=q,C(J,d),B.current=j,R.current=de;return}}B.current={x:0,y:0},R.current={x:0,y:0},k()},[t,J,a,k,c,d,JSON.stringify(re),JSON.stringify(x),C,f,ce,S,JSON.stringify(b)])}const Ux={x:{[ui.Backward]:!1,[ui.Forward]:!1},y:{[ui.Backward]:!1,[ui.Forward]:!1}};function Px(e){let{delta:t,disabled:n}=e;const a=xf(t);return So(o=>{if(n||!a||!o)return Ux;const c={x:Math.sign(t.x-a.x),y:Math.sign(t.y-a.y)};return{x:{[ui.Backward]:o.x[ui.Backward]||c.x===-1,[ui.Forward]:o.x[ui.Forward]||c.x===1},y:{[ui.Backward]:o.y[ui.Backward]||c.y===-1,[ui.Forward]:o.y[ui.Forward]||c.y===1}}},[n,t,a])}function Kx(e,t){const n=t!=null?e.get(t):void 0,a=n?n.node.current:null;return So(o=>{var c;return t==null?null:(c=a??o)!=null?c:null},[a,t])}function Ix(e,t){return g.useMemo(()=>e.reduce((n,a)=>{const{sensor:o}=a,c=o.activators.map(d=>({eventName:d.eventName,handler:t(d.handler,a)}));return[...n,...c]},[]),[e,t])}var no;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(no||(no={}));var Rf;(function(e){e.Optimized="optimized"})(Rf||(Rf={}));const Ny=new Map;function Fx(e,t){let{dragging:n,dependencies:a,config:o}=t;const[c,d]=g.useState(null),{frequency:p,measure:m,strategy:f}=o,S=g.useRef(e),y=B(),b=so(y),x=g.useCallback(function(R){R===void 0&&(R=[]),!b.current&&d(re=>re===null?R:re.concat(R.filter(F=>!re.includes(F))))},[b]),C=g.useRef(null),k=So(R=>{if(y&&!n)return Ny;if(!R||R===Ny||S.current!==e||c!=null){const re=new Map;for(let F of e){if(!F)continue;if(c&&c.length>0&&!c.includes(F.id)&&F.rect.current){re.set(F.id,F.rect.current);continue}const J=F.node.current,ce=J?new Qp(m(J),J):null;F.rect.current=ce,ce&&re.set(F.id,ce)}return re}return R},[e,c,n,y,m]);return g.useEffect(()=>{S.current=e},[e]),g.useEffect(()=>{y||x()},[n,y]),g.useEffect(()=>{c&&c.length>0&&d(null)},[JSON.stringify(c)]),g.useEffect(()=>{y||typeof p!="number"||C.current!==null||(C.current=setTimeout(()=>{x(),C.current=null},p))},[p,y,x,...a]),{droppableRects:k,measureDroppableContainers:x,measuringScheduled:c!=null};function B(){switch(f){case no.Always:return!1;case no.BeforeDragging:return n;default:return!n}}}function Pb(e,t){return So(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function qx(e,t){return Pb(e,t)}function Wx(e){let{callback:t,disabled:n}=e;const a=Gp(t),o=g.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:c}=window;return new c(a)},[a,n]);return g.useEffect(()=>()=>o?.disconnect(),[o]),o}function Du(e){let{callback:t,disabled:n}=e;const a=Gp(t),o=g.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:c}=window;return new c(a)},[n]);return g.useEffect(()=>()=>o?.disconnect(),[o]),o}function Yx(e){return new Qp(bo(e),e)}function By(e,t,n){t===void 0&&(t=Yx);const[a,o]=g.useState(null);function c(){o(m=>{if(!e)return null;if(e.isConnected===!1){var f;return(f=m??n)!=null?f:null}const S=t(e);return JSON.stringify(m)===JSON.stringify(S)?m:S})}const d=Wx({callback(m){if(e)for(const f of m){const{type:S,target:y}=f;if(S==="childList"&&y instanceof HTMLElement&&y.contains(e)){c();break}}}}),p=Du({callback:c});return ar(()=>{c(),e?(p?.observe(e),d?.observe(document.body,{childList:!0,subtree:!0})):(p?.disconnect(),d?.disconnect())},[e]),a}function $x(e){const t=Pb(e);return Db(e,t)}const Ly=[];function Vx(e){const t=g.useRef(e),n=So(a=>e?a&&a!==Ly&&e&&t.current&&e.parentNode===t.current.parentNode?a:Zp(e):Ly,[e]);return g.useEffect(()=>{t.current=e},[e]),n}function Xx(e){const[t,n]=g.useState(null),a=g.useRef(e),o=g.useCallback(c=>{const d=Gd(c.target);d&&n(p=>p?(p.set(d,kf(d)),new Map(p)):null)},[]);return g.useEffect(()=>{const c=a.current;if(e!==c){d(c);const p=e.map(m=>{const f=Gd(m);return f?(f.addEventListener("scroll",o,{passive:!0}),[f,kf(f)]):null}).filter(m=>m!=null);n(p.length?new Map(p):null),a.current=e}return()=>{d(e),d(c)};function d(p){p.forEach(m=>{const f=Gd(m);f?.removeEventListener("scroll",o)})}},[o,e]),g.useMemo(()=>e.length?t?Array.from(t.values()).reduce((c,d)=>Aa(c,d),Ns):Lb(e):Ns,[e,t])}function Oy(e,t){t===void 0&&(t=[]);const n=g.useRef(null);return g.useEffect(()=>{n.current=null},t),g.useEffect(()=>{const a=e!==Ns;a&&!n.current&&(n.current=e),!a&&n.current&&(n.current=null)},[e]),n.current?ou(e,n.current):Ns}function Gx(e){g.useEffect(()=>{if(!Tu)return;const t=e.map(n=>{let{sensor:a}=n;return a.setup==null?void 0:a.setup()});return()=>{for(const n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function Zx(e,t){return g.useMemo(()=>e.reduce((n,a)=>{let{eventName:o,handler:c}=a;return n[o]=d=>{c(d,t)},n},{}),[e,t])}function Kb(e){return g.useMemo(()=>e?Cx(e):null,[e])}const zy=[];function Qx(e,t){t===void 0&&(t=bo);const[n]=e,a=Kb(n?$i(n):null),[o,c]=g.useState(zy);function d(){c(()=>e.length?e.map(m=>Nb(m)?a:new Qp(t(m),m)):zy)}const p=Du({callback:d});return ar(()=>{p?.disconnect(),d(),e.forEach(m=>p?.observe(m))},[e]),o}function Jx(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return yo(t)?t:e}function eE(e){let{measure:t}=e;const[n,a]=g.useState(null),o=g.useCallback(f=>{for(const{target:S}of f)if(yo(S)){a(y=>{const b=t(S);return y?{...y,width:b.width,height:b.height}:b});break}},[t]),c=Du({callback:o}),d=g.useCallback(f=>{const S=Jx(f);c?.disconnect(),S&&c?.observe(S),a(S?t(S):null)},[t,c]),[p,m]=lu(d);return g.useMemo(()=>({nodeRef:p,rect:n,setRef:m}),[n,p,m])}const tE=[{sensor:jb,options:{}},{sensor:zb,options:{}}],iE={current:{}},Gc={draggable:{measure:Dy},droppable:{measure:Dy,strategy:no.WhileDragging,frequency:Rf.Optimized},dragOverlay:{measure:bo}};class Ql extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,a;return(n=(a=this.get(t))==null?void 0:a.node.current)!=null?n:void 0}}const sE={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Ql,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:cu},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Gc,measureDroppableContainers:cu,windowRect:null,measuringScheduled:!1},nE={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:cu,draggableNodes:new Map,over:null,measureDroppableContainers:cu},Ru=g.createContext(nE),rE=g.createContext(sE);function aE(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Ql}}}function lE(e,t){switch(t.type){case ni.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case ni.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case ni.DragEnd:case ni.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ni.RegisterDroppable:{const{element:n}=t,{id:a}=n,o=new Ql(e.droppable.containers);return o.set(a,n),{...e,droppable:{...e.droppable,containers:o}}}case ni.SetDroppableDisabled:{const{id:n,key:a,disabled:o}=t,c=e.droppable.containers.get(n);if(!c||a!==c.key)return e;const d=new Ql(e.droppable.containers);return d.set(n,{...c,disabled:o}),{...e,droppable:{...e.droppable,containers:d}}}case ni.UnregisterDroppable:{const{id:n,key:a}=t,o=e.droppable.containers.get(n);if(!o||a!==o.key)return e;const c=new Ql(e.droppable.containers);return c.delete(n),{...e,droppable:{...e.droppable,containers:c}}}default:return e}}function oE(e){let{disabled:t}=e;const{active:n,activatorEvent:a,draggableNodes:o}=g.useContext(Ru),c=xf(a),d=xf(n?.id);return g.useEffect(()=>{if(!t&&!a&&c&&d!=null){if(!Tb(c)||document.activeElement===c.target)return;const p=o.get(d);if(!p)return;const{activatorNode:m,node:f}=p;if(!m.current&&!f.current)return;requestAnimationFrame(()=>{for(const S of[m.current,f.current]){if(!S)continue;const y=ix(S);if(y){y.focus();break}}})}},[a,t,o,d,c]),null}function cE(e,t){let{transform:n,...a}=t;return e!=null&&e.length?e.reduce((o,c)=>c({transform:o,...a}),n):n}function uE(e){return g.useMemo(()=>({draggable:{...Gc.draggable,...e?.draggable},droppable:{...Gc.droppable,...e?.droppable},dragOverlay:{...Gc.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function hE(e){let{activeNode:t,measure:n,initialRect:a,config:o=!0}=e;const c=g.useRef(!1),{x:d,y:p}=typeof o=="boolean"?{x:o,y:o}:o;ar(()=>{if(!d&&!p||!t){c.current=!1;return}if(c.current||!a)return;const f=t?.node.current;if(!f||f.isConnected===!1)return;const S=n(f),y=Db(S,a);if(d||(y.x=0),p||(y.y=0),c.current=!0,Math.abs(y.x)>0||Math.abs(y.y)>0){const b=Rb(f);b&&b.scrollBy({top:y.y,left:y.x})}},[t,d,p,a,n])}const Ib=g.createContext({...Ns,scaleX:1,scaleY:1});var er;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(er||(er={}));const dE=g.memo(function(t){var n,a,o,c;let{id:d,accessibility:p,autoScroll:m=!0,children:f,sensors:S=tE,collisionDetection:y=_x,measuring:b,modifiers:x,...C}=t;const k=g.useReducer(lE,void 0,aE),[B,R]=k,[re,F]=ox(),[J,ce]=g.useState(er.Uninitialized),q=J===er.Initialized,{draggable:{active:I,nodes:ie,translate:de},droppable:{containers:j}}=B,$=I!=null?ie.get(I):null,H=g.useRef({initial:null,translated:null}),L=g.useMemo(()=>{var ot;return I!=null?{id:I,data:(ot=$?.data)!=null?ot:iE,rect:H}:null},[I,$]),X=g.useRef(null),[G,M]=g.useState(null),[V,Q]=g.useState(null),ve=so(C,Object.values(C)),Se=ku("DndDescribedBy",d),E=g.useMemo(()=>j.getEnabled(),[j]),W=uE(b),{droppableRects:ee,measureDroppableContainers:he,measuringScheduled:ge}=Fx(E,{dragging:q,dependencies:[de.x,de.y],config:W.droppable}),me=Kx(ie,I),Ce=g.useMemo(()=>V?Ef(V):null,[V]),ze=ks(),Ne=qx(me,W.draggable.measure);hE({activeNode:I!=null?ie.get(I):null,config:ze.layoutShiftCompensation,initialRect:Ne,measure:W.draggable.measure});const Re=By(me,W.draggable.measure,Ne),Pe=By(me?me.parentElement:null),Ye=g.useRef({activatorEvent:null,active:null,activeNode:me,collisionRect:null,collisions:null,droppableRects:ee,draggableNodes:ie,draggingNode:null,draggingNodeRect:null,droppableContainers:j,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Be=j.getNodeFor((n=Ye.current.over)==null?void 0:n.id),ae=eE({measure:W.dragOverlay.measure}),Ee=(a=ae.nodeRef.current)!=null?a:me,xe=q?(o=ae.rect)!=null?o:Re:null,Ke=!!(ae.nodeRef.current&&ae.rect),Xe=$x(Ke?null:Re),gt=Kb(Ee?$i(Ee):null),yt=Vx(q?Be??me:null),mi=Qx(yt),te=cE(x,{transform:{x:de.x-Xe.x,y:de.y-Xe.y,scaleX:1,scaleY:1},activatorEvent:V,active:L,activeNodeRect:Re,containerNodeRect:Pe,draggingNodeRect:xe,over:Ye.current.over,overlayNodeRect:ae.rect,scrollableAncestors:yt,scrollableAncestorRects:mi,windowRect:gt}),je=Ce?Aa(Ce,de):null,He=Xx(yt),_i=Oy(He),Vi=Oy(He,[Re]),ai=Aa(te,_i),kt=xe?yx(xe,te):null,ji=L&&kt?y({active:L,collisionRect:kt,droppableRects:ee,droppableContainers:E,pointerCoordinates:je}):null,Ti=px(ji,"id"),[Nt,$s]=g.useState(null),Hi=Ke?te:Aa(te,Vi),qt=vx(Hi,(c=Nt?.rect)!=null?c:null,Re),Jt=g.useRef(null),Dt=g.useCallback((ot,St)=>{let{sensor:Rt,options:li}=St;if(X.current==null)return;const ei=ie.get(X.current);if(!ei)return;const Bt=ot.nativeEvent,nt=new Rt({active:X.current,activeNode:ei,event:Bt,options:li,context:Ye,onAbort(bt){if(!ie.get(bt))return;const{onDragAbort:ct}=ve.current,vi={id:bt};ct?.(vi),re({type:"onDragAbort",event:vi})},onPending(bt,Ge,ct,vi){if(!ie.get(bt))return;const{onDragPending:Ni}=ve.current,ki={id:bt,constraint:Ge,initialCoordinates:ct,offset:vi};Ni?.(ki),re({type:"onDragPending",event:ki})},onStart(bt){const Ge=X.current;if(Ge==null)return;const ct=ie.get(Ge);if(!ct)return;const{onDragStart:vi}=ve.current,Ai={activatorEvent:Bt,active:{id:Ge,data:ct.data,rect:H}};Il.unstable_batchedUpdates(()=>{vi?.(Ai),ce(er.Initializing),R({type:ni.DragStart,initialCoordinates:bt,active:Ge}),re({type:"onDragStart",event:Ai}),M(Jt.current),Q(Bt)})},onMove(bt){R({type:ni.DragMove,coordinates:bt})},onEnd:Wt(ni.DragEnd),onCancel:Wt(ni.DragCancel)});Jt.current=nt;function Wt(bt){return async function(){const{active:ct,collisions:vi,over:Ai,scrollAdjustedTranslate:Ni}=Ye.current;let ki=null;if(ct&&Ni){const{cancelDrop:cs}=ve.current;ki={activatorEvent:Bt,active:ct,collisions:vi,delta:Ni,over:Ai},bt===ni.DragEnd&&typeof cs=="function"&&await Promise.resolve(cs(ki))&&(bt=ni.DragCancel)}X.current=null,Il.unstable_batchedUpdates(()=>{R({type:bt}),ce(er.Uninitialized),$s(null),M(null),Q(null),Jt.current=null;const cs=bt===ni.DragEnd?"onDragEnd":"onDragCancel";if(ki){const gi=ve.current[cs];gi?.(ki),re({type:cs,event:ki})}})}}},[ie]),Cn=g.useCallback((ot,St)=>(Rt,li)=>{const ei=Rt.nativeEvent,Bt=ie.get(li);if(X.current!==null||!Bt||ei.dndKit||ei.defaultPrevented)return;const nt={active:Bt};ot(Rt,St.options,nt)===!0&&(ei.dndKit={capturedBy:St.sensor},X.current=li,Dt(Rt,St))},[ie,Dt]),Bs=Ix(S,Cn);Gx(S),ar(()=>{Re&&J===er.Initializing&&ce(er.Initialized)},[Re,J]),g.useEffect(()=>{const{onDragMove:ot}=ve.current,{active:St,activatorEvent:Rt,collisions:li,over:ei}=Ye.current;if(!St||!Rt)return;const Bt={active:St,activatorEvent:Rt,collisions:li,delta:{x:ai.x,y:ai.y},over:ei};Il.unstable_batchedUpdates(()=>{ot?.(Bt),re({type:"onDragMove",event:Bt})})},[ai.x,ai.y]),g.useEffect(()=>{const{active:ot,activatorEvent:St,collisions:Rt,droppableContainers:li,scrollAdjustedTranslate:ei}=Ye.current;if(!ot||X.current==null||!St||!ei)return;const{onDragOver:Bt}=ve.current,nt=li.get(Ti),Wt=nt&&nt.rect.current?{id:nt.id,rect:nt.rect.current,data:nt.data,disabled:nt.disabled}:null,bt={active:ot,activatorEvent:St,collisions:Rt,delta:{x:ei.x,y:ei.y},over:Wt};Il.unstable_batchedUpdates(()=>{$s(Wt),Bt?.(bt),re({type:"onDragOver",event:bt})})},[Ti]),ar(()=>{Ye.current={activatorEvent:V,active:L,activeNode:me,collisionRect:kt,collisions:ji,droppableRects:ee,draggableNodes:ie,draggingNode:Ee,draggingNodeRect:xe,droppableContainers:j,over:Nt,scrollableAncestors:yt,scrollAdjustedTranslate:ai},H.current={initial:xe,translated:kt}},[L,me,ji,kt,ie,Ee,xe,ee,j,Nt,yt,ai]),Hx({...ze,delta:de,draggingRect:kt,pointerCoordinates:je,scrollableAncestors:yt,scrollableAncestorRects:mi});const Vs=g.useMemo(()=>({active:L,activeNode:me,activeNodeRect:Re,activatorEvent:V,collisions:ji,containerNodeRect:Pe,dragOverlay:ae,draggableNodes:ie,droppableContainers:j,droppableRects:ee,over:Nt,measureDroppableContainers:he,scrollableAncestors:yt,scrollableAncestorRects:mi,measuringConfiguration:W,measuringScheduled:ge,windowRect:gt}),[L,me,Re,V,ji,Pe,ae,ie,j,ee,Nt,he,yt,mi,W,ge,gt]),Ts=g.useMemo(()=>({activatorEvent:V,activators:Bs,active:L,activeNodeRect:Re,ariaDescribedById:{draggable:Se},dispatch:R,draggableNodes:ie,over:Nt,measureDroppableContainers:he}),[V,Bs,L,Re,R,Se,ie,Nt,he]);return xi.createElement(kb.Provider,{value:F},xi.createElement(Ru.Provider,{value:Ts},xi.createElement(rE.Provider,{value:Vs},xi.createElement(Ib.Provider,{value:qt},f)),xi.createElement(oE,{disabled:p?.restoreFocus===!1})),xi.createElement(hx,{...p,hiddenTextDescribedById:Se}));function ks(){const ot=G?.autoScrollEnabled===!1,St=typeof m=="object"?m.enabled===!1:m===!1,Rt=q&&!ot&&!St;return typeof m=="object"?{...m,enabled:Rt}:{enabled:Rt}}}),fE=g.createContext(null),jy="button",pE="Draggable";function Fb(e){let{id:t,data:n,disabled:a=!1,attributes:o}=e;const c=ku(pE),{activators:d,activatorEvent:p,active:m,activeNodeRect:f,ariaDescribedById:S,draggableNodes:y,over:b}=g.useContext(Ru),{role:x=jy,roleDescription:C="draggable",tabIndex:k=0}=o??{},B=m?.id===t,R=g.useContext(B?Ib:fE),[re,F]=lu(),[J,ce]=lu(),q=Zx(d,t),I=so(n);ar(()=>(y.set(t,{id:t,key:c,node:re,activatorNode:J,data:I}),()=>{const de=y.get(t);de&&de.key===c&&y.delete(t)}),[y,t]);const ie=g.useMemo(()=>({role:x,tabIndex:k,"aria-disabled":a,"aria-pressed":B&&x===jy?!0:void 0,"aria-roledescription":C,"aria-describedby":S.draggable}),[a,x,k,B,C,S.draggable]);return{active:m,activatorEvent:p,activeNodeRect:f,attributes:ie,isDragging:B,listeners:a?void 0:q,node:re,over:b,setNodeRef:F,setActivatorNodeRef:ce,transform:R}}const mE="Droppable",_E={timeout:25};function qb(e){let{data:t,disabled:n=!1,id:a,resizeObserverConfig:o}=e;const c=ku(mE),{active:d,dispatch:p,over:m,measureDroppableContainers:f}=g.useContext(Ru),S=g.useRef({disabled:n}),y=g.useRef(!1),b=g.useRef(null),x=g.useRef(null),{disabled:C,updateMeasurementsFor:k,timeout:B}={..._E,...o},R=so(k??a),re=g.useCallback(()=>{if(!y.current){y.current=!0;return}x.current!=null&&clearTimeout(x.current),x.current=setTimeout(()=>{f(Array.isArray(R.current)?R.current:[R.current]),x.current=null},B)},[B]),F=Du({callback:re,disabled:C||!d}),J=g.useCallback((ie,de)=>{F&&(de&&(F.unobserve(de),y.current=!1),ie&&F.observe(ie))},[F]),[ce,q]=lu(J),I=so(t);return g.useEffect(()=>{!F||!ce.current||(F.disconnect(),y.current=!1,F.observe(ce.current))},[ce,F]),g.useEffect(()=>(p({type:ni.RegisterDroppable,element:{id:a,key:c,disabled:n,node:ce,rect:b,data:I}}),()=>p({type:ni.UnregisterDroppable,key:c,id:a})),[a]),g.useEffect(()=>{n!==S.current.disabled&&(p({type:ni.SetDroppableDisabled,id:a,key:c,disabled:n}),S.current.disabled=n)},[a,c,n,p]),{active:d,rect:b,isOver:m?.id===a,node:ce,over:m,setNodeRef:q}}const vE=128,gE=512,yE=64,SE=4096;function Wb(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.activeWorkspaceId!="string"&&t.activeWorkspaceId!==null||!Array.isArray(t.workspaces)||t.workspaces.length>vE)return null;const n=t.workspaces.map(bE);return n.some(a=>a===null)?null:{activeWorkspaceId:t.activeWorkspaceId,workspaces:n}}function bE(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.id!="string"||typeof t.title!="string"||typeof t.activeTabId!="string"&&t.activeTabId!==null||!Array.isArray(t.tabs)||t.tabs.length>gE)return null;const n=t.tabs.map(wE);return n.some(a=>a===null)?null:{id:t.id,title:t.title,activeTabId:t.activeTabId,tabs:n}}function wE(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.id!="string"||typeof t.title!="string"||typeof t.activeTerminalId!="string")return null;const n=CE(t.root);return n?{id:t.id,title:t.title,activeTerminalId:t.activeTerminalId,root:n}:null}function CE(e){if(!e||typeof e!="object")return null;let t=0;return Mf(e,1,()=>(t+=1,t<=SE))}function Mf(e,t,n){if(!e||typeof e!="object"||t>yE||!n())return null;const a=e;if(a.type==="pane")return typeof a.terminalId=="string"?{type:"pane",terminalId:a.terminalId}:null;if(a.type!=="split"||a.direction!=="horizontal"&&a.direction!=="vertical")return null;const o=Mf(a.first,t+1,n),c=Mf(a.second,t+1,n);return!o||!c?null:{type:"split",direction:a.direction,ratio:xE(a.ratio),first:o,second:c}}function xE(e){return typeof e=="number"&&Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}const Yb=[{id:"builtin-character-2260",filename:"character-2260.mp4",contentType:"video/mp4",size:123288,createdAt:"2026-05-26T00:00:00.000Z",url:"/assets/notifications/character-2260.mp4"},{id:"builtin-character-2272",filename:"character-2272.mp4",contentType:"video/mp4",size:55873,createdAt:"2026-05-26T00:00:00.000Z",url:"/assets/notifications/character-2272.mp4"},{id:"builtin-character-2258",filename:"character-2258.mp4",contentType:"video/mp4",size:112612,createdAt:"2026-05-26T00:00:00.000Z",url:"/assets/notifications/character-2258.mp4"}];function Hy(e){return e===void 0?"unknown":e==="error"?"offline":"ok"}function Uy(e){const t=e.trim();return t?t.charAt(0).toUpperCase():"?"}const Py="Local",EE=3e4;function Jd(e){return e===void 0?"":e==="error"?"offline":[`CPU ${Cs(e.cpuPercent)} ${em(e)}`,`MEM ${Cs(e.memoryPercent)} ${Sn(e.memoryUsedBytes,e.memoryTotalBytes)}`,`DISK ${Cs(e.diskPercent)} ${Sn(e.diskUsedBytes,e.diskTotalBytes)}`,`SWAP ${Cs(e.swapPercent)} ${Sn(e.swapUsedBytes,e.swapTotalBytes)}`].join(" · ")}function TE(e){if(!(e===void 0||e==="error"))return[`CPU ${Cs(e.cpuPercent)} (${em(e)})`,`RAM ${Cs(e.memoryPercent)} (${Sn(e.memoryUsedBytes,e.memoryTotalBytes)})`,`Disk ${Cs(e.diskPercent)} (${Sn(e.diskUsedBytes,e.diskTotalBytes)})`,`Swap ${Cs(e.swapPercent)} (${Sn(e.swapUsedBytes,e.swapTotalBytes)})`].join(" · ")}function Cs(e){return typeof e=="number"&&Number.isFinite(e)?`${Math.round(e)}%`:"–"}function em(e){const t=Number.isFinite(e.cores)&&e.cores>0?e.cores:null;return e.cpuPercent===null||e.cpuPercent===void 0||!Number.isFinite(e.cpuPercent)||t===null?`–/${t??"–"} cores`:`${Af(e.cpuPercent/100*t)}/${t} cores`}function Sn(e,t){return!Ky(e)||!Ky(t)?"–/–":kE(e,t)}function kE(e,t){const n=t>=1073741824?"GB":t>=1048576?"MB":"KB",a=n==="GB"?1024**3:n==="MB"?1024**2:1024;return`${Af(e/a)}/${Af(t/a)} ${n}`}function Af(e){return e>=10||Number.isInteger(e)?e.toFixed(0):e.toFixed(1)}function Ky(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function DE(e){return[{label:"CPU",percent:Cs(e.cpuPercent),detail:em(e)},{label:"MEM",percent:Cs(e.memoryPercent),detail:Sn(e.memoryUsedBytes,e.memoryTotalBytes)},{label:"DISK",percent:Cs(e.diskPercent),detail:Sn(e.diskUsedBytes,e.diskTotalBytes)},{label:"SWAP",percent:Cs(e.swapPercent),detail:Sn(e.swapUsedBytes,e.swapTotalBytes)}]}function Iy({entry:e}){return e==="error"?_.jsx("span",{className:"server-list-stats server-list-stats--offline",children:"offline"}):e===void 0?_.jsx("span",{className:"server-list-stats server-list-stats-grid","aria-hidden":"true",children:["CPU","MEM","DISK","SWAP"].map(t=>_.jsxs("span",{className:"server-list-stat-cell",children:[_.jsx("span",{className:"server-list-stat-label",children:t}),_.jsx("span",{className:"server-list-stat-value",children:"–"}),_.jsx("span",{className:"server-list-stat-detail",children:"–"})]},t))}):_.jsx("span",{className:"server-list-stats server-list-stats-grid",title:TE(e),children:DE(e).map(t=>_.jsxs("span",{className:"server-list-stat-cell",children:[_.jsx("span",{className:"server-list-stat-label",children:t.label}),_.jsx("span",{className:"server-list-stat-value",children:t.percent}),_.jsx("span",{className:"server-list-stat-detail",children:t.detail})]},t.label))})}function ef({api:e,activeAgentId:t,onSelectServer:n,onSessionInvalid:a,refreshToken:o=0,compact:c=!1}){const[d,p]=g.useState([]),[m,f]=g.useState(null),[S,y]=g.useState(null),[b,x]=g.useState(""),C=g.useRef(null),[k,B]=g.useState({});g.useEffect(()=>{let q=!1;return e.listAgents().then(I=>{q||p(I.agents)}).catch(()=>{}),e.getMainInfo().then(I=>{q||f(I.name)}).catch(()=>{}),()=>{q=!0}},[e,o]),g.useEffect(()=>{S&&(C.current?.focus(),C.current?.select())},[S]),g.useEffect(()=>{let q=!1;async function I(){let de=!1;const j=[{key:"__main__",load:()=>e.getMainStats()},...d.map(H=>({key:H.id,load:()=>e.getAgentStats(H.id)}))],$=await Promise.all(j.map(async H=>{try{return[H.key,await H.load()]}catch(L){return L instanceof yn&&L.status===401?(de=!0,[H.key,"error"]):[H.key,"error"]}}));if(!q){if(de){a?.();return}B(H=>{const L={};for(const[G,M]of $)L[G]=M;const X=new Set(["__main__",...d.map(G=>G.id)]);for(const G of Object.keys(H))!X.has(G)||G in L||(L[G]=H[G]);return L})}}I();const ie=window.setInterval(()=>{I()},EE);return()=>{q=!0,window.clearInterval(ie)}},[e,d,a]);function R(q){q==="main"?(x(m??""),y({kind:"main"})):(x(q.name),y({kind:"agent",id:q.id}))}async function re(){if(!S)return;const q=b.trim(),I=S;if(y(null),I.kind==="main"){const ie=q||"";try{const de=await e.renameMain(ie);f(de.name)}catch{}}else{if(!q)return;const ie=d.find(de=>de.id===I.id)?.name;p(de=>de.map(j=>j.id===I.id?{...j,name:q}:j));try{await e.renameAgent(I.id,q)}catch{ie!==void 0&&p(de=>de.map(j=>j.id===I.id?{...j,name:ie}:j))}}}function F(){y(null)}const J=m?.trim()||Py,ce=S?.kind==="main";return c?_.jsxs("div",{className:"server-list server-list--compact",children:[_.jsxs("button",{type:"button",className:`server-list-chip${t===null?" server-list-chip--active":""}`,onClick:()=>n(null),"aria-label":J,title:`${J}${Jd(k.__main__)?` — ${Jd(k.__main__)}`:""}`,children:[_.jsx("span",{className:"server-list-chip-initial",children:Uy(J)}),_.jsx("span",{className:"server-list-chip-pip","data-status":Hy(k.__main__)})]}),d.map(q=>{const I=k[q.id],ie=Jd(I);return _.jsxs("button",{type:"button",className:`server-list-chip${t===q.id?" server-list-chip--active":""}`,onClick:()=>n(q.id),"aria-label":q.name,title:`${q.name}${ie?` — ${ie}`:""}`,children:[_.jsx("span",{className:"server-list-chip-initial",children:Uy(q.name)}),_.jsx("span",{className:"server-list-chip-pip","data-status":Hy(I)})]},q.id)})]}):_.jsxs("div",{className:"server-list",children:[_.jsx("div",{className:"server-list-row",children:ce?_.jsx("form",{className:"server-list-editor",onSubmit:q=>{q.preventDefault(),re()},children:_.jsx("input",{ref:C,"aria-label":"Rename main server",value:b,onChange:q=>x(q.target.value),onBlur:()=>{re()},onKeyDown:q=>{q.key==="Escape"&&(q.preventDefault(),F())},placeholder:Py})}):_.jsxs("button",{type:"button",className:`server-list-item${t===null?" server-list-item--active":""}`,onClick:()=>n(null),onDoubleClick:q=>{q.preventDefault(),R("main")},title:"Double-click to rename",children:[_.jsxs("span",{className:"server-list-item-header",children:[_.jsx("span",{className:"server-list-dot"}),_.jsx("span",{className:"server-list-name",children:J})]}),_.jsx(Iy,{entry:k.__main__})]})}),d.map(q=>{const I=S?.kind==="agent"&&S.id===q.id;return _.jsx("div",{className:"server-list-row",children:I?_.jsx("form",{className:"server-list-editor",onSubmit:ie=>{ie.preventDefault(),re()},children:_.jsx("input",{ref:C,"aria-label":`Rename ${q.name}`,value:b,onChange:ie=>x(ie.target.value),onBlur:()=>{re()},onKeyDown:ie=>{ie.key==="Escape"&&(ie.preventDefault(),F())}})}):_.jsxs("button",{type:"button",className:`server-list-item${t===q.id?" server-list-item--active":""}`,onClick:()=>n(q.id),onDoubleClick:ie=>{ie.preventDefault(),R({id:q.id,name:q.name})},title:"Double-click to rename",children:[_.jsxs("span",{className:"server-list-item-header",children:[_.jsx("span",{className:"server-list-dot"}),_.jsx("span",{className:"server-list-name",title:q.url,children:q.name})]}),_.jsx(Iy,{entry:k[q.id]})]})},q.id)})]})}function RE({api:e}){const[t,n]=g.useState([]),[a,o]=g.useState([]),[c,d]=g.useState(!1),[p,m]=g.useState(null),[f,S]=g.useState(""),[y,b]=g.useState("");async function x(){try{const[R,re,F]=await Promise.all([e.listDevices(),e.listNetworks(),e.getSession()]);n(R.devices),o(re.networks),d(F.totpEnabled),m(null)}catch(R){m(R instanceof Error?R.message:"Failed to load")}}g.useEffect(()=>{x()},[]);async function C(R){await e.revokeDevice(R),await x()}async function k(R){await e.removeNetwork(R),await x()}async function B(R){R.preventDefault(),m(null);try{await e.addNetwork({value:f.trim(),label:y.trim()}),S(""),b(""),await x()}catch(re){m(re instanceof Error?re.message:"Failed to add network")}}return _.jsxs(_.Fragment,{children:[p?_.jsx("p",{className:"form-error",children:p}):null,_.jsxs("section",{className:"security-section",children:[_.jsx("h3",{children:"Trusted devices"}),_.jsx("p",{className:"muted",children:"Devices that can re-authenticate with a 2FA code only (no password) for 30 days."}),t.length===0?_.jsx("p",{className:"muted",children:"No trusted devices."}):_.jsx("ul",{className:"security-list",children:t.map(R=>_.jsxs("li",{children:[_.jsxs("div",{children:[_.jsxs("span",{className:"security-item-label",children:[R.label,R.current?_.jsx("span",{className:"security-badge",children:"this device"}):null]}),_.jsxs("span",{className:"security-item-meta",children:["last seen ",new Date(R.lastSeenAt).toLocaleString()]})]}),_.jsx("button",{type:"button",className:"security-remove",onClick:()=>{C(R.id)},children:"revoke"})]},R.id))})]}),_.jsxs("section",{className:"security-section",children:[_.jsx("h3",{children:"Trusted networks"}),_.jsx("p",{className:"muted",children:"Sessions from these IPs/ranges skip the 2FA re-auth prompt."}),a.length===0?_.jsx("p",{className:"muted",children:"No trusted networks."}):_.jsx("ul",{className:"security-list",children:a.map(R=>_.jsxs("li",{children:[_.jsxs("div",{children:[_.jsx("span",{className:"security-item-label",children:R.value}),R.label!==R.value?_.jsx("span",{className:"security-item-meta",children:R.label}):null]}),_.jsx("button",{type:"button",className:"security-remove",onClick:()=>{k(R.id)},children:"remove"})]},R.id))}),_.jsxs("form",{className:"security-add-form",onSubmit:B,children:[_.jsx("input",{type:"text",placeholder:"IP or CIDR (e.g. 203.0.113.4 or 192.168.0.0/24)",value:f,onChange:R=>S(R.currentTarget.value),required:!0}),_.jsx("input",{type:"text",placeholder:"Label (optional)",value:y,onChange:R=>b(R.currentTarget.value)}),_.jsx("button",{type:"submit",disabled:!f.trim(),children:"Add"})]})]}),c?_.jsxs("section",{className:"security-section",children:[_.jsx("h3",{children:"Two-factor authentication"}),_.jsx("p",{className:"muted",children:"2FA is enabled. Disabling it removes the requirement; you will be asked to set it up again on next login."}),_.jsx("button",{type:"button",className:"security-remove",onClick:async()=>{await e.disableTotp(),await x()},children:"Disable 2FA"})]}):null]})}const $b="nterminal.notifications.completionEnabled",tm="nterminal.notifications.completionToastEnabled",im="nterminal.notifications.completionToastDurationSeconds",sm="nterminal.notifications.completionToastPersistent",Nf="nterminal:completion-toast-display",Jl=6.5,Bf=2,Lf=60;function Mu(){return typeof window<"u"&&"Notification"in window}function Vb(){try{return window.localStorage.getItem($b)==="true"}catch{return!1}}function Fy(e){try{window.localStorage.setItem($b,e?"true":"false")}catch{}}function zr(){return{enabled:BE(),durationSeconds:NE(),persistUntilDismissed:LE()}}function ME(e){if(typeof window<"u"){try{window.localStorage.setItem(tm,e?"true":"false")}catch{}rm()}return zr()}function qy(e){const t=Gb(e);if(typeof window<"u"){try{window.localStorage.setItem(im,String(t))}catch{}rm()}return zr()}function AE(e){if(typeof window<"u"){try{window.localStorage.setItem(sm,e?"true":"false")}catch{}rm()}return zr()}function Xb(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===tm||n.key===im||n.key===sm)&&e()};return window.addEventListener(Nf,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Nf,e),window.removeEventListener("storage",t)}}function nm(){return Mu()?window.Notification.permission:"unsupported"}function NE(){if(typeof window>"u")return Jl;try{const e=window.localStorage.getItem(im);return e===null?Jl:Gb(Number(e))}catch{return Jl}}function BE(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(tm)!=="false"}catch{return!0}}function LE(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(sm)==="true"}catch{return!1}}function Gb(e){if(!Number.isFinite(e))return Jl;const t=Math.round(e*2)/2;return Math.max(Bf,Math.min(Lf,t))}function rm(){typeof window<"u"&&window.dispatchEvent(new CustomEvent(Nf))}async function OE(){if(!Mu())return"unsupported";try{return await window.Notification.requestPermission()}catch{return nm()}}function zE(e){if(!Mu()||nm()!=="granted"||!Vb()||typeof document<"u"&&document.visibilityState==="visible")return;const t=e.commandName?`${e.commandName} finished`:"Command finished";try{new Notification(`NTerminal · ${e.tabTitle}`,{body:t,tag:e.terminalId,icon:"/icons/app-icon-384.png",silent:!0})}catch{}}const jE=1500,am="nterminal.terminal.fontSize",lm="nterminal.terminal.fontFamily",Of="nterminal:terminal-font-size",zf="nterminal:terminal-font-family",jf=11,Hf=20,Lr=14,hu=[{id:"meslo",label:"MesloLGS NF",cssFamily:['"MesloLGS NF"','"MesloLGS Nerd Font Mono"','"MesloLGSNerdFontMono"','"JetBrainsMono Nerd Font"','"Hack Nerd Font"','"FiraCode Nerd Font"','"SF Mono"',"Menlo","Monaco","Consolas",'"Liberation Mono"','"Symbols Nerd Font Mono"','"Apple Symbols"','"Apple Color Emoji"',"monospace"].join(", "),webFontFamilies:['"MesloLGS NF"']},{id:"jetbrains",label:"JetBrains Mono",cssFamily:['"JetBrainsMono Nerd Font"','"JetBrains Mono"','"Hack Nerd Font"','"FiraCode Nerd Font"','"SF Mono"',"Menlo","Monaco","Consolas",'"Liberation Mono"','"Symbols Nerd Font Mono"','"Apple Symbols"','"Apple Color Emoji"',"monospace"].join(", "),webFontFamilies:[]},{id:"system",label:"System mono",cssFamily:['"SF Mono"',"Menlo","Monaco","Consolas",'"Liberation Mono"','"Symbols Nerd Font Mono"','"Apple Symbols"','"Apple Color Emoji"',"monospace"].join(", "),webFontFamilies:[]}],Na="meslo";Uf(Na);async function tf(e=Lr,t=Na){if(typeof document>"u"||!document.fonts)return;const n=Jb(t).webFontFamilies;if(n.length===0)return;const a=Promise.all(n.map(o=>document.fonts.load(`${e}px ${o}`))).then(()=>{}).catch(()=>{});await Promise.race([a,new Promise(o=>{globalThis.setTimeout(o,jE)})])}function Zb(e){const t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return Lr;const n=Math.round(t);return Math.max(jf,Math.min(Hf,n))}function Qb(e){return hu.some(t=>t.id===e)?e:Na}function Uf(e){return Jb(e).cssFamily}function Jb(e){return hu.find(t=>t.id===e)??hu[0]}function Pf(){if(typeof window>"u")return Lr;try{const e=window.localStorage.getItem(am);return e?Zb(e):Lr}catch{return Lr}}function Kf(){if(typeof window>"u")return Na;try{return Qb(window.localStorage.getItem(lm))}catch{return Na}}function Hc(e){const t=Zb(e);if(typeof window>"u")return t;try{window.localStorage.setItem(am,String(t))}catch{}return window.dispatchEvent(new CustomEvent(Of,{detail:t})),t}function HE(e){const t=Qb(e);if(typeof window>"u")return t;try{window.localStorage.setItem(lm,t)}catch{}return window.dispatchEvent(new CustomEvent(zf,{detail:t})),t}function e0(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===am&&e()};return window.addEventListener(Of,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Of,e),window.removeEventListener("storage",t)}}function t0(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===lm&&e()};return window.addEventListener(zf,e),window.addEventListener("storage",t),()=>{window.removeEventListener(zf,e),window.removeEventListener("storage",t)}}const om="nterminal.terminal.showScrollProgress",If="nterminal:terminal-scroll-progress";function Ff(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(om)!=="false"}catch{return!0}}function UE(e){if(typeof window<"u"){try{window.localStorage.setItem(om,e?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(If,{detail:e}))}return e}function i0(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===om&&e()};return window.addEventListener(If,e),window.addEventListener("storage",t),()=>{window.removeEventListener(If,e),window.removeEventListener("storage",t)}}const cm="nterminal.shortcuts.workspace.v1",qf="nterminal:workspace-shortcuts",ro=[{id:"server.previous",label:"Previous server",group:"Servers"},{id:"server.next",label:"Next server",group:"Servers"},{id:"tab.previous",label:"Previous tab",group:"Tabs"},{id:"tab.next",label:"Next tab",group:"Tabs"},{id:"tab.index",label:"Select tab 1-9",group:"Tabs",indexed:!0},{id:"pane.index",label:"Select pane 1-9",group:"Panes",indexed:!0},{id:"split.right",label:"Split right",group:"Panes"},{id:"split.down",label:"Split down",group:"Panes"}],um={"server.previous":Mi("ArrowUp",{ctrlKey:!0}),"server.next":Mi("ArrowDown",{ctrlKey:!0}),"tab.previous":Mi("ArrowLeft",{ctrlKey:!0}),"tab.next":Mi("ArrowRight",{ctrlKey:!0}),"tab.index":Mi("Digit",{ctrlKey:!0,altKey:!0}),"pane.index":Mi("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.right":Mi("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":Mi("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0})},PE={"server.previous":Mi("BracketLeft",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"server.next":Mi("BracketRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"tab.previous":Mi("BracketLeft",{ctrlKey:!0,altKey:!0}),"tab.next":Mi("BracketRight",{ctrlKey:!0,altKey:!0}),"tab.index":Mi("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"pane.index":Mi("Digit",{ctrlKey:!0,altKey:!0}),"split.right":Mi("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":Mi("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0})};function jr(){const e=a0(um);if(typeof window>"u")return e;try{const t=window.localStorage.getItem(cm);if(!t)return e;const n=JSON.parse(t);for(const a of ro){const o=n[a.id];if(XE(o)){const c=l0(o,a);VE(c,PE[a.id])||(e[a.id]=c)}}}catch{return e}return e}function Wy(){return JSON.stringify(jr())}function KE(e,t){const n=jr(),a=ro.find(o=>o.id===e);return a&&(n[e]=l0(t,a),hm(n)),n}function IE(e){const t=jr();return t[e]={...um[e]},hm(t),t}function FE(){const e=a0(um);return hm(e),e}function s0(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===cm&&e()};return window.addEventListener(qf,e),window.addEventListener("storage",t),()=>{window.removeEventListener(qf,e),window.removeEventListener("storage",t)}}function qE(e,t){const n=c0(e);return!n||ZE(n)||t.indexed&&o0(e)===null?null:{ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,code:t.indexed?"Digit":n}}function WE(e){const t=jr();for(const n of ro){const a=t[n.id];if(!(!a||!GE(e,a))){if(n.indexed){if(a.code!=="Digit")continue;const o=o0(e);if(o!==null)return{id:n.id,index:o};continue}if(c0(e)===a.code)return{id:n.id,index:null}}}return null}function n0(e){return r0(jr()[e])}function r0(e){const t=[];return e.ctrlKey&&t.push("Ctrl"),e.altKey&&t.push("Alt"),e.shiftKey&&t.push("Shift"),e.metaKey&&t.push("Meta"),t.push(QE(e.code)),t.join("+")}const YE=()=>n0("split.right"),$E=()=>n0("split.down");function Mi(e,t){return{ctrlKey:t.ctrlKey??!1,altKey:t.altKey??!1,shiftKey:t.shiftKey??!1,metaKey:t.metaKey??!1,code:e}}function a0(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{...n}]))}function VE(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey&&e.code===t.code}function hm(e){if(!(typeof window>"u")){try{window.localStorage.setItem(cm,JSON.stringify(e))}catch{}window.dispatchEvent(new CustomEvent(qf))}}function l0(e,t){return{ctrlKey:!!e.ctrlKey,altKey:!!e.altKey,shiftKey:!!e.shiftKey,metaKey:!!e.metaKey,code:t.indexed?"Digit":e.code}}function XE(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.ctrlKey=="boolean"&&typeof t.altKey=="boolean"&&typeof t.shiftKey=="boolean"&&typeof t.metaKey=="boolean"&&typeof t.code=="string"&&t.code.length>0}function GE(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey}function o0(e){const t=/^Digit([1-9])$/.exec(e.code);return t?.[1]?Number(t[1]):/^[1-9]$/.test(e.key)?Number(e.key):null}function c0(e){if(e.code)return e.code;if(/^[a-z]$/i.test(e.key))return`Key${e.key.toUpperCase()}`;if(/^[0-9]$/.test(e.key))return`Digit${e.key}`;switch(e.key){case"[":case"{":return"BracketLeft";case"]":case"}":return"BracketRight";case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":case"Tab":case"Enter":case"Escape":case"Space":return e.key==="Space"?"Space":e.key;default:return null}}function ZE(e){return e==="ControlLeft"||e==="ControlRight"||e==="AltLeft"||e==="AltRight"||e==="ShiftLeft"||e==="ShiftRight"||e==="MetaLeft"||e==="MetaRight"}function QE(e){if(e==="Digit")return"1-9";const t=/^Digit([0-9])$/.exec(e);if(t?.[1])return t[1];const n=/^Key([A-Z])$/.exec(e);if(n?.[1])return n[1];switch(e){case"BracketLeft":return"[";case"BracketRight":return"]";case"ArrowLeft":return"Left";case"ArrowRight":return"Right";case"ArrowUp":return"Up";case"ArrowDown":return"Down";case"Space":return"Space";default:return e.replace(/^(Numpad|Digit|Key)/,"")}}const dm="nterminal.theme.accent",Wf="nterminal:theme-accent",ao=[{id:"aqua",label:"Aqua Teal",accent:"#5EEAD4",soft:"rgba(94, 234, 212, 0.10)",glow:"rgba(94, 234, 212, 0.55)",xtermSelection:"#1f3f45"},{id:"signal-red",label:"Signal Red",accent:"#FF2A3D",soft:"rgba(255, 42, 61, 0.12)",glow:"rgba(255, 42, 61, 0.52)",xtermSelection:"#4a1b22"}],du="aqua";function wo(e){return ao.some(t=>t.id===e)?e:du}function fm(e){return ao.find(t=>t.id===e)??ao[0]}function lr(){if(typeof window>"u")return du;try{return wo(window.localStorage.getItem(dm))}catch{return du}}function JE(e){const t=wo(e);if(typeof window<"u"){try{window.localStorage.setItem(dm,t)}catch{}pm(t),window.dispatchEvent(new CustomEvent(Wf,{detail:t}))}return t}function pm(e=lr()){if(typeof document>"u")return;const t=fm(wo(e)),n=document.documentElement;n.style.setProperty("--nt-accent",t.accent),n.style.setProperty("--nt-accent-soft",t.soft),n.style.setProperty("--nt-accent-glow",t.glow)}function e2(e=lr()){return fm(wo(e)).accent}function t2(e=lr()){return fm(wo(e)).xtermSelection}function u0(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===dm&&(pm(lr()),e())};return window.addEventListener(Wf,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Wf,e),window.removeEventListener("storage",t)}}const i2="Automatic update needs write access to the global npm install. Run the manual update command as the NTerminal runtime user; only the npm install step should use sudo.";function s2(e="nterminal",t=new Date){return{reason:"permission",message:i2,command:`sudo npm i -g ${e}@latest --prefer-online && nterminal restart`,detectedAt:t.toISOString()}}function n2(e){return/\b(?:EACCES|EPERM)\b|permission denied|missing write access|access denied|operation was rejected by your operating system|operation not permitted|root-owned files/i.test(e)}const h0=3600*1e3,r2="local",Yf=new Set,nr=new Map;let or={checking:!1,hasUpdates:!1,lastCheckedAt:null},mm=null,eo=null,fu=0,Jn=null;function a2(e){return Yf.add(e),()=>{Yf.delete(e)}}function Yy(){return or}function l2(e){const t=d2();mm=e,_m(),$f(e,t);const n=()=>{if(document.visibilityState!=="visible"||!cr(e,t))return;const a=or.lastCheckedAt;(a===null||Date.now()-a>=h0)&&$f(e,t)};return document.addEventListener("visibilitychange",n),()=>{document.removeEventListener("visibilitychange",n),cr(e,t)&&h2()}}function o2(e,t){nr.set(e,d0(t)),Ba({...or,hasUpdates:vm(),lastCheckedAt:Date.now()})}function sf(e){e===void 0?nr.clear():nr.set(e,!1),Ba({...or,hasUpdates:vm()})}async function $f(e,t){if(!cr(e,t))return;if(Jn&&Jn.api===e&&Jn.runId===t)return Jn.promise;Ba({...or,checking:!0});const n=c2(e,t).finally(()=>{Jn?.promise===n&&(Jn=null),cr(e,t)&&(Ba({...or,checking:!1,lastCheckedAt:Date.now()}),u2(e,t))});return Jn={api:e,runId:t,promise:n},n}async function c2(e,t){try{const n=await e.listAgents();if(!cr(e,t))return;const a=[{key:r2,check:()=>e.checkUpdate()},...n.agents.map(c=>({key:c.id,check:()=>e.checkAgentUpdate(c.id)}))],o=new Map;if(await Promise.all(a.map(async c=>{try{const d=await c.check();o.set(c.key,d0(d))}catch{o.set(c.key,nr.get(c.key)??!1)}})),!cr(e,t))return;nr.clear();for(const[c,d]of o)nr.set(c,d);Ba({...or,hasUpdates:vm()})}catch{}}function u2(e,t){cr(e,t)&&(_m(),eo=window.setTimeout(()=>{eo=null,cr(e,t)&&$f(e,t)},h0))}function h2(){fu+=1,_m(),mm=null,Jn=null,nr.clear(),Ba({checking:!1,hasUpdates:!1,lastCheckedAt:null})}function _m(){eo!==null&&(window.clearTimeout(eo),eo=null)}function d2(){return fu+=1,fu}function cr(e,t){return mm===e&&fu===t}function d0(e){return e.updateAvailable===!0}function vm(){return Array.from(nr.values()).some(Boolean)}function Ba(e){or=e;for(const t of Array.from(Yf))t()}const f2=e=>new Promise(t=>setTimeout(t,e));function p2({api:e,onAgentRemoved:t}){const[n,a]=g.useState([{key:"local",id:null,name:"Local (main)"}]),[o,c]=g.useState({}),[d,p]=g.useState(!1),[m,f]=g.useState(null),[S,y]=g.useState(!1);function b(j,$){c(H=>({...H,[j]:{...H[j],...$}}))}const x=j=>j.id===null?e.getVersion():e.getAgentVersion(j.id),C=j=>j.id===null?e.checkUpdate():e.checkAgentUpdate(j.id),k=j=>j.id===null?e.runUpdate():e.runAgentUpdate(j.id);g.useEffect(()=>{let j=!1;return e.listAgents().then($=>{if(j)return;const H=[{key:"local",id:null,name:"Local (main)"},...$.agents.map(L=>({key:L.id,id:L.id,name:L.name}))];a(H);for(const L of H)x(L).then(X=>b(L.key,{version:X,manualUpdate:X.manualUpdate??null})).catch(X=>b(L.key,{error:X instanceof Error?X.message:"unreachable"}))}).catch(()=>{}),()=>{j=!0}},[]);async function B(j){b(j.key,{busy:!0,status:"checking…",error:void 0});try{const $=await C(j);o2(j.key,$),b(j.key,{latestVersion:$.latestVersion,updateAvailable:$.updateAvailable,status:I($),...$.updateAvailable===!1?{manualUpdate:null}:{},busy:!1})}catch($){b(j.key,{busy:!1,error:$ instanceof Error?$.message:"check failed"})}}async function R(){p(!0),await Promise.all(n.map(j=>B(j))),p(!1)}async function re(j,$){const H=Date.now()+18e4;for(;Date.now()<H;){await f2(3e3);try{const L=await x(j);if($&&L.runningVersion!==$.runningVersion)return L}catch{}}return null}async function F(j,$={}){let H=o[j.key]?.version;if(!H)try{H=await x(j),b(j.key,{version:H,manualUpdate:H.manualUpdate??null})}catch(M){return b(j.key,{busy:!1,error:M instanceof Error?M.message:"version check failed"}),"failed"}const L=o[j.key]?.manualUpdate??H.manualUpdate??null;if(L&&$.skipManual)return b(j.key,{busy:!1,status:"manual update required",error:void 0,manualUpdate:L}),"manual";b(j.key,{busy:!0,status:"updating…",error:void 0});let X;try{X=await k(j)}catch(M){return b(j.key,{busy:!1,error:M instanceof Error?M.message:"update failed"}),"failed"}if(!X.ok){const M=X.manualUpdate??(n2(X.message)?s2():null);return M?(b(j.key,{busy:!1,status:"manual update required",error:void 0,manualUpdate:M}),"manual"):(b(j.key,{busy:!1,status:void 0,error:X.message}),"failed")}if(!X.changed)return b(j.key,{busy:!1,status:"already up to date",updateAvailable:!1,manualUpdate:null}),sf(j.key),"unchanged";b(j.key,{status:"restarting…"});const G=await re(j,H);return G?(b(j.key,{busy:!1,version:G,updateAvailable:!1,status:"updated",manualUpdate:G.manualUpdate??null}),sf(j.key),j.id===null&&(y(!0),f("Main server updated. Reload the page to use the new client.")),"updated"):(b(j.key,{busy:!1,status:void 0,error:"timed out — check the server log"}),"failed")}async function J(j){if(!(j.id===null||!window.confirm([`Delete secondary server "${j.name}"?`,"","If the secondary is reachable, NTerminal will schedule a clean uninstall on that host, stop its runtime, remove its local state, and remove it from this main server.","If it is already gone or unreachable, only the stale registration on this main server will be removed.","","This can close live terminals on that secondary. Continue?"].join(`
14
- `)))){b(j.key,{busy:!0,status:"deleting…",error:void 0}),f(null);try{const H=await e.uninstallAgent(j.id);a(L=>L.filter(X=>X.key!==j.key)),c(L=>{const X={...L};return delete X[j.key],X}),sf(j.key),t?.(j.id),f(H.message)}catch(H){b(j.key,{busy:!1,status:void 0,error:H instanceof Error?H.message:"delete failed"})}}}async function ce(){p(!0),f(null);const j=n.filter(G=>G.id!==null),$=n.find(G=>G.id===null),H=await Promise.all(j.map(G=>F(G,{skipManual:!0}))),L=H.filter(G=>G==="failed").length;let X=H.filter(G=>G==="manual").length;if(L>0){p(!1);return}if($){const G=await F($,{skipManual:!0});if(G==="manual"&&(X+=1),G==="updated"){p(!1);return}}X>0&&f("Some servers need manual update. Copy and run the command shown on each marked server."),p(!1)}function q(j){return j?j.error?j.error:j.status?j.status:j.manualUpdate?"manual update required":j.version?`v${j.version.version}`:"…":"…"}function I(j){return j.error?j.error:typeof j.updateAvailable=="boolean"?j.updateAvailable?`latest v${j.latestVersion??"available"}`:"up to date":"unknown"}function ie(j){const $=j?.version;return $?`npm package v${$.runningVersion}`:""}async function de(j,$){try{await m2($),b(j,{copiedCommand:!0}),window.setTimeout(()=>b(j,{copiedCommand:!1}),1800)}catch(H){b(j,{error:H instanceof Error?H.message:"copy failed"})}}return _.jsxs("section",{className:"security-section",children:[_.jsx("h3",{children:"Servers"}),_.jsxs("div",{className:"update-actions",children:[_.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{R()},disabled:d,children:"Check for updates"}),_.jsx("button",{type:"button",onClick:()=>{ce()},disabled:d,children:"Update all"})]}),m?_.jsx("p",{className:"settings-status",children:m}):null,S?_.jsxs("div",{className:"server-reload-required",role:"status",children:[_.jsx("span",{children:"Main server update is ready."}),_.jsx("button",{type:"button",onClick:()=>window.location.reload(),children:"Reload page"})]}):null,_.jsx("ul",{className:"security-list",children:n.map(j=>{const $=o[j.key],H=ie($),L=$?.manualUpdate??null,X=$?.version!==void 0&&$?.updateAvailable!==!1&&!L&&!$?.busy&&!d,G=j.id!==null&&!$?.busy&&!d;return _.jsxs("li",{children:[_.jsxs("div",{className:"server-row-main",children:[_.jsxs("div",{children:[_.jsx("span",{className:"security-item-label",children:j.name}),_.jsxs("span",{className:"security-item-meta",children:[H?`${H} — `:"",q($)]})]}),L?_.jsxs("div",{className:"server-manual-update",children:[_.jsx("span",{children:L.message}),_.jsxs("div",{className:"server-manual-command",children:[_.jsx("code",{children:L.command}),_.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{de(j.key,L.command)},children:$?.copiedCommand?"Copied":"Copy"})]})]}):null]}),_.jsxs("div",{className:"server-row-actions",children:[_.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{F(j)},disabled:!X,children:$?.busy?"…":"Update"}),j.id!==null?_.jsx("button",{type:"button",className:"server-delete-button",onClick:()=>{J(j)},disabled:!G,children:"Delete"}):null]})]},j.key)})})]})}async function m2(e){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly","true"),t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();try{if(!document.execCommand("copy"))throw new Error("copy failed")}finally{t.remove()}}const Uc=[{id:"terminal",label:"Terminal"},{id:"shortcuts",label:"Shortcuts"},{id:"notifications",label:"Notifications"},{id:"security",label:"Security"},{id:"servers",label:"Servers"}];function _2({onClose:e,api:t,updateAvailable:n=!1,onNotificationAssetsChanged:a,onAgentRemoved:o}){const c=g.useMemo(()=>t??Eu(),[t]),[d,p]=g.useState(()=>Pf()),[m,f]=g.useState(()=>Kf()),[S,y]=g.useState(()=>Ff()),[b,x]=g.useState(()=>lr()),[C,k]=g.useState(()=>jr()),[B,R]=g.useState(null),[re,F]=g.useState(null),[J,ce]=g.useState("terminal"),[q,I]=g.useState(()=>Vb()),[ie,de]=g.useState(()=>zr()),[j,$]=g.useState(()=>nm()),[H,L]=g.useState([]),[X,G]=g.useState([]),[M,V]=g.useState([]),[Q,ve]=g.useState(5*1024*1024),[Se,E]=g.useState(!1),[W,ee]=g.useState(null),he=g.useRef(null),ge=g.useRef(null),me=g.useRef({terminal:null,shortcuts:null,notifications:null,security:null,servers:null}),Ce=g.useMemo(()=>new Set(X),[X]),ze=!v2(X,M);g.useEffect(()=>e0(()=>p(Pf())),[]),g.useEffect(()=>t0(()=>f(Kf())),[]),g.useEffect(()=>i0(()=>y(Ff())),[]),g.useEffect(()=>u0(()=>x(lr())),[]),g.useEffect(()=>s0(()=>k(jr())),[]),g.useEffect(()=>Xb(()=>de(zr())),[]),g.useEffect(()=>{if(!B)return;const te=ro.find(He=>He.id===B);if(!te)return;const je=He=>{if(He.preventDefault(),He.stopPropagation(),He.key==="Escape"){R(null),F(null);return}const _i=qE(He,te);if(!_i){F(te.indexed?"Press a shortcut ending in a number from 1 to 9.":"Press a complete shortcut.");return}k(KE(B,_i)),R(null),F(null)};return window.addEventListener("keydown",je,!0),()=>window.removeEventListener("keydown",je,!0)},[B]),g.useEffect(()=>{let te=!1;return c.listNotificationAssets().then(je=>{te||Ee(je)}).catch(je=>{te||ee(Pc(je))}),()=>{te=!0}},[c]);function Ne(te){p(Hc(Number(te)))}function Re(te){de(qy(Number(te)))}function Pe(te){ce(te),me.current[te]?.scrollIntoView?.({block:"start",behavior:"smooth"})}function Ye(){const te=ge.current;if(!te)return;if(te.scrollTop+te.clientHeight>=te.scrollHeight-2){ce(Uc[Uc.length-1].id);return}const je=te.getBoundingClientRect();let He="terminal",_i=0;for(const Vi of Uc){const ai=me.current[Vi.id];if(!ai)continue;const kt=ai.getBoundingClientRect(),ji=Math.max(kt.top,je.top),Ti=Math.min(kt.bottom,je.bottom),Nt=Math.max(0,Ti-ji);Nt>_i&&(He=Vi.id,_i=Nt)}ce(He)}function Be(te){k(IE(te)),R(null),F(null)}function ae(){k(FE()),R(null),F(null)}function Ee(te){const je=te.assets.filter(He=>He.enabled).map(He=>He.id);L(te.assets),G(je),V(je),ve(te.maxFileBytes),ee(null)}async function xe(){if(q){Fy(!1),I(!1);return}let te=j;te==="default"&&(te=await OE(),$(te)),te==="granted"&&(Fy(!0),I(!0))}async function Ke(te){const je=te?.[0];if(je){if(je.size>Q){ee(`File must be ${nf(Q)} or smaller.`),gt();return}if(je.type!=="video/mp4"&&je.type!=="video/webm"){ee("Upload an MP4 or WebM video."),gt();return}E(!0),ee(null);try{await c.uploadNotificationAsset(je),Ee(await c.listNotificationAssets()),a?.()}catch(He){ee(Pc(He))}finally{E(!1),gt()}}}async function Xe(te){E(!0),ee(null);try{await c.deleteNotificationAsset(te),Ee(await c.listNotificationAssets()),a?.()}catch(je){ee(Pc(je))}finally{E(!1)}}function gt(){he.current&&(he.current.value="")}function yt(te,je){const He=new Set(X);if(je?He.add(te):He.delete(te),He.size===0){ee("Keep at least one toast video selected.");return}ee(null),G(Array.from(He))}async function mi(){if(X.length===0){ee("Keep at least one toast video selected.");return}E(!0),ee(null);try{const te=await c.updateNotificationAssetSelection({enabledAssetIds:X});Ee(te),a?.()}catch(te){ee(Pc(te))}finally{E(!1)}}return _.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-label":"Settings",onClick:e,children:_.jsxs("div",{className:"security-panel settings-panel",onClick:te=>te.stopPropagation(),children:[_.jsxs("header",{className:"security-panel-header",children:[_.jsx("h2",{children:"Settings"}),_.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:e,children:"×"})]}),_.jsxs("div",{className:"settings-layout",children:[_.jsx("nav",{className:"settings-nav","aria-label":"Settings categories",children:Uc.map(te=>_.jsxs("button",{type:"button","data-active":J===te.id?"true":"false","aria-current":J===te.id?"true":void 0,onClick:()=>Pe(te.id),children:[te.label,te.id==="servers"&&n?_.jsx("span",{className:"update-pulse-dot settings-update-dot","aria-hidden":"true"}):null]},te.id))}),_.jsxs("div",{ref:ge,className:"settings-content",onScroll:Ye,children:[_.jsxs("section",{id:"settings-terminal",ref:te=>{me.current.terminal=te},className:"security-section settings-section",children:[_.jsx("h3",{children:"Terminal"}),_.jsxs("label",{className:"settings-control",children:[_.jsx("span",{children:"Font size"}),_.jsxs("span",{className:"settings-control-value",children:[d,"px"]}),_.jsx("input",{type:"range",min:jf,max:Hf,step:1,value:d,"aria-label":"Terminal font size",onChange:te=>Ne(te.currentTarget.value)})]}),_.jsxs("div",{className:"settings-stepper-row",children:[_.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>p(Hc(d-1)),children:"-"}),_.jsx("input",{type:"number",min:jf,max:Hf,step:1,value:d,"aria-label":"Terminal font size value",onChange:te=>Ne(te.currentTarget.value)}),_.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>p(Hc(d+1)),children:"+"}),_.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:()=>p(Hc(Lr)),children:"Reset"})]}),_.jsxs("label",{className:"settings-control",children:[_.jsx("span",{children:"Font family"}),_.jsx("select",{value:m,"aria-label":"Terminal font family",onChange:te=>f(HE(te.currentTarget.value)),children:hu.map(te=>_.jsx("option",{value:te.id,children:te.label},te.id))})]}),_.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[_.jsx("input",{type:"checkbox",checked:S,onChange:te=>y(UE(te.currentTarget.checked))}),"Show scroll progress"]}),_.jsxs("label",{className:"settings-control",children:[_.jsx("span",{children:"Accent theme"}),_.jsx("select",{value:b,"aria-label":"Theme accent",onChange:te=>x(JE(te.currentTarget.value)),children:ao.map(te=>_.jsx("option",{value:te.id,children:te.label},te.id))})]}),_.jsx("div",{className:"settings-theme-swatches","aria-hidden":"true",children:ao.map(te=>_.jsx("span",{className:"settings-theme-swatch","data-active":b===te.id?"true":"false",style:{"--settings-theme-accent":te.accent}},te.id))})]}),_.jsxs("section",{id:"settings-shortcuts",ref:te=>{me.current.shortcuts=te},className:"security-section settings-section",children:[_.jsxs("div",{className:"settings-section-heading",children:[_.jsx("h3",{children:"Shortcuts"}),_.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:ae,children:"Reset all"})]}),_.jsx("p",{className:"muted",children:"Defaults avoid Chrome's browser-tab shortcuts. Click a shortcut, then press the new key combo."}),re?_.jsx("p",{className:"settings-error",children:re}):null,_.jsx("ul",{className:"settings-shortcut-list","aria-label":"Workspace shortcuts",children:ro.map(te=>{const je=B===te.id;return _.jsxs("li",{children:[_.jsxs("div",{children:[_.jsx("span",{className:"settings-shortcut-label",children:te.label}),_.jsx("span",{className:"settings-shortcut-group",children:te.group})]}),_.jsxs("div",{className:"settings-shortcut-actions",children:[_.jsx("button",{type:"button",className:"settings-shortcut-recorder","data-recording":je?"true":"false",onClick:()=>{R(te.id),F(null)},children:je?"Press keys…":r0(C[te.id])}),_.jsx("button",{type:"button",className:"secondary-button settings-shortcut-reset",onClick:()=>Be(te.id),children:"Reset"})]})]},te.id)})})]}),_.jsxs("section",{id:"settings-notifications",ref:te=>{me.current.notifications=te},className:"security-section settings-section",children:[_.jsx("h3",{children:"Notifications"}),Mu()?_.jsxs(_.Fragment,{children:[_.jsxs("label",{className:"auth-checkbox",children:[_.jsx("input",{type:"checkbox",checked:q&&j==="granted",onChange:()=>{xe()},disabled:j==="denied"}),"System notification when page is hidden"]}),j==="denied"?_.jsx("p",{className:"muted",children:"Notification permission is blocked for this site. Re-enable it in the browser's site settings, then come back here to turn the toggle on."}):_.jsx("p",{className:"muted",children:"Uses browser notifications only when this page isn't visible. Animated toast is controlled separately below."})]}):_.jsx("p",{className:"muted",children:"This browser doesn't expose the Notification API; animated toast and in-app badges can still work."}),_.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[_.jsx("input",{type:"checkbox",checked:ie.enabled,onChange:te=>de(ME(te.currentTarget.checked))}),"Show animated completion toast"]}),_.jsxs("label",{className:"settings-control",children:[_.jsx("span",{children:"Toast duration"}),_.jsx("span",{className:"settings-control-value",children:ie.persistUntilDismissed?"Until closed":`${ie.durationSeconds}s`}),_.jsx("input",{type:"range",min:Bf,max:Lf,step:.5,value:ie.durationSeconds,disabled:!ie.enabled||ie.persistUntilDismissed,"aria-label":"Completion toast duration",onChange:te=>Re(te.currentTarget.value)})]}),_.jsxs("div",{className:"settings-stepper-row settings-duration-row",children:[_.jsx("input",{type:"number",min:Bf,max:Lf,step:.5,value:ie.durationSeconds,disabled:!ie.enabled||ie.persistUntilDismissed,"aria-label":"Completion toast duration value",onChange:te=>Re(te.currentTarget.value)}),_.jsx("button",{type:"button",className:"secondary-button settings-reset-button",disabled:!ie.enabled||ie.persistUntilDismissed,onClick:()=>de(qy(Jl)),children:"Reset"})]}),_.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[_.jsx("input",{type:"checkbox",checked:ie.persistUntilDismissed,disabled:!ie.enabled,onChange:te=>de(AE(te.currentTarget.checked))}),"Keep toast until dismissed"]}),_.jsxs("div",{className:"settings-assets-header",children:[_.jsx("span",{children:"Toast videos"}),_.jsxs("span",{children:[nf(Q)," max"]})]}),_.jsx("input",{ref:he,type:"file",accept:"video/mp4,video/webm",className:"settings-asset-input","aria-label":"Upload toast video",onChange:te=>{Ke(te.currentTarget.files)}}),_.jsx("button",{type:"button",className:"secondary-button settings-upload-button",disabled:Se,onClick:()=>he.current?.click(),children:"Upload video"}),W?_.jsx("p",{className:"settings-error",children:W}):null,H.length>0?_.jsx("ul",{className:"settings-asset-list","aria-label":"Toast videos",children:H.map(te=>_.jsxs("li",{"data-enabled":Ce.has(te.id)?"true":"false",children:[_.jsxs("label",{className:"settings-asset-choice",children:[_.jsx("input",{type:"checkbox",checked:Ce.has(te.id),disabled:Se,"aria-label":`Use ${te.filename}`,onChange:je=>yt(te.id,je.currentTarget.checked)}),_.jsx("video",{src:te.url,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),_.jsxs("span",{className:"settings-asset-copy",children:[_.jsx("span",{children:te.filename}),_.jsx("small",{children:te.source==="built-in"?"Built-in":nf(te.size)})]})]}),te.source==="uploaded"?_.jsx("button",{type:"button",className:"secondary-button settings-asset-delete",disabled:Se,"aria-label":`Delete ${te.filename}`,onClick:()=>{Xe(te.id)},children:"x"}):null]},te.id))}):_.jsx("p",{className:"muted",children:"Built-in videos will be used."}),_.jsx("button",{type:"button",className:"secondary-button settings-save-assets-button",disabled:Se||H.length===0||!ze,onClick:()=>{mi()},children:"Save selected videos"})]}),_.jsx("div",{id:"settings-security",ref:te=>{me.current.security=te},className:"settings-section-group",children:_.jsx(RE,{api:c})}),_.jsx("div",{id:"settings-servers",ref:te=>{me.current.servers=te},className:"settings-section-group",children:_.jsx(p2,{api:c,...o?{onAgentRemoved:o}:{}})})]})]})]})})}function nf(e){return e>=1024*1024?`${Math.round(e/1024/1024*10)/10} MB`:e>=1024?`${Math.round(e/1024*10)/10} KB`:`${e} B`}function Pc(e){return e instanceof Error?e.message:"Request failed."}function v2(e,t){if(e.length!==t.length)return!1;const n=new Set(t);return e.every(a=>n.has(a))}class Dr extends Error{constructor(t,n){super(n),this.status=t,this.name="UploadClientError"}status}function g2(e){const t=e.createXhr?.()??new XMLHttpRequest,n=new FormData,a=e.files.map((o,c)=>({fieldName:`file${c}`,relativePath:o.relativePath,size:o.file.size}));n.append("manifest",JSON.stringify({terminalId:e.terminalId,entries:a}));for(const[o,c]of e.files.entries())n.append(`file${o}`,c.file);return new Promise((o,c)=>{let d=!1;const p=()=>{e.signal?.removeEventListener("abort",S)},m=y=>{d||(d=!0,p(),o(y))},f=y=>{d||(d=!0,p(),c(y))},S=()=>{t.abort(),f(new Dr(0,"Upload aborted."))};if(e.signal?.aborted){f(new Dr(0,"Upload aborted."));return}e.signal?.addEventListener("abort",S,{once:!0}),t.open("POST","/api/uploads"),t.withCredentials=!0,t.upload.onprogress=y=>{if(e.onProgress){if(y.lengthComputable&&y.total>0){e.onProgress({loaded:y.loaded,total:y.total,percent:Math.round(y.loaded/y.total*100)});return}e.onProgress({loaded:y.loaded,total:null,percent:null})}},t.onload=()=>{if(t.status>=200&&t.status<300){try{m(JSON.parse(t.responseText))}catch{f(new Dr(t.status,"Invalid upload response."))}return}f(new Dr(t.status,y2(t.responseText,t.statusText||`HTTP ${t.status}`)))},t.onerror=()=>f(new Dr(0,"Upload failed.")),t.onabort=()=>f(new Dr(0,"Upload aborted.")),t.ontimeout=()=>f(new Dr(0,"Upload timed out.")),t.send(n)})}function y2(e,t){try{const n=JSON.parse(e),a=typeof n.error=="string"?n.error:n.message;if(typeof a=="string"&&a.trim())return a}catch{}return t}const S2="modulepreload",b2=function(e){return"/"+e},$y={},f0=function(t,n,a){let o=Promise.resolve();if(n&&n.length>0){let m=function(f){return Promise.all(f.map(S=>Promise.resolve(S).then(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),p=d?.nonce||d?.getAttribute("nonce");o=m(n.map(f=>{if(f=b2(f),f in $y)return;$y[f]=!0;const S=f.endsWith(".css"),y=S?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${y}`))return;const b=document.createElement("link");if(b.rel=S?"stylesheet":S2,S||(b.as="script"),b.crossOrigin="",b.href=f,p&&b.setAttribute("nonce",p),document.head.appendChild(b),S)return new Promise((x,C)=>{b.addEventListener("load",x),b.addEventListener("error",()=>C(new Error(`Unable to preload CSS for ${f}`)))})}))}function c(d){const p=new Event("vite:preloadError",{cancelable:!0});if(p.payload=d,window.dispatchEvent(p),!p.defaultPrevented)throw d}return o.then(d=>{for(const p of d||[])p.status==="rejected"&&c(p.reason);return t().catch(c)})},w2=g.lazy(()=>f0(()=>import("./MarkdownPreview-DkMcZHuI.js"),[]));function C2({api:e,activeTerminalId:t,activeTerminalCwd:n,onOpenFile:a}){const[o,c]=g.useState(null),[d,p]=g.useState(""),[m,f]=g.useState({}),[S,y]=g.useState(()=>new Set),[b,x]=g.useState(null),[C,k]=g.useState({type:"empty"}),[B,R]=g.useState("idle"),[re,F]=g.useState(null),J=g.useRef(null),ce=g.useRef(null),q=g.useRef(!1),I=g.useRef(0),ie=g.useRef(null);ie.current===null&&t&&(ie.current=t);const de=ie.current,j=t?af(t,n):null,$=o?[o.rootPath,d].filter(Boolean).join("/"):"",H=b?.path??null;g.useEffect(()=>(q.current=!0,()=>{q.current=!1,I.current+=1,ze()}),[]),g.useEffect(()=>{ie.current=t,ce.current=null;const ae=t?af(t,n):null;L(t,ae)},[e]),g.useEffect(()=>{if(!de||t!==de)return;const ae=af(de,n);ae!==ce.current&&L(de,ae)},[de,t,n]);async function L(ae,Ee=j){const xe=Ne();if(ce.current=Ee,ze(),c(null),p(""),f({}),y(new Set),x(null),k({type:"empty"}),F(null),!ae){R("idle");return}R("loading");try{const Ke=await e.createFileRoot({terminalId:ae});if(!Re(xe))return;c({rootToken:Ke.rootToken,rootPath:Ke.rootPath});const Xe=await e.listFiles({rootToken:Ke.rootToken,path:""});if(!Re(xe))return;M(Xe),R("idle")}catch(Ke){if(await Pe(Ke,xe))return;Re(xe)&&(F(Xn(Ke)),R("idle"))}}async function X(ae=d,Ee=o){if(!Ee)return;const xe=Ne();R("loading"),F(null);try{const Ke=await e.listFiles({rootToken:Ee.rootToken,path:ae});if(!Re(xe))return;M(Ke),R("idle")}catch(Ke){if(await Pe(Ke,xe))return;Re(xe)&&(F(Xn(Ke)),R("idle"))}}async function G(){ie.current=t,await L(t,j)}function M(ae){f(Ee=>({...Ee,[ae.path]:E2(ae.entries)}))}async function V(ae){if(!(!rf(ae)||!o)){if(x(ae),F(null),ae.kind==="directory"){p(ae.path),Ce(),await ve(ae);return}if(p(Rr(ae.path)),ae.editable){await E(ae);return}ae.previewKind!=="none"&&await ee(ae,ae.previewKind)}}async function Q(ae){if(!(!rf(ae)||!o)){if(x(ae),F(null),ae.kind==="directory"){p(ae.path),Ce(),await ve(ae);return}if(p(Rr(ae.path)),ae.editable){await W(ae);return}ae.previewKind!=="none"&&await ee(ae,ae.previewKind)}}async function ve(ae){if(S.has(ae.path)){y(Ee=>{const xe=new Set(Ee);return xe.delete(ae.path),xe});return}y(Ee=>new Set(Ee).add(ae.path)),await X(ae.path)}function Se(ae,Ee){ae.key==="Enter"&&(ae.preventDefault(),Q(Ee))}async function E(ae){if(!o)return;const Ee=Ne();R("loading"),ze();try{const xe=await e.readFile({rootToken:o.rootToken,path:ae.path});if(!Re(Ee))return;k({type:"text-preview",file:ae,read:xe}),R("idle")}catch(xe){if(await Pe(xe,Ee))return;Re(Ee)&&(F(Xn(xe)),R("idle"))}}async function W(ae){if(!o)return;const Ee=Ne();R("loading");try{await a({rootToken:o.rootToken,path:ae.path}),Re(Ee)&&R("idle")}catch(xe){if(await Pe(xe,Ee))return;Re(Ee)&&(F(Xn(xe)),R("idle"))}}async function ee(ae,Ee){if(!o)return;const xe=Ne();R("loading"),ze();try{const Ke=await e.previewFile({rootToken:o.rootToken,path:ae.path});if(!Re(xe))return;const Xe=URL.createObjectURL(Ke);if(!Re(xe)){URL.revokeObjectURL(Xe);return}J.current=Xe,k({type:"preview",file:ae,previewKind:Ee,url:Xe}),R("idle")}catch(Ke){if(await Pe(Ke,xe))return;Re(xe)&&(F(Xn(Ke)),R("idle"))}}async function he(ae){if(!o)return;const Ee=ae==="file"?"New file":"New folder",xe=window.prompt(Ee,""),Ke=b?b.kind==="directory"?b.path:Rr(b.path):d,Xe=Vy(xe,Ke);if(Xe){F(null);try{const gt=await e.createFileEntry({rootToken:o.rootToken,path:Xe,kind:ae});x(gt.entry),await X(Ke)}catch(gt){if(await Pe(gt))return;F(Xn(gt))}}}async function ge(){if(!o||!b)return;const ae=window.prompt("Move selected entry",b.path),Ee=Vy(ae,"");if(!Ee||Ee===b.path)return;const xe=Rr(b.path),Ke=Rr(Ee);F(null);try{const Xe=await e.moveFileEntry({rootToken:o.rootToken,sourcePath:b.path,destinationPath:Ee});x(Xe.entry),p(Xe.entry.kind==="directory"?Xe.entry.path:Rr(Xe.entry.path)),Ce(),await X(xe),Ke!==xe&&await X(Ke)}catch(Xe){if(await Pe(Xe))return;F(Xn(Xe))}}async function me(){if(!o||!b)return;const ae=b.path,Ee=Rr(ae);F(null);try{const xe=await e.previewDeleteFileEntry({rootToken:o.rootToken,path:b.path}),Ke=xe.descendantCount>0?` and ${xe.descendantCount} nested item${xe.descendantCount===1?"":"s"}`:"";if(!window.confirm(`Delete ${xe.path}${Ke}?`))return;await e.deleteFileEntry({rootToken:o.rootToken,path:b.path,previewToken:xe.previewToken}),x(null),p(Ee),y(Xe=>{const gt=new Set(Xe);for(const yt of Xe)(yt===ae||yt.startsWith(`${ae}/`))&&gt.delete(yt);return gt}),Ce(),await X(Ee)}catch(xe){if(await Pe(xe))return;F(Xn(xe))}}function Ce(){I.current+=1,ze(),k({type:"empty"})}function ze(){J.current&&(URL.revokeObjectURL(J.current),J.current=null)}function Ne(){return I.current+=1,I.current}function Re(ae){return q.current&&ae===I.current}async function Pe(ae,Ee){return T2(ae)?(Ee!==void 0&&!Re(Ee)||await L(t,j),!0):!1}function Ye(ae,Ee){const xe=rf(ae),Ke=ae.kind==="directory"&&S.has(ae.path),Xe=m[ae.path]??[],gt={"--file-tree-depth":Ee};return _.jsxs(xi.Fragment,{children:[_.jsxs("button",{type:"button",className:"file-entry-button","data-kind":ae.kind,"data-expanded":Ke,"data-active":H===ae.path,disabled:!xe,style:gt,"aria-expanded":ae.kind==="directory"?Ke:void 0,"aria-label":`${ae.kind==="directory"?"Open folder":"Open file"} ${ae.name}`,title:ae.kind==="directory"?"Expand or collapse folder":"Click to preview. Double-click or press Enter to open.",onClick:()=>{V(ae)},onDoubleClick:()=>{Q(ae)},onKeyDown:yt=>Se(yt,ae),children:[_.jsx("span",{className:"file-entry-disclosure","aria-hidden":"true",children:ae.kind==="directory"?Ke?"▾":"▸":""}),_.jsx("span",{className:"file-entry-name",children:ae.name}),_.jsx("small",{children:x2(ae)})]}),Ke?_.jsx("div",{className:"file-tree-children",role:"group",children:Xe.map(yt=>Ye(yt,Ee+1))}):null]},ae.path)}const Be=m[""]??[];return _.jsxs("section",{className:"file-explorer","aria-label":"Files","aria-busy":B==="loading",children:[_.jsxs("header",{className:"file-explorer-header",children:[_.jsx("div",{className:"file-explorer-path",title:$,children:$||"No active pane"}),_.jsxs("div",{className:"file-explorer-toolbar","aria-label":"File actions",children:[_.jsx("button",{type:"button","aria-label":"Refresh files",title:"Refresh",disabled:!t,onClick:()=>{G()},children:"↻"}),_.jsx("button",{type:"button","aria-label":"New file",title:"New file",disabled:!o,onClick:()=>{he("file")},children:"+"}),_.jsx("button",{type:"button","aria-label":"New folder",title:"New folder",disabled:!o,onClick:()=>{he("directory")},children:"▣"})]})]}),re?_.jsx("div",{className:"file-explorer-alert",role:"alert",children:re}):null,_.jsxs("div",{className:"file-explorer-layout",children:[_.jsx("div",{className:"file-tree","aria-label":$?`Files in ${$}`:"Files",children:Be.map(ae=>Ye(ae,0))}),_.jsxs("section",{className:"file-detail","aria-label":"File detail",children:[_.jsxs("div",{className:"file-detail-header",children:[_.jsx("strong",{children:b?.name??"detail"}),_.jsxs("div",{className:"file-detail-actions",children:[_.jsx("button",{type:"button","aria-label":"Move selected entry",disabled:!b,onClick:()=>{ge()},children:"Move"}),_.jsx("button",{type:"button","aria-label":"Delete selected entry",disabled:!b,onClick:()=>{me()},children:"Delete"})]})]}),B==="loading"?_.jsx("div",{className:"file-detail-empty",children:"loading"}):null,C.type==="empty"&&B!=="loading"?_.jsx("div",{className:"file-detail-empty",children:"No file selected"}):null,C.type==="preview"?_.jsxs("div",{className:"file-preview-frame",children:[C.previewKind==="image"?_.jsx("img",{src:C.url,alt:C.file.name}):null,C.previewKind==="pdf"?_.jsx("iframe",{src:C.url,title:C.file.name}):null]}):null,C.type==="text-preview"&&C.read.language==="markdown"?_.jsx("div",{className:"file-markdown-preview","aria-label":`Preview for ${C.file.name}`,children:_.jsx(g.Suspense,{fallback:_.jsx("div",{className:"file-markdown-preview-loading",children:"loading preview"}),children:_.jsx(w2,{content:C.read.content})})}):null,C.type==="text-preview"&&C.read.language==="text"?_.jsx("pre",{className:"file-text-preview","aria-label":`Preview for ${C.file.name}`,children:C.read.content}):null]})]})]})}function rf(e){return e.kind==="directory"||e.editable||e.previewKind!=="none"}function x2(e){return e.kind==="directory"?"dir":e.editable?"edit":e.previewKind!=="none"?e.previewKind:"unsupported"}function af(e,t){return`${e}\0${t??""}`}function E2(e){return[...e].sort((t,n)=>t.kind==="directory"&&n.kind!=="directory"?-1:t.kind!=="directory"&&n.kind==="directory"?1:t.name.localeCompare(n.name))}function Rr(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function Vy(e,t){if(e===null)return null;const n=e.trim().replace(/^\/+/,"").replace(/\/{2,}/g,"/").replace(/\/$/,"");return n?!t||n.includes("/")?n:`${t}/${n}`:null}function Xn(e){return e instanceof Error?e.message:"Request failed"}function T2(e){return e instanceof yn&&e.status===409&&e.message==="terminal_cwd_changed"}const k2=g.lazy(()=>f0(()=>import("./MarkdownPreview-DkMcZHuI.js"),[]));function Xy({api:e,editor:t,canClose:n,onClose:a}){const[o,c]=g.useState(t.read),[d,p]=g.useState(t.read.content),[m,f]=g.useState("idle"),[S,y]=g.useState(null),[b,x]=g.useState(!1),[C,k]=g.useState("edit"),B=g.useRef(t),R=g.useRef(t.read),re=g.useRef(t.read.content),F=g.useRef(!1),J=g.useRef(!1),ce=g.useRef(0),q=d!==o.content&&m!=="saving"&&!b;g.useEffect(()=>(J.current=!0,()=>{J.current=!1,ce.current+=1}),[]),g.useEffect(()=>{ce.current+=1,F.current=!1,B.current=t,R.current=t.read,re.current=t.read.content,c(t.read),p(t.read.content),f("idle"),y(null),x(!1),k("edit")},[t.id,t.read]),g.useEffect(()=>{B.current=t},[t]),g.useEffect(()=>{R.current=o},[o]),g.useEffect(()=>{re.current=d},[d]),g.useEffect(()=>{if(d===o.content||b)return;const $=window.setInterval(()=>{!F.current&&re.current!==R.current.content&&I()},1e3);return()=>window.clearInterval($)},[d===o.content,b,t.id]);async function I(){if(F.current)return;const $=re.current,H=R.current;if($===H.content)return;const L=B.current,X=ce.current;F.current=!0,f("saving"),y(null),x(!1);try{const G=await e.writeFile({rootToken:L.rootToken,path:L.path,content:$,expectedVersion:H.version});if(!J.current||X!==ce.current)return;const M={...H,content:$,version:G.version};R.current=M,c(M),f(re.current===$?"saved":"idle")}catch(G){if(!J.current||X!==ce.current)return;if(G instanceof yn&&G.status===409){x(!0),f("idle");return}y(D2(G)),f("idle")}finally{X===ce.current&&(F.current=!1)}}const ie=m==="saving"?"saving":m==="saved"?"saved":o.language,de=o.language==="markdown",j=de&&C==="preview";return _.jsxs("section",{className:"editor-pane","aria-label":`Editor pane ${t.title}`,children:[_.jsxs("header",{className:"editor-pane-header",children:[_.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),_.jsx("strong",{children:t.title}),_.jsx("span",{className:"terminal-pane-spacer"}),_.jsx("span",{className:"terminal-pane-state",children:ie}),_.jsx("button",{type:"button","aria-label":`Save ${t.title}`,disabled:!q,onClick:()=>{I()},children:"Save"}),de?_.jsx("button",{type:"button","aria-label":`${j?"Edit":"Preview"} ${t.title}`,onClick:()=>k($=>$==="preview"?"edit":"preview"),children:j?"Edit":"Preview"}):null,n?_.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close editor ${t.title}`,onClick:a,children:"x"}):null]}),S?_.jsx("div",{className:"editor-pane-alert",role:"alert",children:S}):null,b?_.jsx("div",{className:"editor-pane-alert",role:"alert",children:"File changed on disk."}):null,j?_.jsx("div",{className:"editor-markdown-preview","aria-label":`Markdown preview for ${t.title}`,children:_.jsx(g.Suspense,{fallback:_.jsx("div",{className:"editor-markdown-preview-loading",children:"loading preview"}),children:_.jsx(k2,{content:d})})}):_.jsx("textarea",{className:"editor-pane-textarea","aria-label":`Editor for ${t.title}`,spellCheck:!1,value:d,onChange:$=>{const H=$.target.value;re.current=H,p(H),f("idle"),y(null),x(!1)}})]})}function D2(e){return e instanceof Error?e.message:"Request failed"}var R2=2,M2=1,A2=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),a=parseInt(n.getPropertyValue("height")),o=Math.max(0,parseInt(n.getPropertyValue("width"))),c=window.getComputedStyle(this._terminal.element),d={top:parseInt(c.getPropertyValue("padding-top")),bottom:parseInt(c.getPropertyValue("padding-bottom")),right:parseInt(c.getPropertyValue("padding-right")),left:parseInt(c.getPropertyValue("padding-left"))},p=d.top+d.bottom,m=d.right+d.left,f=a-p,S=o-m-t;return{cols:Math.max(R2,Math.floor(S/e.css.cell.width)),rows:Math.max(M2,Math.floor(f/e.css.cell.height))}}};var p0=Object.defineProperty,N2=Object.getOwnPropertyDescriptor,B2=(e,t)=>{for(var n in t)p0(e,n,{get:t[n],enumerable:!0})},Ht=(e,t,n,a)=>{for(var o=a>1?void 0:a?N2(t,n):t,c=e.length-1,d;c>=0;c--)(d=e[c])&&(o=(a?d(t,n,o):d(o))||o);return a&&o&&p0(t,n,o),o},ye=(e,t)=>(n,a)=>t(n,a,e),Gy="Terminal input",Vf={get:()=>Gy,set:e=>Gy=e},Zy="Too much output to announce, navigate to rows manually to read",Xf={get:()=>Zy,set:e=>Zy=e};function L2(e){return e.replace(/\r?\n/g,"\r")}function O2(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function z2(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function j2(e,t,n,a){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");m0(o,t,n,a)}}function m0(e,t,n,a){e=L2(e),e=O2(e,n.decPrivateModes.bracketedPasteMode&&a.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function _0(e,t,n){let a=n.getBoundingClientRect(),o=e.clientX-a.left-10,c=e.clientY-a.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${o}px`,t.style.top=`${c}px`,t.style.zIndex="1000",t.focus()}function Qy(e,t,n,a,o){_0(e,t,n),o&&a.rightClickSelect(e),t.value=a.selectionText,t.select()}function tr(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Au(e,t=0,n=e.length){let a="";for(let o=t;o<n;++o){let c=e[o];c>65535?(c-=65536,a+=String.fromCharCode((c>>10)+55296)+String.fromCharCode(c%1024+56320)):a+=String.fromCharCode(c)}return a}var H2=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let a=0,o=0;if(this._interim){let c=e.charCodeAt(o++);56320<=c&&c<=57343?t[a++]=(this._interim-55296)*1024+c-56320+65536:(t[a++]=this._interim,t[a++]=c),this._interim=0}for(let c=o;c<n;++c){let d=e.charCodeAt(c);if(55296<=d&&d<=56319){if(++c>=n)return this._interim=d,a;let p=e.charCodeAt(c);56320<=p&&p<=57343?t[a++]=(d-55296)*1024+p-56320+65536:(t[a++]=d,t[a++]=p);continue}d!==65279&&(t[a++]=d)}return a}},U2=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let a=0,o,c,d,p,m=0,f=0;if(this.interim[0]){let b=!1,x=this.interim[0];x&=(x&224)===192?31:(x&240)===224?15:7;let C=0,k;for(;(k=this.interim[++C]&63)&&C<4;)x<<=6,x|=k;let B=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,R=B-C;for(;f<R;){if(f>=n)return 0;if(k=e[f++],(k&192)!==128){f--,b=!0;break}else this.interim[C++]=k,x<<=6,x|=k&63}b||(B===2?x<128?f--:t[a++]=x:B===3?x<2048||x>=55296&&x<=57343||x===65279||(t[a++]=x):x<65536||x>1114111||(t[a++]=x)),this.interim.fill(0)}let S=n-4,y=f;for(;y<n;){for(;y<S&&!((o=e[y])&128)&&!((c=e[y+1])&128)&&!((d=e[y+2])&128)&&!((p=e[y+3])&128);)t[a++]=o,t[a++]=c,t[a++]=d,t[a++]=p,y+=4;if(o=e[y++],o<128)t[a++]=o;else if((o&224)===192){if(y>=n)return this.interim[0]=o,a;if(c=e[y++],(c&192)!==128){y--;continue}if(m=(o&31)<<6|c&63,m<128){y--;continue}t[a++]=m}else if((o&240)===224){if(y>=n)return this.interim[0]=o,a;if(c=e[y++],(c&192)!==128){y--;continue}if(y>=n)return this.interim[0]=o,this.interim[1]=c,a;if(d=e[y++],(d&192)!==128){y--;continue}if(m=(o&15)<<12|(c&63)<<6|d&63,m<2048||m>=55296&&m<=57343||m===65279)continue;t[a++]=m}else if((o&248)===240){if(y>=n)return this.interim[0]=o,a;if(c=e[y++],(c&192)!==128){y--;continue}if(y>=n)return this.interim[0]=o,this.interim[1]=c,a;if(d=e[y++],(d&192)!==128){y--;continue}if(y>=n)return this.interim[0]=o,this.interim[1]=c,this.interim[2]=d,a;if(p=e[y++],(p&192)!==128){y--;continue}if(m=(o&7)<<18|(c&63)<<12|(d&63)<<6|p&63,m<65536||m>1114111)continue;t[a++]=m}}return a}},v0="",sr=" ",Co=class g0{constructor(){this.fg=0,this.bg=0,this.extended=new pu}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new g0;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},pu=class y0{constructor(t=0,n=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new y0(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},xs=class S0 extends Co{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new pu,this.combinedData=""}static fromCharData(t){let n=new S0;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?tr(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let n=!1;if(t[1].length>2)n=!0;else if(t[1].length===2){let a=t[1].charCodeAt(0);if(55296<=a&&a<=56319){let o=t[1].charCodeAt(1);56320<=o&&o<=57343?this.content=(a-55296)*1024+o-56320+65536|t[2]<<22:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Jy="di$target",Gf="di$dependencies",lf=new Map;function P2(e){return e[Gf]||[]}function pi(e){if(lf.has(e))return lf.get(e);let t=function(n,a,o){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");K2(t,n,o)};return t._id=e,lf.set(e,t),t}function K2(e,t,n){t[Jy]===t?t[Gf].push({id:e,index:n}):(t[Gf]=[{id:e,index:n}],t[Jy]=t)}var Oi=pi("BufferService"),b0=pi("CoreMouseService"),Pr=pi("CoreService"),I2=pi("CharsetService"),gm=pi("InstantiationService"),w0=pi("LogService"),zi=pi("OptionsService"),C0=pi("OscLinkService"),F2=pi("UnicodeService"),xo=pi("DecorationService"),Zf=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let a=[],o=this._optionsService.rawOptions.linkHandler,c=new xs,d=n.getTrimmedLength(),p=-1,m=-1,f=!1;for(let S=0;S<d;S++)if(!(m===-1&&!n.hasContent(S))){if(n.loadCell(S,c),c.hasExtendedAttrs()&&c.extended.urlId)if(m===-1){m=S,p=c.extended.urlId;continue}else f=c.extended.urlId!==p;else m!==-1&&(f=!0);if(f||m!==-1&&S===d-1){let y=this._oscLinkService.getLinkData(p)?.uri;if(y){let b={start:{x:m+1,y:e},end:{x:S+(!f&&S===d-1?1:0),y:e}},x=!1;if(!o?.allowNonHttpProtocols)try{let C=new URL(y);["http:","https:"].includes(C.protocol)||(x=!0)}catch{x=!0}x||a.push({text:y,range:b,activate:(C,k)=>o?o.activate(C,k,b):q2(C,k),hover:(C,k)=>o?.hover?.(C,k,b),leave:(C,k)=>o?.leave?.(C,k,b)})}f=!1,c.hasExtendedAttrs()&&c.extended.urlId?(m=S,p=c.extended.urlId):(m=-1,p=-1)}}t(a)}};Zf=Ht([ye(0,Oi),ye(1,zi),ye(2,C0)],Zf);function q2(e,t){if(confirm(`Do you want to navigate to ${t}?
14
+ `)))){b(j.key,{busy:!0,status:"deleting…",error:void 0}),f(null);try{const H=await e.uninstallAgent(j.id);a(L=>L.filter(X=>X.key!==j.key)),c(L=>{const X={...L};return delete X[j.key],X}),sf(j.key),t?.(j.id),f(H.message)}catch(H){b(j.key,{busy:!1,status:void 0,error:H instanceof Error?H.message:"delete failed"})}}}async function ce(){p(!0),f(null);const j=n.filter(G=>G.id!==null),$=n.find(G=>G.id===null),H=await Promise.all(j.map(G=>F(G,{skipManual:!0}))),L=H.filter(G=>G==="failed").length;let X=H.filter(G=>G==="manual").length;if(L>0){p(!1);return}if($){const G=await F($,{skipManual:!0});if(G==="manual"&&(X+=1),G==="updated"){p(!1);return}}X>0&&f("Some servers need manual update. Copy and run the command shown on each marked server."),p(!1)}function q(j){return j?j.error?j.error:j.status?j.status:j.manualUpdate?"manual update required":j.version?`v${j.version.version}`:"…":"…"}function I(j){return j.error?j.error:typeof j.updateAvailable=="boolean"?j.updateAvailable?`latest v${j.latestVersion??"available"}`:"up to date":"unknown"}function ie(j){const $=j?.version;return $?`npm package v${$.runningVersion}`:""}async function de(j,$){try{await m2($),b(j,{copiedCommand:!0}),window.setTimeout(()=>b(j,{copiedCommand:!1}),1800)}catch(H){b(j,{error:H instanceof Error?H.message:"copy failed"})}}return _.jsxs("section",{className:"security-section",children:[_.jsx("h3",{children:"Servers"}),_.jsxs("div",{className:"update-actions",children:[_.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{R()},disabled:d,children:"Check for updates"}),_.jsx("button",{type:"button",onClick:()=>{ce()},disabled:d,children:"Update all"})]}),m?_.jsx("p",{className:"settings-status",children:m}):null,S?_.jsxs("div",{className:"server-reload-required",role:"status",children:[_.jsx("span",{children:"Main server update is ready."}),_.jsx("button",{type:"button",onClick:()=>window.location.reload(),children:"Reload page"})]}):null,_.jsx("ul",{className:"security-list",children:n.map(j=>{const $=o[j.key],H=ie($),L=$?.manualUpdate??null,X=$?.version!==void 0&&$?.updateAvailable!==!1&&!L&&!$?.busy&&!d,G=j.id!==null&&!$?.busy&&!d;return _.jsxs("li",{children:[_.jsxs("div",{className:"server-row-main",children:[_.jsxs("div",{children:[_.jsx("span",{className:"security-item-label",children:j.name}),_.jsxs("span",{className:"security-item-meta",children:[H?`${H} — `:"",q($)]})]}),L?_.jsxs("div",{className:"server-manual-update",children:[_.jsx("span",{children:L.message}),_.jsxs("div",{className:"server-manual-command",children:[_.jsx("code",{children:L.command}),_.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{de(j.key,L.command)},children:$?.copiedCommand?"Copied":"Copy"})]})]}):null]}),_.jsxs("div",{className:"server-row-actions",children:[_.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{F(j)},disabled:!X,children:$?.busy?"…":"Update"}),j.id!==null?_.jsx("button",{type:"button",className:"server-delete-button",onClick:()=>{J(j)},disabled:!G,children:"Delete"}):null]})]},j.key)})})]})}async function m2(e){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly","true"),t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();try{if(!document.execCommand("copy"))throw new Error("copy failed")}finally{t.remove()}}const Uc=[{id:"terminal",label:"Terminal"},{id:"shortcuts",label:"Shortcuts"},{id:"notifications",label:"Notifications"},{id:"security",label:"Security"},{id:"servers",label:"Servers"}];function _2({onClose:e,api:t,updateAvailable:n=!1,onNotificationAssetsChanged:a,onAgentRemoved:o}){const c=g.useMemo(()=>t??Eu(),[t]),[d,p]=g.useState(()=>Pf()),[m,f]=g.useState(()=>Kf()),[S,y]=g.useState(()=>Ff()),[b,x]=g.useState(()=>lr()),[C,k]=g.useState(()=>jr()),[B,R]=g.useState(null),[re,F]=g.useState(null),[J,ce]=g.useState("terminal"),[q,I]=g.useState(()=>Vb()),[ie,de]=g.useState(()=>zr()),[j,$]=g.useState(()=>nm()),[H,L]=g.useState([]),[X,G]=g.useState([]),[M,V]=g.useState([]),[Q,ve]=g.useState(5*1024*1024),[Se,E]=g.useState(!1),[W,ee]=g.useState(null),he=g.useRef(null),ge=g.useRef(null),me=g.useRef({terminal:null,shortcuts:null,notifications:null,security:null,servers:null}),Ce=g.useMemo(()=>new Set(X),[X]),ze=!v2(X,M);g.useEffect(()=>e0(()=>p(Pf())),[]),g.useEffect(()=>t0(()=>f(Kf())),[]),g.useEffect(()=>i0(()=>y(Ff())),[]),g.useEffect(()=>u0(()=>x(lr())),[]),g.useEffect(()=>s0(()=>k(jr())),[]),g.useEffect(()=>Xb(()=>de(zr())),[]),g.useEffect(()=>{if(!B)return;const te=ro.find(He=>He.id===B);if(!te)return;const je=He=>{if(He.preventDefault(),He.stopPropagation(),He.key==="Escape"){R(null),F(null);return}const _i=qE(He,te);if(!_i){F(te.indexed?"Press a shortcut ending in a number from 1 to 9.":"Press a complete shortcut.");return}k(KE(B,_i)),R(null),F(null)};return window.addEventListener("keydown",je,!0),()=>window.removeEventListener("keydown",je,!0)},[B]),g.useEffect(()=>{let te=!1;return c.listNotificationAssets().then(je=>{te||Ee(je)}).catch(je=>{te||ee(Pc(je))}),()=>{te=!0}},[c]);function Ne(te){p(Hc(Number(te)))}function Re(te){de(qy(Number(te)))}function Pe(te){ce(te),me.current[te]?.scrollIntoView?.({block:"start",behavior:"smooth"})}function Ye(){const te=ge.current;if(!te)return;if(te.scrollTop+te.clientHeight>=te.scrollHeight-2){ce(Uc[Uc.length-1].id);return}const je=te.getBoundingClientRect();let He="terminal",_i=0;for(const Vi of Uc){const ai=me.current[Vi.id];if(!ai)continue;const kt=ai.getBoundingClientRect(),ji=Math.max(kt.top,je.top),Ti=Math.min(kt.bottom,je.bottom),Nt=Math.max(0,Ti-ji);Nt>_i&&(He=Vi.id,_i=Nt)}ce(He)}function Be(te){k(IE(te)),R(null),F(null)}function ae(){k(FE()),R(null),F(null)}function Ee(te){const je=te.assets.filter(He=>He.enabled).map(He=>He.id);L(te.assets),G(je),V(je),ve(te.maxFileBytes),ee(null)}async function xe(){if(q){Fy(!1),I(!1);return}let te=j;te==="default"&&(te=await OE(),$(te)),te==="granted"&&(Fy(!0),I(!0))}async function Ke(te){const je=te?.[0];if(je){if(je.size>Q){ee(`File must be ${nf(Q)} or smaller.`),gt();return}if(je.type!=="video/mp4"&&je.type!=="video/webm"){ee("Upload an MP4 or WebM video."),gt();return}E(!0),ee(null);try{await c.uploadNotificationAsset(je),Ee(await c.listNotificationAssets()),a?.()}catch(He){ee(Pc(He))}finally{E(!1),gt()}}}async function Xe(te){E(!0),ee(null);try{await c.deleteNotificationAsset(te),Ee(await c.listNotificationAssets()),a?.()}catch(je){ee(Pc(je))}finally{E(!1)}}function gt(){he.current&&(he.current.value="")}function yt(te,je){const He=new Set(X);if(je?He.add(te):He.delete(te),He.size===0){ee("Keep at least one toast video selected.");return}ee(null),G(Array.from(He))}async function mi(){if(X.length===0){ee("Keep at least one toast video selected.");return}E(!0),ee(null);try{const te=await c.updateNotificationAssetSelection({enabledAssetIds:X});Ee(te),a?.()}catch(te){ee(Pc(te))}finally{E(!1)}}return _.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-label":"Settings",onClick:e,children:_.jsxs("div",{className:"security-panel settings-panel",onClick:te=>te.stopPropagation(),children:[_.jsxs("header",{className:"security-panel-header",children:[_.jsx("h2",{children:"Settings"}),_.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:e,children:"×"})]}),_.jsxs("div",{className:"settings-layout",children:[_.jsx("nav",{className:"settings-nav","aria-label":"Settings categories",children:Uc.map(te=>_.jsxs("button",{type:"button","data-active":J===te.id?"true":"false","aria-current":J===te.id?"true":void 0,onClick:()=>Pe(te.id),children:[te.label,te.id==="servers"&&n?_.jsx("span",{className:"update-pulse-dot settings-update-dot","aria-hidden":"true"}):null]},te.id))}),_.jsxs("div",{ref:ge,className:"settings-content",onScroll:Ye,children:[_.jsxs("section",{id:"settings-terminal",ref:te=>{me.current.terminal=te},className:"security-section settings-section",children:[_.jsx("h3",{children:"Terminal"}),_.jsxs("label",{className:"settings-control",children:[_.jsx("span",{children:"Font size"}),_.jsxs("span",{className:"settings-control-value",children:[d,"px"]}),_.jsx("input",{type:"range",min:jf,max:Hf,step:1,value:d,"aria-label":"Terminal font size",onChange:te=>Ne(te.currentTarget.value)})]}),_.jsxs("div",{className:"settings-stepper-row",children:[_.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>p(Hc(d-1)),children:"-"}),_.jsx("input",{type:"number",min:jf,max:Hf,step:1,value:d,"aria-label":"Terminal font size value",onChange:te=>Ne(te.currentTarget.value)}),_.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>p(Hc(d+1)),children:"+"}),_.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:()=>p(Hc(Lr)),children:"Reset"})]}),_.jsxs("label",{className:"settings-control",children:[_.jsx("span",{children:"Font family"}),_.jsx("select",{value:m,"aria-label":"Terminal font family",onChange:te=>f(HE(te.currentTarget.value)),children:hu.map(te=>_.jsx("option",{value:te.id,children:te.label},te.id))})]}),_.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[_.jsx("input",{type:"checkbox",checked:S,onChange:te=>y(UE(te.currentTarget.checked))}),"Show scroll progress"]}),_.jsxs("label",{className:"settings-control",children:[_.jsx("span",{children:"Accent theme"}),_.jsx("select",{value:b,"aria-label":"Theme accent",onChange:te=>x(JE(te.currentTarget.value)),children:ao.map(te=>_.jsx("option",{value:te.id,children:te.label},te.id))})]}),_.jsx("div",{className:"settings-theme-swatches","aria-hidden":"true",children:ao.map(te=>_.jsx("span",{className:"settings-theme-swatch","data-active":b===te.id?"true":"false",style:{"--settings-theme-accent":te.accent}},te.id))})]}),_.jsxs("section",{id:"settings-shortcuts",ref:te=>{me.current.shortcuts=te},className:"security-section settings-section",children:[_.jsxs("div",{className:"settings-section-heading",children:[_.jsx("h3",{children:"Shortcuts"}),_.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:ae,children:"Reset all"})]}),_.jsx("p",{className:"muted",children:"Defaults avoid Chrome's browser-tab shortcuts. Click a shortcut, then press the new key combo."}),re?_.jsx("p",{className:"settings-error",children:re}):null,_.jsx("ul",{className:"settings-shortcut-list","aria-label":"Workspace shortcuts",children:ro.map(te=>{const je=B===te.id;return _.jsxs("li",{children:[_.jsxs("div",{children:[_.jsx("span",{className:"settings-shortcut-label",children:te.label}),_.jsx("span",{className:"settings-shortcut-group",children:te.group})]}),_.jsxs("div",{className:"settings-shortcut-actions",children:[_.jsx("button",{type:"button",className:"settings-shortcut-recorder","data-recording":je?"true":"false",onClick:()=>{R(te.id),F(null)},children:je?"Press keys…":r0(C[te.id])}),_.jsx("button",{type:"button",className:"secondary-button settings-shortcut-reset",onClick:()=>Be(te.id),children:"Reset"})]})]},te.id)})})]}),_.jsxs("section",{id:"settings-notifications",ref:te=>{me.current.notifications=te},className:"security-section settings-section",children:[_.jsx("h3",{children:"Notifications"}),Mu()?_.jsxs(_.Fragment,{children:[_.jsxs("label",{className:"auth-checkbox",children:[_.jsx("input",{type:"checkbox",checked:q&&j==="granted",onChange:()=>{xe()},disabled:j==="denied"}),"System notification when page is hidden"]}),j==="denied"?_.jsx("p",{className:"muted",children:"Notification permission is blocked for this site. Re-enable it in the browser's site settings, then come back here to turn the toggle on."}):_.jsx("p",{className:"muted",children:"Uses browser notifications only when this page isn't visible. Animated toast is controlled separately below."})]}):_.jsx("p",{className:"muted",children:"This browser doesn't expose the Notification API; animated toast and in-app badges can still work."}),_.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[_.jsx("input",{type:"checkbox",checked:ie.enabled,onChange:te=>de(ME(te.currentTarget.checked))}),"Show animated completion toast"]}),_.jsxs("label",{className:"settings-control",children:[_.jsx("span",{children:"Toast duration"}),_.jsx("span",{className:"settings-control-value",children:ie.persistUntilDismissed?"Until closed":`${ie.durationSeconds}s`}),_.jsx("input",{type:"range",min:Bf,max:Lf,step:.5,value:ie.durationSeconds,disabled:!ie.enabled||ie.persistUntilDismissed,"aria-label":"Completion toast duration",onChange:te=>Re(te.currentTarget.value)})]}),_.jsxs("div",{className:"settings-stepper-row settings-duration-row",children:[_.jsx("input",{type:"number",min:Bf,max:Lf,step:.5,value:ie.durationSeconds,disabled:!ie.enabled||ie.persistUntilDismissed,"aria-label":"Completion toast duration value",onChange:te=>Re(te.currentTarget.value)}),_.jsx("button",{type:"button",className:"secondary-button settings-reset-button",disabled:!ie.enabled||ie.persistUntilDismissed,onClick:()=>de(qy(Jl)),children:"Reset"})]}),_.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[_.jsx("input",{type:"checkbox",checked:ie.persistUntilDismissed,disabled:!ie.enabled,onChange:te=>de(AE(te.currentTarget.checked))}),"Keep toast until dismissed"]}),_.jsxs("div",{className:"settings-assets-header",children:[_.jsx("span",{children:"Toast videos"}),_.jsxs("span",{children:[nf(Q)," max"]})]}),_.jsx("input",{ref:he,type:"file",accept:"video/mp4,video/webm",className:"settings-asset-input","aria-label":"Upload toast video",onChange:te=>{Ke(te.currentTarget.files)}}),_.jsx("button",{type:"button",className:"secondary-button settings-upload-button",disabled:Se,onClick:()=>he.current?.click(),children:"Upload video"}),W?_.jsx("p",{className:"settings-error",children:W}):null,H.length>0?_.jsx("ul",{className:"settings-asset-list","aria-label":"Toast videos",children:H.map(te=>_.jsxs("li",{"data-enabled":Ce.has(te.id)?"true":"false",children:[_.jsxs("label",{className:"settings-asset-choice",children:[_.jsx("input",{type:"checkbox",checked:Ce.has(te.id),disabled:Se,"aria-label":`Use ${te.filename}`,onChange:je=>yt(te.id,je.currentTarget.checked)}),_.jsx("video",{src:te.url,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),_.jsxs("span",{className:"settings-asset-copy",children:[_.jsx("span",{children:te.filename}),_.jsx("small",{children:te.source==="built-in"?"Built-in":nf(te.size)})]})]}),te.source==="uploaded"?_.jsx("button",{type:"button",className:"secondary-button settings-asset-delete",disabled:Se,"aria-label":`Delete ${te.filename}`,onClick:()=>{Xe(te.id)},children:"x"}):null]},te.id))}):_.jsx("p",{className:"muted",children:"Built-in videos will be used."}),_.jsx("button",{type:"button",className:"secondary-button settings-save-assets-button",disabled:Se||H.length===0||!ze,onClick:()=>{mi()},children:"Save selected videos"})]}),_.jsx("div",{id:"settings-security",ref:te=>{me.current.security=te},className:"settings-section-group",children:_.jsx(RE,{api:c})}),_.jsx("div",{id:"settings-servers",ref:te=>{me.current.servers=te},className:"settings-section-group",children:_.jsx(p2,{api:c,...o?{onAgentRemoved:o}:{}})})]})]})]})})}function nf(e){return e>=1024*1024?`${Math.round(e/1024/1024*10)/10} MB`:e>=1024?`${Math.round(e/1024*10)/10} KB`:`${e} B`}function Pc(e){return e instanceof Error?e.message:"Request failed."}function v2(e,t){if(e.length!==t.length)return!1;const n=new Set(t);return e.every(a=>n.has(a))}class Dr extends Error{constructor(t,n){super(n),this.status=t,this.name="UploadClientError"}status}function g2(e){const t=e.createXhr?.()??new XMLHttpRequest,n=new FormData,a=e.files.map((o,c)=>({fieldName:`file${c}`,relativePath:o.relativePath,size:o.file.size}));n.append("manifest",JSON.stringify({terminalId:e.terminalId,entries:a}));for(const[o,c]of e.files.entries())n.append(`file${o}`,c.file);return new Promise((o,c)=>{let d=!1;const p=()=>{e.signal?.removeEventListener("abort",S)},m=y=>{d||(d=!0,p(),o(y))},f=y=>{d||(d=!0,p(),c(y))},S=()=>{t.abort(),f(new Dr(0,"Upload aborted."))};if(e.signal?.aborted){f(new Dr(0,"Upload aborted."));return}e.signal?.addEventListener("abort",S,{once:!0}),t.open("POST","/api/uploads"),t.withCredentials=!0,t.upload.onprogress=y=>{if(e.onProgress){if(y.lengthComputable&&y.total>0){e.onProgress({loaded:y.loaded,total:y.total,percent:Math.round(y.loaded/y.total*100)});return}e.onProgress({loaded:y.loaded,total:null,percent:null})}},t.onload=()=>{if(t.status>=200&&t.status<300){try{m(JSON.parse(t.responseText))}catch{f(new Dr(t.status,"Invalid upload response."))}return}f(new Dr(t.status,y2(t.responseText,t.statusText||`HTTP ${t.status}`)))},t.onerror=()=>f(new Dr(0,"Upload failed.")),t.onabort=()=>f(new Dr(0,"Upload aborted.")),t.ontimeout=()=>f(new Dr(0,"Upload timed out.")),t.send(n)})}function y2(e,t){try{const n=JSON.parse(e),a=typeof n.error=="string"?n.error:n.message;if(typeof a=="string"&&a.trim())return a}catch{}return t}const S2="modulepreload",b2=function(e){return"/"+e},$y={},f0=function(t,n,a){let o=Promise.resolve();if(n&&n.length>0){let m=function(f){return Promise.all(f.map(S=>Promise.resolve(S).then(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),p=d?.nonce||d?.getAttribute("nonce");o=m(n.map(f=>{if(f=b2(f),f in $y)return;$y[f]=!0;const S=f.endsWith(".css"),y=S?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${y}`))return;const b=document.createElement("link");if(b.rel=S?"stylesheet":S2,S||(b.as="script"),b.crossOrigin="",b.href=f,p&&b.setAttribute("nonce",p),document.head.appendChild(b),S)return new Promise((x,C)=>{b.addEventListener("load",x),b.addEventListener("error",()=>C(new Error(`Unable to preload CSS for ${f}`)))})}))}function c(d){const p=new Event("vite:preloadError",{cancelable:!0});if(p.payload=d,window.dispatchEvent(p),!p.defaultPrevented)throw d}return o.then(d=>{for(const p of d||[])p.status==="rejected"&&c(p.reason);return t().catch(c)})},w2=g.lazy(()=>f0(()=>import("./MarkdownPreview-D8zAIfDx.js"),[]));function C2({api:e,activeTerminalId:t,activeTerminalCwd:n,onOpenFile:a}){const[o,c]=g.useState(null),[d,p]=g.useState(""),[m,f]=g.useState({}),[S,y]=g.useState(()=>new Set),[b,x]=g.useState(null),[C,k]=g.useState({type:"empty"}),[B,R]=g.useState("idle"),[re,F]=g.useState(null),J=g.useRef(null),ce=g.useRef(null),q=g.useRef(!1),I=g.useRef(0),ie=g.useRef(null);ie.current===null&&t&&(ie.current=t);const de=ie.current,j=t?af(t,n):null,$=o?[o.rootPath,d].filter(Boolean).join("/"):"",H=b?.path??null;g.useEffect(()=>(q.current=!0,()=>{q.current=!1,I.current+=1,ze()}),[]),g.useEffect(()=>{ie.current=t,ce.current=null;const ae=t?af(t,n):null;L(t,ae)},[e]),g.useEffect(()=>{if(!de||t!==de)return;const ae=af(de,n);ae!==ce.current&&L(de,ae)},[de,t,n]);async function L(ae,Ee=j){const xe=Ne();if(ce.current=Ee,ze(),c(null),p(""),f({}),y(new Set),x(null),k({type:"empty"}),F(null),!ae){R("idle");return}R("loading");try{const Ke=await e.createFileRoot({terminalId:ae});if(!Re(xe))return;c({rootToken:Ke.rootToken,rootPath:Ke.rootPath});const Xe=await e.listFiles({rootToken:Ke.rootToken,path:""});if(!Re(xe))return;M(Xe),R("idle")}catch(Ke){if(await Pe(Ke,xe))return;Re(xe)&&(F(Xn(Ke)),R("idle"))}}async function X(ae=d,Ee=o){if(!Ee)return;const xe=Ne();R("loading"),F(null);try{const Ke=await e.listFiles({rootToken:Ee.rootToken,path:ae});if(!Re(xe))return;M(Ke),R("idle")}catch(Ke){if(await Pe(Ke,xe))return;Re(xe)&&(F(Xn(Ke)),R("idle"))}}async function G(){ie.current=t,await L(t,j)}function M(ae){f(Ee=>({...Ee,[ae.path]:E2(ae.entries)}))}async function V(ae){if(!(!rf(ae)||!o)){if(x(ae),F(null),ae.kind==="directory"){p(ae.path),Ce(),await ve(ae);return}if(p(Rr(ae.path)),ae.editable){await E(ae);return}ae.previewKind!=="none"&&await ee(ae,ae.previewKind)}}async function Q(ae){if(!(!rf(ae)||!o)){if(x(ae),F(null),ae.kind==="directory"){p(ae.path),Ce(),await ve(ae);return}if(p(Rr(ae.path)),ae.editable){await W(ae);return}ae.previewKind!=="none"&&await ee(ae,ae.previewKind)}}async function ve(ae){if(S.has(ae.path)){y(Ee=>{const xe=new Set(Ee);return xe.delete(ae.path),xe});return}y(Ee=>new Set(Ee).add(ae.path)),await X(ae.path)}function Se(ae,Ee){ae.key==="Enter"&&(ae.preventDefault(),Q(Ee))}async function E(ae){if(!o)return;const Ee=Ne();R("loading"),ze();try{const xe=await e.readFile({rootToken:o.rootToken,path:ae.path});if(!Re(Ee))return;k({type:"text-preview",file:ae,read:xe}),R("idle")}catch(xe){if(await Pe(xe,Ee))return;Re(Ee)&&(F(Xn(xe)),R("idle"))}}async function W(ae){if(!o)return;const Ee=Ne();R("loading");try{await a({rootToken:o.rootToken,path:ae.path}),Re(Ee)&&R("idle")}catch(xe){if(await Pe(xe,Ee))return;Re(Ee)&&(F(Xn(xe)),R("idle"))}}async function ee(ae,Ee){if(!o)return;const xe=Ne();R("loading"),ze();try{const Ke=await e.previewFile({rootToken:o.rootToken,path:ae.path});if(!Re(xe))return;const Xe=URL.createObjectURL(Ke);if(!Re(xe)){URL.revokeObjectURL(Xe);return}J.current=Xe,k({type:"preview",file:ae,previewKind:Ee,url:Xe}),R("idle")}catch(Ke){if(await Pe(Ke,xe))return;Re(xe)&&(F(Xn(Ke)),R("idle"))}}async function he(ae){if(!o)return;const Ee=ae==="file"?"New file":"New folder",xe=window.prompt(Ee,""),Ke=b?b.kind==="directory"?b.path:Rr(b.path):d,Xe=Vy(xe,Ke);if(Xe){F(null);try{const gt=await e.createFileEntry({rootToken:o.rootToken,path:Xe,kind:ae});x(gt.entry),await X(Ke)}catch(gt){if(await Pe(gt))return;F(Xn(gt))}}}async function ge(){if(!o||!b)return;const ae=window.prompt("Move selected entry",b.path),Ee=Vy(ae,"");if(!Ee||Ee===b.path)return;const xe=Rr(b.path),Ke=Rr(Ee);F(null);try{const Xe=await e.moveFileEntry({rootToken:o.rootToken,sourcePath:b.path,destinationPath:Ee});x(Xe.entry),p(Xe.entry.kind==="directory"?Xe.entry.path:Rr(Xe.entry.path)),Ce(),await X(xe),Ke!==xe&&await X(Ke)}catch(Xe){if(await Pe(Xe))return;F(Xn(Xe))}}async function me(){if(!o||!b)return;const ae=b.path,Ee=Rr(ae);F(null);try{const xe=await e.previewDeleteFileEntry({rootToken:o.rootToken,path:b.path}),Ke=xe.descendantCount>0?` and ${xe.descendantCount} nested item${xe.descendantCount===1?"":"s"}`:"";if(!window.confirm(`Delete ${xe.path}${Ke}?`))return;await e.deleteFileEntry({rootToken:o.rootToken,path:b.path,previewToken:xe.previewToken}),x(null),p(Ee),y(Xe=>{const gt=new Set(Xe);for(const yt of Xe)(yt===ae||yt.startsWith(`${ae}/`))&&gt.delete(yt);return gt}),Ce(),await X(Ee)}catch(xe){if(await Pe(xe))return;F(Xn(xe))}}function Ce(){I.current+=1,ze(),k({type:"empty"})}function ze(){J.current&&(URL.revokeObjectURL(J.current),J.current=null)}function Ne(){return I.current+=1,I.current}function Re(ae){return q.current&&ae===I.current}async function Pe(ae,Ee){return T2(ae)?(Ee!==void 0&&!Re(Ee)||await L(t,j),!0):!1}function Ye(ae,Ee){const xe=rf(ae),Ke=ae.kind==="directory"&&S.has(ae.path),Xe=m[ae.path]??[],gt={"--file-tree-depth":Ee};return _.jsxs(xi.Fragment,{children:[_.jsxs("button",{type:"button",className:"file-entry-button","data-kind":ae.kind,"data-expanded":Ke,"data-active":H===ae.path,disabled:!xe,style:gt,"aria-expanded":ae.kind==="directory"?Ke:void 0,"aria-label":`${ae.kind==="directory"?"Open folder":"Open file"} ${ae.name}`,title:ae.kind==="directory"?"Expand or collapse folder":"Click to preview. Double-click or press Enter to open.",onClick:()=>{V(ae)},onDoubleClick:()=>{Q(ae)},onKeyDown:yt=>Se(yt,ae),children:[_.jsx("span",{className:"file-entry-disclosure","aria-hidden":"true",children:ae.kind==="directory"?Ke?"▾":"▸":""}),_.jsx("span",{className:"file-entry-name",children:ae.name}),_.jsx("small",{children:x2(ae)})]}),Ke?_.jsx("div",{className:"file-tree-children",role:"group",children:Xe.map(yt=>Ye(yt,Ee+1))}):null]},ae.path)}const Be=m[""]??[];return _.jsxs("section",{className:"file-explorer","aria-label":"Files","aria-busy":B==="loading",children:[_.jsxs("header",{className:"file-explorer-header",children:[_.jsx("div",{className:"file-explorer-path",title:$,children:$||"No active pane"}),_.jsxs("div",{className:"file-explorer-toolbar","aria-label":"File actions",children:[_.jsx("button",{type:"button","aria-label":"Refresh files",title:"Refresh",disabled:!t,onClick:()=>{G()},children:"↻"}),_.jsx("button",{type:"button","aria-label":"New file",title:"New file",disabled:!o,onClick:()=>{he("file")},children:"+"}),_.jsx("button",{type:"button","aria-label":"New folder",title:"New folder",disabled:!o,onClick:()=>{he("directory")},children:"▣"})]})]}),re?_.jsx("div",{className:"file-explorer-alert",role:"alert",children:re}):null,_.jsxs("div",{className:"file-explorer-layout",children:[_.jsx("div",{className:"file-tree","aria-label":$?`Files in ${$}`:"Files",children:Be.map(ae=>Ye(ae,0))}),_.jsxs("section",{className:"file-detail","aria-label":"File detail",children:[_.jsxs("div",{className:"file-detail-header",children:[_.jsx("strong",{children:b?.name??"detail"}),_.jsxs("div",{className:"file-detail-actions",children:[_.jsx("button",{type:"button","aria-label":"Move selected entry",disabled:!b,onClick:()=>{ge()},children:"Move"}),_.jsx("button",{type:"button","aria-label":"Delete selected entry",disabled:!b,onClick:()=>{me()},children:"Delete"})]})]}),B==="loading"?_.jsx("div",{className:"file-detail-empty",children:"loading"}):null,C.type==="empty"&&B!=="loading"?_.jsx("div",{className:"file-detail-empty",children:"No file selected"}):null,C.type==="preview"?_.jsxs("div",{className:"file-preview-frame",children:[C.previewKind==="image"?_.jsx("img",{src:C.url,alt:C.file.name}):null,C.previewKind==="pdf"?_.jsx("iframe",{src:C.url,title:C.file.name}):null]}):null,C.type==="text-preview"&&C.read.language==="markdown"?_.jsx("div",{className:"file-markdown-preview","aria-label":`Preview for ${C.file.name}`,children:_.jsx(g.Suspense,{fallback:_.jsx("div",{className:"file-markdown-preview-loading",children:"loading preview"}),children:_.jsx(w2,{content:C.read.content})})}):null,C.type==="text-preview"&&C.read.language==="text"?_.jsx("pre",{className:"file-text-preview","aria-label":`Preview for ${C.file.name}`,children:C.read.content}):null]})]})]})}function rf(e){return e.kind==="directory"||e.editable||e.previewKind!=="none"}function x2(e){return e.kind==="directory"?"dir":e.editable?"edit":e.previewKind!=="none"?e.previewKind:"unsupported"}function af(e,t){return`${e}\0${t??""}`}function E2(e){return[...e].sort((t,n)=>t.kind==="directory"&&n.kind!=="directory"?-1:t.kind!=="directory"&&n.kind==="directory"?1:t.name.localeCompare(n.name))}function Rr(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function Vy(e,t){if(e===null)return null;const n=e.trim().replace(/^\/+/,"").replace(/\/{2,}/g,"/").replace(/\/$/,"");return n?!t||n.includes("/")?n:`${t}/${n}`:null}function Xn(e){return e instanceof Error?e.message:"Request failed"}function T2(e){return e instanceof yn&&e.status===409&&e.message==="terminal_cwd_changed"}const k2=g.lazy(()=>f0(()=>import("./MarkdownPreview-D8zAIfDx.js"),[]));function Xy({api:e,editor:t,canClose:n,onClose:a}){const[o,c]=g.useState(t.read),[d,p]=g.useState(t.read.content),[m,f]=g.useState("idle"),[S,y]=g.useState(null),[b,x]=g.useState(!1),[C,k]=g.useState("edit"),B=g.useRef(t),R=g.useRef(t.read),re=g.useRef(t.read.content),F=g.useRef(!1),J=g.useRef(!1),ce=g.useRef(0),q=d!==o.content&&m!=="saving"&&!b;g.useEffect(()=>(J.current=!0,()=>{J.current=!1,ce.current+=1}),[]),g.useEffect(()=>{ce.current+=1,F.current=!1,B.current=t,R.current=t.read,re.current=t.read.content,c(t.read),p(t.read.content),f("idle"),y(null),x(!1),k("edit")},[t.id,t.read]),g.useEffect(()=>{B.current=t},[t]),g.useEffect(()=>{R.current=o},[o]),g.useEffect(()=>{re.current=d},[d]),g.useEffect(()=>{if(d===o.content||b)return;const $=window.setInterval(()=>{!F.current&&re.current!==R.current.content&&I()},1e3);return()=>window.clearInterval($)},[d===o.content,b,t.id]);async function I(){if(F.current)return;const $=re.current,H=R.current;if($===H.content)return;const L=B.current,X=ce.current;F.current=!0,f("saving"),y(null),x(!1);try{const G=await e.writeFile({rootToken:L.rootToken,path:L.path,content:$,expectedVersion:H.version});if(!J.current||X!==ce.current)return;const M={...H,content:$,version:G.version};R.current=M,c(M),f(re.current===$?"saved":"idle")}catch(G){if(!J.current||X!==ce.current)return;if(G instanceof yn&&G.status===409){x(!0),f("idle");return}y(D2(G)),f("idle")}finally{X===ce.current&&(F.current=!1)}}const ie=m==="saving"?"saving":m==="saved"?"saved":o.language,de=o.language==="markdown",j=de&&C==="preview";return _.jsxs("section",{className:"editor-pane","aria-label":`Editor pane ${t.title}`,children:[_.jsxs("header",{className:"editor-pane-header",children:[_.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),_.jsx("strong",{children:t.title}),_.jsx("span",{className:"terminal-pane-spacer"}),_.jsx("span",{className:"terminal-pane-state",children:ie}),_.jsx("button",{type:"button","aria-label":`Save ${t.title}`,disabled:!q,onClick:()=>{I()},children:"Save"}),de?_.jsx("button",{type:"button","aria-label":`${j?"Edit":"Preview"} ${t.title}`,onClick:()=>k($=>$==="preview"?"edit":"preview"),children:j?"Edit":"Preview"}):null,n?_.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close editor ${t.title}`,onClick:a,children:"x"}):null]}),S?_.jsx("div",{className:"editor-pane-alert",role:"alert",children:S}):null,b?_.jsx("div",{className:"editor-pane-alert",role:"alert",children:"File changed on disk."}):null,j?_.jsx("div",{className:"editor-markdown-preview","aria-label":`Markdown preview for ${t.title}`,children:_.jsx(g.Suspense,{fallback:_.jsx("div",{className:"editor-markdown-preview-loading",children:"loading preview"}),children:_.jsx(k2,{content:d})})}):_.jsx("textarea",{className:"editor-pane-textarea","aria-label":`Editor for ${t.title}`,spellCheck:!1,value:d,onChange:$=>{const H=$.target.value;re.current=H,p(H),f("idle"),y(null),x(!1)}})]})}function D2(e){return e instanceof Error?e.message:"Request failed"}var R2=2,M2=1,A2=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),a=parseInt(n.getPropertyValue("height")),o=Math.max(0,parseInt(n.getPropertyValue("width"))),c=window.getComputedStyle(this._terminal.element),d={top:parseInt(c.getPropertyValue("padding-top")),bottom:parseInt(c.getPropertyValue("padding-bottom")),right:parseInt(c.getPropertyValue("padding-right")),left:parseInt(c.getPropertyValue("padding-left"))},p=d.top+d.bottom,m=d.right+d.left,f=a-p,S=o-m-t;return{cols:Math.max(R2,Math.floor(S/e.css.cell.width)),rows:Math.max(M2,Math.floor(f/e.css.cell.height))}}};var p0=Object.defineProperty,N2=Object.getOwnPropertyDescriptor,B2=(e,t)=>{for(var n in t)p0(e,n,{get:t[n],enumerable:!0})},Ht=(e,t,n,a)=>{for(var o=a>1?void 0:a?N2(t,n):t,c=e.length-1,d;c>=0;c--)(d=e[c])&&(o=(a?d(t,n,o):d(o))||o);return a&&o&&p0(t,n,o),o},ye=(e,t)=>(n,a)=>t(n,a,e),Gy="Terminal input",Vf={get:()=>Gy,set:e=>Gy=e},Zy="Too much output to announce, navigate to rows manually to read",Xf={get:()=>Zy,set:e=>Zy=e};function L2(e){return e.replace(/\r?\n/g,"\r")}function O2(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function z2(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function j2(e,t,n,a){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");m0(o,t,n,a)}}function m0(e,t,n,a){e=L2(e),e=O2(e,n.decPrivateModes.bracketedPasteMode&&a.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function _0(e,t,n){let a=n.getBoundingClientRect(),o=e.clientX-a.left-10,c=e.clientY-a.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${o}px`,t.style.top=`${c}px`,t.style.zIndex="1000",t.focus()}function Qy(e,t,n,a,o){_0(e,t,n),o&&a.rightClickSelect(e),t.value=a.selectionText,t.select()}function tr(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Au(e,t=0,n=e.length){let a="";for(let o=t;o<n;++o){let c=e[o];c>65535?(c-=65536,a+=String.fromCharCode((c>>10)+55296)+String.fromCharCode(c%1024+56320)):a+=String.fromCharCode(c)}return a}var H2=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let a=0,o=0;if(this._interim){let c=e.charCodeAt(o++);56320<=c&&c<=57343?t[a++]=(this._interim-55296)*1024+c-56320+65536:(t[a++]=this._interim,t[a++]=c),this._interim=0}for(let c=o;c<n;++c){let d=e.charCodeAt(c);if(55296<=d&&d<=56319){if(++c>=n)return this._interim=d,a;let p=e.charCodeAt(c);56320<=p&&p<=57343?t[a++]=(d-55296)*1024+p-56320+65536:(t[a++]=d,t[a++]=p);continue}d!==65279&&(t[a++]=d)}return a}},U2=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let a=0,o,c,d,p,m=0,f=0;if(this.interim[0]){let b=!1,x=this.interim[0];x&=(x&224)===192?31:(x&240)===224?15:7;let C=0,k;for(;(k=this.interim[++C]&63)&&C<4;)x<<=6,x|=k;let B=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,R=B-C;for(;f<R;){if(f>=n)return 0;if(k=e[f++],(k&192)!==128){f--,b=!0;break}else this.interim[C++]=k,x<<=6,x|=k&63}b||(B===2?x<128?f--:t[a++]=x:B===3?x<2048||x>=55296&&x<=57343||x===65279||(t[a++]=x):x<65536||x>1114111||(t[a++]=x)),this.interim.fill(0)}let S=n-4,y=f;for(;y<n;){for(;y<S&&!((o=e[y])&128)&&!((c=e[y+1])&128)&&!((d=e[y+2])&128)&&!((p=e[y+3])&128);)t[a++]=o,t[a++]=c,t[a++]=d,t[a++]=p,y+=4;if(o=e[y++],o<128)t[a++]=o;else if((o&224)===192){if(y>=n)return this.interim[0]=o,a;if(c=e[y++],(c&192)!==128){y--;continue}if(m=(o&31)<<6|c&63,m<128){y--;continue}t[a++]=m}else if((o&240)===224){if(y>=n)return this.interim[0]=o,a;if(c=e[y++],(c&192)!==128){y--;continue}if(y>=n)return this.interim[0]=o,this.interim[1]=c,a;if(d=e[y++],(d&192)!==128){y--;continue}if(m=(o&15)<<12|(c&63)<<6|d&63,m<2048||m>=55296&&m<=57343||m===65279)continue;t[a++]=m}else if((o&248)===240){if(y>=n)return this.interim[0]=o,a;if(c=e[y++],(c&192)!==128){y--;continue}if(y>=n)return this.interim[0]=o,this.interim[1]=c,a;if(d=e[y++],(d&192)!==128){y--;continue}if(y>=n)return this.interim[0]=o,this.interim[1]=c,this.interim[2]=d,a;if(p=e[y++],(p&192)!==128){y--;continue}if(m=(o&7)<<18|(c&63)<<12|(d&63)<<6|p&63,m<65536||m>1114111)continue;t[a++]=m}}return a}},v0="",sr=" ",Co=class g0{constructor(){this.fg=0,this.bg=0,this.extended=new pu}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new g0;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},pu=class y0{constructor(t=0,n=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new y0(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},xs=class S0 extends Co{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new pu,this.combinedData=""}static fromCharData(t){let n=new S0;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?tr(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let n=!1;if(t[1].length>2)n=!0;else if(t[1].length===2){let a=t[1].charCodeAt(0);if(55296<=a&&a<=56319){let o=t[1].charCodeAt(1);56320<=o&&o<=57343?this.content=(a-55296)*1024+o-56320+65536|t[2]<<22:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Jy="di$target",Gf="di$dependencies",lf=new Map;function P2(e){return e[Gf]||[]}function pi(e){if(lf.has(e))return lf.get(e);let t=function(n,a,o){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");K2(t,n,o)};return t._id=e,lf.set(e,t),t}function K2(e,t,n){t[Jy]===t?t[Gf].push({id:e,index:n}):(t[Gf]=[{id:e,index:n}],t[Jy]=t)}var Oi=pi("BufferService"),b0=pi("CoreMouseService"),Pr=pi("CoreService"),I2=pi("CharsetService"),gm=pi("InstantiationService"),w0=pi("LogService"),zi=pi("OptionsService"),C0=pi("OscLinkService"),F2=pi("UnicodeService"),xo=pi("DecorationService"),Zf=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let a=[],o=this._optionsService.rawOptions.linkHandler,c=new xs,d=n.getTrimmedLength(),p=-1,m=-1,f=!1;for(let S=0;S<d;S++)if(!(m===-1&&!n.hasContent(S))){if(n.loadCell(S,c),c.hasExtendedAttrs()&&c.extended.urlId)if(m===-1){m=S,p=c.extended.urlId;continue}else f=c.extended.urlId!==p;else m!==-1&&(f=!0);if(f||m!==-1&&S===d-1){let y=this._oscLinkService.getLinkData(p)?.uri;if(y){let b={start:{x:m+1,y:e},end:{x:S+(!f&&S===d-1?1:0),y:e}},x=!1;if(!o?.allowNonHttpProtocols)try{let C=new URL(y);["http:","https:"].includes(C.protocol)||(x=!0)}catch{x=!0}x||a.push({text:y,range:b,activate:(C,k)=>o?o.activate(C,k,b):q2(C,k),hover:(C,k)=>o?.hover?.(C,k,b),leave:(C,k)=>o?.leave?.(C,k,b)})}f=!1,c.hasExtendedAttrs()&&c.extended.urlId?(m=S,p=c.extended.urlId):(m=-1,p=-1)}}t(a)}};Zf=Ht([ye(0,Oi),ye(1,zi),ye(2,C0)],Zf);function q2(e,t){if(confirm(`Do you want to navigate to ${t}?
15
15
 
16
16
  WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Nu=pi("CharSizeService"),bn=pi("CoreBrowserService"),ym=pi("MouseService"),wn=pi("RenderService"),W2=pi("SelectionService"),x0=pi("CharacterJoinerService"),Ha=pi("ThemeService"),E0=pi("LinkProviderService"),Y2=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?eS.isErrorNoTelemetry(e)?new eS(e.message+`
17
17
 
@@ -41,4 +41,4 @@ WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){t
41
41
  ${m}`:d.header;return{id:`${p}:${qR(f)}`,kind:IR(d.header,m,t),header:d.header,body:m,text:f,searchText:f.toLowerCase()}})}function KR(e,t){const n=mw(e);return n?n==="User"||n===Oa(t)||n==="System"||n==="Tool output"||n.startsWith("Tool call:"):!1}function mw(e){return(e.match(/^\[[^\]\n]+\]\s+(.+)$/)?.[1]??e).trim()||null}function IR(e,t,n){const a=mw(e);return a==="User"?"user":a===Oa(n)?t.startsWith("[tool call:")||t.startsWith("[tool output]")?"tool":"assistant":a==="System"?"system":a==="Tool output"||a?.startsWith("Tool call:")?"tool":"other"}function FR(e){return e.split(`
42
42
  `).length}function qR(e){let t=5381;for(let n=0;n<e.length;n+=1)t=t*33^e.charCodeAt(n);return(t>>>0).toString(36)}function WR(e){let t=0;for(const n of e){if(!n)continue;const a=n.match(/\r\n|\r|\n/g);t+=a?.length??1}return Math.max(1,t)}function ib(e){const t=[];for(const n of e){const a=_w(n);a&&t.push(a)}return t}function _w(e){return e.replace(/\x1b\[\?([0-9;:]*)([hl])/g,(t,n,a)=>{const o=n.split(";").filter(Boolean).filter(c=>!RR.has(c.split(":")[0]??""));return o.length>0?`\x1B[?${o.join(";")}${a}`:""})}function bf(e,t={}){const n={};return(e?.force||t.force)&&(n.force=!0),(e?.scrollToBottom||t.scrollToBottom)&&(n.scrollToBottom=!0),n}function YR(e){const t=e.buffer.active,n=t.baseY+e.rows;return n<=e.rows?null:{current:Math.max(1,Math.min(n,t.viewportY+1)),total:n}}function ir(e){return e.buffer.active.viewportY>=Math.max(0,e.buffer.active.baseY-1)}function $c(e,t){return!t||ir(e)}function sb(e){return ir(e)?!1:(e.scrollToLine(Math.max(0,e.buffer.active.baseY)),!0)}function $R(e,t,n,a,o,c){const d=p=>{const m=XR(p);m!==0&&(p.cancelable&&p.preventDefault(),p.stopPropagation(),VR(t,m,n,a,o,c))};return e.addEventListener("wheel",d,{capture:!0,passive:!1}),()=>{e.removeEventListener("wheel",d,{capture:!0})}}function VR(e,t,n,a,o,c){const d=()=>{o();try{e.scrollLines(t)}finally{c()}n(),t<0&&e.buffer.active.viewportY<=3&&a(t)};if(e.buffer.active.type==="alternate"){e.write(Np,d);return}d()}function XR(e){const n=e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?e.deltaY/24:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*24:e.deltaY;if(n===0)return 0;const a=n<0?Math.floor(n):Math.ceil(n);return Math.max(-30,Math.min(30,a))}function GR(e,t,n,a,o,c,d){let p=null,m=0;const f={passive:!1};function S(x){p=wf(x),m=0}function y(x){const C=wf(x);if(C===null){p=null,m=0;return}if(p===null){p=C;return}const k=C.clientY-p.clientY;if(p=C,x.cancelable&&x.preventDefault(),k===0)return;if(ZR(t)&&QR(t,C,-k)){m=0;return}m-=k/n();const B=m<0?Math.ceil(m):Math.floor(m);if(B!==0){m-=B,c();try{t.scrollLines(B)}finally{d()}a(),B<0&&t.buffer.active.viewportY<=3&&o(B)}}function b(x){if(x.touches.length>0){p=wf(x);return}p=null,m=0}return e.addEventListener("touchstart",S,f),e.addEventListener("touchmove",y,f),e.addEventListener("touchend",b),e.addEventListener("touchcancel",b),()=>{e.removeEventListener("touchstart",S,f),e.removeEventListener("touchmove",y,f),e.removeEventListener("touchend",b),e.removeEventListener("touchcancel",b)}}function wf(e){if(e.touches.length!==1)return null;const t=e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null}function ZR(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function QR(e,t,n){const a=e.element;return a?(a.dispatchEvent(JR(t,n)),!0):!1}function JR(e,t){const n=typeof WheelEvent=="function"?WheelEvent.DOM_DELTA_PIXEL:0,a={bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,deltaX:0,deltaY:t,deltaMode:n};if(typeof WheelEvent=="function")return new WheelEvent("wheel",a);const o=new Event("wheel",a);return Object.defineProperties(o,{clientX:{value:e.clientX},clientY:{value:e.clientY},deltaX:{value:0},deltaY:{value:t},deltaMode:{value:0}}),o}function Bp({node:e,terminals:t,editors:n,api:a,activeTerminalId:o,visible:c=!0,refreshCwdOnEnter:d=!1,tabId:p,dropZoneActive:m=!1,draggingTerminalId:f=null,mobileFocusLeafKey:S=null,path:y=[],totalPanes:b,onSelect:x,onClose:C,onResize:k,onExit:B,onSnapshot:R,onCloseEditor:re,onAuthClose:F}){const J=b??Lp(e);if(y.length===0&&S){const ie=Op(e),de=ie.some(j=>j.key===S)?S:ie[0]?.key;if(ie.length>1&&de)return _.jsx("div",{className:"mobile-focused-split",children:ie.map(j=>{const $=j.key===de;if(j.type==="editor"){const L=n[j.editorId];return _.jsx("div",{className:"mobile-focused-pane","data-active":$,"aria-hidden":!$,children:L?_.jsx(Xy,{api:a,editor:L,canClose:J>1,onClose:()=>re(j.editorId)}):_.jsx("div",{className:"missing-pane",children:"Editor unavailable"})},j.key)}const H=t[j.terminalId];return H?_.jsx("div",{className:"mobile-focused-pane","data-active":$,"aria-hidden":!$,children:_.jsx(eb,{terminal:H,serverApi:a,active:$,visible:c&&$,canClose:J>1,refreshCwdOnEnter:d&&$,tabId:p,onSelect:()=>x(j.terminalId),onClose:()=>C(j.terminalId),onExit:L=>B(j.terminalId,L),onSnapshot:R,...F?{onAuthClose:F}:{}})},j.key):_.jsx("div",{className:"mobile-focused-pane","data-active":$,"aria-hidden":!$,children:_.jsx("div",{className:"missing-pane",children:"Terminal unavailable"})},j.key)})})}if(e.type==="pane"){const ie=t[e.terminalId];if(!ie)return _.jsx("div",{className:"missing-pane",children:"Terminal unavailable"});const de=_.jsx(eb,{terminal:ie,serverApi:a,active:e.terminalId===o,visible:c,canClose:J>1,refreshCwdOnEnter:d&&e.terminalId===o,tabId:p,onSelect:()=>x(e.terminalId),onClose:()=>C(e.terminalId),onExit:$=>B(e.terminalId,$),onSnapshot:R,...F?{onAuthClose:F}:{}});return m&&f!==e.terminalId?_.jsxs("div",{className:"pane-drop-host",children:[de,_.jsx(Vc,{terminalId:e.terminalId,side:"top"}),_.jsx(Vc,{terminalId:e.terminalId,side:"right"}),_.jsx(Vc,{terminalId:e.terminalId,side:"bottom"}),_.jsx(Vc,{terminalId:e.terminalId,side:"left"})]}):de}if(e.type==="editor"){const ie=n[e.editorId];return ie?_.jsx(Xy,{api:a,editor:ie,canClose:J>1,onClose:()=>re(e.editorId)}):_.jsx("div",{className:"missing-pane",children:"Editor unavailable"})}const ce=`${e.ratio*100}%`,q=`${(1-e.ratio)*100}%`,I=e.direction==="vertical"?{gridTemplateColumns:`${ce} 1px ${q}`}:{gridTemplateRows:`${ce} 1px ${q}`};return _.jsxs("div",{className:"split-pane","data-direction":e.direction,style:I,children:[_.jsx("div",{className:"split-cell",children:_.jsx(Bp,{node:e.first,terminals:t,editors:n,api:a,activeTerminalId:o,visible:c,refreshCwdOnEnter:d,tabId:p,dropZoneActive:m,draggingTerminalId:f,mobileFocusLeafKey:S,path:[...y,0],totalPanes:J,onSelect:x,onClose:C,onResize:k,onExit:B,onSnapshot:R,onCloseEditor:re,...F?{onAuthClose:F}:{}})}),_.jsx(eM,{direction:e.direction,path:y,onResize:k}),_.jsx("div",{className:"split-cell",children:_.jsx(Bp,{node:e.second,terminals:t,editors:n,api:a,activeTerminalId:o,visible:c,refreshCwdOnEnter:d,tabId:p,dropZoneActive:m,draggingTerminalId:f,mobileFocusLeafKey:S,path:[...y,1],totalPanes:J,onSelect:x,onClose:C,onResize:k,onExit:B,onSnapshot:R,onCloseEditor:re,...F?{onAuthClose:F}:{}})})]})}function Vc({terminalId:e,side:t}){const{setNodeRef:n,isOver:a}=qb({id:`pane-${e}-${t}`,data:{kind:"pane-zone",terminalId:e,side:t}});return _.jsx("div",{ref:n,className:`pane-drop-zone pane-drop-zone--${t}`,"data-over":a,"aria-hidden":"true"})}function eM({direction:e,path:t,onResize:n}){function a(o){o.preventDefault(),o.stopPropagation();const c=o.currentTarget;c.setPointerCapture?.(o.pointerId),c.classList.add("is-dragging"),document.body.style.cursor=e==="vertical"?"col-resize":"row-resize";const d=c.parentElement;if(!d)return;const p=d.getBoundingClientRect();function m(S){const y=e==="vertical"?(S.clientX-p.left)/p.width:(S.clientY-p.top)/p.height;n(t,Math.min(.9,Math.max(.1,y)))}function f(){window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",f),c.classList.remove("is-dragging"),document.body.style.cursor=""}window.addEventListener("pointermove",m),window.addEventListener("pointerup",f)}return _.jsx("div",{"aria-label":"Resize panes","aria-orientation":e==="vertical"?"vertical":"horizontal",className:"split-divider","data-direction":e,onPointerDown:a,role:"separator",children:_.jsx("span",{className:"split-divider-handle","aria-hidden":"true"})})}function Lp(e){return e.type==="pane"||e.type==="editor"?1:Lp(e.first)+Lp(e.second)}function Op(e){return e.type==="pane"?[{key:tM(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:iM(e.editorId),type:"editor",editorId:e.editorId}]:[...Op(e.first),...Op(e.second)]}function tM(e){return`terminal:${e}`}function iM(e){return`editor:${e}`}const Am="workspace-default",sM="NTerminal";function nM(){return{workspaces:[],activeWorkspaceId:null,terminals:{}}}function rM(e,t){switch(t.type){case"workspace.hydrated":return zp(t.terminals,t.savedTabs,t.savedWorkspaces,t.savedActiveWorkspaceId);case"workspace.created":return aM(e,{id:t.workspaceId,title:t.title});case"workspace.closed":return oM(e,t.workspaceId);case"workspace.selected":return vw(e,t.workspaceId);case"workspace.renamed":return lM(e,t.workspaceId,t.title);case"terminal.created":return gw(e,t.terminal);case"terminal.split":return cM(e,t.terminal,t.direction);case"terminal.updated":return bM(e,t.terminal);case"terminal.exited":return wM(e,t.terminalId,t.exitCode);case"terminal.closed":return Sw(e,t.terminalId);case"terminal.detached":return CM(e,t.terminalId);case"editor.split":return uM(e,t.editorId,t.title,t.direction);case"editor.closed":return xM(e,t.editorId);case"pane.selected":return vM(e,t.terminalId);case"pane.resized":return gM(e,t.path,t.ratio);case"tab.selected":return dM(e,t.tabId);case"tab.renamed":return _M(e,t.tabId,t.title);case"tab.reordered":return yw(e,t.sourceTabId,t.targetIndex);case"tab.dropped_into_pane":return fM(e,t.sourceTabId,t.sourceTerminalId,t.targetTerminalId,t.side);case"terminal.extracted_to_tab":return pM(e,t.sourceTabId,t.sourceTerminalId,t.targetIndex);case"activePane.closed":return hM(e);default:return e}}function aM(e,t){if(e.workspaces.some(a=>a.id===t.id))return vw(e,t.id);const n={id:t.id,title:t.title,tabs:[],activeTabId:null};return{...e,workspaces:[...e.workspaces,n],activeWorkspaceId:n.id}}function vw(e,t){return e.workspaces.some(n=>n.id===t)?{...e,activeWorkspaceId:t}:e}function lM(e,t,n){const a=n.trim();if(!a)return e;let o=!1;const c=e.workspaces.map(d=>d.id!==t||d.title===a?d:(o=!0,{...d,title:a}));return o?{...e,workspaces:c}:e}function oM(e,t){if(e.workspaces.length<=1||!e.workspaces.some(p=>p.id===t))return e;const n=e.workspaces.find(p=>p.id===t),a=new Set(n?SM(n):[]),o={...e.terminals};for(const p of a)delete o[p];const c=e.workspaces.filter(p=>p.id!==t),d=e.activeWorkspaceId===t?c[0]?.id??null:e.activeWorkspaceId;return{workspaces:c,activeWorkspaceId:d,terminals:o}}function gw(e,t){const n=ww(e),a=Kr(n)??ju(),o=Cw(t);return{...n,activeWorkspaceId:a.id,terminals:{...n.terminals,[t.id]:t},workspaces:n.workspaces.map(c=>c.id===a.id?{...c,tabs:[...c.tabs,o],activeTabId:o.id}:c)}}function cM(e,t,n){const a=Kr(e),o=a?zu(a):void 0;if(!a||!o)return gw(e,t);const c=o.activeTerminalId,d=fo(o.root,c,{type:"split",direction:n,ratio:.5,first:{type:"pane",terminalId:c},second:{type:"pane",terminalId:t.id}});return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(p=>p.id===a.id?{...p,tabs:p.tabs.map(m=>m.id===o.id?{...m,root:d,activeTerminalId:t.id}:m)}:p)}}function uM(e,t,n,a){const o=Kr(e),c=o?zu(o):void 0;if(!o||!c)return e;const d=c.activeTerminalId,p=fo(c.root,d,{type:"split",direction:a,ratio:.5,first:{type:"pane",terminalId:d},second:{type:"editor",editorId:t,title:n}});return{...e,workspaces:e.workspaces.map(m=>m.id===o.id?{...m,tabs:m.tabs.map(f=>f.id===c.id?{...f,root:p,activeTerminalId:d}:f)}:m)}}function hM(e){const t=Kr(e),n=t?zu(t):void 0;return n?Sw(e,n.activeTerminalId):e}function dM(e,t){const n=Kr(e);return!n||!n.tabs.some(a=>a.id===t)?e:{...e,workspaces:e.workspaces.map(a=>a.id===n.id?{...a,activeTabId:t}:a)}}function yw(e,t,n){const a=e.workspaces.map(o=>{const c=o.tabs.findIndex(S=>S.id===t);if(c<0)return o;const d=o.tabs.slice(),[p]=d.splice(c,1);if(!p)return o;const m=Math.max(0,Math.min(d.length,n)),f=d.slice();return f.splice(m,0,p),mM(o.tabs,f)?o:{...o,tabs:f}});return a.every((o,c)=>o===e.workspaces[c])?e:{...e,workspaces:a}}function fM(e,t,n,a,o){if(n===a||!e.terminals[n]||!e.terminals[a])return e;let c=e.workspaces.map(m=>{const f=m.tabs.findIndex(C=>C.id===t);if(f<0)return m;const S=m.tabs[f];if(!S)return m;const y=po(S.root,n);if(!y){const C=m.tabs.filter((k,B)=>B!==f);return{...m,tabs:C}}const b={...S,root:y,activeTerminalId:Es(y)[0]??S.activeTerminalId},x=m.tabs.slice();return x[f]=b,{...m,tabs:x}});const d=o==="left"||o==="right"?"vertical":"horizontal",p=o==="left"||o==="top";return c=c.map(m=>{const f=m.tabs.findIndex(k=>Es(k.root).includes(a));if(f<0)return m;const S=m.tabs[f];if(!S)return m;const y={type:"pane",terminalId:n},b={type:"split",direction:d,ratio:.5,first:p?y:{type:"pane",terminalId:a},second:p?{type:"pane",terminalId:a}:y},x=fo(S.root,a,b),C=m.tabs.slice();return C[f]={...S,root:x,activeTerminalId:n},{...m,tabs:C,activeTabId:S.id}}),ww({...e,workspaces:c})}function pM(e,t,n,a){let o=-1,c=-1;for(let B=0;B<e.workspaces.length;B+=1){const R=e.workspaces[B].tabs.findIndex(re=>re.id===t);if(R>=0){o=B,c=R;break}}if(o<0)return e;const d=e.workspaces[o],p=d.tabs[c],m=Es(p.root);if(!m.includes(n))return e;if(m.length===1)return yw(e,t,a);const f=po(p.root,n);if(!f)return e;const S={...p,root:f,activeTerminalId:Es(f)[0]??p.activeTerminalId},y=e.terminals[n],b={id:`tab-${Date.now().toString(36)}-${n.slice(0,8)}`,title:y?.title??"",activeTerminalId:n,root:{type:"pane",terminalId:n}},x=d.tabs.slice();x[c]=S;const C=Math.max(0,Math.min(x.length,a));x.splice(C,0,b);const k=e.workspaces.slice();return k[o]={...d,tabs:x,activeTabId:b.id},{...e,workspaces:k}}function mM(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]?.id!==t[n]?.id)return!1;return!0}function _M(e,t,n){const a=n.trim();if(!a)return e;let o=!1;const c=e.workspaces.map(d=>{let p=!1;const m=d.tabs.map(f=>f.id!==t||f.title===a?f:(o=!0,p=!0,{...f,title:a}));return p?{...d,tabs:m}:d});return o?{...e,workspaces:c}:e}function vM(e,t){const n=e.workspaces.find(o=>o.tabs.some(c=>mo(c.root,t))),a=n?.tabs.find(o=>mo(o.root,t));return!n||!a?e:{...e,activeWorkspaceId:n.id,workspaces:e.workspaces.map(o=>o.id===n.id?{...o,activeTabId:a.id,tabs:o.tabs.map(c=>c.id===a.id?{...c,activeTerminalId:t}:c)}:o)}}function gM(e,t,n){const a=Kr(e),o=a?zu(a):void 0;if(!a||!o)return e;const c=Kp(o.root,t,xw(n));return c===o.root?e:{...e,workspaces:e.workspaces.map(d=>d.id===a.id?{...d,tabs:d.tabs.map(p=>p.id===o.id?{...p,root:c}:p)}:d)}}function zp(e,t,n,a){const o=Object.fromEntries(e.map(S=>[S.id,S])),c=new Set(e.map(S=>S.id)),d=new Set;let p=EM(t,n,c,d);p.length===0&&(p=[ju()]);const m=typeof a=="string"&&p.some(S=>S.id===a)?a:p[0]?.id??null,f=m??p[0]?.id??Am;for(const S of e){if(d.has(S.id))continue;const y=Cw(S);p=TM(p,f,y),d.add(S.id)}return{workspaces:p.map(Do),activeWorkspaceId:m,terminals:o}}function Nm(e){return Es(e.root)}function yM(e){return Ip(e.root)}function SM(e){return e.tabs.flatMap(t=>Es(t.root))}function Cf(e){const t=e.workspaces.map(n=>{const a=n.tabs.flatMap(o=>{const c=Up(o.root);return c?[{...o,root:c}]:[]});return Do({...n,tabs:a})});return{activeWorkspaceId:t.some(n=>n.id===e.activeWorkspaceId)?e.activeWorkspaceId:t[0]?.id??null,workspaces:t}}function bM(e,t){return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(n=>({...n,tabs:n.tabs.map(a=>mo(a.root,t.id)?{...a,title:a.title||t.title}:a)}))}}function wM(e,t,n){const a=e.terminals[t];return a?{...e,terminals:{...e.terminals,[t]:{...a,status:"exited",exitCode:n}}}:e}function Sw(e,t){const n={...e.terminals};return delete n[t],bw(e,t,n)}function CM(e,t){return e.terminals[t]?bw(e,t,{...e.terminals}):e}function bw(e,t,n){const a=e.workspaces.map(c=>{const d=[];for(const p of c.tabs){const m=po(p.root,t);if(!m)continue;const f=Es(m),S=f.includes(p.activeTerminalId)?p.activeTerminalId:f[0];S&&d.push({...p,root:m,activeTerminalId:S})}return Do({...c,tabs:d})}),o=a.some(c=>c.id===e.activeWorkspaceId);return{workspaces:a,activeWorkspaceId:o?e.activeWorkspaceId:a[0]?.id??null,terminals:n}}function xM(e,t){const n=e.workspaces.map(o=>{const c=[];for(const d of o.tabs){const p=jp(d.root,t);if(!p)continue;const m=Es(p),f=m.includes(d.activeTerminalId)?d.activeTerminalId:m[0];f&&c.push({...d,root:p,activeTerminalId:f})}return Do({...o,tabs:c})}),a=n.some(o=>o.id===e.activeWorkspaceId);return{...e,workspaces:n,activeWorkspaceId:a?e.activeWorkspaceId:n[0]?.id??null}}function EM(e,t,n,a){if(t&&t.length>0){const o=[];for(const c of t)kM(c)&&o.push(nb(c,n,a));if(o.length>0)return o}return[nb({...ju(),tabs:e??[]},n,a)]}function nb(e,t,n){const a=[];for(const o of e.tabs){if(!DM(o))continue;const c=Hp(o.root,t);if(!c)continue;const d=Es(c);for(const m of d)n.add(m);const p=d.includes(o.activeTerminalId)?o.activeTerminalId:d[0];p&&a.push({...o,root:c,activeTerminalId:p})}return Do({...e,tabs:a})}function ww(e){return Kr(e)?e:{...e,workspaces:[ju()],activeWorkspaceId:Am}}function Kr(e){return e.workspaces.find(t=>t.id===e.activeWorkspaceId)??e.workspaces[0]}function zu(e){return e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[0]}function ju(){return{id:Am,title:sM,tabs:[],activeTabId:null}}function Do(e){const t=e.tabs.some(n=>n.id===e.activeTabId);return{...e,activeTabId:t?e.activeTabId:e.tabs[0]?.id??null}}function TM(e,t,n){return e.map(a=>a.id===t?{...a,tabs:[...a.tabs,n],activeTabId:a.activeTabId??n.id}:a)}function Cw(e){return{id:`tab-${e.id}`,title:e.title||e.id,root:{type:"pane",terminalId:e.id},activeTerminalId:e.id}}function fo(e,t,n){return e.type==="pane"?e.terminalId===t?n:e:e.type==="editor"?e:{...e,first:fo(e.first,t,n),second:fo(e.second,t,n)}}function po(e,t){if(e.type==="pane")return e.terminalId===t?null:e;if(e.type==="editor")return e;const n=po(e.first,t),a=po(e.second,t);return n&&a?{...e,first:n,second:a}:n??a}function jp(e,t){if(e.type==="editor")return e.editorId===t?null:e;if(e.type==="pane")return e;const n=jp(e.first,t),a=jp(e.second,t);return n&&a?{...e,first:n,second:a}:n??a}function Hp(e,t){if(e.type==="pane")return t.has(e.terminalId)?e:null;if(e.type==="editor")return null;const n=Hp(e.first,t),a=Hp(e.second,t);return n&&a?{...e,ratio:xw(e.ratio),first:n,second:a}:n??a}function Up(e){if(e.type==="editor")return null;if(e.type==="pane")return e;const t=Up(e.first),n=Up(e.second);return t&&n?{...e,first:t,second:n}:t??n}function kM(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.title=="string"&&(typeof t.activeTabId=="string"||t.activeTabId===null)&&Array.isArray(t.tabs)}function DM(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.title=="string"&&typeof t.activeTerminalId=="string"&&Pp(t.root)}function Pp(e){if(!e||typeof e!="object")return!1;const t=e;return t.type==="pane"?typeof t.terminalId=="string":t.type==="editor"?typeof t.editorId=="string"&&typeof t.title=="string":t.type==="split"?(t.direction==="horizontal"||t.direction==="vertical")&&Pp(t.first)&&Pp(t.second):!1}function Kp(e,t,n){if(e.type==="pane"||e.type==="editor")return e;if(t.length===0)return e.ratio===n?e:{...e,ratio:n};const[a,...o]=t;if(a===0){const c=Kp(e.first,o,n);return c===e.first?e:{...e,first:c}}if(a===1){const c=Kp(e.second,o,n);return c===e.second?e:{...e,second:c}}return e}function xw(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function mo(e,t){return e.type==="pane"?e.terminalId===t:e.type==="editor"?!1:mo(e.first,t)||mo(e.second,t)}function Es(e){return e.type==="pane"?[e.terminalId]:e.type==="editor"?[]:[...Es(e.first),...Es(e.second)]}function Ip(e){return e.type==="pane"||e.type==="editor"?1:Ip(e.first)+Ip(e.second)}const ur=new Map,_o=new Map,vo=new Map;function Pa(e){return e??"__local__"}function RM(e){return{agentId:e,state:nM(),editors:{},loaded:!1,error:null,layoutRevision:null,lastPersistedLayoutJson:null,unreadCompletions:new Set,mutable:{editorIdCounter:0,saveCoord:{pendingLayoutSave:null,saveTimer:null,persistChain:Promise.resolve(),nextPersistQueued:!1,nextPersistLayout:null,queuedBaseRevision:void 0}}}}function Ft(e){const t=Pa(e);let n=ur.get(t);return n||(n=RM(e),ur.set(t,n)),n}function Ew(e,t){const n=Pa(e);let a=_o.get(n);return a||(a=new Set,_o.set(n,a)),a.add(t),()=>{a.delete(t)}}function MM(e){const t=Pa(e),n=_o.get(t);if(n)for(const a of Array.from(n))a()}function Ka(e,t){ur.set(Pa(e),t),MM(e)}const Fp=new Set;function AM(e){return Fp.add(e),()=>{Fp.delete(e)}}function Ul(e,t){const n=Ft(e),a=Pa(e);t.type==="workspace.hydrated"&&vo.delete(a);const o=rM(n.state,t);let c=n.unreadCompletions,d=null;if(t.type==="terminal.updated"){const f=n.state.terminals[t.terminal.id],S=f?.activity==="busy",y=t.terminal.activity==="busy",b=t.terminal.activity==="idle",x=HM(a);if(t.notifyCompletion===!0&&y&&x.add(t.terminal.id),t.notifyCompletion===!0&&S&&b&&x.has(t.terminal.id)){const C=NM(o,t.terminal.id);C&&(d={terminalId:t.terminal.id,tabId:C.tab.id,commandName:f?.currentCommand??null},C.workspace.activeTabId!==C.tab.id&&(c.has(C.tab.id)||(c=new Set(c),c.add(C.tab.id))))}(b||t.terminal.status==="exited")&&x.delete(t.terminal.id)}t.type==="tab.selected"&&c.has(t.tabId)&&(c=new Set(c),c.delete(t.tabId));const p=o!==n.state,m=c!==n.unreadCompletions;if((p||m)&&Ka(e,{...n,state:o,unreadCompletions:c}),m&&Bm(),d)for(const f of Array.from(Fp))f({agentId:e,...d})}function NM(e,t){for(const n of e.workspaces)for(const a of n.tabs)if(Es(a.root).includes(t))return{workspace:n,tab:a};return null}const qp=new Set;function BM(e){return qp.add(e),()=>{qp.delete(e)}}function LM(){let e=0;for(const t of ur.values())e+=t.unreadCompletions.size;return e}function Bm(){for(const e of Array.from(qp))e()}function OM(e,t){const n=Ft(e);if(!n.unreadCompletions.has(t))return;const a=new Set(n.unreadCompletions);a.delete(t),Ka(e,{...n,unreadCompletions:a}),Bm()}function rb(e,t){const n=Ft(e);t!==n.state&&Ka(e,{...n,state:t})}function ab(e,t){const n=Ft(e),a=t(n.editors);a!==n.editors&&Ka(e,{...n,editors:a})}function Ta(e,t,n){const a=Ft(e);a.loaded===t&&a.error===n||Ka(e,{...a,loaded:t,error:n})}function Xc(e,t,n){const a=Ft(e);a.layoutRevision===t&&a.lastPersistedLayoutJson===n||Ka(e,{...a,layoutRevision:t,lastPersistedLayoutJson:n})}function zM(e){const t=Ft(e);return t.mutable.editorIdCounter+=1,t.mutable.editorIdCounter}function jM(e){const t=Pa(e),n=ur.get(t);n&&n.mutable.saveCoord.saveTimer!==null&&window.clearTimeout(n.mutable.saveCoord.saveTimer);const a=n?n.unreadCompletions.size>0:!1;ur.delete(t),_o.delete(t),vo.delete(t),a&&Bm()}function lb(){for(const e of ur.values()){const t=e.mutable.saveCoord.saveTimer;t!==null&&window.clearTimeout(t),e.unreadCompletions.size>0}ur.clear(),_o.clear(),vo.clear()}function HM(e){let t=vo.get(e);return t||(t=new Set,vo.set(e,t)),t}function UM(e,t){let n=!1,a=!1,o=null,c=!1;for(const d of Nm(e)){const p=t[d];if(p){if(p.status==="exited"){c=!0,n=!0;continue}p.activity==="busy"?(a=!0,n=!0,!o&&p.currentCommand&&(o=p.currentCommand)):p.activity==="idle"&&(n=!0)}}return n?c?{state:"exited",commandName:null}:a?{state:"busy",commandName:o}:{state:"idle",commandName:null}:null}function PM(e){return e?e.state==="busy"?e.commandName?`running: ${e.commandName}`:"running":e.state==="exited"?"exited":"idle":""}function KM({tabs:e,activeTabId:t,terminals:n,unreadCompletionTabIds:a,detachedTerminals:o,onSelectTab:c,onCreateTab:d,onToggleWorkspaces:p,onCloseTerminals:m,onReattachTerminal:f,onDeleteTerminal:S,onSplitVertical:y,onSplitHorizontal:b,onRenameTab:x,activePaneAvailable:C}){const[k,B]=g.useState(null),[R,re]=g.useState(null),F=g.useRef(null);g.useEffect(()=>{F.current?.focus(),F.current?.select()},[k?.tabId]);function J(I,ie){B({tabId:I,title:ie})}function ce(){if(!k)return;const I=k.title.trim();I&&x(k.tabId,I),B(null)}function q(){return _.jsxs("div",{className:"terminal-pane-actions","aria-label":"Pane actions",children:[_.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split right",title:`Split right - ${YE()}`,onClick:y,disabled:!C,children:_.jsx("span",{className:"split-icon split-icon-right","aria-hidden":"true"})}),_.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split down",title:`Split down - ${$E()}`,onClick:b,disabled:!C,children:_.jsx("span",{className:"split-icon split-icon-down","aria-hidden":"true"})})]})}return _.jsxs(_.Fragment,{children:[_.jsxs("nav",{className:"terminal-tabs","aria-label":"Terminal tabs",children:[_.jsx("button",{type:"button",className:"mobile-menu-button","aria-label":"Toggle workspaces",title:"Workspaces",onClick:p,children:_.jsxs("span",{className:"hamburger-lines","aria-hidden":"true",children:[_.jsx("span",{}),_.jsx("span",{}),_.jsx("span",{})]})}),_.jsxs("div",{className:"terminal-tab-list",children:[e.map((I,ie)=>{const de=Nm(I),j=yM(I),$=n[I.activeTerminalId],H=I.title||$?.title||I.activeTerminalId,L=I.id===t,X=k?.tabId===I.id,G=UM(I,n),M=a?.has(I.id)??!1;return _.jsxs(xi.Fragment,{children:[_.jsx(ob,{index:ie}),_.jsx(IM,{tab:I,active:L,editing:X,title:H,paneCount:j,terminalIds:de,canClose:e.length>1,editValue:X?k.title:null,editInputRef:X?F:null,activity:G,unread:M,onSelect:()=>c(I.id),onBeginRename:()=>J(I.id,H),onCloseAll:()=>m(de),onCommitRename:ce,onCancelRename:()=>B(null),onRenameChange:V=>B({tabId:I.id,title:V})})]},I.id)}),_.jsx(ob,{index:e.length}),_.jsx("button",{type:"button",className:"tab-add-button","aria-label":"New tab",title:"New tab",onClick:d,children:"+"}),(o?.length??0)>0?_.jsx("div",{className:"terminal-detached-pills","aria-label":"Detached terminals",children:(o??[]).map(I=>_.jsx(FM,{terminal:I,onReattach:()=>f?.(I.id),onDelete:()=>re(I)},I.id))}):null]}),C?q():null]}),R?_.jsx(qM,{terminal:R,onCancel:()=>re(null),onConfirm:()=>{S?.(R.id),re(null)}}):null]})}function IM({tab:e,active:t,editing:n,title:a,paneCount:o,canClose:c,editValue:d,editInputRef:p,activity:m,unread:f,onSelect:S,onBeginRename:y,onCloseAll:b,onCommitRename:x,onCancelRename:C,onRenameChange:k}){const{attributes:B,listeners:R,setNodeRef:re,transform:F,isDragging:J}=Fb({id:`tab-${e.id}`,data:{kind:"tab",tabId:e.id,terminalId:e.activeTerminalId},disabled:n}),ce={transform:Tf.Translate.toString(F),opacity:J?.4:void 0,zIndex:J?2:void 0};return _.jsxs("div",{ref:re,className:"terminal-tab","data-active":t,"data-dragging":J,"data-unread":f?"true":void 0,style:ce,...B,...R,children:[m?_.jsx("span",{className:"terminal-tab-status-dot","data-activity":m.state,"aria-hidden":"true",title:PM(m)}):null,n&&p&&d!==null?_.jsxs("form",{className:"terminal-tab-editor",onSubmit:q=>{q.preventDefault(),x()},children:[_.jsx("input",{ref:p,"aria-label":`Rename ${a}`,value:d,onBlur:x,onChange:q=>k(q.target.value),onKeyDown:q=>{if(q.key==="Enter"){q.preventDefault(),x();return}q.key==="Escape"&&(q.preventDefault(),C())}}),_.jsx("small",{children:o})]}):_.jsxs("button",{type:"button",className:"terminal-tab-select","aria-label":`Select ${a}`,title:a,onClick:S,onDoubleClick:q=>{q.preventDefault(),y()},children:[_.jsx("span",{children:a}),_.jsxs("small",{children:[o," pane",o===1?"":"s"]})]}),c&&!n?_.jsx("button",{type:"button",className:"icon-button","aria-label":`Close ${a}`,title:`Close ${a}`,onPointerDown:q=>q.stopPropagation(),onClick:q=>{q.stopPropagation(),b()},children:"x"}):null]})}function ob({index:e}){const{setNodeRef:t,isOver:n}=qb({id:`tab-position-${e}`,data:{kind:"tab-position",index:e}});return _.jsx("div",{ref:t,className:"terminal-tab-drop-slot","data-over":n,"aria-hidden":"true"})}function FM({terminal:e,onReattach:t,onDelete:n}){const a=e.title||e.cwd||e.id.slice(0,8),o=`${e.title||"Terminal"}
43
43
  ${e.cwd}
44
- (detached — click to re-open, × to delete)`;return _.jsxs("span",{className:"terminal-detached-pill",title:o,children:[_.jsx("button",{type:"button",className:"terminal-detached-pill-open","aria-label":`Re-open ${a}`,onClick:t,children:a}),_.jsx("button",{type:"button",className:"terminal-detached-pill-delete","aria-label":`Delete ${a}`,title:`Delete ${a} — this destroys the underlying shell session.`,onClick:c=>{c.stopPropagation(),n()},children:"×"})]})}function qM({terminal:e,onCancel:t,onConfirm:n}){const a=e.title||e.cwd||e.id.slice(0,8);return _.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"delete-terminal-title",onClick:t,children:_.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:o=>o.stopPropagation(),children:[_.jsxs("header",{className:"security-panel-header",children:[_.jsx("h2",{id:"delete-terminal-title",children:"Delete Terminal"}),_.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:t,children:"×"})]}),_.jsxs("section",{className:"terminal-delete-dialog-body",children:[_.jsx("p",{children:"Delete this terminal?"}),_.jsx("span",{children:a}),_.jsx("small",{children:"The shell session and scrollback will be destroyed."})]}),_.jsxs("div",{className:"terminal-delete-dialog-actions",children:[_.jsx("button",{type:"button",className:"secondary-button",onClick:t,children:"Cancel"}),_.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:n,children:"Delete"})]})]})})}function WM({uploads:e,onDismiss:t,onDismissAll:n,onRetry:a,onCancel:o}){if(e.length===0)return null;const d=e.some(m=>m.status==="failed"||m.status==="partial")?"alert":"status",p=e.filter(m=>m.status==="queued"||m.status==="uploading").length;return _.jsxs("aside",{className:`upload-toast upload-toast-${GM(e)}`,role:d,"aria-live":d==="alert"?"assertive":"polite",children:[_.jsxs("header",{className:"upload-toast-header",children:[_.jsx("strong",{children:e.length===1?su(e[0]):`Uploads ${p>0?`(${p} active)`:`(${e.length})`}`}),_.jsx("button",{type:"button","aria-label":"Dismiss upload status",onClick:n,children:"x"})]}),_.jsx("div",{className:"upload-toast-body upload-queue-body",children:e.map(m=>_.jsx(YM,{upload:m,compact:e.length>1,onDismiss:()=>t(m.id),onRetry:()=>a(m.id),onCancel:()=>o(m.id)},m.id))})]})}function YM({upload:e,compact:t,onDismiss:n,onRetry:a,onCancel:o}){const c="response"in e?e.response:void 0,d=e.status==="failed"||e.status==="partial",p=e.status==="queued"||e.status==="uploading";return _.jsxs("section",{className:"upload-queue-item","data-status":e.status,"aria-label":su(e),children:[_.jsxs("div",{className:"upload-queue-item-header",children:[_.jsx("strong",{children:su(e)}),_.jsxs("div",{className:"upload-queue-actions",children:[p?_.jsx("button",{type:"button",onClick:o,children:"Cancel"}):null,d?_.jsx("button",{type:"button",onClick:a,children:"Retry"}):null,_.jsx("button",{type:"button","aria-label":`Dismiss ${su(e)}`,onClick:n,children:"x"})]})]}),e.status==="queued"?_.jsx("p",{children:e.message??"Queued"}):null,e.status==="uploading"?_.jsx($M,{toast:e}):null,c&&"message"in e&&e.message?_.jsx("p",{className:"upload-toast-muted",children:e.message}):null,c?_.jsx(VM,{response:c,compact:t}):null,e.status==="failed"&&!c&&e.message?_.jsx("p",{children:e.message}):null]})}function $M({toast:e}){const t=e.percent===null?ZM(e.loaded):`${e.percent}%`;return _.jsxs(_.Fragment,{children:[_.jsxs("div",{className:"upload-progress-row",children:[_.jsxs("span",{children:[e.fileCount," file",e.fileCount===1?"":"s"]}),_.jsx("span",{children:t})]}),_.jsx("div",{className:"upload-progress-track","aria-hidden":"true",children:_.jsx("span",{style:{width:e.percent===null?"100%":`${e.percent}%`}})})]})}function VM({response:e,compact:t}){const n=e.results.filter(d=>d.status==="failed"),a=e.results.filter(d=>d.status==="uploaded"),o=t?3:6,c=[...n,...a].slice(0,o);return _.jsxs(_.Fragment,{children:[_.jsx("p",{className:"upload-toast-destination",children:e.destinationCwd}),c.length>0?_.jsx("ul",{className:"upload-result-list",children:c.map((d,p)=>_.jsx(XM,{result:d},`${d.relativePath}-${p}`))}):null,e.results.length>c.length?_.jsxs("p",{className:"upload-toast-muted",children:["+",e.results.length-c.length," more"]}):null]})}function XM({result:e}){const t=e.savedRelativePath??e.relativePath,n=e.status==="uploaded"&&e.savedRelativePath!==void 0&&e.savedRelativePath!==e.relativePath;return _.jsxs("li",{"data-status":e.status,children:[_.jsx("span",{className:"upload-result-path",children:t}),n?_.jsx("span",{className:"upload-result-renamed",children:"renamed"}):null,e.status==="failed"&&e.error?_.jsx("span",{className:"upload-result-error",children:e.error}):null]})}function su(e){if(e.status==="queued")return"Preparing upload";if(e.status==="uploading")return`Uploading ${e.fileCount} file${e.fileCount===1?"":"s"}`;if(e.status==="success"){const t=e.response?.uploaded??e.fileCount;return`Uploaded ${t} file${t===1?"":"s"}`}if(e.status==="partial"){const t=e.response?.uploaded??0,n=(e.response?.uploaded??0)+(e.response?.failed??0)||e.fileCount;return`Uploaded ${t} of ${n} files`}return"Upload failed"}function GM(e){return e.some(t=>t.status==="failed")?"failed":e.some(t=>t.status==="partial")?"partial":e.some(t=>t.status==="uploading")?"uploading":e.some(t=>t.status==="queued")?"queued":"success"}function ZM(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${Math.round(e/(1024*1024))} MB`}function QM({toast:e,onActivate:t,onDismiss:n}){if(!e)return null;const a=e,o=a.commandName?`${a.commandName} finished`:"Command finished";function c(p){p.stopPropagation(),n()}function d(p){p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),t(a))}return _.jsxs("aside",{className:"completion-toast",role:"status","aria-live":"polite",tabIndex:0,onClick:()=>t(a),onKeyDown:d,children:[_.jsx("video",{className:"completion-toast-character",src:a.assetSrc,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),_.jsxs("div",{className:"completion-toast-copy",children:[_.jsx("strong",{children:a.tabTitle}),_.jsx("span",{children:o})]}),_.jsx("button",{type:"button","aria-label":"Dismiss completion alert",onClick:c,children:"x"})]})}const JM=Xl(0,0,1,1),vn=1e-6;function eA(e){return Tw(e).map(t=>t.terminalId)}function Tw(e){return Vl(e,JM).sort(nA).map((t,n)=>({...t,index:n+1}))}function tA(e,t,n){const a=Tw(e),o=a.find(d=>d.terminalId===t);return o?a.filter(d=>d.terminalId!==t).map(d=>sA(o,d,n)).filter(d=>d!==null).sort(rA)[0]?.entry.terminalId??null:null}function iA(e,t){return!Number.isInteger(t)||t<1?null:eA(e)[t-1]??null}function Vl(e,t){if(e.type==="pane")return[{terminalId:e.terminalId,bounds:t}];if(e.type==="editor")return[];const n=aA(e.ratio);if(e.direction==="vertical"){const o=t.left+(t.right-t.left)*n;return[...Vl(e.first,Xl(t.left,t.top,o,t.bottom)),...Vl(e.second,Xl(o,t.top,t.right,t.bottom))]}const a=t.top+(t.bottom-t.top)*n;return[...Vl(e.first,Xl(t.left,t.top,t.right,a)),...Vl(e.second,Xl(t.left,a,t.right,t.bottom))]}function sA(e,t,n){const a=e.bounds,o=t.bounds,c=cb(a.left,a.right,o.left,o.right),d=cb(a.top,a.bottom,o.top,o.bottom);switch(n){case"left":return o.centerX>=a.centerX-vn||d<=vn?null:{entry:t,primaryDistance:Math.max(0,a.left-o.right),perpendicularDistance:Math.abs(a.centerY-o.centerY),overlap:d};case"right":return o.centerX<=a.centerX+vn||d<=vn?null:{entry:t,primaryDistance:Math.max(0,o.left-a.right),perpendicularDistance:Math.abs(a.centerY-o.centerY),overlap:d};case"up":return o.centerY>=a.centerY-vn||c<=vn?null:{entry:t,primaryDistance:Math.max(0,a.top-o.bottom),perpendicularDistance:Math.abs(a.centerX-o.centerX),overlap:c};case"down":return o.centerY<=a.centerY+vn||c<=vn?null:{entry:t,primaryDistance:Math.max(0,o.top-a.bottom),perpendicularDistance:Math.abs(a.centerX-o.centerX),overlap:c};default:return null}}function nA(e,t){return Ma(e.bounds.top,t.bounds.top)||Ma(e.bounds.left,t.bounds.left)}function rA(e,t){return Ma(e.primaryDistance,t.primaryDistance)||Ma(e.perpendicularDistance,t.perpendicularDistance)||Ma(t.overlap,e.overlap)||Ma(e.entry.index,t.entry.index)}function Ma(e,t){const n=e-t;return Math.abs(n)<=vn?0:n}function cb(e,t,n,a){return Math.max(0,Math.min(t,a)-Math.max(e,n))}function Xl(e,t,n,a){return{left:e,top:t,right:n,bottom:a,centerX:e+(n-e)/2,centerY:t+(a-t)/2}}function aA(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}class lA extends Error{constructor(t){super(t),this.name="UploadDropError"}}function ub(e){return e?Array.from(e.types??[]).includes("Files")||Mw(e.items).some(n=>n.kind==="file")?!0:Aw(e.files).length>0:!1}async function oA(e){const t=Mw(e.items).filter(n=>n.kind==="file");return t.length>0?cA(t):uA(e.files)}async function cA(e){const t=[];for(const n of e){const a=pA(n);if(a){await kw(a,"",t);continue}const o=n.getAsFile();if(o){t.push({relativePath:Dw(o),file:o});continue}throw new lA("Folder upload is not supported by this browser.")}return t}function uA(e){return Aw(e).map(t=>({relativePath:Dw(t),file:t}))}async function kw(e,t,n){const a=_A(t,e.name);if(e.isFile){const d=await hA(e);n.push({relativePath:a,file:d});return}if(!e.isDirectory)return;const o=e.createReader(),c=await dA(o);for(const d of c)await kw(d,a,n)}function hA(e){return new Promise((t,n)=>{e.file(t,a=>n(a))})}async function dA(e){const t=[];for(;;){const n=await fA(e);if(n.length===0)return t;t.push(...n)}}function fA(e){return new Promise((t,n)=>{e.readEntries(t,a=>n(a))})}function Dw(e){const t=e.webkitRelativePath;return Rw(typeof t=="string"&&t?t:e.name)}function pA(e){const t=e.webkitGetAsEntry?.();return mA(t)?t:null}function mA(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.name=="string"&&typeof t.isFile=="boolean"&&typeof t.isDirectory=="boolean"}function _A(e,t){return Rw(e?`${e}/${t}`:t)}function Rw(e){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")}function Mw(e){return e?Array.from(e):[]}function Aw(e){return e?Array.from(e):[]}const hb="nterminal.terminalWorkspaces.v2",Nw="nterminal.sidebarCollapsed.v1",vA=75,db=Yb.map(e=>e.url),gA=Yb[0].url;function yA({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:a,sessionExpiresAt:o=null,onLogout:c=async()=>{},onSessionInvalid:d}){const p=g.useMemo(()=>e??Eu(),[e]),m=g.useMemo(()=>t??io(null),[t]),f=g.useMemo(()=>NA(n),[n]),S=g.useMemo(()=>T=>Ew(n,T),[n]),y=g.useMemo(()=>()=>Ft(n),[n]),b=g.useSyncExternalStore(S,y,y),x=b.state,C=b.editors,k=!b.loaded,B=b.error,[R,re]=g.useState(!1),[F,J]=g.useState(()=>jA()),[ce,q]=g.useState("servers"),[I,ie]=g.useState(!1),de=g.useSyncExternalStore(a2,Yy,Yy);g.useSyncExternalStore(s0,Wy,Wy);const[j,$]=g.useState(()=>[null]),[H,L]=g.useState(0),[X,G]=g.useState(()=>[n]),[M,V]=g.useState(()=>new Set),[Q,ve]=g.useState({}),[Se,E]=g.useState(null),W=g.useRef(null);g.useRef(!1);const ee=g.useRef(0),[he,ge]=g.useState(null),me=dx(ky(Hb,{activationConstraint:{distance:8}}),ky(Ub,{activationConstraint:{delay:250,tolerance:5}}));g.useEffect(()=>l2(p),[p]);function Ce(T){const A=T.active.data.current;if(A){if(A.kind==="tab"&&typeof A.tabId=="string"&&typeof A.terminalId=="string"){ge({tabId:A.tabId,terminalId:A.terminalId});return}A.kind==="pane"&&typeof A.sourceTabId=="string"&&typeof A.terminalId=="string"&&ge({tabId:A.sourceTabId,terminalId:A.terminalId})}}function ze(T){ge(null);const A=T.active.data.current,K=T.over?.data.current;if(!(!A||!K||typeof A.terminalId!="string")){if(A.kind==="tab"&&typeof A.tabId=="string"){if(K.kind==="tab-position"&&typeof K.index=="number"){Ge({type:"tab.reordered",sourceTabId:A.tabId,targetIndex:K.index});return}K.kind==="pane-zone"&&typeof K.terminalId=="string"&&(K.side==="top"||K.side==="right"||K.side==="bottom"||K.side==="left")&&Ge({type:"tab.dropped_into_pane",sourceTabId:A.tabId,sourceTerminalId:A.terminalId,targetTerminalId:K.terminalId,side:K.side});return}if(A.kind==="pane"&&typeof A.sourceTabId=="string"){if(K.kind==="tab-position"&&typeof K.index=="number"){Ge({type:"terminal.extracted_to_tab",sourceTabId:A.sourceTabId,sourceTerminalId:A.terminalId,targetIndex:K.index});return}K.kind==="pane-zone"&&typeof K.terminalId=="string"&&(K.side==="top"||K.side==="right"||K.side==="bottom"||K.side==="left")&&Ge({type:"tab.dropped_into_pane",sourceTabId:A.sourceTabId,sourceTerminalId:A.terminalId,targetTerminalId:K.terminalId,side:K.side})}}}function Ne(){ge(null)}const Re=x.workspaces.find(T=>T.id===x.activeWorkspaceId)??x.workspaces[0],Pe=Re?.tabs.find(T=>T.id===Re.activeTabId)??Re?.tabs[0],Ye=Pe?.activeTerminalId??null,Be=Ye?x.terminals[Ye]:void 0,ae=RA("(max-width: 760px)"),Ee=g.useMemo(()=>Pe?wu(Pe.root):[],[Pe]),xe=Re&&Pe?ru(n,Re.id,Pe.id):null,Ke=Pe?Bw(Ee,Pe.activeTerminalId,xe?Q[xe]:void 0):null,Xe=ae&&Ee.length>1,gt=g.useMemo(()=>{const T=new Set;for(const A of x.workspaces)for(const K of A.tabs)for(const ue of Nm(K))T.add(ue);return Object.values(x.terminals).filter(A=>!T.has(A.id))},[x.terminals,x.workspaces]),[yt,mi]=g.useState([]),te=g.useRef([]),je=g.useRef(null),[He,_i]=g.useState(null),[Vi,ai]=g.useState([]),[kt,ji]=g.useState(()=>zr()),Ti=g.useRef(0),Nt=g.useRef(n),$s=g.useRef(db),Hi=g.useRef(kt),qt=g.useRef(()=>{});qt.current=cs;const Jt=g.useCallback(async()=>{try{const T=await p.listNotificationAssets();ai(T.assets.filter(A=>A.enabled).map(A=>A.url))}catch{ai([])}},[p]);g.useEffect(()=>{G(T=>T.some(A=>mn(A,n))?T:[...T,n])},[n]);const Dt=g.useCallback(T=>{const A=Ft(T),K=io(T);for(const ue of Object.keys(A.state.terminals))Ap(K.createWebSocketUrl(ue)),$S(ue);jM(T),G(ue=>ue.filter(pe=>!mn(pe,T))),V(ue=>{const pe=`${nu(T)}:`;let ke=!1;const De=new Set;for(const rt of ue){if(rt.startsWith(pe)){ke=!0;continue}De.add(rt)}return ke?De:ue}),ve(ue=>{const pe=`${nu(T)}:`;let ke=!1;const De={};for(const[rt,ut]of Object.entries(ue)){if(rt.startsWith(pe)){ke=!0;continue}De[rt]=ut}return ke?De:ue})},[]);g.useEffect(()=>{let T=!1;return p.listAgents().then(A=>{if(!T){const K=A.agents.map(pe=>pe.id),ue=[null,...K];n!==null&&!K.includes(n)&&(Dt(n),a?.(null)),$(ue)}}).catch(()=>{}),()=>{T=!0}},[n,p,Dt,a,H]);const Cn=g.useCallback(T=>{Dt(T),L(A=>A+1),mn(T,Nt.current)&&a?.(null)},[Dt,a]);g.useEffect(()=>{$(T=>T.some(A=>mn(A,n))?T:[...T,n])},[n]),g.useEffect(()=>{Nt.current=n},[n]),g.useEffect(()=>{Jt()},[Jt]),g.useEffect(()=>Xb(()=>ji(zr())),[]),g.useEffect(()=>{const T=A=>{qt.current(A)};return window.addEventListener("keydown",T,!0),()=>window.removeEventListener("keydown",T,!0)},[]),g.useEffect(()=>{$s.current=Vi.length>0?Vi:db},[Vi]),g.useEffect(()=>{Hi.current=kt},[kt]),g.useEffect(()=>{if(!b.loaded||!Re||!Pe)return;const T=ru(n,Re.id,Pe.id);V(A=>{if(A.has(T))return A;const K=new Set(A);return K.add(T),K})},[n,b.loaded,Re?.id,Pe?.id]),g.useEffect(()=>()=>{Ir()},[]),g.useEffect(()=>AM(T=>{const A=Ft(T.agentId).state,K=A.workspaces.flatMap(De=>De.tabs).find(De=>De.id===T.tabId),ue=A.terminals[T.terminalId],pe=K?.title?.trim()||ue?.title||T.commandName||"terminal",ke=document.visibilityState==="visible"&&mn(T.agentId,Nt.current)&&T.tabId===AA(A);if(ke||zE({tabTitle:pe,commandName:T.commandName,terminalId:T.terminalId}),!ke&&document.visibilityState==="visible"&&Hi.current.enabled){const De=Ti.current+1;Ti.current=De;const rt=$s.current;_i({id:De,agentId:T.agentId,terminalId:T.terminalId,tabId:T.tabId,tabTitle:pe,commandName:T.commandName,assetSrc:rt[Math.floor(Math.random()*rt.length)]??gA})}}),[]),g.useEffect(()=>{if(!He||kt.persistUntilDismissed)return;const T=window.setTimeout(()=>{_i(A=>A?.id===He.id?null:A)},kt.durationSeconds*1e3);return()=>window.clearTimeout(T)},[He,kt]),g.useEffect(()=>{W.current?.focus(),W.current?.select()},[Se?.workspaceId]),g.useEffect(()=>{HA(F),F&&E(null)},[F]),g.useEffect(()=>{let T=!1;async function A(){if(!Ft(n).loaded){Ta(n,!1,null);try{const ue=BA(f),[pe,ke]=await Promise.all([m.listTerminals(),m.getTerminalLayout()]),De=pe.terminals.length>0?pe.terminals:[(await m.createTerminal({cols:80,rows:24})).terminal];if(!T){const rt=ke.layout?Ow(ke.layout):null,ut=rt??ue??{},yi=zp(De,void 0,ut.savedWorkspaces,ut.savedActiveWorkspaceId),Fr=Cf(yi);rb(n,yi),Xc(n,ke.revision,JSON.stringify(Fr)),Ta(n,!0,null),!rt&&ue&&Ui(Fr,{baseRevision:ke.revision})}}catch(ue){!T&&!bt(ue)&&Ta(n,!0,Kl(ue))}}}return A(),()=>{T=!0}},[n,m]);async function Bs(){await Wt(async()=>{const T=await m.createTerminal({cols:80,rows:24});Ge({type:"terminal.created",terminal:T.terminal})})}async function Vs(T){await Wt(async()=>{const A=Ye?{parentTerminalId:Ye,cols:80,rows:24}:{cols:80,rows:24},K=await m.createTerminal(A);Ge({type:"terminal.split",terminal:K.terminal,direction:T})})}async function Ts(T){if(!Ye)throw new Error("No active pane is available.");const A=await m.readFile(T),K=`editor-${Date.now().toString(36)}-${zM(n)}`,ue=zA(A.path);ab(n,pe=>({...pe,[K]:{id:K,title:ue,rootToken:T.rootToken,path:A.path,read:A}})),xe&&ve(pe=>({...pe,[xe]:Lw(K)})),Ge({type:"editor.split",editorId:K,title:ue,direction:"vertical"})}function ks(T){ab(n,A=>{const K={...A};return delete K[T],K}),Ge({type:"editor.closed",editorId:T})}function ot(T){St([T])}function St(T){for(const A of T)Ge({type:"terminal.detached",terminalId:A})}async function Rt(T){await Wt(async()=>{await Bt(T),Ap(m.createWebSocketUrl(T)),$S(T),Ge({type:"terminal.closed",terminalId:T})})}async function li(T,A){const K=A.trim();if(!K)return;let ue=null;for(const pe of x.workspaces){const ke=pe.tabs.find(De=>De.id===T);if(ke){ue=ke.activeTerminalId;break}}if(Ge({type:"tab.renamed",tabId:T,title:K}),!!ue)try{const pe=await m.renameTerminal(ue,K);ct({type:"terminal.updated",terminal:pe.terminal})}catch(pe){Ta(n,!0,Kl(pe))}}function ei(T){const A=x.terminals[T];A&&Ge({type:"terminal.created",terminal:A})}async function Bt(T){try{await m.closeTerminal(T)}catch(A){if(A instanceof yn&&A.status===404)return;throw A}}async function nt(){await Wt(async()=>{await c()})}async function Wt(T){Ta(n,!0,null);try{await T()}catch(A){if(bt(A))return;Ta(n,!0,Kl(A))}}function bt(T){return T instanceof yn&&T.status===401&&!m.isAgent&&d?(d(),!0):!1}function Ge(T){Ul(n,T);const A=Ft(n),K=A.state;if(!A.loaded||K.workspaces.length===0)return;const ue=Cf(K);JSON.stringify(ue)!==A.lastPersistedLayoutJson&&Qi(ue)}function ct(T){Ul(n,T)}function vi(T,A,K,ue){const pe=ru(T,A,K);ve(ke=>({...ke,[pe]:ue}))}function Ai(T){xe&&ve(A=>({...A,[xe]:T}))}function Ni(T,A){const K=Cu(T);A?vi(n,A.workspaceId,A.tabId,K):Ai(K),Ge({type:"pane.selected",terminalId:T})}function ki(T){Ai(T.key),T.type==="terminal"&&Ge({type:"pane.selected",terminalId:T.terminalId})}function cs(T){if(I||T.isComposing||T.key==="Process"||EA(T.target))return;const A=bA(T);if(!A)return;if(T.preventDefault(),T.stopPropagation(),A.type==="server.previous"||A.type==="server.next"){gi(A.type==="server.next"?1:-1);return}const K=Ft(n).state,ue=K.workspaces.find(De=>De.id===K.activeWorkspaceId)??K.workspaces[0],pe=ue?.tabs.find(De=>De.id===ue.activeTabId)??ue?.tabs[0];if(A.type==="split"){if(!pe)return;Vs(A.direction);return}if(!ue||!pe)return;if(A.type==="tab.previous"||A.type==="tab.next"){const De=xA(ue.tabs,pe.id,A.type==="tab.next"?1:-1);De&&Ge({type:"tab.selected",tabId:De.id});return}if(A.type==="tab.index"){const De=ue.tabs[A.index-1];De&&Ge({type:"tab.selected",tabId:De.id});return}const ke=wA(pe.root,pe.activeTerminalId,A);ke&&Ni(ke,{workspaceId:ue.id,tabId:pe.id})}function gi(T){if(!a||j.length===0)return;const A=j.findIndex(ke=>mn(ke,n)),ue=((A===-1?0:A)+T+j.length)%j.length,pe=j[ue]??null;mn(pe,n)||a(pe)}function mt(T){ub(T.dataTransfer)&&(T.preventDefault(),T.dataTransfer.dropEffect="copy")}function Yt(T){if(!ub(T.dataTransfer))return;T.preventDefault();const A=LA(Ft(n).state),K=ee.current+1;if(ee.current=K,!A){hr({id:K,status:"failed",fileCount:0,message:"No active running terminal is available for upload."});return}hr({id:K,status:"queued",fileCount:0,terminalId:A.id,message:"Preparing upload..."}),us(K,A.id,T.dataTransfer)}async function us(T,A,K){try{const ue=await oA(K);if(ue.length===0)throw new Error("No files were found in the drop.");Xi(T,{id:T,status:"queued",fileCount:ue.length,message:"Queued"},{terminalId:A,files:ue})}catch(ue){Xi(T,{id:T,status:"failed",fileCount:0,message:Kl(ue)},{terminalId:A})}finally{xn()}}async function Xs(T){const A=te.current.find(ke=>ke.id===T);if(!A?.terminalId||!A.files||A.files.length===0)return;const K=A.terminalId,ue=A.files,pe=new AbortController;je.current=T,Xi(T,{id:T,status:"uploading",fileCount:ue.length,loaded:0,total:null,percent:null},{terminalId:K,files:ue,abortController:pe});try{const ke=await g2({terminalId:K,files:ue,signal:pe.signal,onProgress:yi=>{Xi(T,{id:T,status:"uploading",fileCount:ue.length,loaded:yi.loaded,total:yi.total,percent:yi.percent},{terminalId:K,files:ue,abortController:pe})}}),De=ke.failed>0?ke.uploaded>0?"partial":"failed":"success",rt=ke.failed>0?OA(ke):void 0,ut={id:T,status:De,fileCount:ue.length,response:ke};rt&&(ut.message=rt),Xi(T,ut,{terminalId:K,files:ue})}catch(ke){Xi(T,{id:T,status:"failed",fileCount:ue.length,message:pe.signal.aborted?"Upload canceled.":Kl(ke)},{terminalId:K,files:ue})}finally{je.current===T&&(je.current=null),xn()}}function xn(){if(je.current!==null)return;const T=te.current.find(A=>A.status==="queued");T?.terminalId&&T.files&&T.files.length>0&&Xs(T.id)}function hr(T){Gi(A=>[...A,T])}function Xi(T,A,K={}){Gi(ue=>ue.map(pe=>{if(pe.id!==T)return pe;const ke={...A},De=K.terminalId??pe.terminalId,rt=K.files??pe.files;return De!==void 0&&(ke.terminalId=De),rt!==void 0&&(ke.files=rt),K.abortController!==void 0&&(ke.abortController=K.abortController),ke}))}function Gi(T){const A=T(te.current);te.current=A,mi(A)}function En(T){te.current.find(K=>K.id===T)?.abortController?.abort(),je.current===T&&(je.current=null),Gi(K=>K.filter(ue=>ue.id!==T)),xn()}function Ls(){for(const T of te.current)T.abortController?.abort();je.current=null,Gi(()=>[])}function Os(T){const A=te.current.find(K=>K.id===T);if(A){if(A.status==="queued"){En(T);return}A.abortController?.abort()}}function Ds(T){const A=te.current.find(ue=>ue.id===T);if(!A?.terminalId||!A.files||A.files.length===0)return;const K=Zi(A);if(K.length===0){Xi(T,{id:T,status:"failed",fileCount:A.fileCount,message:"No failed files are available to retry."},{terminalId:A.terminalId,files:A.files});return}Xi(T,{id:T,status:"queued",fileCount:K.length,message:"Queued"},{terminalId:A.terminalId,files:K}),xn()}function Zi(T){const A=T.files??[],K="response"in T?T.response:void 0;if(!K)return A;const ue=K.results.filter(De=>De.status==="failed").map(De=>De.relativePath);if(ue.length===0)return[];const pe=new Map;for(const De of A){const rt=pe.get(De.relativePath)??[];rt.push(De),pe.set(De.relativePath,rt)}const ke=[];for(const De of ue){const ut=pe.get(De)?.shift();ut&&ke.push(ut)}return ke}function Lt(T){const K=Ft(T.agentId).state.workspaces.find(ue=>ue.tabs.some(pe=>pe.id===T.tabId));K&&vi(T.agentId,K.id,T.tabId,Cu(T.terminalId)),Ul(T.agentId,{type:"pane.selected",terminalId:T.terminalId}),OM(T.agentId,T.tabId),mn(T.agentId,n)||a?.(T.agentId),_i(null)}function Qi(T){const A=Ft(n).mutable.saveCoord;A.pendingLayoutSave=T,Pl(T,f),A.saveTimer!==null&&window.clearTimeout(A.saveTimer),A.saveTimer=window.setTimeout(()=>{A.saveTimer=null;const K=A.pendingLayoutSave;A.pendingLayoutSave=null,K&&Ui(K)},vA)}function Ir(){const T=Ft(n).mutable.saveCoord;T.saveTimer!==null&&(window.clearTimeout(T.saveTimer),T.saveTimer=null);const A=T.pendingLayoutSave;T.pendingLayoutSave=null,A&&(Pl(A,f),Ui(A))}function Ui(T,A={}){const K=Ft(n).mutable.saveCoord;K.nextPersistLayout=T,A.baseRevision!==void 0&&(K.queuedBaseRevision=A.baseRevision),!K.nextPersistQueued&&(K.nextPersistQueued=!0,K.persistChain=K.persistChain.then(async()=>{K.nextPersistQueued=!1;const ue=K.nextPersistLayout,pe=K.queuedBaseRevision;K.nextPersistLayout=null,K.queuedBaseRevision=void 0,ue&&await zs(ue,pe!==void 0?{baseRevision:pe}:{})}))}async function zs(T,A={}){const K=Ft(n),ue=A.baseRevision??K.layoutRevision,pe={layout:T,...typeof ue=="number"?{baseRevision:ue}:{}};try{const ke=await m.saveTerminalLayout(pe),De=ke.layout??T;Xc(n,ke.revision,JSON.stringify(De)),Pl(De,f);return}catch(ke){if(ke instanceof yn&&ke.status===409)try{const De=await m.getTerminalLayout();if(De.layout){const rt=Ft(n).state,ut=zp(Object.values(rt.terminals),void 0,De.layout.workspaces,De.layout.activeWorkspaceId),yi=Cf(ut);rb(n,ut),Xc(n,De.revision,JSON.stringify(yi)),Pl(yi,f)}else Xc(n,De.revision,K.lastPersistedLayoutJson);return}catch{}Pl(T,f)}}const O=UA(o),fe=!F||R,Oe=fe?ce:"servers";return _.jsx(dE,{sensors:me,onDragStart:Ce,onDragEnd:ze,onDragCancel:Ne,children:_.jsxs("main",{className:"terminal-shell","data-collapsed":F,"data-sidebar-open":R,onDragOver:mt,onDrop:Yt,children:[_.jsx("button",{type:"button",className:"workspace-backdrop","aria-label":"Close workspaces",onClick:()=>re(!1)}),_.jsxs("aside",{className:"workspace-sidebar",children:[_.jsxs("header",{className:"workspace-brand",children:[fe?_.jsx(Cb,{height:20}):_.jsx(wb,{size:24}),_.jsx("button",{type:"button",className:"sidebar-collapse-button","aria-label":F?"Expand sidebar":"Collapse sidebar",title:F?"Expand sidebar":"Collapse sidebar",onClick:()=>J(T=>!T),children:F?">":"<"}),_.jsx("button",{type:"button",className:"sidebar-drawer-close-button","aria-label":"Close workspaces",title:"Close workspaces",onClick:()=>re(!1),children:"x"})]}),_.jsxs("div",{className:"workspace-sidebar-content",children:[fe?_.jsxs("div",{className:"workspace-sidebar-tabs",role:"tablist","aria-label":"Sidebar mode",children:[_.jsx("button",{type:"button",role:"tab","aria-selected":ce==="servers",onClick:()=>{q("servers"),E(null)},children:"Servers"}),_.jsx("button",{type:"button",role:"tab","aria-selected":ce==="files",onClick:()=>{q("files"),E(null)},children:"Files"})]}):null,Oe==="servers"&&fe?_.jsx("nav",{className:"workspace-nav","aria-label":"Servers",children:_.jsx(ef,{api:p,activeAgentId:n,onSelectServer:a??(()=>{}),onSessionInvalid:d,refreshToken:H})}):null,fe?null:_.jsx("nav",{className:"workspace-nav workspace-nav--collapsed","aria-label":"Servers",children:_.jsx(ef,{api:p,activeAgentId:n,onSelectServer:a??(()=>{}),onSessionInvalid:d,refreshToken:H,compact:!0})}),Oe==="files"?_.jsxs(_.Fragment,{children:[fe?_.jsx("nav",{className:"workspace-nav workspace-nav--compact","aria-label":"Servers",children:_.jsx(ef,{api:p,activeAgentId:n,onSelectServer:a??(()=>{}),onSessionInvalid:d,refreshToken:H})}):null,_.jsx(C2,{api:m,activeTerminalId:Ye,activeTerminalCwd:Be?.cwd??null,onOpenFile:Ts})]}):null]}),fe?_.jsxs("div",{className:"workspace-sidebar-footer",children:[_.jsx("span",{children:O}),_.jsxs("div",{className:"workspace-sidebar-footer-actions",children:[_.jsxs("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"settings",title:"Settings",onClick:()=>ie(!0),children:[_.jsx(pb,{name:"settings"}),de.hasUpdates?_.jsx("span",{className:"update-pulse-dot","aria-hidden":"true"}):null]}),_.jsx("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"logout",title:"Logout",onClick:()=>{nt()},children:_.jsx(pb,{name:"logout"})})]})]}):null]}),I?_.jsx(_2,{api:p,onClose:()=>ie(!1),updateAvailable:de.hasUpdates,onNotificationAssetsChanged:()=>{Jt()},onAgentRemoved:Cn}):null,_.jsxs("section",{className:"terminal-main","aria-label":"Terminal workspace","data-mobile-pane-switcher":Xe?"true":void 0,children:[_.jsx(KM,{tabs:Re?.tabs??[],activeTabId:Re?.activeTabId??null,terminals:x.terminals,unreadCompletionTabIds:b.unreadCompletions,detachedTerminals:gt,onSelectTab:T=>Ge({type:"tab.selected",tabId:T}),onCreateTab:()=>{Bs()},onToggleWorkspaces:()=>re(T=>!T),onCloseTerminals:T=>St(T),onReattachTerminal:T=>ei(T),onDeleteTerminal:T=>{Rt(T)},onSplitVertical:()=>{Vs("vertical")},onSplitHorizontal:()=>{Vs("horizontal")},onRenameTab:(T,A)=>{li(T,A)},activePaneAvailable:!!Ye}),Xe?_.jsx(kA,{targets:Ee,activeLeafKey:Ke,terminals:x.terminals,editors:C,onSelect:ki}):null,B?_.jsx("div",{className:"workspace-error",children:B}):null,_.jsxs("section",{className:"workspace-body","aria-busy":k,children:[k?_.jsx("div",{className:"workspace-placeholder",children:"Opening shell..."}):null,!k&&!Pe?_.jsx(TA,{onCreate:()=>{Bs()}}):null,X.map(T=>{const A=mn(T,n);return _.jsx(SA,{agentId:T,active:A,activeServerApi:A?m:void 0,visitedTabKeys:M,refreshCwdOnEnter:A&&Oe==="files",draggingTab:A?he:null,mobileSplitFocus:ae,mobileFocusedLeafByTabKey:Q,onSelect:K=>{A&&Ni(K)},onClose:K=>{A&&ot(K)},onCloseEditor:K=>{A&&ks(K)},onResize:(K,ue)=>{A&&Ge({type:"pane.resized",path:K,ratio:ue})},onExit:(K,ue)=>{A?ct({type:"terminal.exited",terminalId:K,exitCode:ue}):Ul(T,{type:"terminal.exited",terminalId:K,exitCode:ue})},onSnapshot:(K,ue)=>{const pe={type:"terminal.updated",terminal:K,notifyCompletion:ue?.notifyCompletion===!0};A?ct(pe):Ul(T,pe)},...T===null&&d?{onAuthClose:d}:{}},nu(T))})]}),_.jsx(QM,{toast:He,onActivate:Lt,onDismiss:()=>_i(null)}),_.jsx(WM,{uploads:yt,onDismiss:En,onDismissAll:Ls,onRetry:Ds,onCancel:Os})]})]})})}function SA({agentId:e,active:t,activeServerApi:n,visitedTabKeys:a,refreshCwdOnEnter:o,draggingTab:c,mobileSplitFocus:d,mobileFocusedLeafByTabKey:p,onSelect:m,onClose:f,onCloseEditor:S,onResize:y,onExit:b,onSnapshot:x,onAuthClose:C}){const k=g.useMemo(()=>de=>Ew(e,de),[e]),B=g.useMemo(()=>()=>Ft(e),[e]),R=g.useSyncExternalStore(k,B,B),re=g.useMemo(()=>io(e),[e]),F=n??re,J=R.state,ce=J.workspaces.find(de=>de.id===J.activeWorkspaceId)??J.workspaces[0],q=ce?.id??null,ie=(ce?.tabs.find(de=>de.id===ce.activeTabId)??ce?.tabs[0])?.id??null;return!R.loaded||J.workspaces.length===0?null:_.jsx("div",{className:"workspace-server-surface","data-active":t,"aria-hidden":!t,children:J.workspaces.flatMap(de=>de.tabs.map(j=>{const $=t&&de.id===q&&j.id===ie,H=ru(e,de.id,j.id),L=wu(j.root),X=d&&L.length>1?Bw(L,j.activeTerminalId,p[H]):null;return!$&&!a.has(H)?null:_.jsx("div",{className:"workspace-tab-surface","data-active":$,"aria-hidden":!$,children:_.jsx(Bp,{node:j.root,terminals:J.terminals,editors:R.editors,api:F,activeTerminalId:j.activeTerminalId,visible:$,refreshCwdOnEnter:$&&o,tabId:j.id,dropZoneActive:$&&c!==null,draggingTerminalId:$?c?.terminalId??null:null,mobileFocusLeafKey:X,onSelect:m,onClose:f,onCloseEditor:S,onResize:y,onExit:b,onSnapshot:x,...C?{onAuthClose:C}:{}})},`${de.id}:${j.id}`)}))})}function bA(e){const t=WE(e);if(t)switch(t.id){case"server.previous":case"server.next":case"tab.previous":case"tab.next":return{type:t.id};case"tab.index":case"pane.index":return t.index===null?null:{type:t.id,index:t.index};case"split.right":return{type:"split",direction:"vertical"};case"split.down":return{type:"split",direction:"horizontal"};default:return null}if(e.ctrlKey&&e.altKey&&!e.metaKey&&!e.shiftKey){const n=CA(e.key);return n?{type:"pane.direction",direction:n}:null}return null}function wA(e,t,n){switch(n.type){case"pane.direction":return tA(e,t,n.direction);case"pane.index":return iA(e,n.index);default:return null}}function CA(e){switch(e){case"ArrowLeft":return"left";case"ArrowRight":return"right";case"ArrowUp":return"up";case"ArrowDown":return"down";default:return null}}function xA(e,t,n){if(e.length===0)return null;const a=e.findIndex(c=>c.id===t);return e[((a===-1?0:a)+n+e.length)%e.length]??null}function wu(e){return e.type==="pane"?[{key:Cu(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:Lw(e.editorId),type:"editor",editorId:e.editorId,title:e.title}]:[...wu(e.first),...wu(e.second)]}function Bw(e,t,n){if(n&&e.some(o=>o.key===n))return n;const a=t?Cu(t):null;return a&&e.some(o=>o.key===a)?a:e[0]?.key??null}function Cu(e){return`terminal:${e}`}function Lw(e){return`editor:${e}`}function EA(e){if(!(e instanceof HTMLElement)||e.closest(".xterm"))return!1;if(e.closest('input, textarea, select, [role="textbox"]'))return!0;const t=e.closest("[contenteditable]");return t instanceof HTMLElement&&t.getAttribute("contenteditable")?.toLowerCase()!=="false"}function TA({onCreate:e}){return _.jsxs("div",{className:"empty-workspace",children:[_.jsx("span",{children:"No terminal is open."}),_.jsx("button",{type:"button",onClick:e,children:"New tab"})]})}function kA({targets:e,activeLeafKey:t,terminals:n,editors:a,onSelect:o}){const[c,d]=g.useState(!1);if(e.length<=1)return null;const p=t?e.findIndex(b=>b.key===t):-1,m=p>=0?p:0,f=e[m]??e[0],S=fb(f,n,a);function y(b){const x=(m+b+e.length)%e.length,C=e[x];C&&o(C)}return _.jsxs("div",{className:"mobile-pane-switcher",role:"group","aria-label":"Pane switcher",children:[_.jsx("button",{type:"button","aria-label":"Previous pane",onClick:()=>y(-1),children:"<"}),_.jsxs("button",{type:"button",className:"mobile-pane-current","aria-label":"Open pane switcher","aria-haspopup":"dialog","aria-expanded":c,title:S,onClick:()=>d(!0),children:["Pane ",m+1,"/",e.length," | ",S]}),_.jsx("button",{type:"button","aria-label":"Next pane",onClick:()=>y(1),children:">"}),c?_.jsx("div",{className:"mobile-pane-sheet-backdrop",onClick:()=>d(!1),children:_.jsxs("section",{className:"mobile-pane-sheet",role:"dialog","aria-modal":"true","aria-label":"Pane switcher",onClick:b=>b.stopPropagation(),children:[_.jsxs("header",{children:[_.jsx("strong",{children:"Panes"}),_.jsx("button",{type:"button","aria-label":"Close pane switcher",onClick:()=>d(!1),children:"x"})]}),_.jsx("div",{className:"mobile-pane-sheet-list",children:e.map((b,x)=>{const C=fb(b,n,a),k=DA(b,n,a),B=b.key===f.key;return _.jsxs("button",{type:"button","data-active":B,onClick:()=>{o(b),d(!1)},children:[_.jsx("span",{className:"mobile-pane-sheet-index",children:x+1}),_.jsxs("span",{className:"mobile-pane-sheet-copy",children:[_.jsx("strong",{children:C}),_.jsx("small",{children:k})]}),_.jsx("span",{className:"mobile-pane-sheet-type",children:b.type})]},b.key)})})]})}):null]})}function fb(e,t,n){if(e.type==="editor")return n[e.editorId]?.title||e.title||e.editorId;const a=t[e.terminalId];return a?.title||a?.cwd||e.terminalId}function DA(e,t,n){if(e.type==="editor"){const c=n[e.editorId];return c?.path?`editor | ${c.path}`:"editor"}const a=t[e.terminalId];return a?`${a.activity==="busy"?`busy${a.currentCommand?`: ${a.currentCommand}`:""}`:a.activity==="idle"?"idle":a.status} | ${a.cwd}`:"terminal"}function RA(e){const[t,n]=g.useState(()=>MA(e));return g.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function"){n(!1);return}const a=window.matchMedia(e),o=()=>n(a.matches);return o(),typeof a.addEventListener=="function"?(a.addEventListener("change",o),()=>a.removeEventListener("change",o)):(a.addListener(o),()=>a.removeListener(o))},[e]),t}function MA(e){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(e).matches}function mn(e,t){return e===t}function AA(e){const t=e.workspaces.find(a=>a.id===e.activeWorkspaceId)??e.workspaces[0];return(t?.tabs.find(a=>a.id===t.activeTabId)??t?.tabs[0])?.id??null}function nu(e){return e??"__local__"}function ru(e,t,n){return`${nu(e)}:${t}:${n}`}function NA(e){return e?{workspaceKey:`${hb}:${e}`}:{workspaceKey:hb}}function BA(e){const t=localStorage.getItem(e.workspaceKey);if(!t)return null;try{const n=JSON.parse(t),a=Wb(n);return a?Ow(a):null}catch{return null}}function Ow(e){const t=Wb(e);return t?{savedWorkspaces:t.workspaces,savedActiveWorkspaceId:t.activeWorkspaceId}:null}function Pl(e,t){if(e.workspaces.length>0){localStorage.setItem(t.workspaceKey,JSON.stringify(e));return}localStorage.removeItem(t.workspaceKey)}function LA(e){const t=e.workspaces.find(o=>o.id===e.activeWorkspaceId)??e.workspaces[0],n=t?.tabs.find(o=>o.id===t.activeTabId)??t?.tabs[0],a=n?e.terminals[n.activeTerminalId]:void 0;return a?.status==="running"?a:null}function OA(e){return e.results.find(t=>t.status==="failed"&&t.error)?.error}function zA(e){return e.split("/").filter(Boolean).pop()??e}function jA(){try{return localStorage.getItem(Nw)==="true"}catch{return!1}}function HA(e){try{localStorage.setItem(Nw,e?"true":"false")}catch{}}function UA(e){if(!e)return"session · local";const t=Date.parse(e);if(!Number.isFinite(t))return"session · local";const n=t-Date.now();if(n<=0)return"session · expired";const a=Math.max(1,Math.floor(n/6e4));return a<60?`session · ${a}m left`:`session · ${Math.floor(a/60)}h left`}function pb({name:e}){return _.jsxs("svg",{className:"workspace-footer-icon",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[e==="settings"?_.jsxs(_.Fragment,{children:[_.jsx("path",{d:"M4 7h9"}),_.jsx("path",{d:"M17 7h3"}),_.jsx("circle",{cx:"15",cy:"7",r:"2"}),_.jsx("path",{d:"M4 12h3"}),_.jsx("path",{d:"M11 12h9"}),_.jsx("circle",{cx:"9",cy:"12",r:"2"}),_.jsx("path",{d:"M4 17h9"}),_.jsx("path",{d:"M17 17h3"}),_.jsx("circle",{cx:"15",cy:"17",r:"2"})]}):null,e==="logout"?_.jsxs(_.Fragment,{children:[_.jsx("path",{d:"M10 6H6v12h4"}),_.jsx("path",{d:"M13 8l4 4-4 4"}),_.jsx("path",{d:"M8 12h9"})]}):null]})}function Kl(e){return e instanceof Error?e.message:"Request failed"}function PA({api:e,onDone:t}){const[n,a]=g.useState(null),[o,c]=g.useState(null),[d,p]=g.useState(""),[m,f]=g.useState(!1),[S,y]=g.useState(null),[b,x]=g.useState(null);g.useEffect(()=>{let k=!1;return e.setupTotp().then(B=>{k||(a(B.qrDataUrl),c(B.secret))}).catch(B=>{k||x(B instanceof Error?B.message:"Failed to generate QR code")}),()=>{k=!0}},[e]);async function C(k){if(k.preventDefault(),!!o){f(!0),y(null);try{await e.activateTotp({secret:o,otp:d}),t()}catch(B){y(B instanceof Error?B.message:"Verification failed")}finally{f(!1)}}}return b?_.jsx("p",{className:"form-error",children:b}):!n||!o?_.jsx("p",{className:"muted",children:"Generating authenticator setup..."}):_.jsxs("div",{className:"totp-setup",children:[_.jsx("p",{className:"totp-setup-instructions",children:"Scan this QR code with an authenticator app (Google Authenticator, Authy, 1Password, etc.), then enter the 6-digit code to confirm."}),_.jsx("div",{className:"totp-qr-container",children:_.jsx("img",{src:n,alt:"TOTP QR code",width:192,height:192})}),_.jsxs("details",{className:"totp-secret-details",children:[_.jsx("summary",{children:"Can't scan? Enter manually"}),_.jsx("p",{className:"totp-secret-text",children:o})]}),_.jsxs("form",{className:"auth-form",onSubmit:C,children:[_.jsxs("label",{children:["Verification code",_.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:d,onChange:k=>p(k.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),S?_.jsx("p",{className:"form-error",children:S}):null,_.jsx("button",{type:"submit",disabled:m||d.length!==6,children:"Activate 2FA"})]})]})}function KA({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:a}){const o=g.useMemo(()=>e??Eu(),[e]),c=g.useMemo(()=>t??io(null),[t]),[d,p]=g.useState(null),[m,f]=g.useState(null);g.useEffect(()=>{let C=!1;return o.getSession().then(k=>{C||(p(k),f(null))}).catch(k=>{C||(f(go(k)),p(null))}),()=>{C=!0}},[o]);const S=WA(d);async function y(){const C=await o.getSession();p(C),f(null)}async function b(){ZS(),lb(),iR(),f(null),p(null);try{await y()}catch(C){f(go(C))}}if(S==="workspace")return _.jsx(yA,{api:o,serverApi:c,activeAgentId:n,onSelectServer:a,sessionExpiresAt:d?.expiresAt??null,onSessionInvalid:()=>{b()},onLogout:async()=>{ZS(),lb();const C=await o.logout();p(C)}});const x={loading:"Terminal",setup_password:"Set password",setup_totp:"Set up 2FA",login:"Unlock terminal",reauth:"Verify it’s you",workspace:"Terminal"};return _.jsxs("main",{className:"auth-screen",children:[_.jsxs("div",{className:"auth-background","aria-hidden":"true",children:[_.jsx("div",{className:"auth-grid"}),_.jsx("div",{className:"auth-glow"})]}),_.jsxs("section",{className:"auth-panel","aria-busy":S==="loading",children:[_.jsxs("header",{className:"auth-header",children:[_.jsxs("div",{className:"auth-brand",children:[_.jsx(wb,{size:26}),_.jsxs("div",{children:[_.jsx(Cb,{height:17}),_.jsx("p",{className:"auth-host",children:"local terminal"})]})]}),_.jsx("h1",{children:x[S]})]}),m?_.jsx("p",{className:"form-error",children:m}):null,S==="loading"?_.jsx("p",{className:"muted",children:"Checking session..."}):null,S==="loading"&&m?_.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{b()},children:"Retry"}):null,S==="setup_password"?_.jsx(IA,{api:o,onSession:C=>{p(C)}}):null,S==="setup_totp"?_.jsx(PA,{api:o,onDone:()=>{y()}}):null,S==="login"?_.jsx(FA,{api:o,session:d,onSession:p,onRefresh:y}):null,S==="reauth"?_.jsx(qA,{api:o,session:d,onSession:p,onFullLogin:()=>p(C=>C&&{...C,deviceTrusted:!1})}):null]})]})}function IA({api:e,onSession:t}){const[n,a]=g.useState(""),[o,c]=g.useState(""),[d,p]=g.useState(!1),[m,f]=g.useState(null);async function S(y){y.preventDefault(),p(!0),f(null);try{if(n!==o){f("Passwords do not match");return}t(await e.setupPassword({password:n}))}catch(b){f(go(b))}finally{p(!1)}}return _.jsxs("form",{className:"auth-form",onSubmit:S,children:[_.jsxs("label",{children:["Password",_.jsx("input",{autoFocus:!0,value:n,onChange:y=>a(y.currentTarget.value),type:"password",minLength:8,required:!0})]}),_.jsxs("label",{children:["Confirm password",_.jsx("input",{value:o,onChange:y=>c(y.currentTarget.value),type:"password",minLength:8,required:!0})]}),m?_.jsx("p",{className:"form-error",children:m}):null,_.jsx("button",{type:"submit",disabled:d||n.length<8||o.length<8,children:"Set password"})]})}function FA({api:e,session:t,onSession:n,onRefresh:a}){const[o,c]=g.useState(""),[d,p]=g.useState(""),[m,f]=g.useState(!1),[S,y]=g.useState(!1),[b,x]=g.useState(null),C=t?.totpEnabled??!1,k=t?.currentIpWhitelisted??!1;async function B(R){R.preventDefault(),y(!0),x(null);try{n(await e.login({password:o,...C?{otp:d}:{},rememberNetwork:m}))}catch(re){x(go(re))}finally{y(!1)}}return _.jsxs("form",{className:"auth-form",onSubmit:B,children:[_.jsxs("label",{children:["Password",_.jsx("input",{autoFocus:!0,type:"password",value:o,onChange:R=>c(R.currentTarget.value),required:!0})]}),C?_.jsxs("label",{children:["Authenticator code",_.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:d,onChange:R=>p(R.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}):null,k?null:_.jsxs("label",{className:"auth-checkbox",children:[_.jsx("input",{type:"checkbox",checked:m,onChange:R=>f(R.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),b?_.jsx("p",{className:"form-error",children:b}):null,_.jsxs("div",{className:"button-row",children:[_.jsx("button",{type:"submit",disabled:S||o.length===0||C&&d.length!==6,children:"Unlock"}),_.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{a()},disabled:S,children:"Refresh"})]})]})}function qA({api:e,session:t,onSession:n,onFullLogin:a}){const o=t?.currentIpWhitelisted??!1,[c,d]=g.useState(""),[p,m]=g.useState(!1),[f,S]=g.useState(!1),[y,b]=g.useState(null),x=xi.useRef(!1),C=xi.useCallback(async(B,R)=>{S(!0),b(null);try{n(await e.reauth({...B?{otp:B}:{},rememberNetwork:R}))}catch(re){b(go(re))}finally{S(!1)}},[e,n]);g.useEffect(()=>{o&&!x.current&&(x.current=!0,C(void 0,!1))},[o,C]);async function k(B){B.preventDefault(),await C(c,p)}return o&&!y?_.jsx("p",{className:"muted",children:"Reconnecting from a trusted network…"}):_.jsxs("form",{className:"auth-form",onSubmit:k,children:[_.jsx("p",{className:"muted",children:"This device is remembered. Enter your authenticator code to continue."}),_.jsxs("label",{children:["Authenticator code",_.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:c,onChange:B=>d(B.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),_.jsxs("label",{className:"auth-checkbox",children:[_.jsx("input",{type:"checkbox",checked:p,onChange:B=>m(B.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),y?_.jsx("p",{className:"form-error",children:y}):null,_.jsxs("div",{className:"button-row",children:[_.jsx("button",{type:"submit",disabled:f||c.length!==6,children:"Continue"}),_.jsx("button",{type:"button",className:"secondary-button",onClick:a,disabled:f,children:"Use password instead"})]})]})}function WA(e){return e?e.passwordSet?e.authenticated&&!e.totpEnabled?"setup_totp":e.authenticated?"workspace":e.deviceTrusted&&e.totpEnabled?"reauth":"login":"setup_password":"loading"}function go(e){return e instanceof Error?e.message:"Request failed"}const mb="NTerminal",Wp="nterminal.activeAgentId";function YA(){const[e,t]=g.useState(()=>$A()),n=g.useMemo(()=>Eu(),[]),a=g.useMemo(()=>io(e),[e]);g.useEffect(()=>{const c=()=>{const d=LM();document.title=d>0?`(${d}) ${mb}`:mb};return c(),BM(c)},[]);function o(c){VA(c),t(c)}return _.jsx(KA,{api:n,activeAgentId:e,serverApi:a,onSelectServer:o})}function $A(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Wp);return e&&e.trim()?e:null}catch{return null}}function VA(e){if(!(typeof window>"u"))try{if(e){window.localStorage.setItem(Wp,e);return}window.localStorage.removeItem(Wp)}catch{}}const _b=["gesturestart","gesturechange","gestureend"],XA=[".workspace-list",".terminal-tab-list",".mobile-terminal-key-bar",".upload-toast-body",".file-tree",".file-detail",".file-editor",".file-markdown-preview",".editor-markdown-preview"].join(",");function GA(e=window){if(!QA(e))return()=>{};const t={passive:!1},n=e.document;function a(c){c.cancelable&&c.preventDefault()}function o(c){if(c.defaultPrevented)return;const d=c.touches;!d||d.length===0||(d.length>1||!ZA(c.target))&&a(c)}for(const c of _b)n.addEventListener(c,a,t);return n.addEventListener("touchmove",o,t),n.addEventListener("dblclick",a,t),()=>{for(const c of _b)n.removeEventListener(c,a,t);n.removeEventListener("touchmove",o,t),n.removeEventListener("dblclick",a,t)}}function ZA(e){return e instanceof Element&&e.closest(XA)!==null}function QA(e){return e.navigator.maxTouchPoints>0?!0:typeof e.matchMedia=="function"&&e.matchMedia("(pointer: coarse)").matches}const vb="--nterminal-viewport-height",gb="--nterminal-keyboard-inset-bottom",yb="data-nterminal-keyboard-visible",JA=120;function eN(e=window){const t=e.document.documentElement,n=e.visualViewport;function a(){const o=tN(e);o!==null&&t.style.setProperty(vb,`${o}px`),t.style.setProperty(gb,`${zw(e)}px`),t.setAttribute(yb,String(iN(e)))}return a(),n?.addEventListener("resize",a),n?.addEventListener("scroll",a),e.addEventListener("resize",a),e.addEventListener("orientationchange",a),e.addEventListener("pageshow",a),e.document.addEventListener("visibilitychange",a),()=>{n?.removeEventListener("resize",a),n?.removeEventListener("scroll",a),e.removeEventListener("resize",a),e.removeEventListener("orientationchange",a),e.removeEventListener("pageshow",a),e.document.removeEventListener("visibilitychange",a),t.style.removeProperty(vb),t.style.removeProperty(gb),t.removeAttribute(yb)}}function tN(e){const t=e.visualViewport?.height;return xu(t)?t:xu(e.innerHeight)?e.innerHeight:null}function xu(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function iN(e){return zw(e)>JA}function zw(e){const t=e.visualViewport?.height;if(!xu(t)||!xu(e.innerHeight))return 0;const n=typeof e.visualViewport?.offsetTop=="number"?e.visualViewport.offsetTop:0;return Math.max(0,Math.round(e.innerHeight-t-n))}eN();GA();pm();ZC.createRoot(document.getElementById("root")).render(_.jsx(xi.StrictMode,{children:_.jsx(YA,{})}));export{IC as g,_ as j};
44
+ (detached — click to re-open, × to delete)`;return _.jsxs("span",{className:"terminal-detached-pill",title:o,children:[_.jsx("button",{type:"button",className:"terminal-detached-pill-open","aria-label":`Re-open ${a}`,onClick:t,children:a}),_.jsx("button",{type:"button",className:"terminal-detached-pill-delete","aria-label":`Delete ${a}`,title:`Delete ${a} — this destroys the underlying shell session.`,onClick:c=>{c.stopPropagation(),n()},children:"×"})]})}function qM({terminal:e,onCancel:t,onConfirm:n}){const a=e.title||e.cwd||e.id.slice(0,8);return _.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"delete-terminal-title",onClick:t,children:_.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:o=>o.stopPropagation(),children:[_.jsxs("header",{className:"security-panel-header",children:[_.jsx("h2",{id:"delete-terminal-title",children:"Delete Terminal"}),_.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:t,children:"×"})]}),_.jsxs("section",{className:"terminal-delete-dialog-body",children:[_.jsx("p",{children:"Delete this terminal?"}),_.jsx("span",{children:a}),_.jsx("small",{children:"The shell session and scrollback will be destroyed."})]}),_.jsxs("div",{className:"terminal-delete-dialog-actions",children:[_.jsx("button",{type:"button",className:"secondary-button",onClick:t,children:"Cancel"}),_.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:n,children:"Delete"})]})]})})}function WM({uploads:e,onDismiss:t,onDismissAll:n,onRetry:a,onCancel:o}){if(e.length===0)return null;const d=e.some(m=>m.status==="failed"||m.status==="partial")?"alert":"status",p=e.filter(m=>m.status==="queued"||m.status==="uploading").length;return _.jsxs("aside",{className:`upload-toast upload-toast-${GM(e)}`,role:d,"aria-live":d==="alert"?"assertive":"polite",children:[_.jsxs("header",{className:"upload-toast-header",children:[_.jsx("strong",{children:e.length===1?su(e[0]):`Uploads ${p>0?`(${p} active)`:`(${e.length})`}`}),_.jsx("button",{type:"button","aria-label":"Dismiss upload status",onClick:n,children:"x"})]}),_.jsx("div",{className:"upload-toast-body upload-queue-body",children:e.map(m=>_.jsx(YM,{upload:m,compact:e.length>1,onDismiss:()=>t(m.id),onRetry:()=>a(m.id),onCancel:()=>o(m.id)},m.id))})]})}function YM({upload:e,compact:t,onDismiss:n,onRetry:a,onCancel:o}){const c="response"in e?e.response:void 0,d=e.status==="failed"||e.status==="partial",p=e.status==="queued"||e.status==="uploading";return _.jsxs("section",{className:"upload-queue-item","data-status":e.status,"aria-label":su(e),children:[_.jsxs("div",{className:"upload-queue-item-header",children:[_.jsx("strong",{children:su(e)}),_.jsxs("div",{className:"upload-queue-actions",children:[p?_.jsx("button",{type:"button",onClick:o,children:"Cancel"}):null,d?_.jsx("button",{type:"button",onClick:a,children:"Retry"}):null,_.jsx("button",{type:"button","aria-label":`Dismiss ${su(e)}`,onClick:n,children:"x"})]})]}),e.status==="queued"?_.jsx("p",{children:e.message??"Queued"}):null,e.status==="uploading"?_.jsx($M,{toast:e}):null,c&&"message"in e&&e.message?_.jsx("p",{className:"upload-toast-muted",children:e.message}):null,c?_.jsx(VM,{response:c,compact:t}):null,e.status==="failed"&&!c&&e.message?_.jsx("p",{children:e.message}):null]})}function $M({toast:e}){const t=e.percent===null?ZM(e.loaded):`${e.percent}%`;return _.jsxs(_.Fragment,{children:[_.jsxs("div",{className:"upload-progress-row",children:[_.jsxs("span",{children:[e.fileCount," file",e.fileCount===1?"":"s"]}),_.jsx("span",{children:t})]}),_.jsx("div",{className:"upload-progress-track","aria-hidden":"true",children:_.jsx("span",{style:{width:e.percent===null?"100%":`${e.percent}%`}})})]})}function VM({response:e,compact:t}){const n=e.results.filter(d=>d.status==="failed"),a=e.results.filter(d=>d.status==="uploaded"),o=t?3:6,c=[...n,...a].slice(0,o);return _.jsxs(_.Fragment,{children:[_.jsx("p",{className:"upload-toast-destination",children:e.destinationCwd}),c.length>0?_.jsx("ul",{className:"upload-result-list",children:c.map((d,p)=>_.jsx(XM,{result:d},`${d.relativePath}-${p}`))}):null,e.results.length>c.length?_.jsxs("p",{className:"upload-toast-muted",children:["+",e.results.length-c.length," more"]}):null]})}function XM({result:e}){const t=e.savedRelativePath??e.relativePath,n=e.status==="uploaded"&&e.savedRelativePath!==void 0&&e.savedRelativePath!==e.relativePath;return _.jsxs("li",{"data-status":e.status,children:[_.jsx("span",{className:"upload-result-path",children:t}),n?_.jsx("span",{className:"upload-result-renamed",children:"renamed"}):null,e.status==="failed"&&e.error?_.jsx("span",{className:"upload-result-error",children:e.error}):null]})}function su(e){if(e.status==="queued")return"Preparing upload";if(e.status==="uploading")return`Uploading ${e.fileCount} file${e.fileCount===1?"":"s"}`;if(e.status==="success"){const t=e.response?.uploaded??e.fileCount;return`Uploaded ${t} file${t===1?"":"s"}`}if(e.status==="partial"){const t=e.response?.uploaded??0,n=(e.response?.uploaded??0)+(e.response?.failed??0)||e.fileCount;return`Uploaded ${t} of ${n} files`}return"Upload failed"}function GM(e){return e.some(t=>t.status==="failed")?"failed":e.some(t=>t.status==="partial")?"partial":e.some(t=>t.status==="uploading")?"uploading":e.some(t=>t.status==="queued")?"queued":"success"}function ZM(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${Math.round(e/(1024*1024))} MB`}function QM({toast:e,onActivate:t,onDismiss:n}){if(!e)return null;const a=e,o=a.commandName?`${a.commandName} finished`:"Command finished";function c(p){p.stopPropagation(),n()}function d(p){p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),t(a))}return _.jsxs("aside",{className:"completion-toast",role:"status","aria-live":"polite",tabIndex:0,onClick:()=>t(a),onKeyDown:d,children:[_.jsx("video",{className:"completion-toast-character",src:a.assetSrc,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),_.jsxs("div",{className:"completion-toast-copy",children:[_.jsx("strong",{children:a.tabTitle}),_.jsx("span",{children:o})]}),_.jsx("button",{type:"button","aria-label":"Dismiss completion alert",onClick:c,children:"x"})]})}const JM=Xl(0,0,1,1),vn=1e-6;function eA(e){return Tw(e).map(t=>t.terminalId)}function Tw(e){return Vl(e,JM).sort(nA).map((t,n)=>({...t,index:n+1}))}function tA(e,t,n){const a=Tw(e),o=a.find(d=>d.terminalId===t);return o?a.filter(d=>d.terminalId!==t).map(d=>sA(o,d,n)).filter(d=>d!==null).sort(rA)[0]?.entry.terminalId??null:null}function iA(e,t){return!Number.isInteger(t)||t<1?null:eA(e)[t-1]??null}function Vl(e,t){if(e.type==="pane")return[{terminalId:e.terminalId,bounds:t}];if(e.type==="editor")return[];const n=aA(e.ratio);if(e.direction==="vertical"){const o=t.left+(t.right-t.left)*n;return[...Vl(e.first,Xl(t.left,t.top,o,t.bottom)),...Vl(e.second,Xl(o,t.top,t.right,t.bottom))]}const a=t.top+(t.bottom-t.top)*n;return[...Vl(e.first,Xl(t.left,t.top,t.right,a)),...Vl(e.second,Xl(t.left,a,t.right,t.bottom))]}function sA(e,t,n){const a=e.bounds,o=t.bounds,c=cb(a.left,a.right,o.left,o.right),d=cb(a.top,a.bottom,o.top,o.bottom);switch(n){case"left":return o.centerX>=a.centerX-vn||d<=vn?null:{entry:t,primaryDistance:Math.max(0,a.left-o.right),perpendicularDistance:Math.abs(a.centerY-o.centerY),overlap:d};case"right":return o.centerX<=a.centerX+vn||d<=vn?null:{entry:t,primaryDistance:Math.max(0,o.left-a.right),perpendicularDistance:Math.abs(a.centerY-o.centerY),overlap:d};case"up":return o.centerY>=a.centerY-vn||c<=vn?null:{entry:t,primaryDistance:Math.max(0,a.top-o.bottom),perpendicularDistance:Math.abs(a.centerX-o.centerX),overlap:c};case"down":return o.centerY<=a.centerY+vn||c<=vn?null:{entry:t,primaryDistance:Math.max(0,o.top-a.bottom),perpendicularDistance:Math.abs(a.centerX-o.centerX),overlap:c};default:return null}}function nA(e,t){return Ma(e.bounds.top,t.bounds.top)||Ma(e.bounds.left,t.bounds.left)}function rA(e,t){return Ma(e.primaryDistance,t.primaryDistance)||Ma(e.perpendicularDistance,t.perpendicularDistance)||Ma(t.overlap,e.overlap)||Ma(e.entry.index,t.entry.index)}function Ma(e,t){const n=e-t;return Math.abs(n)<=vn?0:n}function cb(e,t,n,a){return Math.max(0,Math.min(t,a)-Math.max(e,n))}function Xl(e,t,n,a){return{left:e,top:t,right:n,bottom:a,centerX:e+(n-e)/2,centerY:t+(a-t)/2}}function aA(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}class lA extends Error{constructor(t){super(t),this.name="UploadDropError"}}function ub(e){return e?Array.from(e.types??[]).includes("Files")||Mw(e.items).some(n=>n.kind==="file")?!0:Aw(e.files).length>0:!1}async function oA(e){const t=Mw(e.items).filter(n=>n.kind==="file");return t.length>0?cA(t):uA(e.files)}async function cA(e){const t=[];for(const n of e){const a=pA(n);if(a){await kw(a,"",t);continue}const o=n.getAsFile();if(o){t.push({relativePath:Dw(o),file:o});continue}throw new lA("Folder upload is not supported by this browser.")}return t}function uA(e){return Aw(e).map(t=>({relativePath:Dw(t),file:t}))}async function kw(e,t,n){const a=_A(t,e.name);if(e.isFile){const d=await hA(e);n.push({relativePath:a,file:d});return}if(!e.isDirectory)return;const o=e.createReader(),c=await dA(o);for(const d of c)await kw(d,a,n)}function hA(e){return new Promise((t,n)=>{e.file(t,a=>n(a))})}async function dA(e){const t=[];for(;;){const n=await fA(e);if(n.length===0)return t;t.push(...n)}}function fA(e){return new Promise((t,n)=>{e.readEntries(t,a=>n(a))})}function Dw(e){const t=e.webkitRelativePath;return Rw(typeof t=="string"&&t?t:e.name)}function pA(e){const t=e.webkitGetAsEntry?.();return mA(t)?t:null}function mA(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.name=="string"&&typeof t.isFile=="boolean"&&typeof t.isDirectory=="boolean"}function _A(e,t){return Rw(e?`${e}/${t}`:t)}function Rw(e){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")}function Mw(e){return e?Array.from(e):[]}function Aw(e){return e?Array.from(e):[]}const hb="nterminal.terminalWorkspaces.v2",Nw="nterminal.sidebarCollapsed.v1",vA=75,db=Yb.map(e=>e.url),gA=Yb[0].url;function yA({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:a,sessionExpiresAt:o=null,onLogout:c=async()=>{},onSessionInvalid:d}){const p=g.useMemo(()=>e??Eu(),[e]),m=g.useMemo(()=>t??io(null),[t]),f=g.useMemo(()=>NA(n),[n]),S=g.useMemo(()=>T=>Ew(n,T),[n]),y=g.useMemo(()=>()=>Ft(n),[n]),b=g.useSyncExternalStore(S,y,y),x=b.state,C=b.editors,k=!b.loaded,B=b.error,[R,re]=g.useState(!1),[F,J]=g.useState(()=>jA()),[ce,q]=g.useState("servers"),[I,ie]=g.useState(!1),de=g.useSyncExternalStore(a2,Yy,Yy);g.useSyncExternalStore(s0,Wy,Wy);const[j,$]=g.useState(()=>[null]),[H,L]=g.useState(0),[X,G]=g.useState(()=>[n]),[M,V]=g.useState(()=>new Set),[Q,ve]=g.useState({}),[Se,E]=g.useState(null),W=g.useRef(null);g.useRef(!1);const ee=g.useRef(0),[he,ge]=g.useState(null),me=dx(ky(Hb,{activationConstraint:{distance:8}}),ky(Ub,{activationConstraint:{delay:250,tolerance:5}}));g.useEffect(()=>l2(p),[p]);function Ce(T){const A=T.active.data.current;if(A){if(A.kind==="tab"&&typeof A.tabId=="string"&&typeof A.terminalId=="string"){ge({tabId:A.tabId,terminalId:A.terminalId});return}A.kind==="pane"&&typeof A.sourceTabId=="string"&&typeof A.terminalId=="string"&&ge({tabId:A.sourceTabId,terminalId:A.terminalId})}}function ze(T){ge(null);const A=T.active.data.current,K=T.over?.data.current;if(!(!A||!K||typeof A.terminalId!="string")){if(A.kind==="tab"&&typeof A.tabId=="string"){if(K.kind==="tab-position"&&typeof K.index=="number"){Ge({type:"tab.reordered",sourceTabId:A.tabId,targetIndex:K.index});return}K.kind==="pane-zone"&&typeof K.terminalId=="string"&&(K.side==="top"||K.side==="right"||K.side==="bottom"||K.side==="left")&&Ge({type:"tab.dropped_into_pane",sourceTabId:A.tabId,sourceTerminalId:A.terminalId,targetTerminalId:K.terminalId,side:K.side});return}if(A.kind==="pane"&&typeof A.sourceTabId=="string"){if(K.kind==="tab-position"&&typeof K.index=="number"){Ge({type:"terminal.extracted_to_tab",sourceTabId:A.sourceTabId,sourceTerminalId:A.terminalId,targetIndex:K.index});return}K.kind==="pane-zone"&&typeof K.terminalId=="string"&&(K.side==="top"||K.side==="right"||K.side==="bottom"||K.side==="left")&&Ge({type:"tab.dropped_into_pane",sourceTabId:A.sourceTabId,sourceTerminalId:A.terminalId,targetTerminalId:K.terminalId,side:K.side})}}}function Ne(){ge(null)}const Re=x.workspaces.find(T=>T.id===x.activeWorkspaceId)??x.workspaces[0],Pe=Re?.tabs.find(T=>T.id===Re.activeTabId)??Re?.tabs[0],Ye=Pe?.activeTerminalId??null,Be=Ye?x.terminals[Ye]:void 0,ae=RA("(max-width: 760px)"),Ee=g.useMemo(()=>Pe?wu(Pe.root):[],[Pe]),xe=Re&&Pe?ru(n,Re.id,Pe.id):null,Ke=Pe?Bw(Ee,Pe.activeTerminalId,xe?Q[xe]:void 0):null,Xe=ae&&Ee.length>1,gt=g.useMemo(()=>{const T=new Set;for(const A of x.workspaces)for(const K of A.tabs)for(const ue of Nm(K))T.add(ue);return Object.values(x.terminals).filter(A=>!T.has(A.id))},[x.terminals,x.workspaces]),[yt,mi]=g.useState([]),te=g.useRef([]),je=g.useRef(null),[He,_i]=g.useState(null),[Vi,ai]=g.useState([]),[kt,ji]=g.useState(()=>zr()),Ti=g.useRef(0),Nt=g.useRef(n),$s=g.useRef(db),Hi=g.useRef(kt),qt=g.useRef(()=>{});qt.current=cs;const Jt=g.useCallback(async()=>{try{const T=await p.listNotificationAssets();ai(T.assets.filter(A=>A.enabled).map(A=>A.url))}catch{ai([])}},[p]);g.useEffect(()=>{G(T=>T.some(A=>mn(A,n))?T:[...T,n])},[n]);const Dt=g.useCallback(T=>{const A=Ft(T),K=io(T);for(const ue of Object.keys(A.state.terminals))Ap(K.createWebSocketUrl(ue)),$S(ue);jM(T),G(ue=>ue.filter(pe=>!mn(pe,T))),V(ue=>{const pe=`${nu(T)}:`;let ke=!1;const De=new Set;for(const rt of ue){if(rt.startsWith(pe)){ke=!0;continue}De.add(rt)}return ke?De:ue}),ve(ue=>{const pe=`${nu(T)}:`;let ke=!1;const De={};for(const[rt,ut]of Object.entries(ue)){if(rt.startsWith(pe)){ke=!0;continue}De[rt]=ut}return ke?De:ue})},[]);g.useEffect(()=>{let T=!1;return p.listAgents().then(A=>{if(!T){const K=A.agents.map(pe=>pe.id),ue=[null,...K];n!==null&&!K.includes(n)&&(Dt(n),a?.(null)),$(ue)}}).catch(()=>{}),()=>{T=!0}},[n,p,Dt,a,H]);const Cn=g.useCallback(T=>{Dt(T),L(A=>A+1),mn(T,Nt.current)&&a?.(null)},[Dt,a]);g.useEffect(()=>{$(T=>T.some(A=>mn(A,n))?T:[...T,n])},[n]),g.useEffect(()=>{Nt.current=n},[n]),g.useEffect(()=>{Jt()},[Jt]),g.useEffect(()=>Xb(()=>ji(zr())),[]),g.useEffect(()=>{const T=A=>{qt.current(A)};return window.addEventListener("keydown",T,!0),()=>window.removeEventListener("keydown",T,!0)},[]),g.useEffect(()=>{$s.current=Vi.length>0?Vi:db},[Vi]),g.useEffect(()=>{Hi.current=kt},[kt]),g.useEffect(()=>{if(!b.loaded||!Re||!Pe)return;const T=ru(n,Re.id,Pe.id);V(A=>{if(A.has(T))return A;const K=new Set(A);return K.add(T),K})},[n,b.loaded,Re?.id,Pe?.id]),g.useEffect(()=>()=>{Ir()},[]),g.useEffect(()=>AM(T=>{const A=Ft(T.agentId).state,K=A.workspaces.flatMap(De=>De.tabs).find(De=>De.id===T.tabId),ue=A.terminals[T.terminalId],pe=K?.title?.trim()||ue?.title||T.commandName||"terminal",ke=document.visibilityState==="visible"&&mn(T.agentId,Nt.current)&&T.tabId===AA(A);if(ke||zE({tabTitle:pe,commandName:T.commandName,terminalId:T.terminalId}),!ke&&document.visibilityState==="visible"&&Hi.current.enabled){const De=Ti.current+1;Ti.current=De;const rt=$s.current;_i({id:De,agentId:T.agentId,terminalId:T.terminalId,tabId:T.tabId,tabTitle:pe,commandName:T.commandName,assetSrc:rt[Math.floor(Math.random()*rt.length)]??gA})}}),[]),g.useEffect(()=>{if(!He||kt.persistUntilDismissed)return;const T=window.setTimeout(()=>{_i(A=>A?.id===He.id?null:A)},kt.durationSeconds*1e3);return()=>window.clearTimeout(T)},[He,kt]),g.useEffect(()=>{W.current?.focus(),W.current?.select()},[Se?.workspaceId]),g.useEffect(()=>{HA(F),F&&E(null)},[F]),g.useEffect(()=>{let T=!1;async function A(){if(!Ft(n).loaded){Ta(n,!1,null);try{const ue=BA(f),[pe,ke]=await Promise.all([m.listTerminals(),m.getTerminalLayout()]),De=pe.terminals.length>0?pe.terminals:[(await m.createTerminal({cols:80,rows:24})).terminal];if(!T){const rt=ke.layout?Ow(ke.layout):null,ut=rt??ue??{},yi=zp(De,void 0,ut.savedWorkspaces,ut.savedActiveWorkspaceId),Fr=Cf(yi);rb(n,yi),Xc(n,ke.revision,JSON.stringify(Fr)),Ta(n,!0,null),!rt&&ue&&Ui(Fr,{baseRevision:ke.revision})}}catch(ue){!T&&!bt(ue)&&Ta(n,!0,Kl(ue))}}}return A(),()=>{T=!0}},[n,m]);async function Bs(){await Wt(async()=>{const T=await m.createTerminal({cols:80,rows:24});Ge({type:"terminal.created",terminal:T.terminal})})}async function Vs(T){await Wt(async()=>{const A=Ye?{parentTerminalId:Ye,cols:80,rows:24}:{cols:80,rows:24},K=await m.createTerminal(A);Ge({type:"terminal.split",terminal:K.terminal,direction:T})})}async function Ts(T){if(!Ye)throw new Error("No active pane is available.");const A=await m.readFile(T),K=`editor-${Date.now().toString(36)}-${zM(n)}`,ue=zA(A.path);ab(n,pe=>({...pe,[K]:{id:K,title:ue,rootToken:T.rootToken,path:A.path,read:A}})),xe&&ve(pe=>({...pe,[xe]:Lw(K)})),Ge({type:"editor.split",editorId:K,title:ue,direction:"vertical"})}function ks(T){ab(n,A=>{const K={...A};return delete K[T],K}),Ge({type:"editor.closed",editorId:T})}function ot(T){St([T])}function St(T){for(const A of T)Ge({type:"terminal.detached",terminalId:A})}async function Rt(T){await Wt(async()=>{await Bt(T),Ap(m.createWebSocketUrl(T)),$S(T),Ge({type:"terminal.closed",terminalId:T})})}async function li(T,A){const K=A.trim();if(!K)return;let ue=null;for(const pe of x.workspaces){const ke=pe.tabs.find(De=>De.id===T);if(ke){ue=ke.activeTerminalId;break}}if(Ge({type:"tab.renamed",tabId:T,title:K}),!!ue)try{const pe=await m.renameTerminal(ue,K);ct({type:"terminal.updated",terminal:pe.terminal})}catch(pe){Ta(n,!0,Kl(pe))}}function ei(T){const A=x.terminals[T];A&&Ge({type:"terminal.created",terminal:A})}async function Bt(T){try{await m.closeTerminal(T)}catch(A){if(A instanceof yn&&A.status===404)return;throw A}}async function nt(){await Wt(async()=>{await c()})}async function Wt(T){Ta(n,!0,null);try{await T()}catch(A){if(bt(A))return;Ta(n,!0,Kl(A))}}function bt(T){return T instanceof yn&&T.status===401&&!m.isAgent&&d?(d(),!0):!1}function Ge(T){Ul(n,T);const A=Ft(n),K=A.state;if(!A.loaded||K.workspaces.length===0)return;const ue=Cf(K);JSON.stringify(ue)!==A.lastPersistedLayoutJson&&Qi(ue)}function ct(T){Ul(n,T)}function vi(T,A,K,ue){const pe=ru(T,A,K);ve(ke=>({...ke,[pe]:ue}))}function Ai(T){xe&&ve(A=>({...A,[xe]:T}))}function Ni(T,A){const K=Cu(T);A?vi(n,A.workspaceId,A.tabId,K):Ai(K),Ge({type:"pane.selected",terminalId:T})}function ki(T){Ai(T.key),T.type==="terminal"&&Ge({type:"pane.selected",terminalId:T.terminalId})}function cs(T){if(I||T.isComposing||T.key==="Process"||EA(T.target))return;const A=bA(T);if(!A)return;if(T.preventDefault(),T.stopPropagation(),A.type==="server.previous"||A.type==="server.next"){gi(A.type==="server.next"?1:-1);return}const K=Ft(n).state,ue=K.workspaces.find(De=>De.id===K.activeWorkspaceId)??K.workspaces[0],pe=ue?.tabs.find(De=>De.id===ue.activeTabId)??ue?.tabs[0];if(A.type==="split"){if(!pe)return;Vs(A.direction);return}if(!ue||!pe)return;if(A.type==="tab.previous"||A.type==="tab.next"){const De=xA(ue.tabs,pe.id,A.type==="tab.next"?1:-1);De&&Ge({type:"tab.selected",tabId:De.id});return}if(A.type==="tab.index"){const De=ue.tabs[A.index-1];De&&Ge({type:"tab.selected",tabId:De.id});return}const ke=wA(pe.root,pe.activeTerminalId,A);ke&&Ni(ke,{workspaceId:ue.id,tabId:pe.id})}function gi(T){if(!a||j.length===0)return;const A=j.findIndex(ke=>mn(ke,n)),ue=((A===-1?0:A)+T+j.length)%j.length,pe=j[ue]??null;mn(pe,n)||a(pe)}function mt(T){ub(T.dataTransfer)&&(T.preventDefault(),T.dataTransfer.dropEffect="copy")}function Yt(T){if(!ub(T.dataTransfer))return;T.preventDefault();const A=LA(Ft(n).state),K=ee.current+1;if(ee.current=K,!A){hr({id:K,status:"failed",fileCount:0,message:"No active running terminal is available for upload."});return}hr({id:K,status:"queued",fileCount:0,terminalId:A.id,message:"Preparing upload..."}),us(K,A.id,T.dataTransfer)}async function us(T,A,K){try{const ue=await oA(K);if(ue.length===0)throw new Error("No files were found in the drop.");Xi(T,{id:T,status:"queued",fileCount:ue.length,message:"Queued"},{terminalId:A,files:ue})}catch(ue){Xi(T,{id:T,status:"failed",fileCount:0,message:Kl(ue)},{terminalId:A})}finally{xn()}}async function Xs(T){const A=te.current.find(ke=>ke.id===T);if(!A?.terminalId||!A.files||A.files.length===0)return;const K=A.terminalId,ue=A.files,pe=new AbortController;je.current=T,Xi(T,{id:T,status:"uploading",fileCount:ue.length,loaded:0,total:null,percent:null},{terminalId:K,files:ue,abortController:pe});try{const ke=await g2({terminalId:K,files:ue,signal:pe.signal,onProgress:yi=>{Xi(T,{id:T,status:"uploading",fileCount:ue.length,loaded:yi.loaded,total:yi.total,percent:yi.percent},{terminalId:K,files:ue,abortController:pe})}}),De=ke.failed>0?ke.uploaded>0?"partial":"failed":"success",rt=ke.failed>0?OA(ke):void 0,ut={id:T,status:De,fileCount:ue.length,response:ke};rt&&(ut.message=rt),Xi(T,ut,{terminalId:K,files:ue})}catch(ke){Xi(T,{id:T,status:"failed",fileCount:ue.length,message:pe.signal.aborted?"Upload canceled.":Kl(ke)},{terminalId:K,files:ue})}finally{je.current===T&&(je.current=null),xn()}}function xn(){if(je.current!==null)return;const T=te.current.find(A=>A.status==="queued");T?.terminalId&&T.files&&T.files.length>0&&Xs(T.id)}function hr(T){Gi(A=>[...A,T])}function Xi(T,A,K={}){Gi(ue=>ue.map(pe=>{if(pe.id!==T)return pe;const ke={...A},De=K.terminalId??pe.terminalId,rt=K.files??pe.files;return De!==void 0&&(ke.terminalId=De),rt!==void 0&&(ke.files=rt),K.abortController!==void 0&&(ke.abortController=K.abortController),ke}))}function Gi(T){const A=T(te.current);te.current=A,mi(A)}function En(T){te.current.find(K=>K.id===T)?.abortController?.abort(),je.current===T&&(je.current=null),Gi(K=>K.filter(ue=>ue.id!==T)),xn()}function Ls(){for(const T of te.current)T.abortController?.abort();je.current=null,Gi(()=>[])}function Os(T){const A=te.current.find(K=>K.id===T);if(A){if(A.status==="queued"){En(T);return}A.abortController?.abort()}}function Ds(T){const A=te.current.find(ue=>ue.id===T);if(!A?.terminalId||!A.files||A.files.length===0)return;const K=Zi(A);if(K.length===0){Xi(T,{id:T,status:"failed",fileCount:A.fileCount,message:"No failed files are available to retry."},{terminalId:A.terminalId,files:A.files});return}Xi(T,{id:T,status:"queued",fileCount:K.length,message:"Queued"},{terminalId:A.terminalId,files:K}),xn()}function Zi(T){const A=T.files??[],K="response"in T?T.response:void 0;if(!K)return A;const ue=K.results.filter(De=>De.status==="failed").map(De=>De.relativePath);if(ue.length===0)return[];const pe=new Map;for(const De of A){const rt=pe.get(De.relativePath)??[];rt.push(De),pe.set(De.relativePath,rt)}const ke=[];for(const De of ue){const ut=pe.get(De)?.shift();ut&&ke.push(ut)}return ke}function Lt(T){const K=Ft(T.agentId).state.workspaces.find(ue=>ue.tabs.some(pe=>pe.id===T.tabId));K&&vi(T.agentId,K.id,T.tabId,Cu(T.terminalId)),Ul(T.agentId,{type:"pane.selected",terminalId:T.terminalId}),OM(T.agentId,T.tabId),mn(T.agentId,n)||a?.(T.agentId),_i(null)}function Qi(T){const A=Ft(n).mutable.saveCoord;A.pendingLayoutSave=T,Pl(T,f),A.saveTimer!==null&&window.clearTimeout(A.saveTimer),A.saveTimer=window.setTimeout(()=>{A.saveTimer=null;const K=A.pendingLayoutSave;A.pendingLayoutSave=null,K&&Ui(K)},vA)}function Ir(){const T=Ft(n).mutable.saveCoord;T.saveTimer!==null&&(window.clearTimeout(T.saveTimer),T.saveTimer=null);const A=T.pendingLayoutSave;T.pendingLayoutSave=null,A&&(Pl(A,f),Ui(A))}function Ui(T,A={}){const K=Ft(n).mutable.saveCoord;K.nextPersistLayout=T,A.baseRevision!==void 0&&(K.queuedBaseRevision=A.baseRevision),!K.nextPersistQueued&&(K.nextPersistQueued=!0,K.persistChain=K.persistChain.then(async()=>{K.nextPersistQueued=!1;const ue=K.nextPersistLayout,pe=K.queuedBaseRevision;K.nextPersistLayout=null,K.queuedBaseRevision=void 0,ue&&await zs(ue,pe!==void 0?{baseRevision:pe}:{})}))}async function zs(T,A={}){const K=Ft(n),ue=A.baseRevision??K.layoutRevision,pe={layout:T,...typeof ue=="number"?{baseRevision:ue}:{}};try{const ke=await m.saveTerminalLayout(pe),De=ke.layout??T;Xc(n,ke.revision,JSON.stringify(De)),Pl(De,f);return}catch(ke){if(ke instanceof yn&&ke.status===409)try{const De=await m.getTerminalLayout();if(De.layout){const rt=Ft(n).state,ut=zp(Object.values(rt.terminals),void 0,De.layout.workspaces,De.layout.activeWorkspaceId),yi=Cf(ut);rb(n,ut),Xc(n,De.revision,JSON.stringify(yi)),Pl(yi,f)}else Xc(n,De.revision,K.lastPersistedLayoutJson);return}catch{}Pl(T,f)}}const O=UA(o),fe=!F||R,Oe=fe?ce:"servers";return _.jsx(dE,{sensors:me,onDragStart:Ce,onDragEnd:ze,onDragCancel:Ne,children:_.jsxs("main",{className:"terminal-shell","data-collapsed":F,"data-sidebar-open":R,onDragOver:mt,onDrop:Yt,children:[_.jsx("button",{type:"button",className:"workspace-backdrop","aria-label":"Close workspaces",onClick:()=>re(!1)}),_.jsxs("aside",{className:"workspace-sidebar",children:[_.jsxs("header",{className:"workspace-brand",children:[fe?_.jsx(Cb,{height:20}):_.jsx(wb,{size:24}),_.jsx("button",{type:"button",className:"sidebar-collapse-button","aria-label":F?"Expand sidebar":"Collapse sidebar",title:F?"Expand sidebar":"Collapse sidebar",onClick:()=>J(T=>!T),children:F?">":"<"}),_.jsx("button",{type:"button",className:"sidebar-drawer-close-button","aria-label":"Close workspaces",title:"Close workspaces",onClick:()=>re(!1),children:"x"})]}),_.jsxs("div",{className:"workspace-sidebar-content",children:[fe?_.jsxs("div",{className:"workspace-sidebar-tabs",role:"tablist","aria-label":"Sidebar mode",children:[_.jsx("button",{type:"button",role:"tab","aria-selected":ce==="servers",onClick:()=>{q("servers"),E(null)},children:"Servers"}),_.jsx("button",{type:"button",role:"tab","aria-selected":ce==="files",onClick:()=>{q("files"),E(null)},children:"Files"})]}):null,Oe==="servers"&&fe?_.jsx("nav",{className:"workspace-nav","aria-label":"Servers",children:_.jsx(ef,{api:p,activeAgentId:n,onSelectServer:a??(()=>{}),onSessionInvalid:d,refreshToken:H})}):null,fe?null:_.jsx("nav",{className:"workspace-nav workspace-nav--collapsed","aria-label":"Servers",children:_.jsx(ef,{api:p,activeAgentId:n,onSelectServer:a??(()=>{}),onSessionInvalid:d,refreshToken:H,compact:!0})}),Oe==="files"?_.jsxs(_.Fragment,{children:[fe?_.jsx("nav",{className:"workspace-nav workspace-nav--compact","aria-label":"Servers",children:_.jsx(ef,{api:p,activeAgentId:n,onSelectServer:a??(()=>{}),onSessionInvalid:d,refreshToken:H})}):null,_.jsx(C2,{api:m,activeTerminalId:Ye,activeTerminalCwd:Be?.cwd??null,onOpenFile:Ts})]}):null]}),fe?_.jsxs("div",{className:"workspace-sidebar-footer",children:[_.jsx("span",{children:O}),_.jsxs("div",{className:"workspace-sidebar-footer-actions",children:[_.jsxs("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"settings",title:"Settings",onClick:()=>ie(!0),children:[_.jsx(pb,{name:"settings"}),de.hasUpdates?_.jsx("span",{className:"update-pulse-dot","aria-hidden":"true"}):null]}),_.jsx("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"logout",title:"Logout",onClick:()=>{nt()},children:_.jsx(pb,{name:"logout"})})]})]}):null]}),I?_.jsx(_2,{api:p,onClose:()=>ie(!1),updateAvailable:de.hasUpdates,onNotificationAssetsChanged:()=>{Jt()},onAgentRemoved:Cn}):null,_.jsxs("section",{className:"terminal-main","aria-label":"Terminal workspace","data-mobile-pane-switcher":Xe?"true":void 0,children:[_.jsx(KM,{tabs:Re?.tabs??[],activeTabId:Re?.activeTabId??null,terminals:x.terminals,unreadCompletionTabIds:b.unreadCompletions,detachedTerminals:gt,onSelectTab:T=>Ge({type:"tab.selected",tabId:T}),onCreateTab:()=>{Bs()},onToggleWorkspaces:()=>re(T=>!T),onCloseTerminals:T=>St(T),onReattachTerminal:T=>ei(T),onDeleteTerminal:T=>{Rt(T)},onSplitVertical:()=>{Vs("vertical")},onSplitHorizontal:()=>{Vs("horizontal")},onRenameTab:(T,A)=>{li(T,A)},activePaneAvailable:!!Ye}),Xe?_.jsx(kA,{targets:Ee,activeLeafKey:Ke,terminals:x.terminals,editors:C,onSelect:ki}):null,B?_.jsx("div",{className:"workspace-error",children:B}):null,_.jsxs("section",{className:"workspace-body","aria-busy":k,children:[k?_.jsx("div",{className:"workspace-placeholder",children:"Opening shell..."}):null,!k&&!Pe?_.jsx(TA,{onCreate:()=>{Bs()}}):null,X.map(T=>{const A=mn(T,n);return _.jsx(SA,{agentId:T,active:A,activeServerApi:A?m:void 0,visitedTabKeys:M,refreshCwdOnEnter:A&&Oe==="files",draggingTab:A?he:null,mobileSplitFocus:ae,mobileFocusedLeafByTabKey:Q,onSelect:K=>{A&&Ni(K)},onClose:K=>{A&&ot(K)},onCloseEditor:K=>{A&&ks(K)},onResize:(K,ue)=>{A&&Ge({type:"pane.resized",path:K,ratio:ue})},onExit:(K,ue)=>{A?ct({type:"terminal.exited",terminalId:K,exitCode:ue}):Ul(T,{type:"terminal.exited",terminalId:K,exitCode:ue})},onSnapshot:(K,ue)=>{const pe={type:"terminal.updated",terminal:K,notifyCompletion:ue?.notifyCompletion===!0};A?ct(pe):Ul(T,pe)},...T===null&&d?{onAuthClose:d}:{}},nu(T))})]}),_.jsx(QM,{toast:He,onActivate:Lt,onDismiss:()=>_i(null)}),_.jsx(WM,{uploads:yt,onDismiss:En,onDismissAll:Ls,onRetry:Ds,onCancel:Os})]})]})})}function SA({agentId:e,active:t,activeServerApi:n,visitedTabKeys:a,refreshCwdOnEnter:o,draggingTab:c,mobileSplitFocus:d,mobileFocusedLeafByTabKey:p,onSelect:m,onClose:f,onCloseEditor:S,onResize:y,onExit:b,onSnapshot:x,onAuthClose:C}){const k=g.useMemo(()=>de=>Ew(e,de),[e]),B=g.useMemo(()=>()=>Ft(e),[e]),R=g.useSyncExternalStore(k,B,B),re=g.useMemo(()=>io(e),[e]),F=n??re,J=R.state,ce=J.workspaces.find(de=>de.id===J.activeWorkspaceId)??J.workspaces[0],q=ce?.id??null,ie=(ce?.tabs.find(de=>de.id===ce.activeTabId)??ce?.tabs[0])?.id??null;return!R.loaded||J.workspaces.length===0?null:_.jsx("div",{className:"workspace-server-surface","data-active":t,"aria-hidden":!t,children:J.workspaces.flatMap(de=>de.tabs.map(j=>{const $=t&&de.id===q&&j.id===ie,H=ru(e,de.id,j.id),L=wu(j.root),X=d&&L.length>1?Bw(L,j.activeTerminalId,p[H]):null;return!$&&!a.has(H)?null:_.jsx("div",{className:"workspace-tab-surface","data-active":$,"aria-hidden":!$,children:_.jsx(Bp,{node:j.root,terminals:J.terminals,editors:R.editors,api:F,activeTerminalId:j.activeTerminalId,visible:$,refreshCwdOnEnter:$&&o,tabId:j.id,dropZoneActive:$&&c!==null,draggingTerminalId:$?c?.terminalId??null:null,mobileFocusLeafKey:X,onSelect:m,onClose:f,onCloseEditor:S,onResize:y,onExit:b,onSnapshot:x,...C?{onAuthClose:C}:{}})},`${de.id}:${j.id}`)}))})}function bA(e){const t=WE(e);if(t)switch(t.id){case"server.previous":case"server.next":case"tab.previous":case"tab.next":return{type:t.id};case"tab.index":case"pane.index":return t.index===null?null:{type:t.id,index:t.index};case"split.right":return{type:"split",direction:"vertical"};case"split.down":return{type:"split",direction:"horizontal"};default:return null}if(e.ctrlKey&&e.altKey&&!e.metaKey&&!e.shiftKey){const n=CA(e.key);return n?{type:"pane.direction",direction:n}:null}return null}function wA(e,t,n){switch(n.type){case"pane.direction":return tA(e,t,n.direction);case"pane.index":return iA(e,n.index);default:return null}}function CA(e){switch(e){case"ArrowLeft":return"left";case"ArrowRight":return"right";case"ArrowUp":return"up";case"ArrowDown":return"down";default:return null}}function xA(e,t,n){if(e.length===0)return null;const a=e.findIndex(c=>c.id===t);return e[((a===-1?0:a)+n+e.length)%e.length]??null}function wu(e){return e.type==="pane"?[{key:Cu(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:Lw(e.editorId),type:"editor",editorId:e.editorId,title:e.title}]:[...wu(e.first),...wu(e.second)]}function Bw(e,t,n){if(n&&e.some(o=>o.key===n))return n;const a=t?Cu(t):null;return a&&e.some(o=>o.key===a)?a:e[0]?.key??null}function Cu(e){return`terminal:${e}`}function Lw(e){return`editor:${e}`}function EA(e){if(!(e instanceof HTMLElement)||e.closest(".xterm"))return!1;if(e.closest('input, textarea, select, [role="textbox"]'))return!0;const t=e.closest("[contenteditable]");return t instanceof HTMLElement&&t.getAttribute("contenteditable")?.toLowerCase()!=="false"}function TA({onCreate:e}){return _.jsxs("div",{className:"empty-workspace",children:[_.jsx("span",{children:"No terminal is open."}),_.jsx("button",{type:"button",onClick:e,children:"New tab"})]})}function kA({targets:e,activeLeafKey:t,terminals:n,editors:a,onSelect:o}){const[c,d]=g.useState(!1);if(e.length<=1)return null;const p=t?e.findIndex(b=>b.key===t):-1,m=p>=0?p:0,f=e[m]??e[0],S=fb(f,n,a);function y(b){const x=(m+b+e.length)%e.length,C=e[x];C&&o(C)}return _.jsxs("div",{className:"mobile-pane-switcher",role:"group","aria-label":"Pane switcher",children:[_.jsx("button",{type:"button","aria-label":"Previous pane",onClick:()=>y(-1),children:"<"}),_.jsxs("button",{type:"button",className:"mobile-pane-current","aria-label":"Open pane switcher","aria-haspopup":"dialog","aria-expanded":c,title:S,onClick:()=>d(!0),children:["Pane ",m+1,"/",e.length," | ",S]}),_.jsx("button",{type:"button","aria-label":"Next pane",onClick:()=>y(1),children:">"}),c?_.jsx("div",{className:"mobile-pane-sheet-backdrop",onClick:()=>d(!1),children:_.jsxs("section",{className:"mobile-pane-sheet",role:"dialog","aria-modal":"true","aria-label":"Pane switcher",onClick:b=>b.stopPropagation(),children:[_.jsxs("header",{children:[_.jsx("strong",{children:"Panes"}),_.jsx("button",{type:"button","aria-label":"Close pane switcher",onClick:()=>d(!1),children:"x"})]}),_.jsx("div",{className:"mobile-pane-sheet-list",children:e.map((b,x)=>{const C=fb(b,n,a),k=DA(b,n,a),B=b.key===f.key;return _.jsxs("button",{type:"button","data-active":B,onClick:()=>{o(b),d(!1)},children:[_.jsx("span",{className:"mobile-pane-sheet-index",children:x+1}),_.jsxs("span",{className:"mobile-pane-sheet-copy",children:[_.jsx("strong",{children:C}),_.jsx("small",{children:k})]}),_.jsx("span",{className:"mobile-pane-sheet-type",children:b.type})]},b.key)})})]})}):null]})}function fb(e,t,n){if(e.type==="editor")return n[e.editorId]?.title||e.title||e.editorId;const a=t[e.terminalId];return a?.title||a?.cwd||e.terminalId}function DA(e,t,n){if(e.type==="editor"){const c=n[e.editorId];return c?.path?`editor | ${c.path}`:"editor"}const a=t[e.terminalId];return a?`${a.activity==="busy"?`busy${a.currentCommand?`: ${a.currentCommand}`:""}`:a.activity==="idle"?"idle":a.status} | ${a.cwd}`:"terminal"}function RA(e){const[t,n]=g.useState(()=>MA(e));return g.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function"){n(!1);return}const a=window.matchMedia(e),o=()=>n(a.matches);return o(),typeof a.addEventListener=="function"?(a.addEventListener("change",o),()=>a.removeEventListener("change",o)):(a.addListener(o),()=>a.removeListener(o))},[e]),t}function MA(e){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(e).matches}function mn(e,t){return e===t}function AA(e){const t=e.workspaces.find(a=>a.id===e.activeWorkspaceId)??e.workspaces[0];return(t?.tabs.find(a=>a.id===t.activeTabId)??t?.tabs[0])?.id??null}function nu(e){return e??"__local__"}function ru(e,t,n){return`${nu(e)}:${t}:${n}`}function NA(e){return e?{workspaceKey:`${hb}:${e}`}:{workspaceKey:hb}}function BA(e){const t=localStorage.getItem(e.workspaceKey);if(!t)return null;try{const n=JSON.parse(t),a=Wb(n);return a?Ow(a):null}catch{return null}}function Ow(e){const t=Wb(e);return t?{savedWorkspaces:t.workspaces,savedActiveWorkspaceId:t.activeWorkspaceId}:null}function Pl(e,t){if(e.workspaces.length>0){localStorage.setItem(t.workspaceKey,JSON.stringify(e));return}localStorage.removeItem(t.workspaceKey)}function LA(e){const t=e.workspaces.find(o=>o.id===e.activeWorkspaceId)??e.workspaces[0],n=t?.tabs.find(o=>o.id===t.activeTabId)??t?.tabs[0],a=n?e.terminals[n.activeTerminalId]:void 0;return a?.status==="running"?a:null}function OA(e){return e.results.find(t=>t.status==="failed"&&t.error)?.error}function zA(e){return e.split("/").filter(Boolean).pop()??e}function jA(){try{return localStorage.getItem(Nw)==="true"}catch{return!1}}function HA(e){try{localStorage.setItem(Nw,e?"true":"false")}catch{}}function UA(e){if(!e)return"session · local";const t=Date.parse(e);if(!Number.isFinite(t))return"session · local";const n=t-Date.now();if(n<=0)return"session · expired";const a=Math.max(1,Math.floor(n/6e4));return a<60?`session · ${a}m left`:`session · ${Math.floor(a/60)}h left`}function pb({name:e}){return _.jsxs("svg",{className:"workspace-footer-icon",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[e==="settings"?_.jsxs(_.Fragment,{children:[_.jsx("path",{d:"M4 7h9"}),_.jsx("path",{d:"M17 7h3"}),_.jsx("circle",{cx:"15",cy:"7",r:"2"}),_.jsx("path",{d:"M4 12h3"}),_.jsx("path",{d:"M11 12h9"}),_.jsx("circle",{cx:"9",cy:"12",r:"2"}),_.jsx("path",{d:"M4 17h9"}),_.jsx("path",{d:"M17 17h3"}),_.jsx("circle",{cx:"15",cy:"17",r:"2"})]}):null,e==="logout"?_.jsxs(_.Fragment,{children:[_.jsx("path",{d:"M10 6H6v12h4"}),_.jsx("path",{d:"M13 8l4 4-4 4"}),_.jsx("path",{d:"M8 12h9"})]}):null]})}function Kl(e){return e instanceof Error?e.message:"Request failed"}function PA({api:e,onDone:t}){const[n,a]=g.useState(null),[o,c]=g.useState(null),[d,p]=g.useState(""),[m,f]=g.useState(!1),[S,y]=g.useState(null),[b,x]=g.useState(null);g.useEffect(()=>{let k=!1;return e.setupTotp().then(B=>{k||(a(B.qrDataUrl),c(B.secret))}).catch(B=>{k||x(B instanceof Error?B.message:"Failed to generate QR code")}),()=>{k=!0}},[e]);async function C(k){if(k.preventDefault(),!!o){f(!0),y(null);try{await e.activateTotp({secret:o,otp:d}),t()}catch(B){y(B instanceof Error?B.message:"Verification failed")}finally{f(!1)}}}return b?_.jsx("p",{className:"form-error",children:b}):!n||!o?_.jsx("p",{className:"muted",children:"Generating authenticator setup..."}):_.jsxs("div",{className:"totp-setup",children:[_.jsx("p",{className:"totp-setup-instructions",children:"Scan this QR code with an authenticator app (Google Authenticator, Authy, 1Password, etc.), then enter the 6-digit code to confirm."}),_.jsx("div",{className:"totp-qr-container",children:_.jsx("img",{src:n,alt:"TOTP QR code",width:192,height:192})}),_.jsxs("details",{className:"totp-secret-details",children:[_.jsx("summary",{children:"Can't scan? Enter manually"}),_.jsx("p",{className:"totp-secret-text",children:o})]}),_.jsxs("form",{className:"auth-form",onSubmit:C,children:[_.jsxs("label",{children:["Verification code",_.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:d,onChange:k=>p(k.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),S?_.jsx("p",{className:"form-error",children:S}):null,_.jsx("button",{type:"submit",disabled:m||d.length!==6,children:"Activate 2FA"})]})]})}function KA({api:e,serverApi:t,activeAgentId:n=null,onSelectServer:a}){const o=g.useMemo(()=>e??Eu(),[e]),c=g.useMemo(()=>t??io(null),[t]),[d,p]=g.useState(null),[m,f]=g.useState(null);g.useEffect(()=>{let C=!1;return o.getSession().then(k=>{C||(p(k),f(null))}).catch(k=>{C||(f(go(k)),p(null))}),()=>{C=!0}},[o]);const S=WA(d);async function y(){const C=await o.getSession();p(C),f(null)}async function b(){ZS(),lb(),iR(),f(null),p(null);try{await y()}catch(C){f(go(C))}}if(S==="workspace")return _.jsx(yA,{api:o,serverApi:c,activeAgentId:n,onSelectServer:a,sessionExpiresAt:d?.expiresAt??null,onSessionInvalid:()=>{b()},onLogout:async()=>{ZS(),lb();const C=await o.logout();p(C)}});const x={loading:"Terminal",setup_password:"Set password",setup_totp:"Set up 2FA",login:"Unlock terminal",reauth:"Verify it’s you",workspace:"Terminal"};return _.jsxs("main",{className:"auth-screen",children:[_.jsxs("div",{className:"auth-background","aria-hidden":"true",children:[_.jsx("div",{className:"auth-grid"}),_.jsx("div",{className:"auth-glow"})]}),_.jsxs("section",{className:"auth-panel","aria-busy":S==="loading",children:[_.jsxs("header",{className:"auth-header",children:[_.jsxs("div",{className:"auth-brand",children:[_.jsx(wb,{size:26}),_.jsxs("div",{children:[_.jsx(Cb,{height:17}),_.jsx("p",{className:"auth-host",children:"local terminal"})]})]}),_.jsx("h1",{children:x[S]})]}),m?_.jsx("p",{className:"form-error",children:m}):null,S==="loading"?_.jsx("p",{className:"muted",children:"Checking session..."}):null,S==="loading"&&m?_.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{b()},children:"Retry"}):null,S==="setup_password"?_.jsx(IA,{api:o,onSession:C=>{p(C)}}):null,S==="setup_totp"?_.jsx(PA,{api:o,onDone:()=>{y()}}):null,S==="login"?_.jsx(FA,{api:o,session:d,onSession:p,onRefresh:y}):null,S==="reauth"?_.jsx(qA,{api:o,session:d,onSession:p,onFullLogin:()=>p(C=>C&&{...C,deviceTrusted:!1})}):null]})]})}function IA({api:e,onSession:t}){const[n,a]=g.useState(""),[o,c]=g.useState(""),[d,p]=g.useState(!1),[m,f]=g.useState(null);async function S(y){y.preventDefault(),p(!0),f(null);try{if(n!==o){f("Passwords do not match");return}t(await e.setupPassword({password:n}))}catch(b){f(go(b))}finally{p(!1)}}return _.jsxs("form",{className:"auth-form",onSubmit:S,children:[_.jsxs("label",{children:["Password",_.jsx("input",{autoFocus:!0,value:n,onChange:y=>a(y.currentTarget.value),type:"password",minLength:8,required:!0})]}),_.jsxs("label",{children:["Confirm password",_.jsx("input",{value:o,onChange:y=>c(y.currentTarget.value),type:"password",minLength:8,required:!0})]}),m?_.jsx("p",{className:"form-error",children:m}):null,_.jsx("button",{type:"submit",disabled:d||n.length<8||o.length<8,children:"Set password"})]})}function FA({api:e,session:t,onSession:n,onRefresh:a}){const[o,c]=g.useState(""),[d,p]=g.useState(""),[m,f]=g.useState(!1),[S,y]=g.useState(!1),[b,x]=g.useState(null),C=t?.totpEnabled??!1,k=t?.currentIpWhitelisted??!1;async function B(R){R.preventDefault(),y(!0),x(null);try{n(await e.login({password:o,...C?{otp:d}:{},rememberNetwork:m}))}catch(re){x(go(re))}finally{y(!1)}}return _.jsxs("form",{className:"auth-form",onSubmit:B,children:[_.jsxs("label",{children:["Password",_.jsx("input",{autoFocus:!0,type:"password",value:o,onChange:R=>c(R.currentTarget.value),required:!0})]}),C?_.jsxs("label",{children:["Authenticator code",_.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:d,onChange:R=>p(R.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}):null,k?null:_.jsxs("label",{className:"auth-checkbox",children:[_.jsx("input",{type:"checkbox",checked:m,onChange:R=>f(R.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),b?_.jsx("p",{className:"form-error",children:b}):null,_.jsxs("div",{className:"button-row",children:[_.jsx("button",{type:"submit",disabled:S||o.length===0||C&&d.length!==6,children:"Unlock"}),_.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{a()},disabled:S,children:"Refresh"})]})]})}function qA({api:e,session:t,onSession:n,onFullLogin:a}){const o=t?.currentIpWhitelisted??!1,[c,d]=g.useState(""),[p,m]=g.useState(!1),[f,S]=g.useState(!1),[y,b]=g.useState(null),x=xi.useRef(!1),C=xi.useCallback(async(B,R)=>{S(!0),b(null);try{n(await e.reauth({...B?{otp:B}:{},rememberNetwork:R}))}catch(re){b(go(re))}finally{S(!1)}},[e,n]);g.useEffect(()=>{o&&!x.current&&(x.current=!0,C(void 0,!1))},[o,C]);async function k(B){B.preventDefault(),await C(c,p)}return o&&!y?_.jsx("p",{className:"muted",children:"Reconnecting from a trusted network…"}):_.jsxs("form",{className:"auth-form",onSubmit:k,children:[_.jsx("p",{className:"muted",children:"This device is remembered. Enter your authenticator code to continue."}),_.jsxs("label",{children:["Authenticator code",_.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:c,onChange:B=>d(B.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),_.jsxs("label",{className:"auth-checkbox",children:[_.jsx("input",{type:"checkbox",checked:p,onChange:B=>m(B.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),y?_.jsx("p",{className:"form-error",children:y}):null,_.jsxs("div",{className:"button-row",children:[_.jsx("button",{type:"submit",disabled:f||c.length!==6,children:"Continue"}),_.jsx("button",{type:"button",className:"secondary-button",onClick:a,disabled:f,children:"Use password instead"})]})]})}function WA(e){return e?e.passwordSet?e.authenticated&&!e.totpEnabled?"setup_totp":e.authenticated?"workspace":e.deviceTrusted&&e.totpEnabled?"reauth":"login":"setup_password":"loading"}function go(e){return e instanceof Error?e.message:"Request failed"}const mb="NTerminal",Wp="nterminal.activeAgentId";function YA(){const[e,t]=g.useState(()=>$A()),n=g.useMemo(()=>Eu(),[]),a=g.useMemo(()=>io(e),[e]);g.useEffect(()=>{const c=()=>{const d=LM();document.title=d>0?`(${d}) ${mb}`:mb};return c(),BM(c)},[]);function o(c){VA(c),t(c)}return _.jsx(KA,{api:n,activeAgentId:e,serverApi:a,onSelectServer:o})}function $A(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Wp);return e&&e.trim()?e:null}catch{return null}}function VA(e){if(!(typeof window>"u"))try{if(e){window.localStorage.setItem(Wp,e);return}window.localStorage.removeItem(Wp)}catch{}}const _b=["gesturestart","gesturechange","gestureend"],XA=[".workspace-list",".terminal-tab-list",".mobile-terminal-key-bar",".upload-toast-body",".file-tree",".file-detail",".file-editor",".file-markdown-preview",".editor-markdown-preview",".settings-content",".settings-nav",".transcript-dialog-scroll",".transcript-filter-group"].join(",");function GA(e=window){if(!QA(e))return()=>{};const t={passive:!1},n=e.document;function a(c){c.cancelable&&c.preventDefault()}function o(c){if(c.defaultPrevented)return;const d=c.touches;!d||d.length===0||(d.length>1||!ZA(c.target))&&a(c)}for(const c of _b)n.addEventListener(c,a,t);return n.addEventListener("touchmove",o,t),n.addEventListener("dblclick",a,t),()=>{for(const c of _b)n.removeEventListener(c,a,t);n.removeEventListener("touchmove",o,t),n.removeEventListener("dblclick",a,t)}}function ZA(e){return e instanceof Element&&e.closest(XA)!==null}function QA(e){return e.navigator.maxTouchPoints>0?!0:typeof e.matchMedia=="function"&&e.matchMedia("(pointer: coarse)").matches}const vb="--nterminal-viewport-height",gb="--nterminal-keyboard-inset-bottom",yb="data-nterminal-keyboard-visible",JA=120;function eN(e=window){const t=e.document.documentElement,n=e.visualViewport;function a(){const o=tN(e);o!==null&&t.style.setProperty(vb,`${o}px`),t.style.setProperty(gb,`${zw(e)}px`),t.setAttribute(yb,String(iN(e)))}return a(),n?.addEventListener("resize",a),n?.addEventListener("scroll",a),e.addEventListener("resize",a),e.addEventListener("orientationchange",a),e.addEventListener("pageshow",a),e.document.addEventListener("visibilitychange",a),()=>{n?.removeEventListener("resize",a),n?.removeEventListener("scroll",a),e.removeEventListener("resize",a),e.removeEventListener("orientationchange",a),e.removeEventListener("pageshow",a),e.document.removeEventListener("visibilitychange",a),t.style.removeProperty(vb),t.style.removeProperty(gb),t.removeAttribute(yb)}}function tN(e){const t=e.visualViewport?.height;return xu(t)?t:xu(e.innerHeight)?e.innerHeight:null}function xu(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function iN(e){return zw(e)>JA}function zw(e){const t=e.visualViewport?.height;if(!xu(t)||!xu(e.innerHeight))return 0;const n=typeof e.visualViewport?.offsetTop=="number"?e.visualViewport.offsetTop:0;return Math.max(0,Math.round(e.innerHeight-t-n))}eN();GA();pm();ZC.createRoot(document.getElementById("root")).render(_.jsx(xi.StrictMode,{children:_.jsx(YA,{})}));export{IC as g,_ as j};
@@ -12,7 +12,7 @@
12
12
  <link rel="icon" type="image/png" sizes="64x64" href="/icons/favicon-64.png" />
13
13
  <link rel="icon" type="image/png" sizes="96x96" href="/icons/favicon-96.png" />
14
14
  <title>NTerminal</title>
15
- <script type="module" crossorigin src="/assets/index-D9dhxxB2.js"></script>
15
+ <script type="module" crossorigin src="/assets/index-CXBkB4aI.js"></script>
16
16
  <link rel="stylesheet" crossorigin href="/assets/index-Bzw1v9JR.css">
17
17
  </head>
18
18
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nterminal",
3
- "version": "1.2.21",
3
+ "version": "1.2.22",
4
4
  "license": "GPL-3.0-only",
5
5
  "type": "module",
6
6
  "packageManager": "npm@10.9.7",