@clawos-dev/clawd 0.2.490 → 0.2.491
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.
package/dist/cli.cjs
CHANGED
|
@@ -65534,7 +65534,7 @@ function computeMethodAccess(args) {
|
|
|
65534
65534
|
}
|
|
65535
65535
|
|
|
65536
65536
|
// src/version.ts
|
|
65537
|
-
var version = "0.2.
|
|
65537
|
+
var version = "0.2.491".length > 0 ? "0.2.491" : "dev";
|
|
65538
65538
|
|
|
65539
65539
|
// src/cli-probe/probe.ts
|
|
65540
65540
|
var fs72 = __toESM(require("fs"), 1);
|
|
@@ -513,7 +513,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
513
513
|
`)},SS=function(){var e=parseInt(document.body.getAttribute(La)||"0",10);return isFinite(e)?e:0},FH=function(){g.useEffect(function(){return document.body.setAttribute(La,(SS()+1).toString()),function(){var e=SS()-1;e<=0?document.body.removeAttribute(La):document.body.setAttribute(La,e.toString())}},[])},HH=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r;FH();var s=g.useMemo(function(){return BH(i)},[i]);return g.createElement(zH,{styles:$H(s,!t,i,n?"":"!important")})},N0=!1;if(typeof window<"u")try{var wd=Object.defineProperty({},"passive",{get:function(){return N0=!0,!0}});window.addEventListener("test",wd,wd),window.removeEventListener("test",wd,wd)}catch{N0=!1}var na=N0?{passive:!1}:!1,UH=function(e){return e.tagName==="TEXTAREA"},zP=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!UH(e)&&n[t]==="visible")},WH=function(e){return zP(e,"overflowY")},VH=function(e){return zP(e,"overflowX")},kS=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=$P(e,r);if(i){var s=FP(e,r),o=s[1],a=s[2];if(o>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},qH=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},KH=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},$P=function(e,t){return e==="v"?WH(t):VH(t)},FP=function(e,t){return e==="v"?qH(t):KH(t)},GH=function(e,t){return e==="h"&&t==="rtl"?-1:1},YH=function(e,t,n,r,i){var s=GH(e,window.getComputedStyle(t).direction),o=s*r,a=n.target,l=t.contains(a),c=!1,u=o>0,d=0,f=0;do{if(!a)break;var p=FP(e,a),m=p[0],v=p[1],w=p[2],x=v-w-s*m;(m||x)&&$P(e,a)&&(d+=x,f+=m);var _=a.parentNode;a=_&&_.nodeType===Node.DOCUMENT_FRAGMENT_NODE?_.host:_}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(u&&Math.abs(d)<1||!u&&Math.abs(f)<1)&&(c=!0),c},Sd=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},CS=function(e){return[e.deltaX,e.deltaY]},ES=function(e){return e&&"current"in e?e.current:e},XH=function(e,t){return e[0]===t[0]&&e[1]===t[1]},QH=function(e){return`
|
|
514
514
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
515
515
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
516
|
-
`)},ZH=0,ra=[];function JH(e){var t=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),i=g.useState(ZH++)[0],s=g.useState(BP)[0],o=g.useRef(e);g.useEffect(function(){o.current=e},[e]),g.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var v=yH([e.lockRef.current],(e.shards||[]).map(ES),!0).filter(Boolean);return v.forEach(function(w){return w.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),v.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var a=g.useCallback(function(v,w){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!o.current.allowPinchZoom;var x=Sd(v),_=n.current,y="deltaX"in v?v.deltaX:_[0]-x[0],S="deltaY"in v?v.deltaY:_[1]-x[1],C,k=v.target,N=Math.abs(y)>Math.abs(S)?"h":"v";if("touches"in v&&N==="h"&&k.type==="range")return!1;var T=window.getSelection(),D=T&&T.anchorNode,P=D?D===k||D.contains(k):!1;if(P)return!1;var O=kS(N,k);if(!O)return!0;if(O?C=N:(C=N==="v"?"h":"v",O=kS(N,k)),!O)return!1;if(!r.current&&"changedTouches"in v&&(y||S)&&(r.current=C),!C)return!0;var R=r.current||C;return YH(R,w,v,R==="h"?y:S)},[]),l=g.useCallback(function(v){var w=v;if(!(!ra.length||ra[ra.length-1]!==s)){var x="deltaY"in w?CS(w):Sd(w),_=t.current.filter(function(C){return C.name===w.type&&(C.target===w.target||w.target===C.shadowParent)&&XH(C.delta,x)})[0];if(_&&_.should){w.cancelable&&w.preventDefault();return}if(!_){var y=(o.current.shards||[]).map(ES).filter(Boolean).filter(function(C){return C.contains(w.target)}),S=y.length>0?a(w,y[0]):!o.current.noIsolation;S&&w.cancelable&&w.preventDefault()}}},[]),c=g.useCallback(function(v,w,x,_){var y={name:v,delta:w,target:x,should:_,shadowParent:eU(x)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(S){return S!==y})},1)},[]),u=g.useCallback(function(v){n.current=Sd(v),r.current=void 0},[]),d=g.useCallback(function(v){c(v.type,CS(v),v.target,a(v,e.lockRef.current))},[]),f=g.useCallback(function(v){c(v.type,Sd(v),v.target,a(v,e.lockRef.current))},[]);g.useEffect(function(){return ra.push(s),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,na),document.addEventListener("touchmove",l,na),document.addEventListener("touchstart",u,na),function(){ra=ra.filter(function(v){return v!==s}),document.removeEventListener("wheel",l,na),document.removeEventListener("touchmove",l,na),document.removeEventListener("touchstart",u,na)}},[]);var p=e.removeScrollBar,m=e.inert;return g.createElement(g.Fragment,null,m?g.createElement(s,{styles:QH(i)}):null,p?g.createElement(HH,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function eU(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const tU=IH(OP,JH);var vy=g.forwardRef(function(e,t){return g.createElement(yp,ri({},e,{ref:t,sideCar:tU}))});vy.classNames=yp.classNames;var T0=["Enter"," "],nU=["ArrowDown","PageUp","Home"],HP=["ArrowUp","PageDown","End"],rU=[...nU,...HP],iU={ltr:[...T0,"ArrowRight"],rtl:[...T0,"ArrowLeft"]},sU={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Nu="Menu",[iu,oU,aU]=QI(Nu),[Ho,UP]=Fo(Nu,[aU,_p,TP]),Tu=_p(),WP=TP(),[VP,Gs]=Ho(Nu),[lU,Iu]=Ho(Nu),qP=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,a=Tu(t),[l,c]=g.useState(null),u=g.useRef(!1),d=gi(s),f=ZI(i);return g.useEffect(()=>{const p=()=>{u.current=!0,document.addEventListener("pointerdown",m,{capture:!0,once:!0}),document.addEventListener("pointermove",m,{capture:!0,once:!0})},m=()=>u.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",m,{capture:!0}),document.removeEventListener("pointermove",m,{capture:!0})}},[]),h.jsx(my,{...a,children:h.jsx(VP,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c,children:h.jsx(lU,{scope:t,onClose:g.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};qP.displayName=Nu;var cU="MenuAnchor",xy=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Tu(n);return h.jsx(kP,{...i,...r,ref:t})});xy.displayName=cU;var _y="MenuPortal",[uU,KP]=Ho(_y,{forceMount:void 0}),GP=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=Gs(_y,t);return h.jsx(uU,{scope:t,forceMount:n,children:h.jsx(ts,{present:n||s.open,children:h.jsx(gy,{asChild:!0,container:i,children:r})})})};GP.displayName=_y;var Sr="MenuContent",[dU,yy]=Ho(Sr),YP=g.forwardRef((e,t)=>{const n=KP(Sr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=Gs(Sr,e.__scopeMenu),o=Iu(Sr,e.__scopeMenu);return h.jsx(iu.Provider,{scope:e.__scopeMenu,children:h.jsx(ts,{present:r||s.open,children:h.jsx(iu.Slot,{scope:e.__scopeMenu,children:o.modal?h.jsx(hU,{...i,ref:t}):h.jsx(fU,{...i,ref:t})})})})}),hU=g.forwardRef((e,t)=>{const n=Gs(Sr,e.__scopeMenu),r=g.useRef(null),i=Jt(t,r);return g.useEffect(()=>{const s=r.current;if(s)return jP(s)},[]),h.jsx(by,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Re(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),fU=g.forwardRef((e,t)=>{const n=Gs(Sr,e.__scopeMenu);return h.jsx(by,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),pU=nu("MenuContent.ScrollLock"),by=g.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:o,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...v}=e,w=Gs(Sr,n),x=Iu(Sr,n),_=Tu(n),y=WP(n),S=oU(n),[C,k]=g.useState(null),N=g.useRef(null),T=Jt(t,N,w.onContentChange),D=g.useRef(0),P=g.useRef(""),O=g.useRef(0),R=g.useRef(null),M=g.useRef("right"),A=g.useRef(0),L=m?vy:g.Fragment,$=m?{as:pU,allowPinchZoom:!0}:void 0,F=z=>{var xe,Ee;const E=P.current+z,H=S().filter(ue=>!ue.disabled),q=document.activeElement,j=(xe=H.find(ue=>ue.ref.current===q))==null?void 0:xe.textValue,re=H.map(ue=>ue.textValue),ie=EU(re,E,j),K=(Ee=H.find(ue=>ue.textValue===ie))==null?void 0:Ee.ref.current;(function ue(je){P.current=je,window.clearTimeout(D.current),je!==""&&(D.current=window.setTimeout(()=>ue(""),1e3))})(E),K&&setTimeout(()=>K.focus())};g.useEffect(()=>()=>window.clearTimeout(D.current),[]),tP();const B=g.useCallback(z=>{var H,q;return M.current===((H=R.current)==null?void 0:H.side)&&TU(z,(q=R.current)==null?void 0:q.area)},[]);return h.jsx(dU,{scope:n,searchRef:P,onItemEnter:g.useCallback(z=>{B(z)&&z.preventDefault()},[B]),onItemLeave:g.useCallback(z=>{var E;B(z)||((E=N.current)==null||E.focus(),k(null))},[B]),onTriggerLeave:g.useCallback(z=>{B(z)&&z.preventDefault()},[B]),pointerGraceTimerRef:O,onPointerGraceIntentChange:g.useCallback(z=>{R.current=z},[]),children:h.jsx(L,{...$,children:h.jsx(oy,{asChild:!0,trapped:i,onMountAutoFocus:Re(s,z=>{var E;z.preventDefault(),(E=N.current)==null||E.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:h.jsx(pp,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:h.jsx(mH,{asChild:!0,...y,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:k,onEntryFocus:Re(l,z=>{x.isUsingKeyboardRef.current||z.preventDefault()}),preventScrollOnEntryFocus:!0,children:h.jsx(CP,{role:"menu","aria-orientation":"vertical","data-state":hR(w.open),"data-radix-menu-content":"",dir:x.dir,..._,...v,ref:T,style:{outline:"none",...v.style},onKeyDown:Re(v.onKeyDown,z=>{const H=z.target.closest("[data-radix-menu-content]")===z.currentTarget,q=z.ctrlKey||z.altKey||z.metaKey,j=z.key.length===1;H&&(z.key==="Tab"&&z.preventDefault(),!q&&j&&F(z.key));const re=N.current;if(z.target!==re||!rU.includes(z.key))return;z.preventDefault();const K=S().filter(xe=>!xe.disabled).map(xe=>xe.ref.current);HP.includes(z.key)&&K.reverse(),kU(K)}),onBlur:Re(e.onBlur,z=>{z.currentTarget.contains(z.target)||(window.clearTimeout(D.current),P.current="")}),onPointerMove:Re(e.onPointerMove,su(z=>{const E=z.target,H=A.current!==z.clientX;if(z.currentTarget.contains(E)&&H){const q=z.clientX>A.current?"right":"left";M.current=q,A.current=z.clientX}}))})})})})})})});YP.displayName=Sr;var mU="MenuGroup",wy=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(jt.div,{role:"group",...r,ref:t})});wy.displayName=mU;var gU="MenuLabel",XP=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(jt.div,{...r,ref:t})});XP.displayName=gU;var lf="MenuItem",NS="menu.itemSelect",bp=g.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=g.useRef(null),o=Iu(lf,e.__scopeMenu),a=yy(lf,e.__scopeMenu),l=Jt(t,s),c=g.useRef(!1),u=()=>{const d=s.current;if(!n&&d){const f=new CustomEvent(NS,{bubbles:!0,cancelable:!0});d.addEventListener(NS,p=>r==null?void 0:r(p),{once:!0}),XI(d,f),f.defaultPrevented?c.current=!1:o.onClose()}};return h.jsx(QP,{...i,ref:l,disabled:n,onClick:Re(e.onClick,u),onPointerDown:d=>{var f;(f=e.onPointerDown)==null||f.call(e,d),c.current=!0},onPointerUp:Re(e.onPointerUp,d=>{var f;c.current||(f=d.currentTarget)==null||f.click()}),onKeyDown:Re(e.onKeyDown,d=>{const f=a.searchRef.current!=="";n||f&&d.key===" "||T0.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});bp.displayName=lf;var QP=g.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=yy(lf,n),a=WP(n),l=g.useRef(null),c=Jt(t,l),[u,d]=g.useState(!1),[f,p]=g.useState("");return g.useEffect(()=>{const m=l.current;m&&p((m.textContent??"").trim())},[s.children]),h.jsx(iu.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:h.jsx(gH,{asChild:!0,...a,focusable:!r,children:h.jsx(jt.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:Re(e.onPointerMove,su(m=>{r?o.onItemLeave(m):(o.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Re(e.onPointerLeave,su(m=>o.onItemLeave(m))),onFocus:Re(e.onFocus,()=>d(!0)),onBlur:Re(e.onBlur,()=>d(!1))})})})}),vU="MenuCheckboxItem",ZP=g.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return h.jsx(rR,{scope:e.__scopeMenu,checked:n,children:h.jsx(bp,{role:"menuitemcheckbox","aria-checked":cf(n)?"mixed":n,...i,ref:t,"data-state":Cy(n),onSelect:Re(i.onSelect,()=>r==null?void 0:r(cf(n)?!0:!n),{checkForDefaultPrevented:!1})})})});ZP.displayName=vU;var JP="MenuRadioGroup",[xU,_U]=Ho(JP,{value:void 0,onValueChange:()=>{}}),eR=g.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=gi(r);return h.jsx(xU,{scope:e.__scopeMenu,value:n,onValueChange:s,children:h.jsx(wy,{...i,ref:t})})});eR.displayName=JP;var tR="MenuRadioItem",nR=g.forwardRef((e,t)=>{const{value:n,...r}=e,i=_U(tR,e.__scopeMenu),s=n===i.value;return h.jsx(rR,{scope:e.__scopeMenu,checked:s,children:h.jsx(bp,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Cy(s),onSelect:Re(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});nR.displayName=tR;var Sy="MenuItemIndicator",[rR,yU]=Ho(Sy,{checked:!1}),iR=g.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=yU(Sy,n);return h.jsx(ts,{present:r||cf(s.checked)||s.checked===!0,children:h.jsx(jt.span,{...i,ref:t,"data-state":Cy(s.checked)})})});iR.displayName=Sy;var bU="MenuSeparator",sR=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(jt.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});sR.displayName=bU;var wU="MenuArrow",oR=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Tu(n);return h.jsx(EP,{...i,...r,ref:t})});oR.displayName=wU;var ky="MenuSub",[SU,aR]=Ho(ky),lR=e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,s=Gs(ky,t),o=Tu(t),[a,l]=g.useState(null),[c,u]=g.useState(null),d=gi(i);return g.useEffect(()=>(s.open===!1&&d(!1),()=>d(!1)),[s.open,d]),h.jsx(my,{...o,children:h.jsx(VP,{scope:t,open:r,onOpenChange:d,content:c,onContentChange:u,children:h.jsx(SU,{scope:t,contentId:Hi(),triggerId:Hi(),trigger:a,onTriggerChange:l,children:n})})})};lR.displayName=ky;var nc="MenuSubTrigger",cR=g.forwardRef((e,t)=>{const n=Gs(nc,e.__scopeMenu),r=Iu(nc,e.__scopeMenu),i=aR(nc,e.__scopeMenu),s=yy(nc,e.__scopeMenu),o=g.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},u=g.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return g.useEffect(()=>u,[u]),g.useEffect(()=>{const d=a.current;return()=>{window.clearTimeout(d),l(null)}},[a,l]),h.jsx(xy,{asChild:!0,...c,children:h.jsx(QP,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":hR(n.open),...e,ref:Su(t,i.onTriggerChange),onClick:d=>{var f;(f=e.onClick)==null||f.call(e,d),!(e.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Re(e.onPointerMove,su(d=>{s.onItemEnter(d),!d.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(s.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:Re(e.onPointerLeave,su(d=>{var p,m;u();const f=(p=n.content)==null?void 0:p.getBoundingClientRect();if(f){const v=(m=n.content)==null?void 0:m.dataset.side,w=v==="right",x=w?-5:5,_=f[w?"left":"right"],y=f[w?"right":"left"];s.onPointerGraceIntentChange({area:[{x:d.clientX+x,y:d.clientY},{x:_,y:f.top},{x:y,y:f.top},{x:y,y:f.bottom},{x:_,y:f.bottom}],side:v}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(d),d.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:Re(e.onKeyDown,d=>{var p;const f=s.searchRef.current!=="";e.disabled||f&&d.key===" "||iU[r.dir].includes(d.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),d.preventDefault())})})})});cR.displayName=nc;var uR="MenuSubContent",dR=g.forwardRef((e,t)=>{const n=KP(Sr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=Gs(Sr,e.__scopeMenu),o=Iu(Sr,e.__scopeMenu),a=aR(uR,e.__scopeMenu),l=g.useRef(null),c=Jt(t,l);return h.jsx(iu.Provider,{scope:e.__scopeMenu,children:h.jsx(ts,{present:r||s.open,children:h.jsx(iu.Slot,{scope:e.__scopeMenu,children:h.jsx(by,{id:a.contentId,"aria-labelledby":a.triggerId,...i,ref:c,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var d;o.isUsingKeyboardRef.current&&((d=l.current)==null||d.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:Re(e.onFocusOutside,u=>{u.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:Re(e.onEscapeKeyDown,u=>{o.onClose(),u.preventDefault()}),onKeyDown:Re(e.onKeyDown,u=>{var p;const d=u.currentTarget.contains(u.target),f=sU[o.dir].includes(u.key);d&&f&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),u.preventDefault())})})})})})});dR.displayName=uR;function hR(e){return e?"open":"closed"}function cf(e){return e==="indeterminate"}function Cy(e){return cf(e)?"indeterminate":e?"checked":"unchecked"}function kU(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function CU(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function EU(e,t,n){const i=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let o=CU(e,Math.max(s,0));i.length===1&&(o=o.filter(c=>c!==n));const l=o.find(c=>c.toLowerCase().startsWith(i.toLowerCase()));return l!==n?l:void 0}function NU(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const a=t[s],l=t[o],c=a.x,u=a.y,d=l.x,f=l.y;u>r!=f>r&&n<(d-c)*(r-u)/(f-u)+c&&(i=!i)}return i}function TU(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return NU(n,t)}function su(e){return t=>t.pointerType==="mouse"?e(t):void 0}var IU=qP,PU=xy,RU=GP,MU=YP,AU=wy,jU=XP,LU=bp,DU=ZP,OU=eR,BU=nR,zU=iR,$U=sR,FU=oR,HU=lR,UU=cR,WU=dR,wp="DropdownMenu",[VU]=Fo(wp,[UP]),Nn=UP(),[qU,fR]=VU(wp),pR=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:a=!0}=e,l=Nn(t),c=g.useRef(null),[u,d]=ku({prop:i,defaultProp:s??!1,onChange:o,caller:wp});return h.jsx(qU,{scope:t,triggerId:Hi(),triggerRef:c,contentId:Hi(),open:u,onOpenChange:d,onOpenToggle:g.useCallback(()=>d(f=>!f),[d]),modal:a,children:h.jsx(IU,{...l,open:u,onOpenChange:d,dir:r,modal:a,children:n})})};pR.displayName=wp;var mR="DropdownMenuTrigger",gR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,s=fR(mR,n),o=Nn(n);return h.jsx(PU,{asChild:!0,...o,children:h.jsx(jt.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...i,ref:Su(t,s.triggerRef),onPointerDown:Re(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:Re(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});gR.displayName=mR;var KU="DropdownMenuPortal",vR=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Nn(t);return h.jsx(RU,{...r,...n})};vR.displayName=KU;var xR="DropdownMenuContent",_R=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=fR(xR,n),s=Nn(n),o=g.useRef(!1);return h.jsx(MU,{id:i.contentId,"aria-labelledby":i.triggerId,...s,...r,ref:t,onCloseAutoFocus:Re(e.onCloseAutoFocus,a=>{var l;o.current||(l=i.triggerRef.current)==null||l.focus(),o.current=!1,a.preventDefault()}),onInteractOutside:Re(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;(!i.modal||u)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});_R.displayName=xR;var GU="DropdownMenuGroup",YU=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nn(n);return h.jsx(AU,{...i,...r,ref:t})});YU.displayName=GU;var XU="DropdownMenuLabel",yR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nn(n);return h.jsx(jU,{...i,...r,ref:t})});yR.displayName=XU;var QU="DropdownMenuItem",bR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nn(n);return h.jsx(LU,{...i,...r,ref:t})});bR.displayName=QU;var ZU="DropdownMenuCheckboxItem",wR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nn(n);return h.jsx(DU,{...i,...r,ref:t})});wR.displayName=ZU;var JU="DropdownMenuRadioGroup",eW=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nn(n);return h.jsx(OU,{...i,...r,ref:t})});eW.displayName=JU;var tW="DropdownMenuRadioItem",nW=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nn(n);return h.jsx(BU,{...i,...r,ref:t})});nW.displayName=tW;var rW="DropdownMenuItemIndicator",SR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nn(n);return h.jsx(zU,{...i,...r,ref:t})});SR.displayName=rW;var iW="DropdownMenuSeparator",kR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nn(n);return h.jsx($U,{...i,...r,ref:t})});kR.displayName=iW;var sW="DropdownMenuArrow",oW=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nn(n);return h.jsx(FU,{...i,...r,ref:t})});oW.displayName=sW;var aW=e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:s}=e,o=Nn(t),[a,l]=ku({prop:r,defaultProp:s??!1,onChange:i,caller:"DropdownMenuSub"});return h.jsx(HU,{...o,open:a,onOpenChange:l,children:n})},lW="DropdownMenuSubTrigger",CR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nn(n);return h.jsx(UU,{...i,...r,ref:t})});CR.displayName=lW;var cW="DropdownMenuSubContent",ER=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nn(n);return h.jsx(WU,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});ER.displayName=cW;var uW=pR,dW=gR,NR=vR,TR=_R,IR=yR,PR=bR,RR=wR,hW=SR,MR=kR,fW=aW,AR=CR,jR=ER;const Ey=uW,Ny=dW,Sp=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(NR,{children:h.jsx(TR,{ref:r,sideOffset:t,className:ne("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...n})}));Sp.displayName=TR.displayName;const pW=fW,LR=g.forwardRef(({className:e,...t},n)=>h.jsx(AR,{ref:n,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100 data-[state=open]:bg-bg-200","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...t}));LR.displayName=AR.displayName;const DR=g.forwardRef(({className:e,...t},n)=>h.jsx(NR,{children:h.jsx(jR,{ref:n,className:ne("z-50 min-w-[6rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...t})}));DR.displayName=jR.displayName;const Ai=g.forwardRef(({className:e,inset:t,...n},r)=>h.jsx(PR,{ref:r,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Ai.displayName=PR.displayName;const mW=g.forwardRef(({className:e,children:t,checked:n,...r},i)=>h.jsxs(RR,{ref:i,checked:n,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-7 pr-2 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...r,children:[h.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:h.jsx(hW,{children:h.jsx(bl,{className:"h-3.5 w-3.5"})})}),t]}));mW.displayName=RR.displayName;const Ty=g.forwardRef(({className:e,...t},n)=>h.jsx(MR,{ref:n,className:ne("-mx-1 my-1 h-px bg-border",e),...t}));Ty.displayName=MR.displayName;const OR=g.forwardRef(({className:e,...t},n)=>h.jsx(IR,{ref:n,className:ne("px-2 py-1.5 text-xs font-semibold text-text-400",e),...t}));OR.displayName=IR.displayName;function gW({tool:e,className:t}){const n=c9(e);return h.jsx("span",{"data-testid":n?`session-icon-${e}`:"session-icon-default","aria-label":n?iy(e):"未知引擎",className:ne("w-3.5 h-3.5 shrink-0 inline-flex items-center justify-center",fp(e),t),children:h.jsx(hp,{tool:e,className:"w-full h-full"})})}function vW({sessionId:e,hasUnread:t,running:n=!1,awaitingUser:r=!1,style:i}){return r?h.jsx(j$,{"data-testid":`awaiting-dot-${e}`,style:i,className:"w-3 h-3 text-warning shrink-0 animate-pulse",strokeWidth:2.25,"aria-label":"awaiting user"}):t?h.jsx("span",{"data-testid":`unread-dot-${e}`,style:i,className:"w-2 h-2 rounded-full bg-error shrink-0","aria-label":"unread"}):n?h.jsx("span",{"data-testid":`running-dot-${e}`,style:i,className:"w-2 h-2 rounded-full bg-success shrink-0 animate-pulse","aria-label":"running"}):null}function BR(e){return e.compositionActive||!!e.nativeIsComposing||e.keyCode===229}function zR(e){return e.key==="Enter"&&!e.shiftKey&&!BR(e)}function Pu(e,t){const n=g.useRef(!1),r=g.useCallback(()=>{n.current=!0},[]),i=g.useCallback(()=>{setTimeout(()=>{n.current=!1},0)},[]);return{onKeyDown:g.useCallback(o=>{const a=o.nativeEvent;if(zR({key:o.key,shiftKey:o.shiftKey,compositionActive:n.current,nativeIsComposing:a.isComposing,keyCode:a.keyCode})){o.preventDefault(),e();return}t&&o.key==="Escape"&&(o.preventDefault(),t())},[e,t]),onCompositionStart:r,onCompositionEnd:i}}function xW({open:e,initialLabel:t,placeholder:n,onSubmit:r,onCancel:i,title:s="Edit session",fieldLabel:o="Label",testId:a="session-edit-dialog",requireNonEmpty:l=!1}){const[c,u]=g.useState(t);g.useEffect(()=>{e&&u(t)},[e,t]);const d=c.trim(),f=l&&d==="",p=()=>{f||r({label:d})},m=Pu(p,i);return e?hl.createPortal(h.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center bg-bg-0/40 backdrop-blur-[2px]",onClick:i,"data-testid":`${a}-overlay`,children:h.jsxs("div",{"data-testid":a,className:"w-[420px] max-w-[calc(100vw-32px)] rounded-2xl border border-text-100/[0.12] flex flex-col gap-4 p-5",style:{backgroundColor:"var(--bg-0)",boxShadow:"0 12px 40px rgba(0,0,0,0.04)"},onClick:v=>v.stopPropagation(),children:[h.jsx("div",{className:"text-[15px] font-semibold text-text-100",children:s}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-[12px] font-semibold text-text-200 mb-1",children:o}),h.jsx("input",{autoFocus:!0,type:"text",value:c,onChange:v=>u(v.target.value),...m,placeholder:n,"data-testid":`${a}-label`,className:"w-full px-3 py-2 text-[13px] bg-bg-50 border border-bg-300 rounded-lg focus:outline-none focus:border-text-300 transition-colors"})]}),h.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[h.jsx("button",{type:"button",onClick:i,className:"px-4 py-1.5 text-[12px] text-text-300 rounded-lg hover:bg-text-100/5 transition-colors cursor-pointer",children:"Cancel"}),h.jsx("button",{type:"button",onClick:p,disabled:f,"data-testid":`${a}-save`,className:"px-4 py-1.5 text-[12px] font-medium text-bg-0 rounded-lg bg-text-100 hover:bg-text-200 transition-colors cursor-pointer disabled:cursor-not-allowed disabled:opacity-40",children:"Save"})]})]})}),document.body):null}var _W=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),yW="VisuallyHidden",$R=g.forwardRef((e,t)=>h.jsx(jt.span,{...e,ref:t,style:{..._W,...e.style}}));$R.displayName=yW;var bW=$R,[kp]=Fo("Tooltip",[_p]),Cp=_p(),FR="TooltipProvider",wW=700,I0="tooltip.open",[SW,Iy]=kp(FR),HR=e=>{const{__scopeTooltip:t,delayDuration:n=wW,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,o=g.useRef(!0),a=g.useRef(!1),l=g.useRef(0);return g.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),h.jsx(SW,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:g.useCallback(()=>{window.clearTimeout(l.current),o.current=!1},[]),onClose:g.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:g.useCallback(c=>{a.current=c},[]),disableHoverableContent:i,children:s})};HR.displayName=FR;var ou="Tooltip",[kW,Ep]=kp(ou),UR=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=e,l=Iy(ou,e.__scopeTooltip),c=Cp(t),[u,d]=g.useState(null),f=Hi(),p=g.useRef(0),m=o??l.disableHoverableContent,v=a??l.delayDuration,w=g.useRef(!1),[x,_]=ku({prop:r,defaultProp:i??!1,onChange:N=>{N?(l.onOpen(),document.dispatchEvent(new CustomEvent(I0))):l.onClose(),s==null||s(N)},caller:ou}),y=g.useMemo(()=>x?w.current?"delayed-open":"instant-open":"closed",[x]),S=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,w.current=!1,_(!0)},[_]),C=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,_(!1)},[_]),k=g.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{w.current=!0,_(!0),p.current=0},v)},[v,_]);return g.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),h.jsx(my,{...c,children:h.jsx(kW,{scope:t,contentId:f,open:x,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:g.useCallback(()=>{l.isOpenDelayedRef.current?k():S()},[l.isOpenDelayedRef,k,S]),onTriggerLeave:g.useCallback(()=>{m?C():(window.clearTimeout(p.current),p.current=0)},[C,m]),onOpen:S,onClose:C,disableHoverableContent:m,children:n})})};UR.displayName=ou;var P0="TooltipTrigger",WR=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Ep(P0,n),s=Iy(P0,n),o=Cp(n),a=g.useRef(null),l=Jt(t,a,i.onTriggerChange),c=g.useRef(!1),u=g.useRef(!1),d=g.useCallback(()=>c.current=!1,[]);return g.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),h.jsx(kP,{asChild:!0,...o,children:h.jsx(jt.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:l,onPointerMove:Re(e.onPointerMove,f=>{f.pointerType!=="touch"&&!u.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),u.current=!0)}),onPointerLeave:Re(e.onPointerLeave,()=>{i.onTriggerLeave(),u.current=!1}),onPointerDown:Re(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Re(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:Re(e.onBlur,i.onClose),onClick:Re(e.onClick,i.onClose)})})});WR.displayName=P0;var CW="TooltipPortal",[qae,EW]=kp(CW,{forceMount:void 0}),Za="TooltipContent",VR=g.forwardRef((e,t)=>{const n=EW(Za,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,o=Ep(Za,e.__scopeTooltip);return h.jsx(ts,{present:r||o.open,children:o.disableHoverableContent?h.jsx(qR,{side:i,...s,ref:t}):h.jsx(NW,{side:i,...s,ref:t})})}),NW=g.forwardRef((e,t)=>{const n=Ep(Za,e.__scopeTooltip),r=Iy(Za,e.__scopeTooltip),i=g.useRef(null),s=Jt(t,i),[o,a]=g.useState(null),{trigger:l,onClose:c}=n,u=i.current,{onPointerInTransitChange:d}=r,f=g.useCallback(()=>{a(null),d(!1)},[d]),p=g.useCallback((m,v)=>{const w=m.currentTarget,x={x:m.clientX,y:m.clientY},_=MW(x,w.getBoundingClientRect()),y=AW(x,_),S=jW(v.getBoundingClientRect()),C=DW([...y,...S]);a(C),d(!0)},[d]);return g.useEffect(()=>()=>f(),[f]),g.useEffect(()=>{if(l&&u){const m=w=>p(w,u),v=w=>p(w,l);return l.addEventListener("pointerleave",m),u.addEventListener("pointerleave",v),()=>{l.removeEventListener("pointerleave",m),u.removeEventListener("pointerleave",v)}}},[l,u,p,f]),g.useEffect(()=>{if(o){const m=v=>{const w=v.target,x={x:v.clientX,y:v.clientY},_=(l==null?void 0:l.contains(w))||(u==null?void 0:u.contains(w)),y=!LW(x,o);_?f():y&&(f(),c())};return document.addEventListener("pointermove",m),()=>document.removeEventListener("pointermove",m)}},[l,u,o,c,f]),h.jsx(qR,{...e,ref:s})}),[TW,IW]=kp(ou,{isInside:!1}),PW=_9("TooltipContent"),qR=g.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=e,l=Ep(Za,n),c=Cp(n),{onClose:u}=l;return g.useEffect(()=>(document.addEventListener(I0,u),()=>document.removeEventListener(I0,u)),[u]),g.useEffect(()=>{if(l.trigger){const d=f=>{const p=f.target;p!=null&&p.contains(l.trigger)&&u()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[l.trigger,u]),h.jsx(pp,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:d=>d.preventDefault(),onDismiss:u,children:h.jsxs(CP,{"data-state":l.stateAttribute,...c,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[h.jsx(PW,{children:r}),h.jsx(TW,{scope:n,isInside:!0,children:h.jsx(bW,{id:l.contentId,role:"tooltip",children:i||r})})]})})});VR.displayName=Za;var KR="TooltipArrow",RW=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Cp(n);return IW(KR,n).isInside?null:h.jsx(EP,{...i,...r,ref:t})});RW.displayName=KR;function MW(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function AW(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function jW(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function LW(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const a=t[s],l=t[o],c=a.x,u=a.y,d=l.x,f=l.y;u>r!=f>r&&n<(d-c)*(r-u)/(f-u)+c&&(i=!i)}return i}function DW(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),OW(t)}function OW(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const s=t[t.length-1],o=t[t.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],o=n[n.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var BW=HR,zW=UR,$W=WR,GR=VR;const uf=BW,Np=zW,Tp=$W,Ru=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(GR,{ref:r,sideOffset:t,className:ne("z-50 overflow-hidden rounded-sm border border-border bg-bg-0 px-2 py-1 text-xs text-text-300 shadow-md",e),...n}));Ru.displayName=GR.displayName;const FW={held:!1,indexBySessionId:new Map},HW=g.createContext(FW);function UW(){return g.useContext(HW)}const WW=Array.from({length:9},(e,t)=>({id:`switch-session-${t+1}`,combo:{key:String(t+1),mod:!0},label:`切换到第 ${t+1} 个会话`,group:"会话",desktopOnly:!0,hiddenInList:!0})),VW=[{id:"new-session",combo:{key:"n",mod:!0},label:"新建任务",description:"打开快捷新建弹窗",group:"通用",desktopOnly:!0},{id:"open-search",combo:{key:"k",mod:!0},label:"全局搜索",description:"搜会话内容 / persona / 联系人",group:"通用",desktopOnly:!0},{id:"search-tab-prev",combo:{key:"ArrowLeft",mod:!0},label:"搜索:上一组",description:"搜索浮层里切到左边那个 tab(会话 / persona / 联系人)",group:"通用"},{id:"search-tab-next",combo:{key:"ArrowRight",mod:!0},label:"搜索:下一组",description:"搜索浮层里切到右边那个 tab",group:"通用"},...WW,{id:"archive-session",combo:{key:"Backspace",mod:!0,shift:!0},label:"归档当前会话",description:"归档当前聊天区的会话,Enter 确认 / Esc 取消",group:"会话",desktopOnly:!0},{id:"tab-prev",combo:{key:"ArrowLeft",mod:!0,shift:!0},label:"上一个标签页",description:"连按快速移动,停下或松开修饰键后切换",group:"标签页"},{id:"tab-next",combo:{key:"ArrowRight",mod:!0,shift:!0},label:"下一个标签页",description:"连按快速移动,停下或松开修饰键后切换",group:"标签页"},{id:"toggle-hive",combo:{key:"h",mod:!0,shift:!0},label:"Hive 看板",description:"全屏看所有 agent 在干什么;Esc 或点任意行退出",group:"通用"},{id:"send-message",combo:{key:"Enter"},label:"发送消息",description:"在输入框中发送当前内容",group:"输入",displayOnly:!0},{id:"newline",combo:{key:"Enter",shift:!0},label:"换行",description:"在输入框中插入换行",group:"输入",displayOnly:!0},{id:"interrupt",combo:{key:"Escape"},label:"打断回复",description:"打断当前回复;2 秒内按两次停止任务",group:"输入",displayOnly:!0}];VW.filter(e=>!e.displayOnly);function qW(){return/Mac|iP(hone|od|ad)/.test(navigator.platform)}const KW=10,GW=20,YW=16,TS=20,IS=60,XW=4;function kd({testId:e,label:t,children:n}){return h.jsxs(Np,{children:[h.jsx(Tp,{asChild:!0,children:h.jsx("span",{"data-testid":e,role:"img","aria-label":t,tabIndex:0,className:"inline-flex shrink-0",children:n})}),h.jsx(Ru,{side:"bottom",children:t})]})}function QW({session:e,active:t,hasUnread:n,running:r=!1,awaitingUser:i=!1,onSelect:s,onEdit:o,onDelete:a,onPin:l,onArchive:c,quickAction:u,depth:d=0,chevron:f,showCopyResume:p=!0,contactDisplayName:m,ownerPrincipalId:v,creatorDisplayName:w,dispatchedFromSessionTitle:x}){const[_,y]=g.useState(!1),S=UW(),C=S.held?S.indexBySessionId.get(e.sessionId):void 0,k=!!e.pinnedAt,N=d===0,T=d===0&&!!c,D=KW+d*GW;let P=null;u==="pin"&&N&&l?P={icon:k?h.jsx(Kw,{className:"w-4 h-4"}):h.jsx(Gw,{className:"w-4 h-4"}),label:k?"取消置顶":"置顶",run:()=>l(e.sessionId,!k)}:u==="archive"&&T&&c?P={icon:h.jsx(Ww,{className:"w-4 h-4"}),label:"归档",run:()=>c(e.sessionId,!0)}:u==="rename"&&o&&(P={icon:h.jsx(_0,{className:"w-4 h-4"}),label:"重命名",run:()=>y(!0)});const O=g.useCallback(async()=>{const $=GI(e);if($)try{await navigator.clipboard.writeText($)}catch{}},[e]),R=sy(e),M=e.originOwnerPrincipalId,A=M?`@${m??`…${M.slice(-8)}`}`:null,L=!!(e.ownerPersonaId&&v&&e.creatorPrincipalId&&e.creatorPrincipalId!==v&&!e.larkChatId&&!e.shiftFiredFromSessionId&&!e.dispatchedFromSessionId);return h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-testid":`session-item-${e.sessionId}`,onClick:s,style:{paddingLeft:D,display:"grid",gridTemplateColumns:f?`${YW}px ${TS}px 1fr auto ${IS}px`:`${TS}px 1fr auto ${IS}px`,gridTemplateAreas:f?'"chev icon name dot time"':'"icon name dot time"',columnGap:`${XW}px`,alignItems:"center"},className:ne("group relative rounded-lg cursor-pointer transition-all duration-150 pr-2.5 py-1.5",t?"bg-accent-dim":"hover:bg-sidebar-hover-bg"),children:[t?h.jsx("span",{"aria-hidden":"true",className:"absolute left-0 top-1/2 -translate-y-1/2 w-[3px] h-7 rounded-r-full bg-accent"}):null,h.jsx("div",{style:{gridArea:"chev"},className:"flex items-center justify-center",children:f??null}),h.jsx("div",{style:{gridArea:"icon"},className:"flex items-center justify-center",children:h.jsx(gW,{tool:e.tool})}),h.jsxs("div",{style:{gridArea:"name"},className:"flex items-center gap-1 min-w-0",children:[h.jsxs(uf,{delayDuration:200,skipDelayDuration:100,children:[e.dispatchedFromSessionId?h.jsx(kd,{testId:`dispatched-icon-${e.sessionId}`,label:`来自【${x??"另一会话"}】dispatch`,children:h.jsx(e8,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,e.shiftFiredFromSessionId?h.jsx(kd,{testId:`shift-fired-icon-${e.sessionId}`,label:"定时任务",children:h.jsx(C$,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,e.larkChatId?h.jsx(kd,{testId:`lark-chat-icon-${e.sessionId}`,label:e.larkChatType==="p2p"?"来自飞书DM":"来自飞书群",children:h.jsx(I8,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,L?h.jsx(kd,{testId:`guest-created-icon-${e.sessionId}`,label:w?`${w}创建`:"其他人创建",children:h.jsx(hF,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null]}),h.jsx("span",{"data-testid":`session-title-${e.sessionId}`,className:ne("text-[13px] truncate min-w-0","group-hover:whitespace-normal group-hover:overflow-visible group-hover:break-words",t?"text-text-100 font-medium":"text-text-200"),children:R}),A?h.jsx("span",{"data-testid":`session-mirror-chip-${e.sessionId}`,title:`在 ${A.replace(/^@/,"")} 的设备上`,className:"shrink-0 inline-flex items-center px-1.5 py-0 rounded text-[10px] bg-accent-dim/40 text-accent border border-accent/20 max-w-[120px] truncate",children:A}):null]}),h.jsx(vW,{sessionId:e.sessionId,hasUnread:n,running:r,awaitingUser:i,style:{gridArea:"dot"}}),C!=null?h.jsx("span",{style:{gridArea:"time"},"data-testid":`session-quick-switch-badge-${e.sessionId}`,className:"text-right shrink-0 transition-opacity duration-150 group-hover:opacity-0",children:h.jsx("span",{className:"inline-flex items-center justify-center h-[18px] px-1.5 rounded-[5px] border border-border bg-bg-200/70 text-[11px] text-text-200 font-medium leading-none",children:qW()?`⌘${C}`:`Ctrl+${C}`})}):h.jsx("span",{style:{gridArea:"time"},className:ne("text-[11px] text-text-400/70 text-right shrink-0","transition-opacity duration-150 group-hover:opacity-0"),children:e.updatedAt?u9(e.updatedAt):""}),o||a||l||c?h.jsxs("div",{className:"absolute right-2 top-[3px] flex items-center opacity-0 group-hover:opacity-100 data-[state=open]:opacity-100 transition-opacity",children:[P?h.jsx(uf,{delayDuration:200,skipDelayDuration:100,children:h.jsxs(Np,{children:[h.jsx(Tp,{asChild:!0,children:h.jsx("button",{type:"button",onClick:$=>{$.stopPropagation(),P.run()},className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":P.label,"data-testid":`quick-action-${u}-${e.sessionId}`,children:P.icon})}),h.jsx(Ru,{side:"bottom",children:P.label})]})}):null,h.jsxs(Ey,{modal:!1,children:[h.jsx(Ny,{asChild:!0,children:h.jsx("button",{type:"button",onClick:$=>$.stopPropagation(),className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":"session actions","data-testid":`session-menu-${e.sessionId}`,children:h.jsx(SI,{className:"w-4 h-4"})})}),h.jsxs(Sp,{align:"end",onClick:$=>$.stopPropagation(),children:[l&&N&&h.jsxs(Ai,{onSelect:()=>l(e.sessionId,!k),"data-testid":`session-${k?"unpin":"pin"}-${e.sessionId}`,children:[k?h.jsx(Kw,{className:"w-3 h-3 mr-2 text-text-400"}):h.jsx(Gw,{className:"w-3 h-3 mr-2 text-text-400"}),k?"Unpin":"Pin"]}),T&&c&&h.jsxs(Ai,{onSelect:()=>c(e.sessionId,!0),"data-testid":`session-archive-${e.sessionId}`,children:[h.jsx(Ww,{className:"w-3 h-3 mr-2 text-text-400"}),"Archive"]}),o&&h.jsxs(Ai,{onSelect:()=>y(!0),"data-testid":`session-rename-${e.sessionId}`,children:[h.jsx(_0,{className:"w-3 h-3 mr-2 text-text-400"}),"Rename"]}),p&&e.toolSessionId?h.jsxs(Ai,{onSelect:()=>void O(),"data-testid":`session-copy-resume-${e.sessionId}`,children:[h.jsx(dp,{className:"w-3 h-3 mr-2 text-text-400"}),"Copy Resume Command"]}):null,(l||o||p&&e.toolSessionId)&&a&&h.jsx(Ty,{}),a&&h.jsxs(Ai,{onSelect:()=>void a(e.sessionId),className:"text-destructive focus:text-destructive focus:bg-destructive/10","data-testid":`session-delete-${e.sessionId}`,children:[h.jsx(ty,{className:"w-3 h-3 mr-2"}),"Delete"]})]})]})]}):null]}),o?h.jsx(xW,{open:_,initialLabel:e.label??"",placeholder:e.cwd.split("/").pop()||"",onSubmit:$=>{o(e.sessionId,$),y(!1)},onCancel:()=>y(!1)}):null]})}function Py({node:e,depth:t=0,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,quickAction:d,getContactDisplayName:f,showCopyResume:p,ownerPrincipalId:m,getCreatorDisplayName:v,getSessionDisplayName:w,parentSession:x}){const _=e.children.length>0,{isCollapsed:y,toggle:S}=x$(),C=!y(e.session.sessionId),k=g.useCallback(T=>{T.stopPropagation(),S(e.session.sessionId)},[S,e.session.sessionId]),N=_?h.jsx("button",{type:"button",onClick:k,"data-testid":`session-chevron-${e.session.sessionId}`,"aria-label":C?"collapse":"expand","aria-expanded":C,className:"shrink-0 flex items-center justify-center w-4 h-4 text-text-400 hover:text-text-100 cursor-pointer",children:C?h.jsx(Yn,{className:"w-3 h-3"}):h.jsx(Bn,{className:"w-3 h-3"})}):null;return h.jsxs("div",{"data-testid":`session-tree-node-${e.session.sessionId}`,children:[h.jsx(QW,{session:e.session,active:n===e.session.sessionId,hasUnread:(r==null?void 0:r.has(e.session.sessionId))??!1,running:(i==null?void 0:i.has(e.session.sessionId))??!1,awaitingUser:(s==null?void 0:s.has(e.session.sessionId))??!1,onSelect:()=>o(e.session.sessionId),onEdit:a,onDelete:l,onPin:c,onArchive:u,quickAction:d,showCopyResume:p,ownerPrincipalId:m,creatorDisplayName:e.session.creatorPrincipalId?v==null?void 0:v(e.session.creatorPrincipalId):void 0,dispatchedFromSessionTitle:e.session.dispatchedFromSessionId?(w==null?void 0:w(e.session.dispatchedFromSessionId))??((x==null?void 0:x.sessionId)===e.session.dispatchedFromSessionId?sy(x):void 0):void 0,depth:t,chevron:N,contactDisplayName:e.session.originOwnerPrincipalId?f==null?void 0:f(e.session.originOwnerPrincipalId):void 0}),_&&C?h.jsx("div",{"data-testid":`session-tree-children-${e.session.sessionId}`,children:e.children.map(T=>h.jsx(Py,{node:T,depth:t+1,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,quickAction:d,getContactDisplayName:f,showCopyResume:p,ownerPrincipalId:m,getCreatorDisplayName:v,getSessionDisplayName:w,parentSession:e.session},T.session.sessionId))}):null]})}function ZW(e){return e.forkedFromSessionId??e.dispatchedFromSessionId??e.shiftFiredFromSessionId}function YR(e){e=e.filter(s=>!s.ephemeral&&s.deployId===void 0);const t=new Map;for(const s of e)t.set(s.sessionId,s);const n=new Map,r=[];for(const s of e){const o=ZW(s);if(o&&t.has(o)){const a=n.get(o)??[];a.push(s),n.set(o,a)}else r.push(s)}const i=s=>{const a=[...n.get(s.sessionId)??[]].sort((l,c)=>l.createdAt<c.createdAt?-1:l.createdAt>c.createdAt?1:0);return{session:s,children:a.map(i)}};return[...r].sort(JW).map(i)}function XR(e){return[...e].sort((t,n)=>t.session.updatedAt<n.session.updatedAt?1:t.session.updatedAt>n.session.updatedAt?-1:0)}function JW(e,t){const n=typeof e.pinnedAt=="number",r=typeof t.pinnedAt=="number";if(n&&r){const i=typeof e.pinSortOrder=="number",s=typeof t.pinSortOrder=="number";return i&&s?e.pinSortOrder-t.pinSortOrder:i?-1:s?1:t.pinnedAt-e.pinnedAt}return n?-1:r||e.updatedAt<t.updatedAt?1:e.updatedAt>t.updatedAt?-1:0}function eV(e){return e.appBuilderProject?`[app] ${e.appBuilderProject}`:e.label?e.label:e.aiLabel?e.aiLabel:e.cwd.split("/").filter(Boolean).pop()??""}function PS(e,t){const n=t.trim().toLowerCase();return n===""?!0:e.toLowerCase().includes(n)}const tV={isCollapsed:()=>!1,toggle:()=>{},prune:()=>{}};function nV({personas:e,activePersonaId:t,onSelectPersona:n,onCreateSession:r,sessions:i,activeSessionId:s,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,isPersonaExpanded:p,onTogglePersonaExpanded:m,onEditSession:v,onPinSession:w,showCopyResume:x,treatSessionsAsRoots:_,searchQuery:y}){const[S,C]=g.useState(null),[k,N]=g.useState(()=>new Set),T=p??(L=>k.has(L)),D=g.useCallback(L=>{if(m){m(L);return}N($=>{const F=new Set($);return F.has(L)?F.delete(L):F.add(L),F})},[m]),P=g.useMemo(()=>i==null?void 0:i.filter(L=>!L.ephemeral),[i]),O=g.useMemo(()=>new Map((P??[]).map(L=>[L.sessionId,sy(L)])),[P]),R=g.useCallback(L=>f==null?void 0:f.get(L),[f]),M=g.useCallback(L=>O.get(L),[O]);if(e.length===0)return h.jsx(rV,{});const A=(y??"").trim();return A?h.jsx(Z_.Provider,{value:tV,children:h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(L=>{const $=P?P.filter(E=>E.ownerPersonaId===L.personaId).sort((E,H)=>H.updatedAt>E.updatedAt?1:-1):[],F=PS(L.label,A),B=$.filter(E=>PS(eV(E),A));if(!F&&B.length===0)return null;const z=F?$:B;return h.jsx(RS,{persona:L,active:L.personaId===t,editing:!1,onSelectPersona:n,onSubmitCreateSession:()=>{},onCancelCreateSession:()=>{},personaSessions:z,collapsed:!1,onToggleCollapsed:()=>{},activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:w,showCopyResume:x,treatSessionsAsRoots:_,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,getCreatorDisplayName:R,getSessionDisplayName:M},L.personaId)})})}):h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(L=>{const $=P?P.filter(F=>F.ownerPersonaId===L.personaId).sort((F,B)=>B.updatedAt>F.updatedAt?1:-1):[];return h.jsx(RS,{persona:L,active:L.personaId===t,editing:L.personaId===S,onSelectPersona:n,onStartCreateSession:r?()=>C(L.personaId):void 0,onSubmitCreateSession:F=>{C(null),r==null||r(L.personaId,F)},onCancelCreateSession:()=>C(null),personaSessions:$,collapsed:!T(L.personaId),onToggleCollapsed:()=>D(L.personaId),activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:w,showCopyResume:x,treatSessionsAsRoots:_,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,getCreatorDisplayName:R,getSessionDisplayName:M},L.personaId)})})}function rV(){return h.jsx("div",{className:"px-3 py-3 text-[11px] leading-relaxed text-text-400",children:"还没有 persona。点上方 Personas 标题右侧 + 创建第一个。"})}function RS({persona:e,active:t,editing:n,onSelectPersona:r,onStartCreateSession:i,onSubmitCreateSession:s,onCancelCreateSession:o,personaSessions:a,collapsed:l,onToggleCollapsed:c,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:w,onPinSession:x,showCopyResume:_,treatSessionsAsRoots:y,ownerPrincipalId:S,creatorDisplayNameByOwnerId:C,getCreatorDisplayName:k,getSessionDisplayName:N}){const T=a.length>0,D=!l,P=g.useMemo(()=>{const M=[],A=new Map;for(const L of a){const $=L.creatorPrincipalId;if(L.larkChatId!=null||!$||S&&$===S){M.push(L);continue}const F=$,B=(C==null?void 0:C.get(F))??`…${F.slice(-8)}`,z=A.get(F);z?z.sessions.push(L):A.set(F,{groupKey:F,displayName:B,sessions:[L]})}return{self:M,byPeer:[...A.values()]}},[a,S,C]),O=P.byPeer.length>0,R=g.useMemo(()=>D&&!O?XR(YR(a)):[],[D,O,a]);return h.jsxs("div",{"data-testid":`persona-node-${e.personaId}`,children:[h.jsxs("div",{className:ne("group flex items-center gap-1 px-2 py-1.5 cursor-pointer",t?"bg-accent-dim text-text-100":"hover:bg-bg-200 text-text-200"),onClick:()=>r==null?void 0:r(e.personaId),role:"button",tabIndex:0,children:[T?h.jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),c()},"aria-label":D?"collapse":"expand","aria-expanded":D,"data-testid":`persona-chevron-${e.personaId}`,className:"flex h-4 w-4 shrink-0 items-center justify-center text-text-400 hover:text-text-100",children:D?h.jsx(Yn,{className:"h-3 w-3"}):h.jsx(Bn,{className:"h-3 w-3"})}):h.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),h.jsx(hp,{tool:e.tool,className:ne("h-3.5 w-3.5 shrink-0",fp(e.tool))}),h.jsx("span",{className:"flex-1 truncate text-[13px]",children:e.label}),T?h.jsx("span",{className:"shrink-0 text-[10px] text-text-400 tabular-nums","aria-label":`${a.length} sessions`,children:a.length}):null,i?h.jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),i()},"aria-label":"新建会话",title:"新建会话","data-testid":`persona-create-session-${e.personaId}`,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded text-text-400 opacity-0 hover:bg-text-100/10 hover:text-text-100 focus-visible:opacity-100 group-hover:opacity-100",children:h.jsx(H8,{className:"h-3.5 w-3.5"})}):null]}),n?h.jsx(iV,{personaId:e.personaId,tool:e.tool,onSubmit:s,onCancel:o}):null,T&&D?h.jsx("div",{"data-testid":`persona-sessions-${e.personaId}`,children:O?h.jsxs(h.Fragment,{children:[P.self.length>0&&h.jsx(MS,{groupKey:`${e.personaId}-self`,label:"我自己",testId:`persona-sessions-${e.personaId}-self`,sessions:P.self,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:w,onPinSession:x,showCopyResume:_,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:N}),P.byPeer.map(M=>h.jsx(MS,{groupKey:`${e.personaId}-peer-${M.groupKey}`,label:M.displayName,testId:`persona-sessions-${e.personaId}-peer-${M.groupKey}`,sessions:M.sessions,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:w,onPinSession:x,showCopyResume:_,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:N},`${e.personaId}-peer-${M.groupKey}`))]}):R.map(M=>h.jsx(Py,{node:M,depth:y?0:1,activeId:u,unreadIds:p,runningIds:f,awaitingIds:d,onSelect:A=>m==null?void 0:m(A),onDelete:v,onEdit:w,onPin:x,showCopyResume:_,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:N},M.session.sessionId))}):null]})}function MS({label:e,testId:t,sessions:n,activeSessionId:r,awaitingIds:i,runningIds:s,unreadIds:o,onSelectSession:a,onDeleteSession:l,onEditSession:c,onPinSession:u,showCopyResume:d,ownerPrincipalId:f,getCreatorDisplayName:p,getSessionDisplayName:m}){const[v,w]=g.useState(!1),x=!v,_=g.useMemo(()=>x?XR(YR(n)):[],[x,n]);return h.jsxs("div",{"data-testid":t,children:[h.jsxs("button",{type:"button",onClick:()=>w(y=>!y),"aria-label":x?"collapse":"expand","aria-expanded":x,"data-testid":`${t}-chevron`,className:"flex items-center gap-1 w-full pl-7 pr-2 py-0.5 text-[11px] text-text-400 hover:text-text-200 transition-colors",children:[x?h.jsx(Yn,{className:"h-3 w-3"}):h.jsx(Bn,{className:"h-3 w-3"}),h.jsx(PI,{className:"h-3 w-3","aria-hidden":!0}),h.jsx("span",{className:"truncate",children:e}),h.jsx("span",{className:"ml-auto tabular-nums",children:n.length})]}),x&&h.jsx("div",{children:_.map(y=>h.jsx(Py,{node:y,depth:2,activeId:r,unreadIds:o,runningIds:s,awaitingIds:i,onSelect:S=>a==null?void 0:a(S),onDelete:l,onEdit:c,onPin:u,showCopyResume:d,ownerPrincipalId:f,getCreatorDisplayName:p,getSessionDisplayName:m},y.session.sessionId))})]})}function iV({personaId:e,tool:t,onSubmit:n,onCancel:r}){const[i,s]=g.useState(""),o=g.useRef(null),a=i.trim(),l=a.length>0;g.useEffect(()=>{var d;(d=o.current)==null||d.focus()},[]);const c=g.useCallback(()=>{l&&n(a)},[l,a,n]),u=Pu(c,r);return h.jsxs("div",{className:"flex items-center gap-1.5 pl-9 pr-2 py-1","data-testid":`persona-new-session-row-${e}`,children:[h.jsx(hp,{tool:t,className:ne("h-3 w-3 shrink-0",fp(t))}),h.jsx("input",{ref:o,type:"text",value:i,onChange:d=>s(d.target.value),...u,onBlur:r,placeholder:"session label...","data-testid":`persona-new-session-input-${e}`,className:"flex-1 min-w-0 bg-bg-100 border border-text-100/15 rounded px-1.5 py-0.5 text-[12px] text-text-100 placeholder:text-text-400 focus:outline-none focus:border-text-100/40"}),h.jsx("button",{type:"button",onMouseDown:d=>{d.preventDefault(),c()},disabled:!l,"aria-label":"确认",title:"确认(Enter)","data-testid":`persona-new-session-confirm-${e}`,className:"flex h-4 w-4 shrink-0 items-center justify-center rounded text-text-300 hover:bg-text-100/10 hover:text-text-100 disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:text-text-300",children:h.jsx(bl,{className:"h-3 w-3"})}),h.jsx("button",{type:"button",onMouseDown:d=>{d.preventDefault(),r()},"aria-label":"取消",title:"取消(Esc)","data-testid":`persona-new-session-cancel-${e}`,className:"flex h-4 w-4 shrink-0 items-center justify-center rounded text-text-300 hover:bg-text-100/10 hover:text-text-100",children:h.jsx(Pr,{className:"h-3 w-3"})})]})}function sV(e,t){const n=getComputedStyle(e),r=parseFloat(n.fontSize);return t*r}function oV(e,t){const n=getComputedStyle(e.ownerDocument.documentElement),r=parseFloat(n.fontSize);return t*r}function aV(e){return e/100*window.innerHeight}function lV(e){return e/100*window.innerWidth}function cV(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function rc({groupSize:e,panelElement:t,styleProp:n}){let r;const[i,s]=cV(n);switch(s){case"%":{r=i/100*e;break}case"px":{r=i;break}case"rem":{r=oV(t,i);break}case"em":{r=sV(t,i);break}case"vh":{r=aV(i);break}case"vw":{r=lV(i);break}}return r}function Mn(e){return parseFloat(e.toFixed(3))}function Ja({group:e}){const{orientation:t,panels:n}=e;return n.reduce((r,i)=>(r+=t==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,r),0)}function R0(e){const{panels:t}=e,n=Ja({group:e});return n===0?t.map(r=>({groupResizeBehavior:r.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:r.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:r.panelConstraints.disabled,minSize:0,maxSize:100,panelId:r.id})):t.map(r=>{const{element:i,panelConstraints:s}=r;let o=0;if(s.collapsedSize!==void 0){const u=rc({groupSize:n,panelElement:i,styleProp:s.collapsedSize});o=Mn(u/n*100)}let a;if(s.defaultSize!==void 0){const u=rc({groupSize:n,panelElement:i,styleProp:s.defaultSize});a=Mn(u/n*100)}let l=0;if(s.minSize!==void 0){const u=rc({groupSize:n,panelElement:i,styleProp:s.minSize});l=Mn(u/n*100)}let c=100;if(s.maxSize!==void 0){const u=rc({groupSize:n,panelElement:i,styleProp:s.maxSize});c=Mn(u/n*100)}return{groupResizeBehavior:s.groupResizeBehavior,collapsedSize:o,collapsible:s.collapsible===!0,defaultSize:a,disabled:s.disabled,minSize:l,maxSize:c,panelId:r.id}})}function at(e,t="Assertion error"){if(!e)throw Error(t)}function M0(e,t){return Array.from(t).sort(e==="horizontal"?uV:dV)}function uV(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function dV(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function QR(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function ZR(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function hV({orientation:e,rects:t,targetRect:n}){const r={x:n.x+n.width/2,y:n.y+n.height/2};let i,s=Number.MAX_VALUE;for(const o of t){const{x:a,y:l}=ZR(r,o),c=e==="horizontal"?a:l;c<s&&(s=c,i=o)}return at(i,"No rect found"),i}let Cd;function fV(){return Cd===void 0&&(typeof matchMedia=="function"?Cd=!!matchMedia("(pointer:coarse)").matches:Cd=!1),Cd}function JR(e){const{element:t,orientation:n,panels:r,separators:i}=e,s=M0(n,Array.from(t.children).filter(QR).map(m=>({element:m}))).map(({element:m})=>m),o=[];let a=!1,l=!1,c=-1,u=-1,d=0,f,p=[];{let m=-1;for(const v of s)v.hasAttribute("data-panel")&&(m++,v.hasAttribute("data-disabled")||(d++,c===-1&&(c=m),u=m))}if(d>1){let m=-1;for(const v of s)if(v.hasAttribute("data-panel")){m++;const w=r.find(x=>x.element===v);if(w){if(f){const x=f.element.getBoundingClientRect(),_=v.getBoundingClientRect();let y;if(l){const S=n==="horizontal"?new DOMRect(x.right,x.top,0,x.height):new DOMRect(x.left,x.bottom,x.width,0),C=n==="horizontal"?new DOMRect(_.left,_.top,0,_.height):new DOMRect(_.left,_.top,_.width,0);switch(p.length){case 0:{y=[S,C];break}case 1:{const k=p[0],N=hV({orientation:n,rects:[x,_],targetRect:k.element.getBoundingClientRect()});y=[k,N===x?C:S];break}default:{y=p;break}}}else p.length?y=p:y=[n==="horizontal"?new DOMRect(x.right,_.top,_.left-x.right,_.height):new DOMRect(_.left,x.bottom,_.width,_.top-x.bottom)];for(const S of y){let C="width"in S?S:S.element.getBoundingClientRect();const k=fV()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(C.width<k){const T=k-C.width;C=new DOMRect(C.x-T/2,C.y,C.width+T,C.height)}if(C.height<k){const T=k-C.height;C=new DOMRect(C.x,C.y-T/2,C.width,C.height+T)}const N=m<=c||m>u;!a&&!N&&o.push({group:e,groupSize:Ja({group:e}),panels:[f,w],separator:"width"in S?void 0:S,rect:C}),a=!1}}l=!1,f=w,p=[]}}else if(v.hasAttribute("data-separator")){v.ariaDisabled!==null&&(a=!0);const w=i.find(x=>x.element===v);w?p.push(w):(f=void 0,p=[])}else l=!0}return o}var bs;class e5{constructor(){R1(this,bs,{})}addListener(t,n){const r=Pl(this,bs)[t];return r===void 0?Pl(this,bs)[t]=[n]:r.includes(n)||r.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const r=Pl(this,bs)[t];if(r!==void 0)if(r.length===1)r[0].call(null,n);else{let i=!1,s=null;const o=Array.from(r);for(let a=0;a<o.length;a++){const l=o[a];try{l.call(null,n)}catch(c){s===null&&(i=!0,s=c)}}if(i)throw s}}removeAllListeners(){M1(this,bs,{})}removeListener(t,n){const r=Pl(this,bs)[t];if(r!==void 0){const i=r.indexOf(n);i>=0&&r.splice(i,1)}}}bs=new WeakMap;let Da={cursorFlags:0,state:"inactive"};const Ry=new e5;function Io(){return Da}function pV(e){return Ry.addListener("change",e)}function mV(e){const t=Da,n={...Da};n.cursorFlags=e,Da=n,Ry.emit("change",{prev:t,next:n})}function Oa(e){const t=Da;Da=e,Ry.emit("change",{prev:t,next:e})}const gV=e=>e,Gm=()=>{},t5=1,n5=2,r5=4,i5=8,AS=3,jS=12;let Ed;function LS(){return Ed===void 0&&(Ed=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(Ed=!0)),Ed}function vV({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case"active":case"hover":t.forEach(s=>{if(!s.mutableState.disableCursor)switch(s.orientation){case"horizontal":{r++;break}case"vertical":{i++;break}}})}if(!(r===0&&i===0)){switch(n){case"active":{if(e&&LS()){const s=(e&t5)!==0,o=(e&n5)!==0,a=(e&r5)!==0,l=(e&i5)!==0;if(s)return a?"se-resize":l?"ne-resize":"e-resize";if(o)return a?"sw-resize":l?"nw-resize":"w-resize";if(a)return"s-resize";if(l)return"n-resize"}break}}return LS()?r>0&&i>0?"move":r>0?"ew-resize":"ns-resize":r>0&&i>0?"grab":r>0?"col-resize":"row-resize"}}const DS=new WeakMap;function My(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=DS.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));const r=Io();switch(r.state){case"active":case"hover":{const i=vV({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(o=>o.group),state:r.state}),s=`*, *:hover {cursor: ${i} !important; }`;if(t===s)return;t=s,i?n.cssRules.length===0?n.insertRule(s):n.replaceSync(s):n.cssRules.length===1&&n.deleteRule(0);break}case"inactive":{t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}}DS.set(e,{prevStyle:t,styleSheet:n})}let si=new Map;const s5=new e5;function xV(e){si=new Map(si),si.delete(e)}function OS(e,t){for(const[n]of si)if(n.id===e)return n}function Ls(e,t){for(const[n,r]of si)if(n.id===e)return r;if(t)throw Error(`Could not find data for Group with id ${e}`)}function Uo(){return si}function Ay(e,t){return s5.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function Xi(e,t,n){const r=si.get(e);si=new Map(si),si.set(e,t),s5.emit("groupChange",{group:e,isUserInteraction:(n==null?void 0:n.isUserInteraction)===!0,prev:r,next:t})}function o5(e){const t=Io();let n=!1;switch(t.state){case"active":Oa({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(My(e),n=!0,t.hitRegions.forEach(r=>{const i=Ls(r.group.id,!0);Xi(r.group,i,{isUserInteraction:!0})}))}return n}function BS(e){e.defaultPrevented||o5(e.currentTarget)}function _V(e,t,n){let r,i={x:1/0,y:1/0};for(const s of t){const o=ZR(n,s.rect);switch(e){case"horizontal":{o.x<=i.x&&(r=s,i=o);break}case"vertical":{o.y<=i.y&&(r=s,i=o);break}}}return r?{distance:i,hitRegion:r}:void 0}function yV(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function bV(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:FS(e),b:FS(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();at(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:$S(zS(n.a)),b:$S(zS(n.b))};if(i.a===i.b){const s=r.childNodes,o={a:n.a.at(-1),b:n.b.at(-1)};let a=s.length;for(;a--;){const l=s[a];if(l===o.a)return 1;if(l===o.b)return-1}}return Math.sign(i.a-i.b)}const wV=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function SV(e){const t=getComputedStyle(a5(e)??e).display;return t==="flex"||t==="inline-flex"}function kV(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||SV(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||wV.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function zS(e){let t=e.length;for(;t--;){const n=e[t];if(at(n,"Missing node"),kV(n))return n}return null}function $S(e){return e&&Number(getComputedStyle(e).zIndex)||0}function FS(e){const t=[];for(;e;)t.push(e),e=a5(e);return t}function a5(e){const{parentNode:t}=e;return yV(t)?t.host:t}function CV(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function EV({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!QR(n)||n.contains(e)||e.contains(n))return!0;if(bV(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(CV(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function jy(e,t){const n=[];return t.forEach((r,i)=>{if(i.disabled)return;const s=JR(i),o=_V(i.orientation,s,{x:e.clientX,y:e.clientY});o&&o.distance.x<=0&&o.distance.y<=0&&EV({groupElement:i.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&n.push(o.hitRegion)}),n}function NV(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function Sn(e,t,n=0){return Math.abs(Mn(e)-Mn(t))<=n}function ti(e,t){return Sn(e,t)?0:e>t?1:-1}function Ca({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){const{collapsedSize:i=0,collapsible:s,disabled:o,maxSize:a=100,minSize:l=0}=t;if(o&&!e)return n;if(ti(r,l)<0)if(s){const c=(i+l)/2;ti(r,c)<0?r=i:r=l}else r=l;return r=Math.min(a,r),r=Mn(r),r}function au({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(Sn(e,0))return t;const o=s==="imperative-api",a=Object.values(t),l=Object.values(i),c=[...a],[u,d]=r;at(u!=null,"Invalid first pivot index"),at(d!=null,"Invalid second pivot index");let f=0;switch(s){case"keyboard":{{const v=e<0?d:u,w=n[v];at(w,`Panel constraints not found for index ${v}`);const{collapsedSize:x=0,collapsible:_,minSize:y=0}=w;if(_){const S=a[v];if(at(S!=null,`Previous layout not found for panel index ${v}`),Sn(S,x)){const C=y-S;ti(C,Math.abs(e))>0&&(e=e<0?0-C:C)}}}{const v=e<0?u:d,w=n[v];at(w,`No panel constraints found for index ${v}`);const{collapsedSize:x=0,collapsible:_,minSize:y=0}=w;if(_){const S=a[v];if(at(S!=null,`Previous layout not found for panel index ${v}`),Sn(S,y)){const C=S-x;ti(C,Math.abs(e))>0&&(e=e<0?0-C:C)}}}break}default:{const v=e<0?d:u,w=n[v];at(w,`Panel constraints not found for index ${v}`);const x=a[v],{collapsible:_,collapsedSize:y,minSize:S}=w;if(_&&ti(x,S)<0)if(e>0){const C=S-y,k=C/2,N=x+e;ti(N,S)<0&&(e=ti(e,k)<=0?0:C)}else{const C=S-y,k=100-C/2,N=x-e;ti(N,S)<0&&(e=ti(100+e,k)>0?0:-C)}break}}{const v=e<0?1:-1;let w=e<0?d:u,x=0;for(;;){const y=a[w];at(y!=null,`Previous layout not found for panel index ${w}`);const S=Ca({overrideDisabledPanels:o,panelConstraints:n[w],prevSize:y,size:100})-y;if(x+=S,w+=v,w<0||w>=n.length)break}const _=Math.min(Math.abs(e),Math.abs(x));e=e<0?0-_:_}{let v=e<0?u:d;for(;v>=0&&v<n.length;){const w=Math.abs(e)-Math.abs(f),x=a[v];at(x!=null,`Previous layout not found for panel index ${v}`);const _=x-w,y=Ca({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:x,size:_});if(!Sn(x,y)&&(f+=x-y,c[v]=y,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?v--:v++}}if(NV(l,c))return i;{const v=e<0?d:u,w=a[v];at(w!=null,`Previous layout not found for panel index ${v}`);const x=w+f,_=Ca({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:w,size:x});if(c[v]=_,!Sn(_,x)){let y=x-_,S=e<0?d:u;for(;S>=0&&S<n.length;){const C=c[S];at(C!=null,`Previous layout not found for panel index ${S}`);const k=C+y,N=Ca({overrideDisabledPanels:o,panelConstraints:n[S],prevSize:C,size:k});if(Sn(C,N)||(y-=N-C,c[S]=N),Sn(y,0))break;e>0?S--:S++}}}const p=Object.values(c).reduce((v,w)=>w+v,0);if(!Sn(p,100,.1))return i;const m=Object.keys(i);return c.reduce((v,w,x)=>(v[m[x]]=w,v),{})}function Po(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||ti(e[n],t[n])!==0)return!1;return!0}function Ro({layout:e,panelConstraints:t}){const n=Object.values(e),r=[...n],i=r.reduce((a,l)=>a+l,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(a=>`${a}%`).join(", ")}`);if(!Sn(i,100)&&r.length>0)for(let a=0;a<t.length;a++){const l=r[a];at(l!=null,`No layout data found for index ${a}`);const c=100/i*l;r[a]=c}let s=0;for(let a=0;a<t.length;a++){const l=n[a];at(l!=null,`No layout data found for index ${a}`);const c=r[a];at(c!=null,`No layout data found for index ${a}`);const u=Ca({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});c!=u&&(s+=c-u,r[a]=u)}if(!Sn(s,0))for(let a=0;a<t.length;a++){const l=r[a];at(l!=null,`No layout data found for index ${a}`);const c=l+s,u=Ca({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});if(l!==u&&(s-=u-l,r[a]=u,Sn(s,0)))break}const o=Object.keys(e);return r.reduce((a,l,c)=>(a[o[c]]=l,a),{})}function l5({groupId:e,panelId:t}){const n=()=>{const l=Uo();for(const[c,{defaultLayoutDeferred:u,derivedPanelConstraints:d,layout:f,groupSize:p,separatorToPanels:m}]of l)if(c.id===e)return{defaultLayoutDeferred:u,derivedPanelConstraints:d,group:c,groupSize:p,layout:f,separatorToPanels:m};throw Error(`Group ${e} not found`)},r=()=>{const l=n().derivedPanelConstraints.find(c=>c.panelId===t);if(l!==void 0)return l;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{const l=n().group.panels.find(c=>c.id===t);if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},s=()=>{const l=n().layout[t];if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},o=({nextSize:l,panels:c,prevLayout:u,derivedPanelConstraints:d})=>{const f=s(),p=c.findIndex(w=>w.id===t),m=p===0,v=p===c.length-1;if(v&&l<f&&(m||c.slice(0,p).every((w,x)=>{const _=d[x];return(_==null?void 0:_.collapsible)&&Sn(_.collapsedSize,u[_.panelId])}))){const w=c.slice(0,p).reduce((x,_)=>x+u[_.id],0);return{...u,[t]:Mn(100-w)}}return au({delta:v?f-l:l-f,initialLayout:u,panelConstraints:d,pivotIndices:v?[p-1,p]:[p,p+1],prevLayout:u,trigger:"imperative-api"})},a=l=>{const c=s();if(l===c)return;const{defaultLayoutDeferred:u,derivedPanelConstraints:d,group:f,groupSize:p,layout:m,separatorToPanels:v}=n(),w=o({nextSize:l,panels:f.panels,prevLayout:m,derivedPanelConstraints:d}),x=Ro({layout:w,panelConstraints:d});Po(m,x)||Xi(f,{defaultLayoutDeferred:u,derivedPanelConstraints:d,groupSize:p,layout:x,separatorToPanels:v})};return{collapse:()=>{const{collapsible:l,collapsedSize:c}=r(),{mutableValues:u}=i(),d=s();l&&d!==c&&(u.expandToSize=d,a(c))},expand:()=>{const{collapsible:l,collapsedSize:c,minSize:u}=r(),{mutableValues:d}=i(),f=s();if(l&&f===c){let p=d.expandToSize??u;p===0&&(p=1),a(p)}},getSize:()=>{const{group:l}=n(),c=s(),{element:u}=i(),d=l.orientation==="horizontal"?u.offsetWidth:u.offsetHeight;return{asPercentage:c,inPixels:d}},isCollapsed:()=>{const{collapsible:l,collapsedSize:c}=r(),u=s();return l&&Sn(c,u)},resize:l=>{const{group:c}=n(),{element:u}=i(),d=Ja({group:c}),f=rc({groupSize:d,panelElement:u,styleProp:l}),p=Mn(f/d*100);a(p)}}}function HS(e){if(e.defaultPrevented)return;const t=Uo();jy(e,t).forEach(n=>{if(n.separator&&!n.separator.disableDoubleClick){const r=n.panels.find(i=>i.panelConstraints.defaultSize!==void 0);if(r){const i=r.panelConstraints.defaultSize,s=l5({groupId:n.group.id,panelId:r.id});s&&i!==void 0&&(s.resize(i),e.preventDefault())}}})}function ah(e){const t=Uo();for(const[n]of t)if(n.separators.some(r=>r.element===e))return n;throw Error("Could not find parent Group for separator element")}function c5({groupId:e}){const t=()=>{const n=Uo();for(const[r,i]of n)if(r.id===e)return{group:r,...i};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:n,layout:r}=t();return n?{}:r},setLayout(n){const{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:s,groupSize:o,layout:a,separatorToPanels:l}=t(),c=Ro({layout:n,panelConstraints:i});return r?a:(Po(a,c)||Xi(s,{defaultLayoutDeferred:r,derivedPanelConstraints:i,groupSize:o,layout:c,separatorToPanels:l}),c)}}}function eo(e,t){const n=ah(e),r=Ls(n.id,!0),i=n.separators.find(u=>u.element===e);at(i,"Matching separator not found");const s=r.separatorToPanels.get(i);at(s,"Matching panels not found");const o=s.map(u=>n.panels.indexOf(u)),a=c5({groupId:n.id}).getLayout(),l=au({delta:t,initialLayout:a,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:a,trigger:"keyboard"}),c=Ro({layout:l,panelConstraints:r.derivedPanelConstraints});Po(a,c)||Xi(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels},{isUserInteraction:!0})}function US(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=ah(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&eo(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&eo(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&eo(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&eo(t,-5);break}case"End":{e.preventDefault(),eo(t,100);break}case"Enter":{e.preventDefault();const r=ah(t),i=Ls(r.id,!0),{derivedPanelConstraints:s,layout:o,separatorToPanels:a}=i,l=r.separators.find(f=>f.element===t);at(l,"Matching separator not found");const c=a.get(l);at(c,"Matching panels not found");const u=c[0],d=s.find(f=>f.panelId===u.id);if(at(d,"Panel metadata not found"),d.collapsible){const f=o[u.id],p=d.collapsedSize===f?r.mutableState.expandedPanelSizes[u.id]??d.minSize:d.collapsedSize;eo(t,p-f)}break}case"F6":{e.preventDefault();const r=ah(t).separators.map(o=>o.element),i=Array.from(r).findIndex(o=>o===e.currentTarget);at(i!==null,"Index not found");const s=e.shiftKey?i>0?i-1:r.length-1:i+1<r.length?i+1:0;r[s].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),eo(t,-100);break}}}function WS(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=Uo(),n=jy(e,t),r=new Map;let i=!1;n.forEach(s=>{s.separator&&(i||(i=!0,s.separator.element.focus({focusVisible:!1,preventScroll:!0})));const o=t.get(s.group);o&&r.set(s.group,o.layout)}),Oa({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}function u5({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:s,prevCursorFlags:o}){let a=0;n.forEach(c=>{const{group:u,groupSize:d}=c,{orientation:f,panels:p}=u,{disableCursor:m}=u.mutableState;let v=0;s?f==="horizontal"?v=(t.clientX-s.x)/d*100:v=(t.clientY-s.y)/d*100:f==="horizontal"?v=t.clientX<0?-100:100:v=t.clientY<0?-100:100;const w=r.get(u),x=i.get(u);if(!w||!x)return;const{defaultLayoutDeferred:_,derivedPanelConstraints:y,groupSize:S,layout:C,separatorToPanels:k}=x;if(y&&C&&k){const N=au({delta:v,initialLayout:w,panelConstraints:y,pivotIndices:c.panels.map(T=>p.indexOf(T)),prevLayout:C,trigger:"mouse-or-touch"});if(Po(N,C)){if(v!==0&&!m)switch(f){case"horizontal":{a|=v<0?t5:n5;break}case"vertical":{a|=v<0?r5:i5;break}}}else Xi(c.group,{defaultLayoutDeferred:_,derivedPanelConstraints:y,groupSize:S,layout:N,separatorToPanels:k})}});let l=0;t.movementX===0?l|=o&AS:l|=a&AS,t.movementY===0?l|=o&jS:l|=a&jS,mV(l),My(e)}function VS(e){const t=Uo(),n=Io();switch(n.state){case"active":u5({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function qS(e){var r,i;if(e.defaultPrevented)return;const t=Io(),n=Uo();switch(t.state){case"active":{if(e.buttons===0){Oa({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(s=>{const o=Ls(s.group.id,!0);Xi(s.group,o,{isUserInteraction:!0})});return}for(const s of t.hitRegions)if(s.separator){const{element:o}=s.separator;(r=o.hasPointerCapture)!=null&&r.call(o,e.pointerId)||((i=o.setPointerCapture)==null||i.call(o,e.pointerId))}u5({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const s=jy(e,n);s.length===0?t.state!=="inactive"&&Oa({cursorFlags:0,state:"inactive"}):Oa({cursorFlags:0,hitRegions:s,state:"hover"}),My(e.currentTarget);break}}}function KS(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(Io().state){case"hover":Oa({cursorFlags:0,state:"inactive"})}}function GS(e){e.defaultPrevented||e.pointerType==="mouse"&&e.button>0||o5(e.currentTarget)&&e.preventDefault()}function YS(e){let t=0,n=0;const r={};for(const s of e)if(s.defaultSize!==void 0){t++;const o=Mn(s.defaultSize);n+=o,r[s.panelId]=o}else r[s.panelId]=void 0;const i=e.length-t;if(i!==0){const s=Mn((100-n)/i);for(const o of e)o.defaultSize===void 0&&(r[o.panelId]=s)}return r}function TV(e,t,n){if(!n[0])return;const r=e.panels.find(l=>l.element===t);if(!r||!r.onResize)return;const i=Ja({group:e}),s=e.orientation==="horizontal"?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,a={asPercentage:Mn(s/i*100),inPixels:s};r.mutableValues.prevSize=a,r.onResize(a,r.id,o)}function IV(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function PV({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,s=0,o=!1;const a=new Map,l=[];for(const d of e.panels){const f=r[d.id]??0;switch(d.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{o=!0;const p=f/100*n,m=Mn(p/t*100);a.set(d.id,m),i+=m;break}case"preserve-relative-size":default:{l.push(d.id),s+=f;break}}}if(!o||l.length===0)return r;const c=100-i,u={...r};if(a.forEach((d,f)=>{u[f]=d}),s>0)for(const d of l){const f=r[d]??0;u[d]=Mn(f/s*c)}else{const d=Mn(c/l.length);for(const f of l)u[f]=d}return u}function RV(e,t){const n=e.map(i=>i.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n)if(!r.includes(i))return!1;return!0}const ia=new Map;function MV(e){let t=!0;at(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,s=new n(m=>{for(const v of m){const{borderBoxSize:w,target:x}=v;if(x===e.element){if(t){const _=Ja({group:e});if(_===0)return;const y=Ls(e.id);if(!y)return;const S=R0(e),C=y.defaultLayoutDeferred?YS(S):y.layout,k=PV({group:e,nextGroupSize:_,prevGroupSize:y.groupSize,prevLayout:C}),N=Ro({layout:k,panelConstraints:S});if(!y.defaultLayoutDeferred&&Po(y.layout,N)&&IV(y.derivedPanelConstraints,S)&&y.groupSize===_)return;Xi(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:S,groupSize:_,layout:N,separatorToPanels:y.separatorToPanels})}}else TV(e,x,w)}});s.observe(e.element),e.panels.forEach(m=>{at(!r.has(m.id),`Panel ids must be unique; id "${m.id}" was used more than once`),r.add(m.id),m.onResize&&s.observe(m.element)});const o=Ja({group:e}),a=R0(e),l=e.panels.map(({id:m})=>m).join(",");let c=e.mutableState.defaultLayout;c&&(RV(e.panels,c)||(c=void 0));const u=e.mutableState.layouts[l]??c??YS(a),d=Ro({layout:u,panelConstraints:a}),f=e.element.ownerDocument;ia.set(f,(ia.get(f)??0)+1);const p=new Map;return JR(e).forEach(m=>{m.separator&&p.set(m.separator,m.panels)}),Xi(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:a,groupSize:o,layout:d,separatorToPanels:p}),e.separators.forEach(m=>{at(!i.has(m.id),`Separator ids must be unique; id "${m.id}" was used more than once`),i.add(m.id),m.element.addEventListener("keydown",US)}),ia.get(f)===1&&(f.addEventListener("contextmenu",BS,!0),f.addEventListener("dblclick",HS,!0),f.addEventListener("pointerdown",WS,!0),f.addEventListener("pointerleave",VS),f.addEventListener("pointermove",qS),f.addEventListener("pointerout",KS),f.addEventListener("pointerup",GS,!0)),function(){t=!1,ia.set(f,Math.max(0,(ia.get(f)??0)-1)),xV(e),e.separators.forEach(m=>{m.element.removeEventListener("keydown",US)}),ia.get(f)||(f.removeEventListener("contextmenu",BS,!0),f.removeEventListener("dblclick",HS,!0),f.removeEventListener("pointerdown",WS,!0),f.removeEventListener("pointerleave",VS),f.removeEventListener("pointermove",qS),f.removeEventListener("pointerout",KS),f.removeEventListener("pointerup",GS,!0)),s.disconnect()}}function AV(){const[e,t]=g.useState({}),n=g.useCallback(()=>t({}),[]);return[e,n]}function Ly(e){const t=g.useId();return`${e??t}`}const Wo=typeof window<"u"?g.useLayoutEffect:g.useEffect;function Sc(e){const t=g.useRef(e);return Wo(()=>{t.current=e},[e]),g.useCallback((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[t])}function Dy(...e){return Sc(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function Oy(e){const t=g.useRef({...e});return Wo(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const d5=g.createContext(null);function jV(e,t){const n=g.useRef({getLayout:()=>({}),setLayout:gV});g.useImperativeHandle(t,()=>n.current,[]),Wo(()=>{Object.assign(n.current,c5({groupId:e}))})}function By({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:s,groupRef:o,id:a,onLayoutChange:l,onLayoutChanged:c,orientation:u="horizontal",resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){const m=g.useRef({onLayoutChange:{},onLayoutChanged:{}}),v=Sc(O=>{Po(m.current.onLayoutChange,O)||(m.current.onLayoutChange=O,l==null||l(O))}),w=Sc((O,R)=>{Po(m.current.onLayoutChanged,O)||(m.current.onLayoutChanged=O,c==null||c(O,{isUserInteraction:R}))}),x=Ly(a),_=g.useRef(null),[y,S]=AV(),C=g.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),k=Dy(_,s);jV(x,o);const N=Sc((O,R)=>{const M=Io(),A=OS(O),L=Ls(O);if(L){let $=!1;switch(M.state){case"active":{$=M.hitRegions.some(F=>F.group===A);break}}return{flexGrow:L.layout[R]??1,pointerEvents:$?"none":void 0}}if(n!=null&&n[R])return{flexGrow:n==null?void 0:n[R]}}),T=Oy({defaultLayout:n,disableCursor:r}),D=g.useMemo(()=>({get disableCursor(){return!!T.disableCursor},getPanelStyles:N,id:x,orientation:u,registerPanel:O=>{const R=C.current;return R.panels=M0(u,[...R.panels,O]),S(),()=>{R.panels=R.panels.filter(M=>M!==O),S()}},registerSeparator:O=>{const R=C.current;return R.separators=M0(u,[...R.separators,O]),S(),()=>{R.separators=R.separators.filter(M=>M!==O),S()}},updatePanelProps:(O,{disabled:R})=>{const M=C.current.panels.find($=>$.id===O);M&&(M.panelConstraints.disabled=R);const A=OS(x),L=Ls(x);A&&L&&Xi(A,{...L,derivedPanelConstraints:R0(A)})},updateSeparatorProps:(O,{disabled:R,disableDoubleClick:M})=>{const A=C.current.separators.find(L=>L.id===O);A&&(A.disabled=R,A.disableDoubleClick=M)}}),[N,x,S,u,T]),P=g.useRef(null);return Wo(()=>{const O=_.current;if(O===null)return;const R=C.current;let M;if(T.defaultLayout!==void 0&&Object.keys(T.defaultLayout).length===R.panels.length){M={};for(const E of R.panels){const H=T.defaultLayout[E.id];H!==void 0&&(M[E.id]=H)}}const A={disabled:!!i,element:O,id:x,mutableState:{defaultLayout:M,disableCursor:!!T.disableCursor,expandedPanelSizes:C.current.lastExpandedPanelSizes,layouts:C.current.layouts},orientation:u,panels:R.panels,resizeTargetMinimumSize:R.resizeTargetMinimumSize,separators:R.separators};P.current=A;const L=MV(A),{defaultLayoutDeferred:$,derivedPanelConstraints:F,layout:B}=Ls(A.id,!0);!$&&F.length>0&&(v(B),w(B,!1));const z=Ay(x,E=>{const{defaultLayoutDeferred:H,derivedPanelConstraints:q,layout:j}=E.next;if(H||q.length===0)return;const re=A.panels.map(({id:K})=>K).join(",");A.mutableState.layouts[re]=j,q.forEach(K=>{if(K.collapsible){const{layout:xe}=E.prev??{};if(xe){const Ee=Sn(K.collapsedSize,j[K.panelId]),ue=Sn(K.collapsedSize,xe[K.panelId]);Ee&&!ue&&(A.mutableState.expandedPanelSizes[K.panelId]=xe[K.panelId])}}});const ie=Io().state!=="active";v(j),ie&&w(j,E.isUserInteraction)});return()=>{P.current=null,L(),z()}},[i,x,w,v,u,y,T]),g.useEffect(()=>{const O=P.current;O&&(O.mutableState.defaultLayout=n,O.mutableState.disableCursor=!!r)}),h.jsx(d5.Provider,{value:D,children:h.jsx("div",{...p,className:t,"data-group":!0,"data-testid":x,id:x,ref:k,style:{height:"100%",width:"100%",overflow:"hidden",...f,display:"flex",flexDirection:u==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:u==="horizontal"?"pan-y":"pan-x"},children:e})})}By.displayName="Group";function zy(){const e=g.useContext(d5);return at(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function LV(e,t){const{id:n}=zy(),r=g.useRef({collapse:Gm,expand:Gm,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Gm});g.useImperativeHandle(t,()=>r.current,[]),Wo(()=>{Object.assign(r.current,l5({groupId:n,panelId:e}))})}function df({children:e,className:t,collapsedSize:n="0%",collapsible:r=!1,defaultSize:i,disabled:s,elementRef:o,groupResizeBehavior:a="preserve-relative-size",id:l,maxSize:c="100%",minSize:u="0%",onResize:d,panelRef:f,style:p,...m}){const v=!!l,w=Ly(l),x=Oy({disabled:s}),_=g.useRef(null),y=Dy(_,o),{getPanelStyles:S,id:C,orientation:k,registerPanel:N,updatePanelProps:T}=zy(),D=d!==null,P=Sc((A,L,$)=>{d==null||d(A,l,$)});Wo(()=>{const A=_.current;if(A!==null){const L={element:A,id:w,idIsStable:v,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:D?P:void 0,panelConstraints:{groupResizeBehavior:a,collapsedSize:n,collapsible:r,defaultSize:i,disabled:x.disabled,maxSize:c,minSize:u}};return N(L)}},[a,n,r,i,D,w,v,c,u,P,N,x]),g.useEffect(()=>{T(w,{disabled:s})},[s,w,T]),LV(w,f);const O=()=>{const A=S(C,w);if(A)return JSON.stringify(A)},R=g.useSyncExternalStore(A=>Ay(C,A),O,O);let M;return R?M=JSON.parse(R):i!==void 0?M={flexGrow:void 0,flexShrink:void 0,flexBasis:i}:M={flexGrow:1},h.jsx("div",{...m,"data-disabled":s||void 0,"data-panel":!0,"data-testid":w,id:w,ref:y,style:{...DV,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...M},children:h.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...p,touchAction:k==="horizontal"?"pan-y":"pan-x"},children:e})})}df.displayName="Panel";const DV={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function OV({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,s;const o=e[n],a=t.find(l=>l.panelId===n);if(a){const l=a.maxSize,c=a.collapsible?a.collapsedSize:a.minSize,u=[r,r+1];s=Ro({layout:au({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=Ro({layout:au({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:s,valueNow:o}}function h5({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:s,style:o,...a}){const l=Ly(s),c=Oy({disabled:n,disableDoubleClick:r}),[u,d]=g.useState({}),[f,p]=g.useState("inactive"),[m,v]=g.useState(!1),w=g.useRef(null),x=Dy(w,i),{disableCursor:_,id:y,orientation:S,registerSeparator:C,updateSeparatorProps:k}=zy(),N=S==="horizontal"?"vertical":"horizontal";Wo(()=>{const P=w.current;if(P!==null){const O={disabled:c.disabled,disableDoubleClick:c.disableDoubleClick,element:P,id:l},R=C(O),M=pV(L=>{p(L.next.state!=="inactive"&&L.next.hitRegions.some($=>$.separator===O)?L.next.state:"inactive")}),A=Ay(y,L=>{const{derivedPanelConstraints:$,layout:F,separatorToPanels:B}=L.next,z=B.get(O);if(z){const E=z[0],H=z.indexOf(E);d(OV({layout:F,panelConstraints:$,panelId:E.id,panelIndex:H}))}});return()=>{M(),A(),R()}}},[y,l,C,c]),g.useEffect(()=>{k(l,{disabled:n,disableDoubleClick:r})},[n,r,l,k]);let T;n&&!_&&(T="not-allowed");let D;if(n)D="disabled";else switch(f){case"active":{D="active";break}default:m?D="focus":D=f}return h.jsx("div",{...a,"aria-controls":u.valueControls,"aria-disabled":n||void 0,"aria-orientation":N,"aria-valuemax":u.valueMax,"aria-valuemin":u.valueMin,"aria-valuenow":u.valueNow,children:e,className:t,"data-separator":D,"data-testid":l,id:l,onBlur:()=>v(!1),onFocus:()=>v(!0),ref:x,role:"separator",style:{flexBasis:"auto",cursor:T,...o,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}h5.displayName="Separator";function BV(e){if(!e)return;const t=e.contextUsage,n=e.contextWindowSize;if(!t||!n||n<=0)return;const r=t.inputTokens+(t.cacheReadTokens??0)+(t.cacheCreateTokens??0);if(!(r<=0))return Math.round(r/n*100)}function f5(e,t){const n=zo(),r=e?`session/${e}`:"",i=pi(r)??Jc,s=g.useCallback(d=>{!e||!r||n.setData(r,f=>pI(f??Jc,d,e))},[n,r,e]),o=g.useCallback(()=>{e&&s({type:"session:change",sessionId:e})},[s,e]),a=g.useCallback(d=>{e&&s({type:"permission:clear",sessionId:e,requestId:d})},[s,e]),l=g.useCallback(d=>{e&&s({type:"permission:request",sessionId:e,requestId:d.requestId,tool:d.tool,input:d.input,...d.toolUseId?{toolUseId:d.toolUseId}:{}})},[s,e]),c=g.useCallback(d=>{e&&s({type:"session:question:clear",sessionId:e,toolUseId:d})},[s,e]),u=g.useCallback((d,f)=>{e&&s({type:"session:question:submitted",sessionId:e,toolUseId:d,answers:f})},[s,e]);return{...i,reset:o,clearPermission:a,restorePermission:l,clearQuestion:c,markQuestionSubmitted:u}}function zV(e){return e.kind!=="user-text"?!1:e.meta===void 0||e.meta==="slash-command"||ap(e.meta)}function $V(e,t={}){let n=0;if(t.implicitCloseOnUserText){for(const r of e)zV(r)&&n++;return n}for(const r of e)r.kind==="turn-end"&&n++;return n}const FV=50;function HV({api:e,sessionId:t,toolSessionId:n,initialTurns:r,implicitCloseOnUserText:i,pageSize:s=FV}){const[o,a]=g.useState({messages:[],total:0,loading:!1,error:null}),l=g.useRef(n),c=g.useRef(null),u=g.useRef(0),d=g.useRef(!0);return g.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]),g.useEffect(()=>{const f=l.current;if(l.current=n,!(c.current!==t)&&!(typeof f=="string"&&f!==n))return;if(a({messages:[],total:0,loading:!1,error:null}),!t){c.current=null;return}c.current=t;const v=++u.current;a(w=>({...w,loading:!0,error:null})),(async()=>{let w=[],x=!1,_=r===void 0?{}:{limit:s},y=Number.POSITIVE_INFINITY;for(;;){let S;try{S=await e.historyRead({sessionId:t,..._})}catch(O){if(v!==u.current||!d.current)return;const R=O.message??"history load failed";a(x?M=>({...M,error:R}):{messages:[],total:0,loading:!1,error:R});return}if(v!==u.current||!d.current)return;w=[...S.messages??[],...w];const C=S.total??0,k=typeof S.offset=="number"?S.offset:0,N=k>=y,T=k<=0||N;y=k;const D=r!==void 0&&$V(w,{implicitCloseOnUserText:i})>=r;if(x?a({messages:w,total:C,loading:!1,error:null}):(T||D)&&(x=!0,a({messages:w,total:C,loading:!1,error:null})),T)return;const P=Math.max(0,k-s);_={offset:P,limit:k-P}}})()},[e,t,n,s,r]),o}const UV=["TaskCreate","TaskUpdate","TaskList","TaskGet"];function WV(e){return UV.includes(e)}function p5(e){return e==="in_progress"||e==="completed"?e:"pending"}function VV(e,t){if(!t||typeof t!="object")return e;const n=t,r=typeof n.subject=="string"&&n.subject?n.subject:typeof n.content=="string"&&n.content?n.content:null;if(!r)return e;const i=typeof n.activeForm=="string"?n.activeForm:void 0,s=typeof n.description=="string"?n.description:void 0;return[...e,{id:String(e.length+1),content:r,status:p5(n.status),activeForm:i,description:s}]}function qV(e,t){if(!t||typeof t!="object")return e;const n=t,r=typeof n.taskId=="string"&&n.taskId?n.taskId:typeof n.id=="string"&&n.id?n.id:null;if(!r)return e;const i=e.findIndex(a=>a.id===r);if(i<0)return e;const s=[...e],o={...s[i]};return"status"in n&&(o.status=p5(n.status)),typeof n.subject=="string"&&(o.content=n.subject),typeof n.content=="string"&&(o.content=n.content),typeof n.activeForm=="string"&&(o.activeForm=n.activeForm),typeof n.description=="string"&&(o.description=n.description),s[i]=o,s}function KV(e){let t=[],n=-1;for(let r=0;r<e.length;r++){const i=e[r];if(i.kind==="task-event")switch(n=r,i.name){case"TaskCreate":t=VV(t,i.input);break;case"TaskUpdate":t=qV(t,i.input);break}}return{tasks:t,lastEventIndex:n}}function GV(e){return e==="TodoWrite"}function YV(e){if(!e||typeof e!="object")return null;const t=e;if(!Array.isArray(t.todos))return null;const n=[];for(const r of t.todos){if(!r||typeof r!="object")continue;const i=r,s=typeof i.content=="string"?i.content:"";if(!s)continue;const o=i.status==="in_progress"||i.status==="completed"?i.status:"pending",a=typeof i.activeForm=="string"?i.activeForm:void 0;n.push({content:s,status:o,activeForm:a})}return n}function XV(e,t,n){var s;const r=[],i=new Map;for(let o=0;o<e.length;o++){const a=e[o],l=typeof a.seq=="number"?a.seq:o;switch(a.kind){case"session_init":r.push({kind:"session-init",seq:l,toolSessionId:a.toolSessionId});break;case"text":XS(r,l,"assistant-text",a.text,a.partialId,a.uuid);break;case"thinking":XS(r,l,"assistant-thinking",a.text,a.partialId);break;case"user_text":{a.meta==="task-notification"?r.push({kind:"agent-notification",seq:l,text:a.text,taskId:a.taskId,parentToolUseId:a.parentToolUseId}):a.meta?r.push({kind:"user-meta",seq:l,metaKind:a.meta,text:a.text}):r.push({kind:"user-text",seq:l,text:a.text,uuid:a.uuid,...a.sender&&(a.sender.principal!=="owner"||aI.test(a.text))?{senderDisplayName:a.sender.displayName}:{},senderPrincipal:((s=a.sender)==null?void 0:s.principal)==="guest"?"guest":"owner"});break}case"tool_call":m5(r,l,a.toolUseId,a.tool,a.input,a.toolKind);break;case"tool_result":{const c=i.get(a.toolUseId);if(c!==void 0){if(a.askQuestionAnswers){const d=r[c];d.submittedAnswers=a.askQuestionAnswers}i.delete(a.toolUseId);break}const u={kind:"tool-result",seq:l,toolUseId:a.toolUseId,output:a.output,error:a.error};a.toolResultExtra&&(u.toolResultExtra=a.toolResultExtra),r.push(u);break}case"attachment_memories":r.push({kind:"memory-callout",seq:l,memories:a.memories});break;case"permission_request":{if(!t||a.requestId!==t)break;r.push({kind:"permission-inline",seq:l,requestId:a.requestId,tool:a.tool,input:a.input});break}case"ask_user_question":i.set(a.toolUseId,r.length),r.push({kind:"question-card",seq:l,toolUseId:a.toolUseId,questions:a.questions});break;case"turn_end":{const c={kind:"turn-end",seq:l};a.durationMs!==void 0&&(c.durationMs=a.durationMs),a.reason!==void 0&&(c.reason=a.reason),r.push(c);break}case"subagent_progress":{const c={kind:"agent-progress",seq:l,toolUseId:a.toolUseId,agentId:a.agentId,status:a.status};a.description&&(c.description=a.description),a.lastToolName&&(c.lastToolName=a.lastToolName),a.prompt&&(c.prompt=a.prompt),a.stats&&(c.stats=a.stats),r.push(c);break}case"error":r.push({kind:"error",seq:l,message:a.message});break}}return r}function m5(e,t,n,r,i,s){if(GV(r)){const o=YV(i);if(o){e.push({kind:"todo-checklist",seq:t,toolUseId:n,todos:o});return}}if(r==="Agent"){const o=i??{},a=typeof o.description=="string"&&o.description?o.description:typeof o.subagent_type=="string"&&o.subagent_type?o.subagent_type:"Subagent";e.push({kind:"agent-call",seq:t,toolUseId:n,description:a,input:i});return}if(WV(r)){e.push({kind:"task-event",seq:t,toolUseId:n,name:r,input:i});return}e.push({kind:"tool-call",seq:t,toolUseId:n,tool:r,toolKind:s,input:i})}function XS(e,t,n,r,i,s){let o=-1;for(let c=e.length-1;c>=0;c--)if(e[c].kind===n){o=c;break}const a=o>=0?e[o]:null;if(i){if(a&&a.partialId===i){const u=n==="assistant-text"?{kind:n,seq:a.seq,text:a.text+r,partialId:i,...s?{uuid:s}:{}}:{kind:n,seq:a.seq,text:a.text+r,partialId:i};e[o]=u;return}const c=n==="assistant-text"?{kind:n,seq:t,text:r,partialId:i,...s?{uuid:s}:{}}:{kind:n,seq:t,text:r,partialId:i};e.push(c);return}if(a&&a.partialId){const c=n==="assistant-text"?{kind:n,seq:a.seq,text:r,...s?{uuid:s}:{}}:{kind:n,seq:a.seq,text:r};e[o]=c;return}const l=n==="assistant-text"?{kind:n,seq:t,text:r,...s?{uuid:s}:{}}:{kind:n,seq:t,text:r};e.push(l)}const QV="AskUserQuestion";function g5(e,t=0,n){var o;const r=[],i=new Map;let s=t;for(const a of e){const l=s++,c=a.toolUseId??`hist-${l}`;switch(a.kind){case"user-text":if(a.meta==="task-notification")r.push({kind:"agent-notification",seq:l,text:a.text??"",taskId:a.taskId,parentToolUseId:a.parentToolUseId});else if(a.meta)r.push({kind:"user-meta",seq:l,metaKind:a.meta,text:a.text??""});else{const u=aI.exec(a.text??""),d=(o=pz.exec(a.text??""))==null?void 0:o[1],f=(u==null?void 0:u[2])??d,p=(u==null?void 0:u[1])==="guest"||d?"guest":"owner";r.push({kind:"user-text",seq:l,text:a.text??"",uuid:a.uuid,...f?{senderDisplayName:f}:{},senderPrincipal:p})}break;case"assistant-text":r.push({kind:"assistant-text",seq:l,text:a.text??"",uuid:a.uuid});break;case"tool_call":{if(a.tool===QV){const u=a.input??{},d=Array.isArray(u.questions)?u.questions:[];i.set(c,r.length),r.push({kind:"question-card",seq:l,toolUseId:c,questions:d});break}m5(r,l,c,a.tool??"",a.input,n);break}case"tool_result":{const u=i.get(c);if(u!==void 0){if(a.askQuestionAnswers){const f=r[u];f.submittedAnswers=a.askQuestionAnswers}i.delete(c);break}const d={kind:"tool-result",seq:l,toolUseId:c,output:a.output};a.error!==void 0&&(d.error=a.error),a.toolResultExtra&&(d.toolResultExtra=a.toolResultExtra),r.push(d);break}case"attachment_memories":a.memories&&a.memories.length>0&&r.push({kind:"memory-callout",seq:l,memories:a.memories});break;case"summary":break;case"turn-end":{const u={kind:"turn-end",seq:l};typeof a.durationMs=="number"&&(u.durationMs=a.durationMs),r.push(u);break}}}return r}const ZV=5e5;function JV(e){const t=ZV-e.length;return e.map(n=>({...n,seq:n.seq+t}))}const eq=/<command-name>([\s\S]*?)<\/command-name>/i,tq=/<command-message>([\s\S]*?)<\/command-message>/i,nq=/<command-args>([\s\S]*?)<\/command-args>/i,rq=/<(local-command-[a-z]+|command-(?:stdout|stderr))>[\s\S]*?<\/\1>/gi;function Ip(e){if(!e)return{commandName:null,commandMessage:null,commandArgs:null,body:""};const t=e.match(eq),n=e.match(tq),r=e.match(nq);let i=e;return t&&(i=i.replace(t[0],"")),n&&(i=i.replace(n[0],"")),r&&(i=i.replace(r[0],"")),i=i.replace(rq,""),i=i.trim(),{commandName:t?t[1].trim():null,commandMessage:n?n[1].trim():null,commandArgs:r?r[1].trim():null,body:i}}function QS(e){const t=Ip(e);return t.commandName?t.commandArgs?`${t.commandName} ${t.commandArgs}`:t.commandName:e}function ZS(e){return e.kind==="user-text"?!0:e.kind!=="user-meta"?!1:e.metaKind==="slash-command"||ap(e.metaKind)}function iq(e,t){const n=t.find(ZS);if(!n)return e;const r=QS(n.text);for(let s=e.length-1;s>=0;s--){const o=e[s];if(ZS(o)&&QS(o.text)===r)return e.slice(0,s)}const i=e[e.length-1];return i!==void 0&&i.kind!=="turn-end"?[...e,{kind:"turn-end",seq:i.seq+1}]:e}function sq(e){return e==="running"||e==="observing"}function v5(e){return e==="running"||e==="running-idle"||e==="observing"}const oq=1e6,aq=5;function x5(e){const t=yi(),n=g.useMemo(()=>new Q_(t),[t]),r=pi("sessions"),i=g.useMemo(()=>r==null?void 0:r.find(E=>E.sessionId===e),[r,e]),s=i==null?void 0:i.toolSessionId,o=i==null?void 0:i.tool,a=f5(e),{events:l,pendingPermissions:c,queued:u,status:d,clearPermission:f,restorePermission:p}=a,m=Uz(),v=HV({api:n,sessionId:e,toolSessionId:s,initialTurns:m==="owner"?void 0:aq,implicitCloseOnUserText:o==="codex"}),w=g.useMemo(()=>v.messages.filter(E=>!E.isSidechain),[v.messages]),x=g.useMemo(()=>JV(g5(w,0,o)),[w,o]),_=c[0]??null,y=g.useMemo(()=>XV(l,(_==null?void 0:_.requestId)??null),[l,_==null?void 0:_.requestId]),S=g.useMemo(()=>iq(x,y),[x,y]),C=g.useMemo(()=>y.map((E,H)=>({...E,seq:oq+H})),[y]),k=g.useMemo(()=>[...S,...C],[S,C]),N=v5(d),T=sq(d),D=(i==null?void 0:i.resolvedModel)??(i==null?void 0:i.model),P=g.useMemo(()=>({sessionLabel:(i==null?void 0:i.label)||(i==null?void 0:i.aiLabel)||(i==null?void 0:i.larkChatName)||(i==null?void 0:i.larkChatId)||e,sessionId:e,...i!=null&&i.larkChatId?{larkChatName:i.larkChatName??i.larkChatId,larkChatType:i.larkChatType??"group"}:{},...D?{model:D}:{},...(()=>{const E=i==null?void 0:i.gitBranch;return E?{gitBranch:E}:{}})(),...(()=>{const E=BV(i);return E!==void 0?{contextPct:E}:{}})(),...i!=null&&i.cwd?{cwd:i.cwd}:{},...(()=>{const E=i==null?void 0:i.permissionMode;return E?{permissionMode:E}:{}})(),procAlive:N,streamInProgress:T,pinnedAt:(i==null?void 0:i.pinnedAt)??null}),[i,e,D,N,T]),O=g.useMemo(()=>t.isOpen?d==="error"?{kind:"error",message:"session error"}:{kind:"ready"}:{kind:"closed"},[t.isOpen,d]),R=g.useCallback(async(E,H)=>{await n.sessionSend(e,E,H)},[n,e]),M=g.useCallback(async E=>{await n.sessionDequeue(e,E)},[n,e]),A=g.useCallback(async()=>(await n.sessionInterrupt(e)).queued??[],[n,e]),L=g.useCallback(async E=>{if(!(i!=null&&i.cwd)||!s)throw new Error("fork requires sessionFile with cwd + toolSessionId");await n.sessionFork({cwd:i.cwd,toolSessionId:s,messageUuid:E})},[n,i==null?void 0:i.cwd,s]),$=g.useCallback(async E=>{await n.sessionRewind({sessionId:e,userMessageId:E,dryRun:!1})},[n,e]),F=g.useCallback(async E=>{await n.sessionUpdate(e,{model:E})},[n,e]),B=g.useCallback(async()=>{await n.sessionNew(e)},[n,e]),z=g.useCallback(async(E,H)=>{const q=c.find(j=>j.requestId===E);q&&f(E);try{await n.permissionRespond({sessionId:e,permissionRequestId:E,allow:H==="allow"})}catch(j){throw!((j==null?void 0:j.message)??"").startsWith("PERMISSION_REQUEST_STALE")&&q&&p(q),j}},[n,e,c,f,p]);return g.useMemo(()=>({lines:k,connState:O,meta:P,historyLoading:v.loading,historyError:v.error,pendingPermissions:c,queued:u,sendText:R,dequeue:M,interrupt:A,fork:L,rewind:$,switchModel:F,clearSession:B,respondPermission:z}),[k,O,P,v.loading,v.error,c,u,R,M,A,L,$,F,B,z])}function lq(e,t,n,r=!0){const i=g.useRef({sid:null,tsid:void 0});g.useEffect(()=>{const s=i.current;i.current={sid:t,tsid:n},!(!r||!n||s.sid===t&&(s.tsid===void 0||s.tsid===null)&&typeof n=="string")&&e.sessionObserve({sessionId:t,toolSessionId:n}).catch(()=>{})},[e,t,n,r])}function cq(e,t,n){const r=g.useRef(e),i=g.useRef(t),s=g.useRef(n);s.current=n,g.useEffect(()=>{const o=r.current,a=i.current;r.current=e,i.current=t;const l=o!==e,c=typeof a=="string"&&t==null;!l&&!c||s.current()},[e,t])}const uq=/^Scheduled (?:recurring job|one-shot task) ([0-9a-f]{8}) \(([^)]+)\)/;function dq(e){const t=new Map,n=new Map,r=new Map;for(const i of e)if(i.kind==="tool_call"&&i.tool==="CronCreate"){const s=i.input;if(!s||typeof s.cron!="string"||typeof s.prompt!="string")continue;const o=i.ts;t.set(i.toolUseId,{cron:s.cron,prompt:s.prompt,recurring:s.recurring!==!1,ts:typeof o=="string"?o:"",toolUseId:i.toolUseId})}else if(i.kind==="tool_call"&&i.tool==="CronDelete"){const s=i.input;if(!s||typeof s.id!="string")continue;n.set(i.toolUseId,s.id)}else if(i.kind==="tool_result"){const s=t.get(i.toolUseId);if(s){if(t.delete(i.toolUseId),i.error||typeof i.output!="string")continue;const a=i.output.match(uq);if(!a)continue;r.set(a[1],{id:a[1],cron:s.cron,prompt:s.prompt,recurring:s.recurring,humanSchedule:a[2],createdAt:s.ts,toolUseId:s.toolUseId});continue}const o=n.get(i.toolUseId);o!==void 0&&(n.delete(i.toolUseId),i.error||r.delete(o))}return Array.from(r.values()).sort((i,s)=>i.createdAt.localeCompare(s.createdAt))}function _5(e){var n;if(e.error)return!1;if(e.pending)return!0;if(e.notifications.length>0)return!1;const t=(n=e.progress)==null?void 0:n.status;return t==="running"?!0:t==="started"?hq(e.input):!1}function hq(e){return!e||typeof e!="object"?!1:e.run_in_background===!0}function fq(e){return e.filter(t=>t.kind==="merged-agent"&&_5(t))}function y5(e){const{tasks:t,lastEventIndex:n}=KV(e);let r=-1;for(let c=e.length-1;c>=0;c--)if(e[c].kind==="todo-checklist"){r=c;break}const i=[],s=new Map,o=new Map,a=new Map,l=(c,u)=>{var f,p,m,v,w;if(((f=c.progress)==null?void 0:f.status)==="completed"||((p=c.progress)==null?void 0:p.status)==="failed")return;const d={agentId:u.agentId,status:u.status};u.description?d.description=u.description:(m=c.progress)!=null&&m.description&&(d.description=c.progress.description),u.lastToolName?d.lastToolName=u.lastToolName:(v=c.progress)!=null&&v.lastToolName&&(d.lastToolName=c.progress.lastToolName),u.stats?d.stats=u.stats:(w=c.progress)!=null&&w.stats&&(d.stats=c.progress.stats),c.progress=d,(u.status==="completed"||u.status==="failed")&&(c.pending=!1)};for(let c=0;c<e.length;c++){const u=e[c];switch(u.kind){case"tool-call":{const d={kind:"merged-tool",seq:u.seq,tool:u.tool,toolKind:u.toolKind,toolUseId:u.toolUseId,input:u.input,pending:!0};s.set(u.toolUseId,i.length),i.push(d);break}case"tool-result":{const d=s.get(u.toolUseId);if(d!==void 0){const p=i[d];p.output=u.output,p.error=u.error,p.pending=!1,s.delete(u.toolUseId);break}const f=o.get(u.toolUseId);if(f!==void 0){const p=i[f];p.output=u.output,p.error=u.error,p.pending=!1,u.toolResultExtra&&(p.toolResultExtra=u.toolResultExtra);break}break}case"agent-call":{const d={kind:"merged-agent",seq:u.seq,toolUseId:u.toolUseId,description:u.description,input:u.input,pending:!0,notifications:[]};o.set(u.toolUseId,i.length),i.push(d);const f=a.get(u.toolUseId);f&&(l(d,f),a.delete(u.toolUseId));break}case"agent-progress":{const d=o.get(u.toolUseId);if(d!==void 0){l(i[d],u);break}const f=a.get(u.toolUseId);if((f==null?void 0:f.status)==="completed"||(f==null?void 0:f.status)==="failed")break;a.set(u.toolUseId,u);break}case"agent-notification":{const d=u.parentToolUseId;if(d){const f=o.get(d);if(f!==void 0){i[f].notifications.push({text:u.text,taskId:u.taskId});break}}i.push({kind:"agent-notification",seq:u.seq,text:u.text,taskId:u.taskId,parentToolUseId:u.parentToolUseId});break}case"todo-checklist":{c===r&&u.todos.length>0&&i.push({kind:"todo-checklist",seq:u.seq,toolUseId:u.toolUseId,todos:u.todos});break}case"task-event":{c===n&&t.length>0&&i.push({kind:"plan-card",seq:u.seq,tasks:t});break}default:i.push(u)}}return i}const pq=new Set(["permission-inline","question-card"]);function mq(e){return e.kind==="user-text"?!0:e.kind!=="user-meta"?!1:e.metaKind==="slash-command"||ap(e.metaKind)}function gq(e){return e.kind==="user-text"&&e.continuesTurn===!0}function vq(e,t={}){const n=[];let r=null;const i=(s,o)=>{r&&(n.push(xq(r,s,o)),r=null)};for(const s of e){if(s.kind==="turn-end"){i(s,!0);continue}if(mq(s)&&(r===null||!gq(s))){i(void 0,!0),r={query:s,body:[]};continue}r===null?r={body:[s]}:r.body.push(s)}return i(void 0,t.closeTrailing===!0),n}function xq(e,t,n){const{query:r,body:i}=e,s=_q(i,t,n),o=yq(i,s),a=wq(i,o),l=r??i[0]??t,c={kind:"turn",seq:l?l.seq:0,status:s,process:a,tail:o};return r&&(c.query=r),(t==null?void 0:t.durationMs)!==void 0&&(c.durationMs=t.durationMs),c}function _q(e,t,n){if(!n)return"running";if((t==null?void 0:t.reason)==="interrupted")return"interrupted";const r=A0(e,i=>i.kind==="error");return r>=0&&!e.slice(r+1).some(s=>s.kind==="assistant-text")?"error":"done"}function yq(e,t){if(t==="running"){const r=[];for(let i=e.length-1;i>=0&&pq.has(e[i].kind);i--)r.unshift(e[i]);return r}const n=t==="error"?A0(e,r=>r.kind==="error"):A0(e,r=>r.kind==="assistant-text");return n>=0?[e[n]]:[]}const bq=new Set(["assistant-thinking","user-meta"]);function wq(e,t){const n=new Set(t),r=[];let i=null;const s=()=>{i&&(r.push({kind:"tool-group",seq:i[0].seq,items:i}),i=null)};for(const o of e){if(n.has(o)){s();continue}if(o.kind==="merged-tool"){i?i.push(o):i=[o];continue}if(bq.has(o.kind)){r.push(o);continue}s(),r.push(o)}return s(),r}function A0(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}const Sq={Read:["正在读取","已读取"],Bash:["正在运行","已运行"],Grep:["正在搜索","已搜索"],Glob:["正在搜索","已搜索"],Edit:["正在编辑","已编辑"],Write:["正在写入","已写入"],WebFetch:["正在抓取","已抓取"],WebSearch:["正在搜索","已搜索"],Skill:["正在读取","已读取"]};function kq(e){if(!e||typeof e!="object")return"";const t=e,n=t.command??t.file_path??t.path??t.pattern??t.query??t.url??t.description;if(typeof n=="string")return n;for(const r of Object.values(t))if(typeof r=="string"&&r)return r;return""}function b5(e){const t=Sq[e.tool],n=t?e.pending?t[0]:t[1]:e.pending?`正在执行 ${e.tool}`:`已执行 ${e.tool}`,r=kq(e.input);return r?`${n} ${r}`:n}function Cq({item:e,renderItemDetail:t}){const[n,r]=g.useState(!1),i=n?Yn:Bn,s=n?(t==null?void 0:t(e))??null:null;return h.jsxs("div",{className:"min-w-0 max-w-full",children:[h.jsxs("button",{type:"button",onClick:()=>r(o=>!o),"aria-expanded":n,"data-testid":"tool-call-group-row",className:ne("flex w-full items-center gap-1.5 text-left cursor-pointer min-w-0 py-0.5 text-[13px] hover:text-text-200",e.error?"text-destructive/80":"text-text-400"),children:[e.pending?h.jsx(Ln,{className:"w-3.5 h-3.5 animate-spin shrink-0"}):h.jsx(i,{className:"w-3.5 h-3.5 shrink-0 opacity-60"}),h.jsx("span",{className:"truncate min-w-0",children:b5(e)})]}),n?h.jsx("div",{"data-testid":"tool-call-group-row-detail",className:"pl-5 py-1 min-w-0 space-y-1.5 text-[12px] text-text-300",children:s!==null?s:h.jsxs(h.Fragment,{children:[h.jsx("pre",{className:"min-w-0 max-w-full overflow-auto whitespace-pre-wrap font-mono",children:JSON.stringify(e.input,null,2)}),e.output!==void 0?h.jsx("pre",{className:"min-w-0 max-w-full overflow-auto whitespace-pre-wrap font-mono text-text-400",children:typeof e.output=="string"?e.output:JSON.stringify(e.output,null,2)}):null,e.error?h.jsx("pre",{className:"min-w-0 max-w-full overflow-auto whitespace-pre-wrap font-mono text-destructive",children:e.error}):null]})}):null]})}function Eq({items:e,renderItemDetail:t}){const[n,r]=g.useState(!1);if(e.length===0)return null;const i=e.some(l=>l.pending),s=i?[...e].reverse().find(l=>l.pending):e[e.length-1],o=!i&&e.length>1?` 等 ${e.length} 项`:"",a=n?Yn:Bn;return h.jsxs("div",{"data-testid":"tool-call-group",className:"min-w-0 max-w-full",children:[h.jsxs("button",{type:"button",onClick:()=>r(l=>!l),"aria-expanded":n,"data-testid":"tool-call-group-header",className:"flex w-full items-center gap-1.5 text-left cursor-pointer min-w-0 py-0.5 text-[13px] text-text-400 hover:text-text-200",children:[i&&!n?h.jsx(Ln,{className:"w-3.5 h-3.5 animate-spin shrink-0"}):h.jsx(a,{className:"w-3.5 h-3.5 shrink-0"}),n?h.jsx("span",{className:"min-w-0 truncate opacity-70",children:i?"正在执行":`${e.length} 项`}):h.jsxs("span",{className:ne("truncate min-w-0",i&&"text-text-300"),children:[b5(s),o]})]}),n?h.jsx("div",{className:"mt-0.5 flex flex-col pl-5",children:e.map(l=>h.jsx(Cq,{item:l,renderItemDetail:t},l.toolUseId))}):null]})}function Nq(e){const t=Math.round(e/1e3);if(t<60)return`${t}秒`;const n=Math.floor(t/60),r=t%60;return r>0?`${n}分${r}秒`:`${n}分钟`}function Tq(e,t){const n=t!==void 0?`耗时 ${Nq(t)}`:"";switch(e){case"interrupted":return n?`已中断 · ${n}`:"已中断";case"error":return n?`出错 · ${n}`:"出错";default:return n||"已完成"}}function Iq({status:e="done",durationMs:t,defaultExpanded:n=!1,children:r}){const[i,s]=g.useState(n),o=i?Yn:Bn;return h.jsxs("div",{"data-testid":"turn-process-block",className:"min-w-0 max-w-full border-t border-border pt-2",children:[h.jsxs("button",{type:"button",onClick:()=>s(a=>!a),"aria-expanded":i,"data-testid":"turn-process-block-header",className:ne("flex w-full items-center gap-1 text-left cursor-pointer min-w-0 py-0.5 text-[13px]",e!=="done"?"text-destructive/80 hover:text-destructive":"text-text-400 hover:text-text-200"),children:[h.jsx("span",{className:"truncate min-w-0",children:Tq(e,t)}),h.jsx(o,{className:"w-3.5 h-3.5 shrink-0"})]}),i?h.jsx("div",{"data-testid":"turn-process-body",className:"mt-2 flex flex-col gap-2 border-l-2 border-border pl-3",children:r}):null]})}const Pq=/<(system-reminder|related-dir|clawd-shift-fire)\b[^>]*>[\s\S]*?<\/\1>/gi,Rq=/<builder-preview\b[^>]*\/>/gi,Mq=/<(clawd-dispatch-task|clawd-dispatch-result)\b[^>]*>([\s\S]*?)<\/\1>/gi,Aq=/<\/?(brief|detail|files)>/gi;function w5(e){return e?e.replace(Mq,(t,n,r)=>wz(r.replace(Aq,"")).trim()).replace(Pq,"").replace(Rq,"").trim():""}const jq=w5;function Lq(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Dq=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Oq=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Bq={};function JS(e,t){return(Bq.jsx?Oq:Dq).test(e)}const zq=/[ \t\n\f\r]/g;function $q(e){return typeof e=="object"?e.type==="text"?ek(e.value):!1:ek(e)}function ek(e){return e.replace(zq,"")===""}class Mu{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Mu.prototype.normal={};Mu.prototype.property={};Mu.prototype.space=void 0;function S5(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Mu(n,r,t)}function j0(e){return e.toLowerCase()}class Xn{constructor(t,n){this.attribute=n,this.property=t}}Xn.prototype.attribute="";Xn.prototype.booleanish=!1;Xn.prototype.boolean=!1;Xn.prototype.commaOrSpaceSeparated=!1;Xn.prototype.commaSeparated=!1;Xn.prototype.defined=!1;Xn.prototype.mustUseProperty=!1;Xn.prototype.number=!1;Xn.prototype.overloadedBoolean=!1;Xn.prototype.property="";Xn.prototype.spaceSeparated=!1;Xn.prototype.space=void 0;let Fq=0;const Le=Vo(),Ft=Vo(),L0=Vo(),Z=Vo(),ct=Vo(),Ba=Vo(),tr=Vo();function Vo(){return 2**++Fq}const D0=Object.freeze(Object.defineProperty({__proto__:null,boolean:Le,booleanish:Ft,commaOrSpaceSeparated:tr,commaSeparated:Ba,number:Z,overloadedBoolean:L0,spaceSeparated:ct},Symbol.toStringTag,{value:"Module"})),Ym=Object.keys(D0);class $y extends Xn{constructor(t,n,r,i){let s=-1;if(super(t,n),tk(this,"space",i),typeof r=="number")for(;++s<Ym.length;){const o=Ym[s];tk(this,Ym[s],(r&D0[o])===D0[o])}}}$y.prototype.defined=!0;function tk(e,t,n){n&&(e[t]=n)}function kl(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new $y(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[j0(r)]=r,n[j0(s.attribute)]=r}return new Mu(t,n,e.space)}const k5=kl({properties:{ariaActiveDescendant:null,ariaAtomic:Ft,ariaAutoComplete:null,ariaBusy:Ft,ariaChecked:Ft,ariaColCount:Z,ariaColIndex:Z,ariaColSpan:Z,ariaControls:ct,ariaCurrent:null,ariaDescribedBy:ct,ariaDetails:null,ariaDisabled:Ft,ariaDropEffect:ct,ariaErrorMessage:null,ariaExpanded:Ft,ariaFlowTo:ct,ariaGrabbed:Ft,ariaHasPopup:null,ariaHidden:Ft,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ct,ariaLevel:Z,ariaLive:null,ariaModal:Ft,ariaMultiLine:Ft,ariaMultiSelectable:Ft,ariaOrientation:null,ariaOwns:ct,ariaPlaceholder:null,ariaPosInSet:Z,ariaPressed:Ft,ariaReadOnly:Ft,ariaRelevant:null,ariaRequired:Ft,ariaRoleDescription:ct,ariaRowCount:Z,ariaRowIndex:Z,ariaRowSpan:Z,ariaSelected:Ft,ariaSetSize:Z,ariaSort:null,ariaValueMax:Z,ariaValueMin:Z,ariaValueNow:Z,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function C5(e,t){return t in e?e[t]:t}function E5(e,t){return C5(e,t.toLowerCase())}const Hq=kl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ba,acceptCharset:ct,accessKey:ct,action:null,allow:null,allowFullScreen:Le,allowPaymentRequest:Le,allowUserMedia:Le,alt:null,as:null,async:Le,autoCapitalize:null,autoComplete:ct,autoFocus:Le,autoPlay:Le,blocking:ct,capture:null,charSet:null,checked:Le,cite:null,className:ct,cols:Z,colSpan:null,content:null,contentEditable:Ft,controls:Le,controlsList:ct,coords:Z|Ba,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Le,defer:Le,dir:null,dirName:null,disabled:Le,download:L0,draggable:Ft,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Le,formTarget:null,headers:ct,height:Z,hidden:L0,high:Z,href:null,hrefLang:null,htmlFor:ct,httpEquiv:ct,id:null,imageSizes:null,imageSrcSet:null,inert:Le,inputMode:null,integrity:null,is:null,isMap:Le,itemId:null,itemProp:ct,itemRef:ct,itemScope:Le,itemType:ct,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Le,low:Z,manifest:null,max:null,maxLength:Z,media:null,method:null,min:null,minLength:Z,multiple:Le,muted:Le,name:null,nonce:null,noModule:Le,noValidate:Le,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:Le,optimum:Z,pattern:null,ping:ct,placeholder:null,playsInline:Le,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Le,referrerPolicy:null,rel:ct,required:Le,reversed:Le,rows:Z,rowSpan:Z,sandbox:ct,scope:null,scoped:Le,seamless:Le,selected:Le,shadowRootClonable:Le,shadowRootDelegatesFocus:Le,shadowRootMode:null,shape:null,size:Z,sizes:null,slot:null,span:Z,spellCheck:Ft,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Z,step:null,style:null,tabIndex:Z,target:null,title:null,translate:null,type:null,typeMustMatch:Le,useMap:null,value:Ft,width:Z,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ct,axis:null,background:null,bgColor:null,border:Z,borderColor:null,bottomMargin:Z,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Le,declare:Le,event:null,face:null,frame:null,frameBorder:null,hSpace:Z,leftMargin:Z,link:null,longDesc:null,lowSrc:null,marginHeight:Z,marginWidth:Z,noResize:Le,noHref:Le,noShade:Le,noWrap:Le,object:null,profile:null,prompt:null,rev:null,rightMargin:Z,rules:null,scheme:null,scrolling:Ft,standby:null,summary:null,text:null,topMargin:Z,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Z,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Le,disableRemotePlayback:Le,prefix:null,property:null,results:Z,security:null,unselectable:null},space:"html",transform:E5}),Uq=kl({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:tr,accentHeight:Z,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Z,amplitude:Z,arabicForm:null,ascent:Z,attributeName:null,attributeType:null,azimuth:Z,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Z,by:null,calcMode:null,capHeight:Z,className:ct,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:Z,diffuseConstant:Z,direction:null,display:null,dur:null,divisor:Z,dominantBaseline:null,download:Le,dx:null,dy:null,edgeMode:null,editable:null,elevation:Z,enableBackground:null,end:null,event:null,exponent:Z,externalResourcesRequired:null,fill:null,fillOpacity:Z,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:Ba,g2:Ba,glyphName:Ba,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Z,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Z,horizOriginX:Z,horizOriginY:Z,id:null,ideographic:Z,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Z,k:Z,k1:Z,k2:Z,k3:Z,k4:Z,kernelMatrix:tr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Z,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:Z,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:Z,overlineThickness:Z,paintOrder:null,panose1:null,path:null,pathLength:Z,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ct,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Z,pointsAtY:Z,pointsAtZ:Z,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:tr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:tr,rev:tr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:tr,requiredFeatures:tr,requiredFonts:tr,requiredFormats:tr,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:Z,specularExponent:Z,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Z,strikethroughThickness:Z,string:null,stroke:null,strokeDashArray:tr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Z,strokeOpacity:Z,strokeWidth:null,style:null,surfaceScale:Z,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:tr,tabIndex:Z,tableValues:null,target:null,targetX:Z,targetY:Z,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:tr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Z,underlineThickness:Z,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Z,values:null,vAlphabetic:Z,vMathematical:Z,vectorEffect:null,vHanging:Z,vIdeographic:Z,version:null,vertAdvY:Z,vertOriginX:Z,vertOriginY:Z,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Z,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:C5}),N5=kl({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()}}),T5=kl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:E5}),I5=kl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Wq={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"},Vq=/[A-Z]/g,nk=/-[a-z]/g,qq=/^data[-\w.:]+$/i;function Kq(e,t){const n=j0(t);let r=t,i=Xn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&qq.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(nk,Yq);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!nk.test(s)){let o=s.replace(Vq,Gq);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=$y}return new i(r,t)}function Gq(e){return"-"+e.toLowerCase()}function Yq(e){return e.charAt(1).toUpperCase()}const Xq=S5([k5,Hq,N5,T5,I5],"html"),Fy=S5([k5,Uq,N5,T5,I5],"svg");function Qq(e){return e.join(" ").trim()}var Hy={},rk=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,Zq=/\n/g,Jq=/^\s*/,eK=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,tK=/^:\s*/,nK=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,rK=/^[;\s]*/,iK=/^\s+|\s+$/g,sK=`
|
|
516
|
+
`)},ZH=0,ra=[];function JH(e){var t=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),i=g.useState(ZH++)[0],s=g.useState(BP)[0],o=g.useRef(e);g.useEffect(function(){o.current=e},[e]),g.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var v=yH([e.lockRef.current],(e.shards||[]).map(ES),!0).filter(Boolean);return v.forEach(function(w){return w.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),v.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var a=g.useCallback(function(v,w){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!o.current.allowPinchZoom;var x=Sd(v),_=n.current,y="deltaX"in v?v.deltaX:_[0]-x[0],S="deltaY"in v?v.deltaY:_[1]-x[1],C,k=v.target,N=Math.abs(y)>Math.abs(S)?"h":"v";if("touches"in v&&N==="h"&&k.type==="range")return!1;var T=window.getSelection(),D=T&&T.anchorNode,P=D?D===k||D.contains(k):!1;if(P)return!1;var O=kS(N,k);if(!O)return!0;if(O?C=N:(C=N==="v"?"h":"v",O=kS(N,k)),!O)return!1;if(!r.current&&"changedTouches"in v&&(y||S)&&(r.current=C),!C)return!0;var R=r.current||C;return YH(R,w,v,R==="h"?y:S)},[]),l=g.useCallback(function(v){var w=v;if(!(!ra.length||ra[ra.length-1]!==s)){var x="deltaY"in w?CS(w):Sd(w),_=t.current.filter(function(C){return C.name===w.type&&(C.target===w.target||w.target===C.shadowParent)&&XH(C.delta,x)})[0];if(_&&_.should){w.cancelable&&w.preventDefault();return}if(!_){var y=(o.current.shards||[]).map(ES).filter(Boolean).filter(function(C){return C.contains(w.target)}),S=y.length>0?a(w,y[0]):!o.current.noIsolation;S&&w.cancelable&&w.preventDefault()}}},[]),c=g.useCallback(function(v,w,x,_){var y={name:v,delta:w,target:x,should:_,shadowParent:eU(x)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(S){return S!==y})},1)},[]),u=g.useCallback(function(v){n.current=Sd(v),r.current=void 0},[]),d=g.useCallback(function(v){c(v.type,CS(v),v.target,a(v,e.lockRef.current))},[]),f=g.useCallback(function(v){c(v.type,Sd(v),v.target,a(v,e.lockRef.current))},[]);g.useEffect(function(){return ra.push(s),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,na),document.addEventListener("touchmove",l,na),document.addEventListener("touchstart",u,na),function(){ra=ra.filter(function(v){return v!==s}),document.removeEventListener("wheel",l,na),document.removeEventListener("touchmove",l,na),document.removeEventListener("touchstart",u,na)}},[]);var p=e.removeScrollBar,m=e.inert;return g.createElement(g.Fragment,null,m?g.createElement(s,{styles:QH(i)}):null,p?g.createElement(HH,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function eU(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const tU=IH(OP,JH);var vy=g.forwardRef(function(e,t){return g.createElement(yp,ri({},e,{ref:t,sideCar:tU}))});vy.classNames=yp.classNames;var T0=["Enter"," "],nU=["ArrowDown","PageUp","Home"],HP=["ArrowUp","PageDown","End"],rU=[...nU,...HP],iU={ltr:[...T0,"ArrowRight"],rtl:[...T0,"ArrowLeft"]},sU={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Nu="Menu",[iu,oU,aU]=QI(Nu),[Ho,UP]=Fo(Nu,[aU,_p,TP]),Tu=_p(),WP=TP(),[VP,Gs]=Ho(Nu),[lU,Iu]=Ho(Nu),qP=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,a=Tu(t),[l,c]=g.useState(null),u=g.useRef(!1),d=gi(s),f=ZI(i);return g.useEffect(()=>{const p=()=>{u.current=!0,document.addEventListener("pointerdown",m,{capture:!0,once:!0}),document.addEventListener("pointermove",m,{capture:!0,once:!0})},m=()=>u.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",m,{capture:!0}),document.removeEventListener("pointermove",m,{capture:!0})}},[]),h.jsx(my,{...a,children:h.jsx(VP,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c,children:h.jsx(lU,{scope:t,onClose:g.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};qP.displayName=Nu;var cU="MenuAnchor",xy=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Tu(n);return h.jsx(kP,{...i,...r,ref:t})});xy.displayName=cU;var _y="MenuPortal",[uU,KP]=Ho(_y,{forceMount:void 0}),GP=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=Gs(_y,t);return h.jsx(uU,{scope:t,forceMount:n,children:h.jsx(ts,{present:n||s.open,children:h.jsx(gy,{asChild:!0,container:i,children:r})})})};GP.displayName=_y;var Sr="MenuContent",[dU,yy]=Ho(Sr),YP=g.forwardRef((e,t)=>{const n=KP(Sr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=Gs(Sr,e.__scopeMenu),o=Iu(Sr,e.__scopeMenu);return h.jsx(iu.Provider,{scope:e.__scopeMenu,children:h.jsx(ts,{present:r||s.open,children:h.jsx(iu.Slot,{scope:e.__scopeMenu,children:o.modal?h.jsx(hU,{...i,ref:t}):h.jsx(fU,{...i,ref:t})})})})}),hU=g.forwardRef((e,t)=>{const n=Gs(Sr,e.__scopeMenu),r=g.useRef(null),i=Jt(t,r);return g.useEffect(()=>{const s=r.current;if(s)return jP(s)},[]),h.jsx(by,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Re(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),fU=g.forwardRef((e,t)=>{const n=Gs(Sr,e.__scopeMenu);return h.jsx(by,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),pU=nu("MenuContent.ScrollLock"),by=g.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:o,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...v}=e,w=Gs(Sr,n),x=Iu(Sr,n),_=Tu(n),y=WP(n),S=oU(n),[C,k]=g.useState(null),N=g.useRef(null),T=Jt(t,N,w.onContentChange),D=g.useRef(0),P=g.useRef(""),O=g.useRef(0),R=g.useRef(null),M=g.useRef("right"),A=g.useRef(0),L=m?vy:g.Fragment,$=m?{as:pU,allowPinchZoom:!0}:void 0,F=z=>{var xe,Ee;const E=P.current+z,H=S().filter(ue=>!ue.disabled),q=document.activeElement,j=(xe=H.find(ue=>ue.ref.current===q))==null?void 0:xe.textValue,re=H.map(ue=>ue.textValue),ie=EU(re,E,j),K=(Ee=H.find(ue=>ue.textValue===ie))==null?void 0:Ee.ref.current;(function ue(je){P.current=je,window.clearTimeout(D.current),je!==""&&(D.current=window.setTimeout(()=>ue(""),1e3))})(E),K&&setTimeout(()=>K.focus())};g.useEffect(()=>()=>window.clearTimeout(D.current),[]),tP();const B=g.useCallback(z=>{var H,q;return M.current===((H=R.current)==null?void 0:H.side)&&TU(z,(q=R.current)==null?void 0:q.area)},[]);return h.jsx(dU,{scope:n,searchRef:P,onItemEnter:g.useCallback(z=>{B(z)&&z.preventDefault()},[B]),onItemLeave:g.useCallback(z=>{var E;B(z)||((E=N.current)==null||E.focus(),k(null))},[B]),onTriggerLeave:g.useCallback(z=>{B(z)&&z.preventDefault()},[B]),pointerGraceTimerRef:O,onPointerGraceIntentChange:g.useCallback(z=>{R.current=z},[]),children:h.jsx(L,{...$,children:h.jsx(oy,{asChild:!0,trapped:i,onMountAutoFocus:Re(s,z=>{var E;z.preventDefault(),(E=N.current)==null||E.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:h.jsx(pp,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:h.jsx(mH,{asChild:!0,...y,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:k,onEntryFocus:Re(l,z=>{x.isUsingKeyboardRef.current||z.preventDefault()}),preventScrollOnEntryFocus:!0,children:h.jsx(CP,{role:"menu","aria-orientation":"vertical","data-state":hR(w.open),"data-radix-menu-content":"",dir:x.dir,..._,...v,ref:T,style:{outline:"none",...v.style},onKeyDown:Re(v.onKeyDown,z=>{const H=z.target.closest("[data-radix-menu-content]")===z.currentTarget,q=z.ctrlKey||z.altKey||z.metaKey,j=z.key.length===1;H&&(z.key==="Tab"&&z.preventDefault(),!q&&j&&F(z.key));const re=N.current;if(z.target!==re||!rU.includes(z.key))return;z.preventDefault();const K=S().filter(xe=>!xe.disabled).map(xe=>xe.ref.current);HP.includes(z.key)&&K.reverse(),kU(K)}),onBlur:Re(e.onBlur,z=>{z.currentTarget.contains(z.target)||(window.clearTimeout(D.current),P.current="")}),onPointerMove:Re(e.onPointerMove,su(z=>{const E=z.target,H=A.current!==z.clientX;if(z.currentTarget.contains(E)&&H){const q=z.clientX>A.current?"right":"left";M.current=q,A.current=z.clientX}}))})})})})})})});YP.displayName=Sr;var mU="MenuGroup",wy=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(jt.div,{role:"group",...r,ref:t})});wy.displayName=mU;var gU="MenuLabel",XP=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(jt.div,{...r,ref:t})});XP.displayName=gU;var lf="MenuItem",NS="menu.itemSelect",bp=g.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=g.useRef(null),o=Iu(lf,e.__scopeMenu),a=yy(lf,e.__scopeMenu),l=Jt(t,s),c=g.useRef(!1),u=()=>{const d=s.current;if(!n&&d){const f=new CustomEvent(NS,{bubbles:!0,cancelable:!0});d.addEventListener(NS,p=>r==null?void 0:r(p),{once:!0}),XI(d,f),f.defaultPrevented?c.current=!1:o.onClose()}};return h.jsx(QP,{...i,ref:l,disabled:n,onClick:Re(e.onClick,u),onPointerDown:d=>{var f;(f=e.onPointerDown)==null||f.call(e,d),c.current=!0},onPointerUp:Re(e.onPointerUp,d=>{var f;c.current||(f=d.currentTarget)==null||f.click()}),onKeyDown:Re(e.onKeyDown,d=>{const f=a.searchRef.current!=="";n||f&&d.key===" "||T0.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});bp.displayName=lf;var QP=g.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=yy(lf,n),a=WP(n),l=g.useRef(null),c=Jt(t,l),[u,d]=g.useState(!1),[f,p]=g.useState("");return g.useEffect(()=>{const m=l.current;m&&p((m.textContent??"").trim())},[s.children]),h.jsx(iu.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:h.jsx(gH,{asChild:!0,...a,focusable:!r,children:h.jsx(jt.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:Re(e.onPointerMove,su(m=>{r?o.onItemLeave(m):(o.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Re(e.onPointerLeave,su(m=>o.onItemLeave(m))),onFocus:Re(e.onFocus,()=>d(!0)),onBlur:Re(e.onBlur,()=>d(!1))})})})}),vU="MenuCheckboxItem",ZP=g.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return h.jsx(rR,{scope:e.__scopeMenu,checked:n,children:h.jsx(bp,{role:"menuitemcheckbox","aria-checked":cf(n)?"mixed":n,...i,ref:t,"data-state":Cy(n),onSelect:Re(i.onSelect,()=>r==null?void 0:r(cf(n)?!0:!n),{checkForDefaultPrevented:!1})})})});ZP.displayName=vU;var JP="MenuRadioGroup",[xU,_U]=Ho(JP,{value:void 0,onValueChange:()=>{}}),eR=g.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=gi(r);return h.jsx(xU,{scope:e.__scopeMenu,value:n,onValueChange:s,children:h.jsx(wy,{...i,ref:t})})});eR.displayName=JP;var tR="MenuRadioItem",nR=g.forwardRef((e,t)=>{const{value:n,...r}=e,i=_U(tR,e.__scopeMenu),s=n===i.value;return h.jsx(rR,{scope:e.__scopeMenu,checked:s,children:h.jsx(bp,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Cy(s),onSelect:Re(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});nR.displayName=tR;var Sy="MenuItemIndicator",[rR,yU]=Ho(Sy,{checked:!1}),iR=g.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=yU(Sy,n);return h.jsx(ts,{present:r||cf(s.checked)||s.checked===!0,children:h.jsx(jt.span,{...i,ref:t,"data-state":Cy(s.checked)})})});iR.displayName=Sy;var bU="MenuSeparator",sR=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(jt.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});sR.displayName=bU;var wU="MenuArrow",oR=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Tu(n);return h.jsx(EP,{...i,...r,ref:t})});oR.displayName=wU;var ky="MenuSub",[SU,aR]=Ho(ky),lR=e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,s=Gs(ky,t),o=Tu(t),[a,l]=g.useState(null),[c,u]=g.useState(null),d=gi(i);return g.useEffect(()=>(s.open===!1&&d(!1),()=>d(!1)),[s.open,d]),h.jsx(my,{...o,children:h.jsx(VP,{scope:t,open:r,onOpenChange:d,content:c,onContentChange:u,children:h.jsx(SU,{scope:t,contentId:Hi(),triggerId:Hi(),trigger:a,onTriggerChange:l,children:n})})})};lR.displayName=ky;var nc="MenuSubTrigger",cR=g.forwardRef((e,t)=>{const n=Gs(nc,e.__scopeMenu),r=Iu(nc,e.__scopeMenu),i=aR(nc,e.__scopeMenu),s=yy(nc,e.__scopeMenu),o=g.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},u=g.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return g.useEffect(()=>u,[u]),g.useEffect(()=>{const d=a.current;return()=>{window.clearTimeout(d),l(null)}},[a,l]),h.jsx(xy,{asChild:!0,...c,children:h.jsx(QP,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":hR(n.open),...e,ref:Su(t,i.onTriggerChange),onClick:d=>{var f;(f=e.onClick)==null||f.call(e,d),!(e.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Re(e.onPointerMove,su(d=>{s.onItemEnter(d),!d.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(s.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:Re(e.onPointerLeave,su(d=>{var p,m;u();const f=(p=n.content)==null?void 0:p.getBoundingClientRect();if(f){const v=(m=n.content)==null?void 0:m.dataset.side,w=v==="right",x=w?-5:5,_=f[w?"left":"right"],y=f[w?"right":"left"];s.onPointerGraceIntentChange({area:[{x:d.clientX+x,y:d.clientY},{x:_,y:f.top},{x:y,y:f.top},{x:y,y:f.bottom},{x:_,y:f.bottom}],side:v}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(d),d.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:Re(e.onKeyDown,d=>{var p;const f=s.searchRef.current!=="";e.disabled||f&&d.key===" "||iU[r.dir].includes(d.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),d.preventDefault())})})})});cR.displayName=nc;var uR="MenuSubContent",dR=g.forwardRef((e,t)=>{const n=KP(Sr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=Gs(Sr,e.__scopeMenu),o=Iu(Sr,e.__scopeMenu),a=aR(uR,e.__scopeMenu),l=g.useRef(null),c=Jt(t,l);return h.jsx(iu.Provider,{scope:e.__scopeMenu,children:h.jsx(ts,{present:r||s.open,children:h.jsx(iu.Slot,{scope:e.__scopeMenu,children:h.jsx(by,{id:a.contentId,"aria-labelledby":a.triggerId,...i,ref:c,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var d;o.isUsingKeyboardRef.current&&((d=l.current)==null||d.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:Re(e.onFocusOutside,u=>{u.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:Re(e.onEscapeKeyDown,u=>{o.onClose(),u.preventDefault()}),onKeyDown:Re(e.onKeyDown,u=>{var p;const d=u.currentTarget.contains(u.target),f=sU[o.dir].includes(u.key);d&&f&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),u.preventDefault())})})})})})});dR.displayName=uR;function hR(e){return e?"open":"closed"}function cf(e){return e==="indeterminate"}function Cy(e){return cf(e)?"indeterminate":e?"checked":"unchecked"}function kU(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function CU(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function EU(e,t,n){const i=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let o=CU(e,Math.max(s,0));i.length===1&&(o=o.filter(c=>c!==n));const l=o.find(c=>c.toLowerCase().startsWith(i.toLowerCase()));return l!==n?l:void 0}function NU(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const a=t[s],l=t[o],c=a.x,u=a.y,d=l.x,f=l.y;u>r!=f>r&&n<(d-c)*(r-u)/(f-u)+c&&(i=!i)}return i}function TU(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return NU(n,t)}function su(e){return t=>t.pointerType==="mouse"?e(t):void 0}var IU=qP,PU=xy,RU=GP,MU=YP,AU=wy,jU=XP,LU=bp,DU=ZP,OU=eR,BU=nR,zU=iR,$U=sR,FU=oR,HU=lR,UU=cR,WU=dR,wp="DropdownMenu",[VU]=Fo(wp,[UP]),Nn=UP(),[qU,fR]=VU(wp),pR=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:a=!0}=e,l=Nn(t),c=g.useRef(null),[u,d]=ku({prop:i,defaultProp:s??!1,onChange:o,caller:wp});return h.jsx(qU,{scope:t,triggerId:Hi(),triggerRef:c,contentId:Hi(),open:u,onOpenChange:d,onOpenToggle:g.useCallback(()=>d(f=>!f),[d]),modal:a,children:h.jsx(IU,{...l,open:u,onOpenChange:d,dir:r,modal:a,children:n})})};pR.displayName=wp;var mR="DropdownMenuTrigger",gR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,s=fR(mR,n),o=Nn(n);return h.jsx(PU,{asChild:!0,...o,children:h.jsx(jt.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...i,ref:Su(t,s.triggerRef),onPointerDown:Re(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:Re(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});gR.displayName=mR;var KU="DropdownMenuPortal",vR=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Nn(t);return h.jsx(RU,{...r,...n})};vR.displayName=KU;var xR="DropdownMenuContent",_R=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=fR(xR,n),s=Nn(n),o=g.useRef(!1);return h.jsx(MU,{id:i.contentId,"aria-labelledby":i.triggerId,...s,...r,ref:t,onCloseAutoFocus:Re(e.onCloseAutoFocus,a=>{var l;o.current||(l=i.triggerRef.current)==null||l.focus(),o.current=!1,a.preventDefault()}),onInteractOutside:Re(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;(!i.modal||u)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});_R.displayName=xR;var GU="DropdownMenuGroup",YU=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nn(n);return h.jsx(AU,{...i,...r,ref:t})});YU.displayName=GU;var XU="DropdownMenuLabel",yR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nn(n);return h.jsx(jU,{...i,...r,ref:t})});yR.displayName=XU;var QU="DropdownMenuItem",bR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nn(n);return h.jsx(LU,{...i,...r,ref:t})});bR.displayName=QU;var ZU="DropdownMenuCheckboxItem",wR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nn(n);return h.jsx(DU,{...i,...r,ref:t})});wR.displayName=ZU;var JU="DropdownMenuRadioGroup",eW=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nn(n);return h.jsx(OU,{...i,...r,ref:t})});eW.displayName=JU;var tW="DropdownMenuRadioItem",nW=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nn(n);return h.jsx(BU,{...i,...r,ref:t})});nW.displayName=tW;var rW="DropdownMenuItemIndicator",SR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nn(n);return h.jsx(zU,{...i,...r,ref:t})});SR.displayName=rW;var iW="DropdownMenuSeparator",kR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nn(n);return h.jsx($U,{...i,...r,ref:t})});kR.displayName=iW;var sW="DropdownMenuArrow",oW=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nn(n);return h.jsx(FU,{...i,...r,ref:t})});oW.displayName=sW;var aW=e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:s}=e,o=Nn(t),[a,l]=ku({prop:r,defaultProp:s??!1,onChange:i,caller:"DropdownMenuSub"});return h.jsx(HU,{...o,open:a,onOpenChange:l,children:n})},lW="DropdownMenuSubTrigger",CR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nn(n);return h.jsx(UU,{...i,...r,ref:t})});CR.displayName=lW;var cW="DropdownMenuSubContent",ER=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nn(n);return h.jsx(WU,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});ER.displayName=cW;var uW=pR,dW=gR,NR=vR,TR=_R,IR=yR,PR=bR,RR=wR,hW=SR,MR=kR,fW=aW,AR=CR,jR=ER;const Ey=uW,Ny=dW,Sp=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(NR,{children:h.jsx(TR,{ref:r,sideOffset:t,className:ne("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...n})}));Sp.displayName=TR.displayName;const pW=fW,LR=g.forwardRef(({className:e,...t},n)=>h.jsx(AR,{ref:n,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100 data-[state=open]:bg-bg-200","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...t}));LR.displayName=AR.displayName;const DR=g.forwardRef(({className:e,...t},n)=>h.jsx(NR,{children:h.jsx(jR,{ref:n,className:ne("z-50 min-w-[6rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...t})}));DR.displayName=jR.displayName;const Ai=g.forwardRef(({className:e,inset:t,...n},r)=>h.jsx(PR,{ref:r,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Ai.displayName=PR.displayName;const mW=g.forwardRef(({className:e,children:t,checked:n,...r},i)=>h.jsxs(RR,{ref:i,checked:n,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-7 pr-2 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...r,children:[h.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:h.jsx(hW,{children:h.jsx(bl,{className:"h-3.5 w-3.5"})})}),t]}));mW.displayName=RR.displayName;const Ty=g.forwardRef(({className:e,...t},n)=>h.jsx(MR,{ref:n,className:ne("-mx-1 my-1 h-px bg-border",e),...t}));Ty.displayName=MR.displayName;const OR=g.forwardRef(({className:e,...t},n)=>h.jsx(IR,{ref:n,className:ne("px-2 py-1.5 text-xs font-semibold text-text-400",e),...t}));OR.displayName=IR.displayName;function gW({tool:e,className:t}){const n=c9(e);return h.jsx("span",{"data-testid":n?`session-icon-${e}`:"session-icon-default","aria-label":n?iy(e):"未知引擎",className:ne("w-3.5 h-3.5 shrink-0 inline-flex items-center justify-center",fp(e),t),children:h.jsx(hp,{tool:e,className:"w-full h-full"})})}function vW({sessionId:e,hasUnread:t,running:n=!1,awaitingUser:r=!1,style:i}){return r?h.jsx(j$,{"data-testid":`awaiting-dot-${e}`,style:i,className:"w-3 h-3 text-warning shrink-0 animate-pulse",strokeWidth:2.25,"aria-label":"awaiting user"}):t?h.jsx("span",{"data-testid":`unread-dot-${e}`,style:i,className:"w-2 h-2 rounded-full bg-error shrink-0","aria-label":"unread"}):n?h.jsx("span",{"data-testid":`running-dot-${e}`,style:i,className:"w-2 h-2 rounded-full bg-success shrink-0 animate-pulse","aria-label":"running"}):null}function BR(e){return e.compositionActive||!!e.nativeIsComposing||e.keyCode===229}function zR(e){return e.key==="Enter"&&!e.shiftKey&&!BR(e)}function Pu(e,t){const n=g.useRef(!1),r=g.useCallback(()=>{n.current=!0},[]),i=g.useCallback(()=>{setTimeout(()=>{n.current=!1},0)},[]);return{onKeyDown:g.useCallback(o=>{const a=o.nativeEvent;if(zR({key:o.key,shiftKey:o.shiftKey,compositionActive:n.current,nativeIsComposing:a.isComposing,keyCode:a.keyCode})){o.preventDefault(),e();return}t&&o.key==="Escape"&&(o.preventDefault(),t())},[e,t]),onCompositionStart:r,onCompositionEnd:i}}function xW({open:e,initialLabel:t,placeholder:n,onSubmit:r,onCancel:i,title:s="Edit session",fieldLabel:o="Label",testId:a="session-edit-dialog",requireNonEmpty:l=!1}){const[c,u]=g.useState(t);g.useEffect(()=>{e&&u(t)},[e,t]);const d=c.trim(),f=l&&d==="",p=()=>{f||r({label:d})},m=Pu(p,i);return e?hl.createPortal(h.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center bg-bg-0/40 backdrop-blur-[2px]",onClick:i,"data-testid":`${a}-overlay`,children:h.jsxs("div",{"data-testid":a,className:"w-[420px] max-w-[calc(100vw-32px)] rounded-2xl border border-text-100/[0.12] flex flex-col gap-4 p-5",style:{backgroundColor:"var(--bg-0)",boxShadow:"0 12px 40px rgba(0,0,0,0.04)"},onClick:v=>v.stopPropagation(),children:[h.jsx("div",{className:"text-[15px] font-semibold text-text-100",children:s}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-[12px] font-semibold text-text-200 mb-1",children:o}),h.jsx("input",{autoFocus:!0,type:"text",value:c,onChange:v=>u(v.target.value),...m,placeholder:n,"data-testid":`${a}-label`,className:"w-full px-3 py-2 text-[13px] bg-bg-50 border border-bg-300 rounded-lg focus:outline-none focus:border-text-300 transition-colors"})]}),h.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[h.jsx("button",{type:"button",onClick:i,className:"px-4 py-1.5 text-[12px] text-text-300 rounded-lg hover:bg-text-100/5 transition-colors cursor-pointer",children:"Cancel"}),h.jsx("button",{type:"button",onClick:p,disabled:f,"data-testid":`${a}-save`,className:"px-4 py-1.5 text-[12px] font-medium text-bg-0 rounded-lg bg-text-100 hover:bg-text-200 transition-colors cursor-pointer disabled:cursor-not-allowed disabled:opacity-40",children:"Save"})]})]})}),document.body):null}var _W=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),yW="VisuallyHidden",$R=g.forwardRef((e,t)=>h.jsx(jt.span,{...e,ref:t,style:{..._W,...e.style}}));$R.displayName=yW;var bW=$R,[kp]=Fo("Tooltip",[_p]),Cp=_p(),FR="TooltipProvider",wW=700,I0="tooltip.open",[SW,Iy]=kp(FR),HR=e=>{const{__scopeTooltip:t,delayDuration:n=wW,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,o=g.useRef(!0),a=g.useRef(!1),l=g.useRef(0);return g.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),h.jsx(SW,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:g.useCallback(()=>{window.clearTimeout(l.current),o.current=!1},[]),onClose:g.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:g.useCallback(c=>{a.current=c},[]),disableHoverableContent:i,children:s})};HR.displayName=FR;var ou="Tooltip",[kW,Ep]=kp(ou),UR=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=e,l=Iy(ou,e.__scopeTooltip),c=Cp(t),[u,d]=g.useState(null),f=Hi(),p=g.useRef(0),m=o??l.disableHoverableContent,v=a??l.delayDuration,w=g.useRef(!1),[x,_]=ku({prop:r,defaultProp:i??!1,onChange:N=>{N?(l.onOpen(),document.dispatchEvent(new CustomEvent(I0))):l.onClose(),s==null||s(N)},caller:ou}),y=g.useMemo(()=>x?w.current?"delayed-open":"instant-open":"closed",[x]),S=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,w.current=!1,_(!0)},[_]),C=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,_(!1)},[_]),k=g.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{w.current=!0,_(!0),p.current=0},v)},[v,_]);return g.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),h.jsx(my,{...c,children:h.jsx(kW,{scope:t,contentId:f,open:x,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:g.useCallback(()=>{l.isOpenDelayedRef.current?k():S()},[l.isOpenDelayedRef,k,S]),onTriggerLeave:g.useCallback(()=>{m?C():(window.clearTimeout(p.current),p.current=0)},[C,m]),onOpen:S,onClose:C,disableHoverableContent:m,children:n})})};UR.displayName=ou;var P0="TooltipTrigger",WR=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Ep(P0,n),s=Iy(P0,n),o=Cp(n),a=g.useRef(null),l=Jt(t,a,i.onTriggerChange),c=g.useRef(!1),u=g.useRef(!1),d=g.useCallback(()=>c.current=!1,[]);return g.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),h.jsx(kP,{asChild:!0,...o,children:h.jsx(jt.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:l,onPointerMove:Re(e.onPointerMove,f=>{f.pointerType!=="touch"&&!u.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),u.current=!0)}),onPointerLeave:Re(e.onPointerLeave,()=>{i.onTriggerLeave(),u.current=!1}),onPointerDown:Re(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Re(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:Re(e.onBlur,i.onClose),onClick:Re(e.onClick,i.onClose)})})});WR.displayName=P0;var CW="TooltipPortal",[qae,EW]=kp(CW,{forceMount:void 0}),Za="TooltipContent",VR=g.forwardRef((e,t)=>{const n=EW(Za,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,o=Ep(Za,e.__scopeTooltip);return h.jsx(ts,{present:r||o.open,children:o.disableHoverableContent?h.jsx(qR,{side:i,...s,ref:t}):h.jsx(NW,{side:i,...s,ref:t})})}),NW=g.forwardRef((e,t)=>{const n=Ep(Za,e.__scopeTooltip),r=Iy(Za,e.__scopeTooltip),i=g.useRef(null),s=Jt(t,i),[o,a]=g.useState(null),{trigger:l,onClose:c}=n,u=i.current,{onPointerInTransitChange:d}=r,f=g.useCallback(()=>{a(null),d(!1)},[d]),p=g.useCallback((m,v)=>{const w=m.currentTarget,x={x:m.clientX,y:m.clientY},_=MW(x,w.getBoundingClientRect()),y=AW(x,_),S=jW(v.getBoundingClientRect()),C=DW([...y,...S]);a(C),d(!0)},[d]);return g.useEffect(()=>()=>f(),[f]),g.useEffect(()=>{if(l&&u){const m=w=>p(w,u),v=w=>p(w,l);return l.addEventListener("pointerleave",m),u.addEventListener("pointerleave",v),()=>{l.removeEventListener("pointerleave",m),u.removeEventListener("pointerleave",v)}}},[l,u,p,f]),g.useEffect(()=>{if(o){const m=v=>{const w=v.target,x={x:v.clientX,y:v.clientY},_=(l==null?void 0:l.contains(w))||(u==null?void 0:u.contains(w)),y=!LW(x,o);_?f():y&&(f(),c())};return document.addEventListener("pointermove",m),()=>document.removeEventListener("pointermove",m)}},[l,u,o,c,f]),h.jsx(qR,{...e,ref:s})}),[TW,IW]=kp(ou,{isInside:!1}),PW=_9("TooltipContent"),qR=g.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=e,l=Ep(Za,n),c=Cp(n),{onClose:u}=l;return g.useEffect(()=>(document.addEventListener(I0,u),()=>document.removeEventListener(I0,u)),[u]),g.useEffect(()=>{if(l.trigger){const d=f=>{const p=f.target;p!=null&&p.contains(l.trigger)&&u()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[l.trigger,u]),h.jsx(pp,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:d=>d.preventDefault(),onDismiss:u,children:h.jsxs(CP,{"data-state":l.stateAttribute,...c,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[h.jsx(PW,{children:r}),h.jsx(TW,{scope:n,isInside:!0,children:h.jsx(bW,{id:l.contentId,role:"tooltip",children:i||r})})]})})});VR.displayName=Za;var KR="TooltipArrow",RW=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Cp(n);return IW(KR,n).isInside?null:h.jsx(EP,{...i,...r,ref:t})});RW.displayName=KR;function MW(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function AW(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function jW(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function LW(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const a=t[s],l=t[o],c=a.x,u=a.y,d=l.x,f=l.y;u>r!=f>r&&n<(d-c)*(r-u)/(f-u)+c&&(i=!i)}return i}function DW(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),OW(t)}function OW(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const s=t[t.length-1],o=t[t.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],o=n[n.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var BW=HR,zW=UR,$W=WR,GR=VR;const uf=BW,Np=zW,Tp=$W,Ru=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(GR,{ref:r,sideOffset:t,className:ne("z-50 overflow-hidden rounded-sm border border-border bg-bg-0 px-2 py-1 text-xs text-text-300 shadow-md",e),...n}));Ru.displayName=GR.displayName;const FW={held:!1,indexBySessionId:new Map},HW=g.createContext(FW);function UW(){return g.useContext(HW)}const WW=Array.from({length:9},(e,t)=>({id:`switch-session-${t+1}`,combo:{key:String(t+1),mod:!0},label:`切换到第 ${t+1} 个会话`,group:"会话",desktopOnly:!0,hiddenInList:!0})),VW=[{id:"new-session",combo:{key:"n",mod:!0},label:"新建任务",description:"打开快捷新建弹窗",group:"通用",desktopOnly:!0},{id:"open-search",combo:{key:"k",mod:!0},label:"全局搜索",description:"搜会话内容 / persona / 联系人",group:"通用",desktopOnly:!0},{id:"search-tab-prev",combo:{key:"ArrowLeft",mod:!0},label:"搜索:上一组",description:"搜索浮层里切到左边那个 tab(会话 / persona / 联系人)",group:"通用"},{id:"search-tab-next",combo:{key:"ArrowRight",mod:!0},label:"搜索:下一组",description:"搜索浮层里切到右边那个 tab",group:"通用"},...WW,{id:"archive-session",combo:{key:"Backspace",mod:!0,shift:!0},label:"归档当前会话",description:"归档当前聊天区的会话,Enter 确认 / Esc 取消",group:"会话",desktopOnly:!0},{id:"tab-prev",combo:{key:"ArrowLeft",mod:!0,shift:!0},label:"上一个标签页",description:"连按快速移动,停下或松开修饰键后切换",group:"标签页"},{id:"tab-next",combo:{key:"ArrowRight",mod:!0,shift:!0},label:"下一个标签页",description:"连按快速移动,停下或松开修饰键后切换",group:"标签页"},{id:"toggle-hive",combo:{key:"h",mod:!0,shift:!0},label:"Hive 看板",description:"全屏看所有 agent 在干什么;Esc 或点任意行退出",group:"通用"},{id:"send-message",combo:{key:"Enter"},label:"发送消息",description:"在输入框中发送当前内容",group:"输入",displayOnly:!0},{id:"newline",combo:{key:"Enter",shift:!0},label:"换行",description:"在输入框中插入换行",group:"输入",displayOnly:!0},{id:"interrupt",combo:{key:"Escape"},label:"打断回复",description:"打断当前回复;2 秒内按两次停止任务",group:"输入",displayOnly:!0}];VW.filter(e=>!e.displayOnly);function qW(){return/Mac|iP(hone|od|ad)/.test(navigator.platform)}const KW=10,GW=20,YW=16,TS=20,IS=60,XW=4;function kd({testId:e,label:t,children:n}){return h.jsxs(Np,{children:[h.jsx(Tp,{asChild:!0,children:h.jsx("span",{"data-testid":e,role:"img","aria-label":t,tabIndex:0,className:"inline-flex shrink-0",children:n})}),h.jsx(Ru,{side:"bottom",children:t})]})}function QW({session:e,active:t,hasUnread:n,running:r=!1,awaitingUser:i=!1,onSelect:s,onEdit:o,onDelete:a,onPin:l,onArchive:c,quickAction:u,depth:d=0,chevron:f,showCopyResume:p=!0,contactDisplayName:m,ownerPrincipalId:v,creatorDisplayName:w,dispatchedFromSessionTitle:x}){const[_,y]=g.useState(!1),S=UW(),C=S.held?S.indexBySessionId.get(e.sessionId):void 0,k=!!e.pinnedAt,N=d===0,T=d===0&&!!c,D=KW+d*GW;let P=null;u==="pin"&&N&&l?P={icon:k?h.jsx(Kw,{className:"w-4 h-4"}):h.jsx(Gw,{className:"w-4 h-4"}),label:k?"取消置顶":"置顶",run:()=>l(e.sessionId,!k)}:u==="archive"&&T&&c?P={icon:h.jsx(Ww,{className:"w-4 h-4"}),label:"归档",run:()=>c(e.sessionId,!0)}:u==="rename"&&o&&(P={icon:h.jsx(_0,{className:"w-4 h-4"}),label:"重命名",run:()=>y(!0)});const O=g.useCallback(async()=>{const $=GI(e);if($)try{await navigator.clipboard.writeText($)}catch{}},[e]),R=sy(e),M=e.originOwnerPrincipalId,A=M?`@${m??`…${M.slice(-8)}`}`:null,L=!!(e.ownerPersonaId&&v&&e.creatorPrincipalId&&e.creatorPrincipalId!==v&&!e.larkChatId&&!e.shiftFiredFromSessionId&&!e.dispatchedFromSessionId);return h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-testid":`session-item-${e.sessionId}`,onClick:s,style:{paddingLeft:D,display:"grid",gridTemplateColumns:f?`${YW}px ${TS}px 1fr auto ${IS}px`:`${TS}px 1fr auto ${IS}px`,gridTemplateAreas:f?'"chev icon name dot time"':'"icon name dot time"',columnGap:`${XW}px`,alignItems:"center"},className:ne("group relative rounded-lg cursor-pointer transition-all duration-150 pr-2.5 py-1.5",t?"bg-accent-dim":"hover:bg-sidebar-hover-bg"),children:[t?h.jsx("span",{"aria-hidden":"true",className:"absolute left-0 top-1/2 -translate-y-1/2 w-[3px] h-7 rounded-r-full bg-accent"}):null,h.jsx("div",{style:{gridArea:"chev"},className:"flex items-center justify-center",children:f??null}),h.jsx("div",{style:{gridArea:"icon"},className:"flex items-center justify-center",children:h.jsx(gW,{tool:e.tool})}),h.jsxs("div",{style:{gridArea:"name"},className:"flex items-center gap-1 min-w-0",children:[h.jsxs(uf,{delayDuration:200,skipDelayDuration:100,children:[e.dispatchedFromSessionId?h.jsx(kd,{testId:`dispatched-icon-${e.sessionId}`,label:`来自【${x??"另一会话"}】dispatch`,children:h.jsx(e8,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,e.shiftFiredFromSessionId?h.jsx(kd,{testId:`shift-fired-icon-${e.sessionId}`,label:"定时任务",children:h.jsx(C$,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,e.larkChatId?h.jsx(kd,{testId:`lark-chat-icon-${e.sessionId}`,label:e.larkChatType==="p2p"?"来自飞书DM":"来自飞书群",children:h.jsx(I8,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,L?h.jsx(kd,{testId:`guest-created-icon-${e.sessionId}`,label:w?`${w}创建`:"其他人创建",children:h.jsx(hF,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null]}),h.jsx("span",{"data-testid":`session-title-${e.sessionId}`,className:ne("text-[13px] truncate min-w-0","group-hover:whitespace-normal group-hover:overflow-visible group-hover:break-words",t?"text-text-100 font-medium":"text-text-200"),children:R}),A?h.jsx("span",{"data-testid":`session-mirror-chip-${e.sessionId}`,title:`在 ${A.replace(/^@/,"")} 的设备上`,className:"shrink-0 inline-flex items-center px-1.5 py-0 rounded text-[10px] bg-accent-dim/40 text-accent border border-accent/20 max-w-[120px] truncate",children:A}):null]}),h.jsx(vW,{sessionId:e.sessionId,hasUnread:n,running:r,awaitingUser:i,style:{gridArea:"dot"}}),C!=null?h.jsx("span",{style:{gridArea:"time"},"data-testid":`session-quick-switch-badge-${e.sessionId}`,className:"text-right shrink-0 transition-opacity duration-150 group-hover:opacity-0",children:h.jsx("span",{className:"inline-flex items-center justify-center h-[18px] px-1.5 rounded-[5px] border border-border bg-bg-200/70 text-[11px] text-text-200 font-medium leading-none",children:qW()?`⌘${C}`:`Ctrl+${C}`})}):h.jsx("span",{style:{gridArea:"time"},className:ne("text-[11px] text-text-400/70 text-right shrink-0","transition-opacity duration-150 group-hover:opacity-0"),children:e.updatedAt?u9(e.updatedAt):""}),o||a||l||c?h.jsxs("div",{className:"absolute right-2 top-[3px] flex items-center opacity-0 group-hover:opacity-100 data-[state=open]:opacity-100 transition-opacity",children:[P?h.jsx(uf,{delayDuration:200,skipDelayDuration:100,children:h.jsxs(Np,{children:[h.jsx(Tp,{asChild:!0,children:h.jsx("button",{type:"button",onClick:$=>{$.stopPropagation(),P.run()},className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":P.label,"data-testid":`quick-action-${u}-${e.sessionId}`,children:P.icon})}),h.jsx(Ru,{side:"bottom",children:P.label})]})}):null,h.jsxs(Ey,{modal:!1,children:[h.jsx(Ny,{asChild:!0,children:h.jsx("button",{type:"button",onClick:$=>$.stopPropagation(),className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":"session actions","data-testid":`session-menu-${e.sessionId}`,children:h.jsx(SI,{className:"w-4 h-4"})})}),h.jsxs(Sp,{align:"end",onClick:$=>$.stopPropagation(),children:[l&&N&&h.jsxs(Ai,{onSelect:()=>l(e.sessionId,!k),"data-testid":`session-${k?"unpin":"pin"}-${e.sessionId}`,children:[k?h.jsx(Kw,{className:"w-3 h-3 mr-2 text-text-400"}):h.jsx(Gw,{className:"w-3 h-3 mr-2 text-text-400"}),k?"Unpin":"Pin"]}),T&&c&&h.jsxs(Ai,{onSelect:()=>c(e.sessionId,!0),"data-testid":`session-archive-${e.sessionId}`,children:[h.jsx(Ww,{className:"w-3 h-3 mr-2 text-text-400"}),"Archive"]}),o&&h.jsxs(Ai,{onSelect:()=>y(!0),"data-testid":`session-rename-${e.sessionId}`,children:[h.jsx(_0,{className:"w-3 h-3 mr-2 text-text-400"}),"Rename"]}),p&&e.toolSessionId?h.jsxs(Ai,{onSelect:()=>void O(),"data-testid":`session-copy-resume-${e.sessionId}`,children:[h.jsx(dp,{className:"w-3 h-3 mr-2 text-text-400"}),"Copy Resume Command"]}):null,(l||o||p&&e.toolSessionId)&&a&&h.jsx(Ty,{}),a&&h.jsxs(Ai,{onSelect:()=>void a(e.sessionId),className:"text-destructive focus:text-destructive focus:bg-destructive/10","data-testid":`session-delete-${e.sessionId}`,children:[h.jsx(ty,{className:"w-3 h-3 mr-2"}),"Delete"]})]})]})]}):null]}),o?h.jsx(xW,{open:_,initialLabel:e.label??"",placeholder:e.cwd.split("/").pop()||"",onSubmit:$=>{o(e.sessionId,$),y(!1)},onCancel:()=>y(!1)}):null]})}function Py({node:e,depth:t=0,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,quickAction:d,getContactDisplayName:f,showCopyResume:p,ownerPrincipalId:m,getCreatorDisplayName:v,getSessionDisplayName:w,parentSession:x}){const _=e.children.length>0,{isCollapsed:y,toggle:S}=x$(),C=!y(e.session.sessionId),k=g.useCallback(T=>{T.stopPropagation(),S(e.session.sessionId)},[S,e.session.sessionId]),N=_?h.jsx("button",{type:"button",onClick:k,"data-testid":`session-chevron-${e.session.sessionId}`,"aria-label":C?"collapse":"expand","aria-expanded":C,className:"shrink-0 flex items-center justify-center w-4 h-4 text-text-400 hover:text-text-100 cursor-pointer",children:C?h.jsx(Yn,{className:"w-3 h-3"}):h.jsx(Bn,{className:"w-3 h-3"})}):null;return h.jsxs("div",{"data-testid":`session-tree-node-${e.session.sessionId}`,children:[h.jsx(QW,{session:e.session,active:n===e.session.sessionId,hasUnread:(r==null?void 0:r.has(e.session.sessionId))??!1,running:(i==null?void 0:i.has(e.session.sessionId))??!1,awaitingUser:(s==null?void 0:s.has(e.session.sessionId))??!1,onSelect:()=>o(e.session.sessionId),onEdit:a,onDelete:l,onPin:c,onArchive:u,quickAction:d,showCopyResume:p,ownerPrincipalId:m,creatorDisplayName:e.session.creatorPrincipalId?v==null?void 0:v(e.session.creatorPrincipalId):void 0,dispatchedFromSessionTitle:e.session.dispatchedFromSessionId?(w==null?void 0:w(e.session.dispatchedFromSessionId))??((x==null?void 0:x.sessionId)===e.session.dispatchedFromSessionId?sy(x):void 0):void 0,depth:t,chevron:N,contactDisplayName:e.session.originOwnerPrincipalId?f==null?void 0:f(e.session.originOwnerPrincipalId):void 0}),_&&C?h.jsx("div",{"data-testid":`session-tree-children-${e.session.sessionId}`,children:e.children.map(T=>h.jsx(Py,{node:T,depth:t+1,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,quickAction:d,getContactDisplayName:f,showCopyResume:p,ownerPrincipalId:m,getCreatorDisplayName:v,getSessionDisplayName:w,parentSession:e.session},T.session.sessionId))}):null]})}function ZW(e){return e.forkedFromSessionId??e.dispatchedFromSessionId??e.shiftFiredFromSessionId}function YR(e){e=e.filter(s=>!s.ephemeral&&s.deployId===void 0);const t=new Map;for(const s of e)t.set(s.sessionId,s);const n=new Map,r=[];for(const s of e){const o=ZW(s);if(o&&t.has(o)){const a=n.get(o)??[];a.push(s),n.set(o,a)}else r.push(s)}const i=s=>{const a=[...n.get(s.sessionId)??[]].sort((l,c)=>l.createdAt<c.createdAt?-1:l.createdAt>c.createdAt?1:0);return{session:s,children:a.map(i)}};return[...r].sort(JW).map(i)}function XR(e){return[...e].sort((t,n)=>t.session.updatedAt<n.session.updatedAt?1:t.session.updatedAt>n.session.updatedAt?-1:0)}function JW(e,t){const n=typeof e.pinnedAt=="number",r=typeof t.pinnedAt=="number";if(n&&r){const i=typeof e.pinSortOrder=="number",s=typeof t.pinSortOrder=="number";return i&&s?e.pinSortOrder-t.pinSortOrder:i?-1:s?1:t.pinnedAt-e.pinnedAt}return n?-1:r||e.updatedAt<t.updatedAt?1:e.updatedAt>t.updatedAt?-1:0}function eV(e){return e.appBuilderProject?`[app] ${e.appBuilderProject}`:e.label?e.label:e.aiLabel?e.aiLabel:e.cwd.split("/").filter(Boolean).pop()??""}function PS(e,t){const n=t.trim().toLowerCase();return n===""?!0:e.toLowerCase().includes(n)}const tV={isCollapsed:()=>!1,toggle:()=>{},prune:()=>{}};function nV({personas:e,activePersonaId:t,onSelectPersona:n,onCreateSession:r,sessions:i,activeSessionId:s,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,isPersonaExpanded:p,onTogglePersonaExpanded:m,onEditSession:v,onPinSession:w,showCopyResume:x,treatSessionsAsRoots:_,searchQuery:y}){const[S,C]=g.useState(null),[k,N]=g.useState(()=>new Set),T=p??(L=>k.has(L)),D=g.useCallback(L=>{if(m){m(L);return}N($=>{const F=new Set($);return F.has(L)?F.delete(L):F.add(L),F})},[m]),P=g.useMemo(()=>i==null?void 0:i.filter(L=>!L.ephemeral),[i]),O=g.useMemo(()=>new Map((P??[]).map(L=>[L.sessionId,sy(L)])),[P]),R=g.useCallback(L=>f==null?void 0:f.get(L),[f]),M=g.useCallback(L=>O.get(L),[O]);if(e.length===0)return h.jsx(rV,{});const A=(y??"").trim();return A?h.jsx(Z_.Provider,{value:tV,children:h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(L=>{const $=P?P.filter(E=>E.ownerPersonaId===L.personaId).sort((E,H)=>H.updatedAt>E.updatedAt?1:-1):[],F=PS(L.label,A),B=$.filter(E=>PS(eV(E),A));if(!F&&B.length===0)return null;const z=F?$:B;return h.jsx(RS,{persona:L,active:L.personaId===t,editing:!1,onSelectPersona:n,onSubmitCreateSession:()=>{},onCancelCreateSession:()=>{},personaSessions:z,collapsed:!1,onToggleCollapsed:()=>{},activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:w,showCopyResume:x,treatSessionsAsRoots:_,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,getCreatorDisplayName:R,getSessionDisplayName:M},L.personaId)})})}):h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(L=>{const $=P?P.filter(F=>F.ownerPersonaId===L.personaId).sort((F,B)=>B.updatedAt>F.updatedAt?1:-1):[];return h.jsx(RS,{persona:L,active:L.personaId===t,editing:L.personaId===S,onSelectPersona:n,onStartCreateSession:r?()=>C(L.personaId):void 0,onSubmitCreateSession:F=>{C(null),r==null||r(L.personaId,F)},onCancelCreateSession:()=>C(null),personaSessions:$,collapsed:!T(L.personaId),onToggleCollapsed:()=>D(L.personaId),activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:w,showCopyResume:x,treatSessionsAsRoots:_,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,getCreatorDisplayName:R,getSessionDisplayName:M},L.personaId)})})}function rV(){return h.jsx("div",{className:"px-3 py-3 text-[11px] leading-relaxed text-text-400",children:"还没有 persona。点上方 Personas 标题右侧 + 创建第一个。"})}function RS({persona:e,active:t,editing:n,onSelectPersona:r,onStartCreateSession:i,onSubmitCreateSession:s,onCancelCreateSession:o,personaSessions:a,collapsed:l,onToggleCollapsed:c,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:w,onPinSession:x,showCopyResume:_,treatSessionsAsRoots:y,ownerPrincipalId:S,creatorDisplayNameByOwnerId:C,getCreatorDisplayName:k,getSessionDisplayName:N}){const T=a.length>0,D=!l,P=g.useMemo(()=>{const M=[],A=new Map;for(const L of a){const $=L.creatorPrincipalId;if(L.larkChatId!=null||!$||S&&$===S){M.push(L);continue}const F=$,B=(C==null?void 0:C.get(F))??`…${F.slice(-8)}`,z=A.get(F);z?z.sessions.push(L):A.set(F,{groupKey:F,displayName:B,sessions:[L]})}return{self:M,byPeer:[...A.values()]}},[a,S,C]),O=P.byPeer.length>0,R=g.useMemo(()=>D&&!O?XR(YR(a)):[],[D,O,a]);return h.jsxs("div",{"data-testid":`persona-node-${e.personaId}`,children:[h.jsxs("div",{className:ne("group flex items-center gap-1 px-2 py-1.5 cursor-pointer",t?"bg-accent-dim text-text-100":"hover:bg-bg-200 text-text-200"),onClick:()=>r==null?void 0:r(e.personaId),role:"button",tabIndex:0,children:[T?h.jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),c()},"aria-label":D?"collapse":"expand","aria-expanded":D,"data-testid":`persona-chevron-${e.personaId}`,className:"flex h-4 w-4 shrink-0 items-center justify-center text-text-400 hover:text-text-100",children:D?h.jsx(Yn,{className:"h-3 w-3"}):h.jsx(Bn,{className:"h-3 w-3"})}):h.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),h.jsx(hp,{tool:e.tool,className:ne("h-3.5 w-3.5 shrink-0",fp(e.tool))}),h.jsx("span",{className:"flex-1 truncate text-[13px]",children:e.label}),T?h.jsx("span",{className:"shrink-0 text-[10px] text-text-400 tabular-nums","aria-label":`${a.length} sessions`,children:a.length}):null,i?h.jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),i()},"aria-label":"新建会话",title:"新建会话","data-testid":`persona-create-session-${e.personaId}`,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded text-text-400 opacity-0 hover:bg-text-100/10 hover:text-text-100 focus-visible:opacity-100 group-hover:opacity-100",children:h.jsx(H8,{className:"h-3.5 w-3.5"})}):null]}),n?h.jsx(iV,{personaId:e.personaId,tool:e.tool,onSubmit:s,onCancel:o}):null,T&&D?h.jsx("div",{"data-testid":`persona-sessions-${e.personaId}`,children:O?h.jsxs(h.Fragment,{children:[P.self.length>0&&h.jsx(MS,{groupKey:`${e.personaId}-self`,label:"我自己",testId:`persona-sessions-${e.personaId}-self`,sessions:P.self,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:w,onPinSession:x,showCopyResume:_,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:N}),P.byPeer.map(M=>h.jsx(MS,{groupKey:`${e.personaId}-peer-${M.groupKey}`,label:M.displayName,testId:`persona-sessions-${e.personaId}-peer-${M.groupKey}`,sessions:M.sessions,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:w,onPinSession:x,showCopyResume:_,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:N},`${e.personaId}-peer-${M.groupKey}`))]}):R.map(M=>h.jsx(Py,{node:M,depth:y?0:1,activeId:u,unreadIds:p,runningIds:f,awaitingIds:d,onSelect:A=>m==null?void 0:m(A),onDelete:v,onEdit:w,onPin:x,showCopyResume:_,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:N},M.session.sessionId))}):null]})}function MS({label:e,testId:t,sessions:n,activeSessionId:r,awaitingIds:i,runningIds:s,unreadIds:o,onSelectSession:a,onDeleteSession:l,onEditSession:c,onPinSession:u,showCopyResume:d,ownerPrincipalId:f,getCreatorDisplayName:p,getSessionDisplayName:m}){const[v,w]=g.useState(!1),x=!v,_=g.useMemo(()=>x?XR(YR(n)):[],[x,n]);return h.jsxs("div",{"data-testid":t,children:[h.jsxs("button",{type:"button",onClick:()=>w(y=>!y),"aria-label":x?"collapse":"expand","aria-expanded":x,"data-testid":`${t}-chevron`,className:"flex items-center gap-1 w-full pl-7 pr-2 py-0.5 text-[11px] text-text-400 hover:text-text-200 transition-colors",children:[x?h.jsx(Yn,{className:"h-3 w-3"}):h.jsx(Bn,{className:"h-3 w-3"}),h.jsx(PI,{className:"h-3 w-3","aria-hidden":!0}),h.jsx("span",{className:"truncate",children:e}),h.jsx("span",{className:"ml-auto tabular-nums",children:n.length})]}),x&&h.jsx("div",{children:_.map(y=>h.jsx(Py,{node:y,depth:2,activeId:r,unreadIds:o,runningIds:s,awaitingIds:i,onSelect:S=>a==null?void 0:a(S),onDelete:l,onEdit:c,onPin:u,showCopyResume:d,ownerPrincipalId:f,getCreatorDisplayName:p,getSessionDisplayName:m},y.session.sessionId))})]})}function iV({personaId:e,tool:t,onSubmit:n,onCancel:r}){const[i,s]=g.useState(""),o=g.useRef(null),a=i.trim(),l=a.length>0;g.useEffect(()=>{var d;(d=o.current)==null||d.focus()},[]);const c=g.useCallback(()=>{l&&n(a)},[l,a,n]),u=Pu(c,r);return h.jsxs("div",{className:"flex items-center gap-1.5 pl-9 pr-2 py-1","data-testid":`persona-new-session-row-${e}`,children:[h.jsx(hp,{tool:t,className:ne("h-3 w-3 shrink-0",fp(t))}),h.jsx("input",{ref:o,type:"text",value:i,onChange:d=>s(d.target.value),...u,onBlur:r,placeholder:"session label...","data-testid":`persona-new-session-input-${e}`,className:"flex-1 min-w-0 bg-bg-100 border border-text-100/15 rounded px-1.5 py-0.5 text-[12px] text-text-100 placeholder:text-text-400 focus:outline-none focus:border-text-100/40"}),h.jsx("button",{type:"button",onMouseDown:d=>{d.preventDefault(),c()},disabled:!l,"aria-label":"确认",title:"确认(Enter)","data-testid":`persona-new-session-confirm-${e}`,className:"flex h-4 w-4 shrink-0 items-center justify-center rounded text-text-300 hover:bg-text-100/10 hover:text-text-100 disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:text-text-300",children:h.jsx(bl,{className:"h-3 w-3"})}),h.jsx("button",{type:"button",onMouseDown:d=>{d.preventDefault(),r()},"aria-label":"取消",title:"取消(Esc)","data-testid":`persona-new-session-cancel-${e}`,className:"flex h-4 w-4 shrink-0 items-center justify-center rounded text-text-300 hover:bg-text-100/10 hover:text-text-100",children:h.jsx(Pr,{className:"h-3 w-3"})})]})}function sV(e,t){const n=getComputedStyle(e),r=parseFloat(n.fontSize);return t*r}function oV(e,t){const n=getComputedStyle(e.ownerDocument.documentElement),r=parseFloat(n.fontSize);return t*r}function aV(e){return e/100*window.innerHeight}function lV(e){return e/100*window.innerWidth}function cV(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function rc({groupSize:e,panelElement:t,styleProp:n}){let r;const[i,s]=cV(n);switch(s){case"%":{r=i/100*e;break}case"px":{r=i;break}case"rem":{r=oV(t,i);break}case"em":{r=sV(t,i);break}case"vh":{r=aV(i);break}case"vw":{r=lV(i);break}}return r}function Mn(e){return parseFloat(e.toFixed(3))}function Ja({group:e}){const{orientation:t,panels:n}=e;return n.reduce((r,i)=>(r+=t==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,r),0)}function R0(e){const{panels:t}=e,n=Ja({group:e});return n===0?t.map(r=>({groupResizeBehavior:r.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:r.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:r.panelConstraints.disabled,minSize:0,maxSize:100,panelId:r.id})):t.map(r=>{const{element:i,panelConstraints:s}=r;let o=0;if(s.collapsedSize!==void 0){const u=rc({groupSize:n,panelElement:i,styleProp:s.collapsedSize});o=Mn(u/n*100)}let a;if(s.defaultSize!==void 0){const u=rc({groupSize:n,panelElement:i,styleProp:s.defaultSize});a=Mn(u/n*100)}let l=0;if(s.minSize!==void 0){const u=rc({groupSize:n,panelElement:i,styleProp:s.minSize});l=Mn(u/n*100)}let c=100;if(s.maxSize!==void 0){const u=rc({groupSize:n,panelElement:i,styleProp:s.maxSize});c=Mn(u/n*100)}return{groupResizeBehavior:s.groupResizeBehavior,collapsedSize:o,collapsible:s.collapsible===!0,defaultSize:a,disabled:s.disabled,minSize:l,maxSize:c,panelId:r.id}})}function at(e,t="Assertion error"){if(!e)throw Error(t)}function M0(e,t){return Array.from(t).sort(e==="horizontal"?uV:dV)}function uV(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function dV(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function QR(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function ZR(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function hV({orientation:e,rects:t,targetRect:n}){const r={x:n.x+n.width/2,y:n.y+n.height/2};let i,s=Number.MAX_VALUE;for(const o of t){const{x:a,y:l}=ZR(r,o),c=e==="horizontal"?a:l;c<s&&(s=c,i=o)}return at(i,"No rect found"),i}let Cd;function fV(){return Cd===void 0&&(typeof matchMedia=="function"?Cd=!!matchMedia("(pointer:coarse)").matches:Cd=!1),Cd}function JR(e){const{element:t,orientation:n,panels:r,separators:i}=e,s=M0(n,Array.from(t.children).filter(QR).map(m=>({element:m}))).map(({element:m})=>m),o=[];let a=!1,l=!1,c=-1,u=-1,d=0,f,p=[];{let m=-1;for(const v of s)v.hasAttribute("data-panel")&&(m++,v.hasAttribute("data-disabled")||(d++,c===-1&&(c=m),u=m))}if(d>1){let m=-1;for(const v of s)if(v.hasAttribute("data-panel")){m++;const w=r.find(x=>x.element===v);if(w){if(f){const x=f.element.getBoundingClientRect(),_=v.getBoundingClientRect();let y;if(l){const S=n==="horizontal"?new DOMRect(x.right,x.top,0,x.height):new DOMRect(x.left,x.bottom,x.width,0),C=n==="horizontal"?new DOMRect(_.left,_.top,0,_.height):new DOMRect(_.left,_.top,_.width,0);switch(p.length){case 0:{y=[S,C];break}case 1:{const k=p[0],N=hV({orientation:n,rects:[x,_],targetRect:k.element.getBoundingClientRect()});y=[k,N===x?C:S];break}default:{y=p;break}}}else p.length?y=p:y=[n==="horizontal"?new DOMRect(x.right,_.top,_.left-x.right,_.height):new DOMRect(_.left,x.bottom,_.width,_.top-x.bottom)];for(const S of y){let C="width"in S?S:S.element.getBoundingClientRect();const k=fV()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(C.width<k){const T=k-C.width;C=new DOMRect(C.x-T/2,C.y,C.width+T,C.height)}if(C.height<k){const T=k-C.height;C=new DOMRect(C.x,C.y-T/2,C.width,C.height+T)}const N=m<=c||m>u;!a&&!N&&o.push({group:e,groupSize:Ja({group:e}),panels:[f,w],separator:"width"in S?void 0:S,rect:C}),a=!1}}l=!1,f=w,p=[]}}else if(v.hasAttribute("data-separator")){v.ariaDisabled!==null&&(a=!0);const w=i.find(x=>x.element===v);w?p.push(w):(f=void 0,p=[])}else l=!0}return o}var bs;class e5{constructor(){R1(this,bs,{})}addListener(t,n){const r=Pl(this,bs)[t];return r===void 0?Pl(this,bs)[t]=[n]:r.includes(n)||r.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const r=Pl(this,bs)[t];if(r!==void 0)if(r.length===1)r[0].call(null,n);else{let i=!1,s=null;const o=Array.from(r);for(let a=0;a<o.length;a++){const l=o[a];try{l.call(null,n)}catch(c){s===null&&(i=!0,s=c)}}if(i)throw s}}removeAllListeners(){M1(this,bs,{})}removeListener(t,n){const r=Pl(this,bs)[t];if(r!==void 0){const i=r.indexOf(n);i>=0&&r.splice(i,1)}}}bs=new WeakMap;let Da={cursorFlags:0,state:"inactive"};const Ry=new e5;function Io(){return Da}function pV(e){return Ry.addListener("change",e)}function mV(e){const t=Da,n={...Da};n.cursorFlags=e,Da=n,Ry.emit("change",{prev:t,next:n})}function Oa(e){const t=Da;Da=e,Ry.emit("change",{prev:t,next:e})}const gV=e=>e,Gm=()=>{},t5=1,n5=2,r5=4,i5=8,AS=3,jS=12;let Ed;function LS(){return Ed===void 0&&(Ed=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(Ed=!0)),Ed}function vV({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case"active":case"hover":t.forEach(s=>{if(!s.mutableState.disableCursor)switch(s.orientation){case"horizontal":{r++;break}case"vertical":{i++;break}}})}if(!(r===0&&i===0)){switch(n){case"active":{if(e&&LS()){const s=(e&t5)!==0,o=(e&n5)!==0,a=(e&r5)!==0,l=(e&i5)!==0;if(s)return a?"se-resize":l?"ne-resize":"e-resize";if(o)return a?"sw-resize":l?"nw-resize":"w-resize";if(a)return"s-resize";if(l)return"n-resize"}break}}return LS()?r>0&&i>0?"move":r>0?"ew-resize":"ns-resize":r>0&&i>0?"grab":r>0?"col-resize":"row-resize"}}const DS=new WeakMap;function My(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=DS.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));const r=Io();switch(r.state){case"active":case"hover":{const i=vV({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(o=>o.group),state:r.state}),s=`*, *:hover {cursor: ${i} !important; }`;if(t===s)return;t=s,i?n.cssRules.length===0?n.insertRule(s):n.replaceSync(s):n.cssRules.length===1&&n.deleteRule(0);break}case"inactive":{t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}}DS.set(e,{prevStyle:t,styleSheet:n})}let si=new Map;const s5=new e5;function xV(e){si=new Map(si),si.delete(e)}function OS(e,t){for(const[n]of si)if(n.id===e)return n}function Ls(e,t){for(const[n,r]of si)if(n.id===e)return r;if(t)throw Error(`Could not find data for Group with id ${e}`)}function Uo(){return si}function Ay(e,t){return s5.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function Xi(e,t,n){const r=si.get(e);si=new Map(si),si.set(e,t),s5.emit("groupChange",{group:e,isUserInteraction:(n==null?void 0:n.isUserInteraction)===!0,prev:r,next:t})}function o5(e){const t=Io();let n=!1;switch(t.state){case"active":Oa({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(My(e),n=!0,t.hitRegions.forEach(r=>{const i=Ls(r.group.id,!0);Xi(r.group,i,{isUserInteraction:!0})}))}return n}function BS(e){e.defaultPrevented||o5(e.currentTarget)}function _V(e,t,n){let r,i={x:1/0,y:1/0};for(const s of t){const o=ZR(n,s.rect);switch(e){case"horizontal":{o.x<=i.x&&(r=s,i=o);break}case"vertical":{o.y<=i.y&&(r=s,i=o);break}}}return r?{distance:i,hitRegion:r}:void 0}function yV(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function bV(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:FS(e),b:FS(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();at(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:$S(zS(n.a)),b:$S(zS(n.b))};if(i.a===i.b){const s=r.childNodes,o={a:n.a.at(-1),b:n.b.at(-1)};let a=s.length;for(;a--;){const l=s[a];if(l===o.a)return 1;if(l===o.b)return-1}}return Math.sign(i.a-i.b)}const wV=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function SV(e){const t=getComputedStyle(a5(e)??e).display;return t==="flex"||t==="inline-flex"}function kV(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||SV(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||wV.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function zS(e){let t=e.length;for(;t--;){const n=e[t];if(at(n,"Missing node"),kV(n))return n}return null}function $S(e){return e&&Number(getComputedStyle(e).zIndex)||0}function FS(e){const t=[];for(;e;)t.push(e),e=a5(e);return t}function a5(e){const{parentNode:t}=e;return yV(t)?t.host:t}function CV(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function EV({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!QR(n)||n.contains(e)||e.contains(n))return!0;if(bV(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(CV(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function jy(e,t){const n=[];return t.forEach((r,i)=>{if(i.disabled)return;const s=JR(i),o=_V(i.orientation,s,{x:e.clientX,y:e.clientY});o&&o.distance.x<=0&&o.distance.y<=0&&EV({groupElement:i.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&n.push(o.hitRegion)}),n}function NV(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function Sn(e,t,n=0){return Math.abs(Mn(e)-Mn(t))<=n}function ti(e,t){return Sn(e,t)?0:e>t?1:-1}function Ca({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){const{collapsedSize:i=0,collapsible:s,disabled:o,maxSize:a=100,minSize:l=0}=t;if(o&&!e)return n;if(ti(r,l)<0)if(s){const c=(i+l)/2;ti(r,c)<0?r=i:r=l}else r=l;return r=Math.min(a,r),r=Mn(r),r}function au({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(Sn(e,0))return t;const o=s==="imperative-api",a=Object.values(t),l=Object.values(i),c=[...a],[u,d]=r;at(u!=null,"Invalid first pivot index"),at(d!=null,"Invalid second pivot index");let f=0;switch(s){case"keyboard":{{const v=e<0?d:u,w=n[v];at(w,`Panel constraints not found for index ${v}`);const{collapsedSize:x=0,collapsible:_,minSize:y=0}=w;if(_){const S=a[v];if(at(S!=null,`Previous layout not found for panel index ${v}`),Sn(S,x)){const C=y-S;ti(C,Math.abs(e))>0&&(e=e<0?0-C:C)}}}{const v=e<0?u:d,w=n[v];at(w,`No panel constraints found for index ${v}`);const{collapsedSize:x=0,collapsible:_,minSize:y=0}=w;if(_){const S=a[v];if(at(S!=null,`Previous layout not found for panel index ${v}`),Sn(S,y)){const C=S-x;ti(C,Math.abs(e))>0&&(e=e<0?0-C:C)}}}break}default:{const v=e<0?d:u,w=n[v];at(w,`Panel constraints not found for index ${v}`);const x=a[v],{collapsible:_,collapsedSize:y,minSize:S}=w;if(_&&ti(x,S)<0)if(e>0){const C=S-y,k=C/2,N=x+e;ti(N,S)<0&&(e=ti(e,k)<=0?0:C)}else{const C=S-y,k=100-C/2,N=x-e;ti(N,S)<0&&(e=ti(100+e,k)>0?0:-C)}break}}{const v=e<0?1:-1;let w=e<0?d:u,x=0;for(;;){const y=a[w];at(y!=null,`Previous layout not found for panel index ${w}`);const S=Ca({overrideDisabledPanels:o,panelConstraints:n[w],prevSize:y,size:100})-y;if(x+=S,w+=v,w<0||w>=n.length)break}const _=Math.min(Math.abs(e),Math.abs(x));e=e<0?0-_:_}{let v=e<0?u:d;for(;v>=0&&v<n.length;){const w=Math.abs(e)-Math.abs(f),x=a[v];at(x!=null,`Previous layout not found for panel index ${v}`);const _=x-w,y=Ca({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:x,size:_});if(!Sn(x,y)&&(f+=x-y,c[v]=y,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?v--:v++}}if(NV(l,c))return i;{const v=e<0?d:u,w=a[v];at(w!=null,`Previous layout not found for panel index ${v}`);const x=w+f,_=Ca({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:w,size:x});if(c[v]=_,!Sn(_,x)){let y=x-_,S=e<0?d:u;for(;S>=0&&S<n.length;){const C=c[S];at(C!=null,`Previous layout not found for panel index ${S}`);const k=C+y,N=Ca({overrideDisabledPanels:o,panelConstraints:n[S],prevSize:C,size:k});if(Sn(C,N)||(y-=N-C,c[S]=N),Sn(y,0))break;e>0?S--:S++}}}const p=Object.values(c).reduce((v,w)=>w+v,0);if(!Sn(p,100,.1))return i;const m=Object.keys(i);return c.reduce((v,w,x)=>(v[m[x]]=w,v),{})}function Po(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||ti(e[n],t[n])!==0)return!1;return!0}function Ro({layout:e,panelConstraints:t}){const n=Object.values(e),r=[...n],i=r.reduce((a,l)=>a+l,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(a=>`${a}%`).join(", ")}`);if(!Sn(i,100)&&r.length>0)for(let a=0;a<t.length;a++){const l=r[a];at(l!=null,`No layout data found for index ${a}`);const c=100/i*l;r[a]=c}let s=0;for(let a=0;a<t.length;a++){const l=n[a];at(l!=null,`No layout data found for index ${a}`);const c=r[a];at(c!=null,`No layout data found for index ${a}`);const u=Ca({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});c!=u&&(s+=c-u,r[a]=u)}if(!Sn(s,0))for(let a=0;a<t.length;a++){const l=r[a];at(l!=null,`No layout data found for index ${a}`);const c=l+s,u=Ca({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});if(l!==u&&(s-=u-l,r[a]=u,Sn(s,0)))break}const o=Object.keys(e);return r.reduce((a,l,c)=>(a[o[c]]=l,a),{})}function l5({groupId:e,panelId:t}){const n=()=>{const l=Uo();for(const[c,{defaultLayoutDeferred:u,derivedPanelConstraints:d,layout:f,groupSize:p,separatorToPanels:m}]of l)if(c.id===e)return{defaultLayoutDeferred:u,derivedPanelConstraints:d,group:c,groupSize:p,layout:f,separatorToPanels:m};throw Error(`Group ${e} not found`)},r=()=>{const l=n().derivedPanelConstraints.find(c=>c.panelId===t);if(l!==void 0)return l;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{const l=n().group.panels.find(c=>c.id===t);if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},s=()=>{const l=n().layout[t];if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},o=({nextSize:l,panels:c,prevLayout:u,derivedPanelConstraints:d})=>{const f=s(),p=c.findIndex(w=>w.id===t),m=p===0,v=p===c.length-1;if(v&&l<f&&(m||c.slice(0,p).every((w,x)=>{const _=d[x];return(_==null?void 0:_.collapsible)&&Sn(_.collapsedSize,u[_.panelId])}))){const w=c.slice(0,p).reduce((x,_)=>x+u[_.id],0);return{...u,[t]:Mn(100-w)}}return au({delta:v?f-l:l-f,initialLayout:u,panelConstraints:d,pivotIndices:v?[p-1,p]:[p,p+1],prevLayout:u,trigger:"imperative-api"})},a=l=>{const c=s();if(l===c)return;const{defaultLayoutDeferred:u,derivedPanelConstraints:d,group:f,groupSize:p,layout:m,separatorToPanels:v}=n(),w=o({nextSize:l,panels:f.panels,prevLayout:m,derivedPanelConstraints:d}),x=Ro({layout:w,panelConstraints:d});Po(m,x)||Xi(f,{defaultLayoutDeferred:u,derivedPanelConstraints:d,groupSize:p,layout:x,separatorToPanels:v})};return{collapse:()=>{const{collapsible:l,collapsedSize:c}=r(),{mutableValues:u}=i(),d=s();l&&d!==c&&(u.expandToSize=d,a(c))},expand:()=>{const{collapsible:l,collapsedSize:c,minSize:u}=r(),{mutableValues:d}=i(),f=s();if(l&&f===c){let p=d.expandToSize??u;p===0&&(p=1),a(p)}},getSize:()=>{const{group:l}=n(),c=s(),{element:u}=i(),d=l.orientation==="horizontal"?u.offsetWidth:u.offsetHeight;return{asPercentage:c,inPixels:d}},isCollapsed:()=>{const{collapsible:l,collapsedSize:c}=r(),u=s();return l&&Sn(c,u)},resize:l=>{const{group:c}=n(),{element:u}=i(),d=Ja({group:c}),f=rc({groupSize:d,panelElement:u,styleProp:l}),p=Mn(f/d*100);a(p)}}}function HS(e){if(e.defaultPrevented)return;const t=Uo();jy(e,t).forEach(n=>{if(n.separator&&!n.separator.disableDoubleClick){const r=n.panels.find(i=>i.panelConstraints.defaultSize!==void 0);if(r){const i=r.panelConstraints.defaultSize,s=l5({groupId:n.group.id,panelId:r.id});s&&i!==void 0&&(s.resize(i),e.preventDefault())}}})}function ah(e){const t=Uo();for(const[n]of t)if(n.separators.some(r=>r.element===e))return n;throw Error("Could not find parent Group for separator element")}function c5({groupId:e}){const t=()=>{const n=Uo();for(const[r,i]of n)if(r.id===e)return{group:r,...i};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:n,layout:r}=t();return n?{}:r},setLayout(n){const{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:s,groupSize:o,layout:a,separatorToPanels:l}=t(),c=Ro({layout:n,panelConstraints:i});return r?a:(Po(a,c)||Xi(s,{defaultLayoutDeferred:r,derivedPanelConstraints:i,groupSize:o,layout:c,separatorToPanels:l}),c)}}}function eo(e,t){const n=ah(e),r=Ls(n.id,!0),i=n.separators.find(u=>u.element===e);at(i,"Matching separator not found");const s=r.separatorToPanels.get(i);at(s,"Matching panels not found");const o=s.map(u=>n.panels.indexOf(u)),a=c5({groupId:n.id}).getLayout(),l=au({delta:t,initialLayout:a,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:a,trigger:"keyboard"}),c=Ro({layout:l,panelConstraints:r.derivedPanelConstraints});Po(a,c)||Xi(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels},{isUserInteraction:!0})}function US(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=ah(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&eo(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&eo(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&eo(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&eo(t,-5);break}case"End":{e.preventDefault(),eo(t,100);break}case"Enter":{e.preventDefault();const r=ah(t),i=Ls(r.id,!0),{derivedPanelConstraints:s,layout:o,separatorToPanels:a}=i,l=r.separators.find(f=>f.element===t);at(l,"Matching separator not found");const c=a.get(l);at(c,"Matching panels not found");const u=c[0],d=s.find(f=>f.panelId===u.id);if(at(d,"Panel metadata not found"),d.collapsible){const f=o[u.id],p=d.collapsedSize===f?r.mutableState.expandedPanelSizes[u.id]??d.minSize:d.collapsedSize;eo(t,p-f)}break}case"F6":{e.preventDefault();const r=ah(t).separators.map(o=>o.element),i=Array.from(r).findIndex(o=>o===e.currentTarget);at(i!==null,"Index not found");const s=e.shiftKey?i>0?i-1:r.length-1:i+1<r.length?i+1:0;r[s].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),eo(t,-100);break}}}function WS(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=Uo(),n=jy(e,t),r=new Map;let i=!1;n.forEach(s=>{s.separator&&(i||(i=!0,s.separator.element.focus({focusVisible:!1,preventScroll:!0})));const o=t.get(s.group);o&&r.set(s.group,o.layout)}),Oa({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}function u5({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:s,prevCursorFlags:o}){let a=0;n.forEach(c=>{const{group:u,groupSize:d}=c,{orientation:f,panels:p}=u,{disableCursor:m}=u.mutableState;let v=0;s?f==="horizontal"?v=(t.clientX-s.x)/d*100:v=(t.clientY-s.y)/d*100:f==="horizontal"?v=t.clientX<0?-100:100:v=t.clientY<0?-100:100;const w=r.get(u),x=i.get(u);if(!w||!x)return;const{defaultLayoutDeferred:_,derivedPanelConstraints:y,groupSize:S,layout:C,separatorToPanels:k}=x;if(y&&C&&k){const N=au({delta:v,initialLayout:w,panelConstraints:y,pivotIndices:c.panels.map(T=>p.indexOf(T)),prevLayout:C,trigger:"mouse-or-touch"});if(Po(N,C)){if(v!==0&&!m)switch(f){case"horizontal":{a|=v<0?t5:n5;break}case"vertical":{a|=v<0?r5:i5;break}}}else Xi(c.group,{defaultLayoutDeferred:_,derivedPanelConstraints:y,groupSize:S,layout:N,separatorToPanels:k})}});let l=0;t.movementX===0?l|=o&AS:l|=a&AS,t.movementY===0?l|=o&jS:l|=a&jS,mV(l),My(e)}function VS(e){const t=Uo(),n=Io();switch(n.state){case"active":u5({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function qS(e){var r,i;if(e.defaultPrevented)return;const t=Io(),n=Uo();switch(t.state){case"active":{if(e.buttons===0){Oa({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(s=>{const o=Ls(s.group.id,!0);Xi(s.group,o,{isUserInteraction:!0})});return}for(const s of t.hitRegions)if(s.separator){const{element:o}=s.separator;(r=o.hasPointerCapture)!=null&&r.call(o,e.pointerId)||((i=o.setPointerCapture)==null||i.call(o,e.pointerId))}u5({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const s=jy(e,n);s.length===0?t.state!=="inactive"&&Oa({cursorFlags:0,state:"inactive"}):Oa({cursorFlags:0,hitRegions:s,state:"hover"}),My(e.currentTarget);break}}}function KS(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(Io().state){case"hover":Oa({cursorFlags:0,state:"inactive"})}}function GS(e){e.defaultPrevented||e.pointerType==="mouse"&&e.button>0||o5(e.currentTarget)&&e.preventDefault()}function YS(e){let t=0,n=0;const r={};for(const s of e)if(s.defaultSize!==void 0){t++;const o=Mn(s.defaultSize);n+=o,r[s.panelId]=o}else r[s.panelId]=void 0;const i=e.length-t;if(i!==0){const s=Mn((100-n)/i);for(const o of e)o.defaultSize===void 0&&(r[o.panelId]=s)}return r}function TV(e,t,n){if(!n[0])return;const r=e.panels.find(l=>l.element===t);if(!r||!r.onResize)return;const i=Ja({group:e}),s=e.orientation==="horizontal"?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,a={asPercentage:Mn(s/i*100),inPixels:s};r.mutableValues.prevSize=a,r.onResize(a,r.id,o)}function IV(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function PV({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,s=0,o=!1;const a=new Map,l=[];for(const d of e.panels){const f=r[d.id]??0;switch(d.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{o=!0;const p=f/100*n,m=Mn(p/t*100);a.set(d.id,m),i+=m;break}case"preserve-relative-size":default:{l.push(d.id),s+=f;break}}}if(!o||l.length===0)return r;const c=100-i,u={...r};if(a.forEach((d,f)=>{u[f]=d}),s>0)for(const d of l){const f=r[d]??0;u[d]=Mn(f/s*c)}else{const d=Mn(c/l.length);for(const f of l)u[f]=d}return u}function RV(e,t){const n=e.map(i=>i.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n)if(!r.includes(i))return!1;return!0}const ia=new Map;function MV(e){let t=!0;at(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,s=new n(m=>{for(const v of m){const{borderBoxSize:w,target:x}=v;if(x===e.element){if(t){const _=Ja({group:e});if(_===0)return;const y=Ls(e.id);if(!y)return;const S=R0(e),C=y.defaultLayoutDeferred?YS(S):y.layout,k=PV({group:e,nextGroupSize:_,prevGroupSize:y.groupSize,prevLayout:C}),N=Ro({layout:k,panelConstraints:S});if(!y.defaultLayoutDeferred&&Po(y.layout,N)&&IV(y.derivedPanelConstraints,S)&&y.groupSize===_)return;Xi(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:S,groupSize:_,layout:N,separatorToPanels:y.separatorToPanels})}}else TV(e,x,w)}});s.observe(e.element),e.panels.forEach(m=>{at(!r.has(m.id),`Panel ids must be unique; id "${m.id}" was used more than once`),r.add(m.id),m.onResize&&s.observe(m.element)});const o=Ja({group:e}),a=R0(e),l=e.panels.map(({id:m})=>m).join(",");let c=e.mutableState.defaultLayout;c&&(RV(e.panels,c)||(c=void 0));const u=e.mutableState.layouts[l]??c??YS(a),d=Ro({layout:u,panelConstraints:a}),f=e.element.ownerDocument;ia.set(f,(ia.get(f)??0)+1);const p=new Map;return JR(e).forEach(m=>{m.separator&&p.set(m.separator,m.panels)}),Xi(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:a,groupSize:o,layout:d,separatorToPanels:p}),e.separators.forEach(m=>{at(!i.has(m.id),`Separator ids must be unique; id "${m.id}" was used more than once`),i.add(m.id),m.element.addEventListener("keydown",US)}),ia.get(f)===1&&(f.addEventListener("contextmenu",BS,!0),f.addEventListener("dblclick",HS,!0),f.addEventListener("pointerdown",WS,!0),f.addEventListener("pointerleave",VS),f.addEventListener("pointermove",qS),f.addEventListener("pointerout",KS),f.addEventListener("pointerup",GS,!0)),function(){t=!1,ia.set(f,Math.max(0,(ia.get(f)??0)-1)),xV(e),e.separators.forEach(m=>{m.element.removeEventListener("keydown",US)}),ia.get(f)||(f.removeEventListener("contextmenu",BS,!0),f.removeEventListener("dblclick",HS,!0),f.removeEventListener("pointerdown",WS,!0),f.removeEventListener("pointerleave",VS),f.removeEventListener("pointermove",qS),f.removeEventListener("pointerout",KS),f.removeEventListener("pointerup",GS,!0)),s.disconnect()}}function AV(){const[e,t]=g.useState({}),n=g.useCallback(()=>t({}),[]);return[e,n]}function Ly(e){const t=g.useId();return`${e??t}`}const Wo=typeof window<"u"?g.useLayoutEffect:g.useEffect;function Sc(e){const t=g.useRef(e);return Wo(()=>{t.current=e},[e]),g.useCallback((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[t])}function Dy(...e){return Sc(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function Oy(e){const t=g.useRef({...e});return Wo(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const d5=g.createContext(null);function jV(e,t){const n=g.useRef({getLayout:()=>({}),setLayout:gV});g.useImperativeHandle(t,()=>n.current,[]),Wo(()=>{Object.assign(n.current,c5({groupId:e}))})}function By({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:s,groupRef:o,id:a,onLayoutChange:l,onLayoutChanged:c,orientation:u="horizontal",resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){const m=g.useRef({onLayoutChange:{},onLayoutChanged:{}}),v=Sc(O=>{Po(m.current.onLayoutChange,O)||(m.current.onLayoutChange=O,l==null||l(O))}),w=Sc((O,R)=>{Po(m.current.onLayoutChanged,O)||(m.current.onLayoutChanged=O,c==null||c(O,{isUserInteraction:R}))}),x=Ly(a),_=g.useRef(null),[y,S]=AV(),C=g.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),k=Dy(_,s);jV(x,o);const N=Sc((O,R)=>{const M=Io(),A=OS(O),L=Ls(O);if(L){let $=!1;switch(M.state){case"active":{$=M.hitRegions.some(F=>F.group===A);break}}return{flexGrow:L.layout[R]??1,pointerEvents:$?"none":void 0}}if(n!=null&&n[R])return{flexGrow:n==null?void 0:n[R]}}),T=Oy({defaultLayout:n,disableCursor:r}),D=g.useMemo(()=>({get disableCursor(){return!!T.disableCursor},getPanelStyles:N,id:x,orientation:u,registerPanel:O=>{const R=C.current;return R.panels=M0(u,[...R.panels,O]),S(),()=>{R.panels=R.panels.filter(M=>M!==O),S()}},registerSeparator:O=>{const R=C.current;return R.separators=M0(u,[...R.separators,O]),S(),()=>{R.separators=R.separators.filter(M=>M!==O),S()}},updatePanelProps:(O,{disabled:R})=>{const M=C.current.panels.find($=>$.id===O);M&&(M.panelConstraints.disabled=R);const A=OS(x),L=Ls(x);A&&L&&Xi(A,{...L,derivedPanelConstraints:R0(A)})},updateSeparatorProps:(O,{disabled:R,disableDoubleClick:M})=>{const A=C.current.separators.find(L=>L.id===O);A&&(A.disabled=R,A.disableDoubleClick=M)}}),[N,x,S,u,T]),P=g.useRef(null);return Wo(()=>{const O=_.current;if(O===null)return;const R=C.current;let M;if(T.defaultLayout!==void 0&&Object.keys(T.defaultLayout).length===R.panels.length){M={};for(const E of R.panels){const H=T.defaultLayout[E.id];H!==void 0&&(M[E.id]=H)}}const A={disabled:!!i,element:O,id:x,mutableState:{defaultLayout:M,disableCursor:!!T.disableCursor,expandedPanelSizes:C.current.lastExpandedPanelSizes,layouts:C.current.layouts},orientation:u,panels:R.panels,resizeTargetMinimumSize:R.resizeTargetMinimumSize,separators:R.separators};P.current=A;const L=MV(A),{defaultLayoutDeferred:$,derivedPanelConstraints:F,layout:B}=Ls(A.id,!0);!$&&F.length>0&&(v(B),w(B,!1));const z=Ay(x,E=>{const{defaultLayoutDeferred:H,derivedPanelConstraints:q,layout:j}=E.next;if(H||q.length===0)return;const re=A.panels.map(({id:K})=>K).join(",");A.mutableState.layouts[re]=j,q.forEach(K=>{if(K.collapsible){const{layout:xe}=E.prev??{};if(xe){const Ee=Sn(K.collapsedSize,j[K.panelId]),ue=Sn(K.collapsedSize,xe[K.panelId]);Ee&&!ue&&(A.mutableState.expandedPanelSizes[K.panelId]=xe[K.panelId])}}});const ie=Io().state!=="active";v(j),ie&&w(j,E.isUserInteraction)});return()=>{P.current=null,L(),z()}},[i,x,w,v,u,y,T]),g.useEffect(()=>{const O=P.current;O&&(O.mutableState.defaultLayout=n,O.mutableState.disableCursor=!!r)}),h.jsx(d5.Provider,{value:D,children:h.jsx("div",{...p,className:t,"data-group":!0,"data-testid":x,id:x,ref:k,style:{height:"100%",width:"100%",overflow:"hidden",...f,display:"flex",flexDirection:u==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:u==="horizontal"?"pan-y":"pan-x"},children:e})})}By.displayName="Group";function zy(){const e=g.useContext(d5);return at(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function LV(e,t){const{id:n}=zy(),r=g.useRef({collapse:Gm,expand:Gm,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Gm});g.useImperativeHandle(t,()=>r.current,[]),Wo(()=>{Object.assign(r.current,l5({groupId:n,panelId:e}))})}function df({children:e,className:t,collapsedSize:n="0%",collapsible:r=!1,defaultSize:i,disabled:s,elementRef:o,groupResizeBehavior:a="preserve-relative-size",id:l,maxSize:c="100%",minSize:u="0%",onResize:d,panelRef:f,style:p,...m}){const v=!!l,w=Ly(l),x=Oy({disabled:s}),_=g.useRef(null),y=Dy(_,o),{getPanelStyles:S,id:C,orientation:k,registerPanel:N,updatePanelProps:T}=zy(),D=d!==null,P=Sc((A,L,$)=>{d==null||d(A,l,$)});Wo(()=>{const A=_.current;if(A!==null){const L={element:A,id:w,idIsStable:v,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:D?P:void 0,panelConstraints:{groupResizeBehavior:a,collapsedSize:n,collapsible:r,defaultSize:i,disabled:x.disabled,maxSize:c,minSize:u}};return N(L)}},[a,n,r,i,D,w,v,c,u,P,N,x]),g.useEffect(()=>{T(w,{disabled:s})},[s,w,T]),LV(w,f);const O=()=>{const A=S(C,w);if(A)return JSON.stringify(A)},R=g.useSyncExternalStore(A=>Ay(C,A),O,O);let M;return R?M=JSON.parse(R):i!==void 0?M={flexGrow:void 0,flexShrink:void 0,flexBasis:i}:M={flexGrow:1},h.jsx("div",{...m,"data-disabled":s||void 0,"data-panel":!0,"data-testid":w,id:w,ref:y,style:{...DV,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...M},children:h.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...p,touchAction:k==="horizontal"?"pan-y":"pan-x"},children:e})})}df.displayName="Panel";const DV={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function OV({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,s;const o=e[n],a=t.find(l=>l.panelId===n);if(a){const l=a.maxSize,c=a.collapsible?a.collapsedSize:a.minSize,u=[r,r+1];s=Ro({layout:au({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=Ro({layout:au({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:s,valueNow:o}}function h5({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:s,style:o,...a}){const l=Ly(s),c=Oy({disabled:n,disableDoubleClick:r}),[u,d]=g.useState({}),[f,p]=g.useState("inactive"),[m,v]=g.useState(!1),w=g.useRef(null),x=Dy(w,i),{disableCursor:_,id:y,orientation:S,registerSeparator:C,updateSeparatorProps:k}=zy(),N=S==="horizontal"?"vertical":"horizontal";Wo(()=>{const P=w.current;if(P!==null){const O={disabled:c.disabled,disableDoubleClick:c.disableDoubleClick,element:P,id:l},R=C(O),M=pV(L=>{p(L.next.state!=="inactive"&&L.next.hitRegions.some($=>$.separator===O)?L.next.state:"inactive")}),A=Ay(y,L=>{const{derivedPanelConstraints:$,layout:F,separatorToPanels:B}=L.next,z=B.get(O);if(z){const E=z[0],H=z.indexOf(E);d(OV({layout:F,panelConstraints:$,panelId:E.id,panelIndex:H}))}});return()=>{M(),A(),R()}}},[y,l,C,c]),g.useEffect(()=>{k(l,{disabled:n,disableDoubleClick:r})},[n,r,l,k]);let T;n&&!_&&(T="not-allowed");let D;if(n)D="disabled";else switch(f){case"active":{D="active";break}default:m?D="focus":D=f}return h.jsx("div",{...a,"aria-controls":u.valueControls,"aria-disabled":n||void 0,"aria-orientation":N,"aria-valuemax":u.valueMax,"aria-valuemin":u.valueMin,"aria-valuenow":u.valueNow,children:e,className:t,"data-separator":D,"data-testid":l,id:l,onBlur:()=>v(!1),onFocus:()=>v(!0),ref:x,role:"separator",style:{flexBasis:"auto",cursor:T,...o,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}h5.displayName="Separator";function BV(e){if(!e)return;const t=e.contextUsage,n=e.contextWindowSize;if(!t||!n||n<=0)return;const r=t.inputTokens+(t.cacheReadTokens??0)+(t.cacheCreateTokens??0);if(!(r<=0))return Math.round(r/n*100)}function f5(e,t){const n=zo(),r=e?`session/${e}`:"",i=pi(r)??Jc,s=g.useCallback(d=>{!e||!r||n.setData(r,f=>pI(f??Jc,d,e))},[n,r,e]),o=g.useCallback(()=>{e&&s({type:"session:change",sessionId:e})},[s,e]),a=g.useCallback(d=>{e&&s({type:"permission:clear",sessionId:e,requestId:d})},[s,e]),l=g.useCallback(d=>{e&&s({type:"permission:request",sessionId:e,requestId:d.requestId,tool:d.tool,input:d.input,...d.toolUseId?{toolUseId:d.toolUseId}:{}})},[s,e]),c=g.useCallback(d=>{e&&s({type:"session:question:clear",sessionId:e,toolUseId:d})},[s,e]),u=g.useCallback((d,f)=>{e&&s({type:"session:question:submitted",sessionId:e,toolUseId:d,answers:f})},[s,e]);return{...i,reset:o,clearPermission:a,restorePermission:l,clearQuestion:c,markQuestionSubmitted:u}}function zV(e){return e.kind!=="user-text"?!1:e.meta===void 0||e.meta==="slash-command"||ap(e.meta)}function $V(e,t={}){let n=0;if(t.implicitCloseOnUserText){for(const r of e)zV(r)&&n++;return n}for(const r of e)r.kind==="turn-end"&&n++;return n}const FV=50;function HV({api:e,sessionId:t,toolSessionId:n,initialTurns:r,implicitCloseOnUserText:i,pageSize:s=FV}){const[o,a]=g.useState({messages:[],total:0,loading:!1,error:null}),l=g.useRef(n),c=g.useRef(null),u=g.useRef(0),d=g.useRef(!0);return g.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]),g.useEffect(()=>{const f=l.current;if(l.current=n,!(c.current!==t)&&!(typeof f=="string"&&f!==n))return;if(a({messages:[],total:0,loading:!1,error:null}),!t){c.current=null;return}c.current=t;const v=++u.current;a(w=>({...w,loading:!0,error:null})),(async()=>{let w=[],x=!1,_=r===void 0?{}:{limit:s},y=Number.POSITIVE_INFINITY;for(;;){let S;try{S=await e.historyRead({sessionId:t,..._})}catch(O){if(v!==u.current||!d.current)return;const R=O.message??"history load failed";a(x?M=>({...M,error:R}):{messages:[],total:0,loading:!1,error:R});return}if(v!==u.current||!d.current)return;w=[...S.messages??[],...w];const C=S.total??0,k=typeof S.offset=="number"?S.offset:0,N=k>=y,T=k<=0||N;y=k;const D=r!==void 0&&$V(w,{implicitCloseOnUserText:i})>=r;if(x?a({messages:w,total:C,loading:!1,error:null}):(T||D)&&(x=!0,a({messages:w,total:C,loading:!1,error:null})),T)return;const P=Math.max(0,k-s);_={offset:P,limit:k-P}}})()},[e,t,n,s,r]),o}const UV=["TaskCreate","TaskUpdate","TaskList","TaskGet"];function WV(e){return UV.includes(e)}function p5(e){return e==="in_progress"||e==="completed"?e:"pending"}function VV(e,t){if(!t||typeof t!="object")return e;const n=t,r=typeof n.subject=="string"&&n.subject?n.subject:typeof n.content=="string"&&n.content?n.content:null;if(!r)return e;const i=typeof n.activeForm=="string"?n.activeForm:void 0,s=typeof n.description=="string"?n.description:void 0;return[...e,{id:String(e.length+1),content:r,status:p5(n.status),activeForm:i,description:s}]}function qV(e,t){if(!t||typeof t!="object")return e;const n=t,r=typeof n.taskId=="string"&&n.taskId?n.taskId:typeof n.id=="string"&&n.id?n.id:null;if(!r)return e;const i=e.findIndex(a=>a.id===r);if(i<0)return e;const s=[...e],o={...s[i]};return"status"in n&&(o.status=p5(n.status)),typeof n.subject=="string"&&(o.content=n.subject),typeof n.content=="string"&&(o.content=n.content),typeof n.activeForm=="string"&&(o.activeForm=n.activeForm),typeof n.description=="string"&&(o.description=n.description),s[i]=o,s}function KV(e){let t=[],n=-1;for(let r=0;r<e.length;r++){const i=e[r];if(i.kind==="task-event")switch(n=r,i.name){case"TaskCreate":t=VV(t,i.input);break;case"TaskUpdate":t=qV(t,i.input);break}}return{tasks:t,lastEventIndex:n}}function GV(e){return e==="TodoWrite"}function YV(e){if(!e||typeof e!="object")return null;const t=e;if(!Array.isArray(t.todos))return null;const n=[];for(const r of t.todos){if(!r||typeof r!="object")continue;const i=r,s=typeof i.content=="string"?i.content:"";if(!s)continue;const o=i.status==="in_progress"||i.status==="completed"?i.status:"pending",a=typeof i.activeForm=="string"?i.activeForm:void 0;n.push({content:s,status:o,activeForm:a})}return n}function XV(e,t,n){var s;const r=[],i=new Map;for(let o=0;o<e.length;o++){const a=e[o],l=typeof a.seq=="number"?a.seq:o;switch(a.kind){case"session_init":r.push({kind:"session-init",seq:l,toolSessionId:a.toolSessionId});break;case"text":XS(r,l,"assistant-text",a.text,a.partialId,a.uuid);break;case"thinking":XS(r,l,"assistant-thinking",a.text,a.partialId);break;case"user_text":{a.meta==="task-notification"?r.push({kind:"agent-notification",seq:l,text:a.text,taskId:a.taskId,parentToolUseId:a.parentToolUseId}):a.meta?r.push({kind:"user-meta",seq:l,metaKind:a.meta,text:a.text}):r.push({kind:"user-text",seq:l,text:a.text,uuid:a.uuid,...a.sender&&(a.sender.principal!=="owner"||aI.test(a.text))?{senderDisplayName:a.sender.displayName}:{},senderPrincipal:((s=a.sender)==null?void 0:s.principal)==="guest"?"guest":"owner"});break}case"tool_call":m5(r,l,a.toolUseId,a.tool,a.input,a.toolKind);break;case"tool_result":{const c=i.get(a.toolUseId);if(c!==void 0){if(a.askQuestionAnswers){const d=r[c];d.submittedAnswers=a.askQuestionAnswers}i.delete(a.toolUseId);break}const u={kind:"tool-result",seq:l,toolUseId:a.toolUseId,output:a.output,error:a.error};a.toolResultExtra&&(u.toolResultExtra=a.toolResultExtra),r.push(u);break}case"attachment_memories":r.push({kind:"memory-callout",seq:l,memories:a.memories});break;case"permission_request":{if(!t||a.requestId!==t)break;r.push({kind:"permission-inline",seq:l,requestId:a.requestId,tool:a.tool,input:a.input});break}case"ask_user_question":i.set(a.toolUseId,r.length),r.push({kind:"question-card",seq:l,toolUseId:a.toolUseId,questions:a.questions});break;case"turn_end":{const c={kind:"turn-end",seq:l};a.durationMs!==void 0&&(c.durationMs=a.durationMs),a.reason!==void 0&&(c.reason=a.reason),r.push(c);break}case"subagent_progress":{const c={kind:"agent-progress",seq:l,toolUseId:a.toolUseId,agentId:a.agentId,status:a.status};a.description&&(c.description=a.description),a.lastToolName&&(c.lastToolName=a.lastToolName),a.prompt&&(c.prompt=a.prompt),a.stats&&(c.stats=a.stats),r.push(c);break}case"error":r.push({kind:"error",seq:l,message:a.message});break}}return r}function m5(e,t,n,r,i,s){if(GV(r)){const o=YV(i);if(o){e.push({kind:"todo-checklist",seq:t,toolUseId:n,todos:o});return}}if(r==="Agent"){const o=i??{},a=typeof o.description=="string"&&o.description?o.description:typeof o.subagent_type=="string"&&o.subagent_type?o.subagent_type:"Subagent";e.push({kind:"agent-call",seq:t,toolUseId:n,description:a,input:i});return}if(WV(r)){e.push({kind:"task-event",seq:t,toolUseId:n,name:r,input:i});return}e.push({kind:"tool-call",seq:t,toolUseId:n,tool:r,toolKind:s,input:i})}function XS(e,t,n,r,i,s){let o=-1;for(let c=e.length-1;c>=0;c--)if(e[c].kind===n){o=c;break}const a=o>=0?e[o]:null;if(i){if(a&&a.partialId===i){const u=n==="assistant-text"?{kind:n,seq:a.seq,text:a.text+r,partialId:i,...s?{uuid:s}:{}}:{kind:n,seq:a.seq,text:a.text+r,partialId:i};e[o]=u;return}const c=n==="assistant-text"?{kind:n,seq:t,text:r,partialId:i,...s?{uuid:s}:{}}:{kind:n,seq:t,text:r,partialId:i};e.push(c);return}if(a&&a.partialId){const c=n==="assistant-text"?{kind:n,seq:a.seq,text:r,...s?{uuid:s}:{}}:{kind:n,seq:a.seq,text:r};e[o]=c;return}const l=n==="assistant-text"?{kind:n,seq:t,text:r,...s?{uuid:s}:{}}:{kind:n,seq:t,text:r};e.push(l)}const QV="AskUserQuestion";function g5(e,t=0,n){var o;const r=[],i=new Map;let s=t;for(const a of e){const l=s++,c=a.toolUseId??`hist-${l}`;switch(a.kind){case"user-text":if(a.meta==="task-notification")r.push({kind:"agent-notification",seq:l,text:a.text??"",taskId:a.taskId,parentToolUseId:a.parentToolUseId});else if(a.meta)r.push({kind:"user-meta",seq:l,metaKind:a.meta,text:a.text??""});else{const u=aI.exec(a.text??""),d=(o=pz.exec(a.text??""))==null?void 0:o[1],f=(u==null?void 0:u[2])??d,p=(u==null?void 0:u[1])==="guest"||d?"guest":"owner";r.push({kind:"user-text",seq:l,text:a.text??"",uuid:a.uuid,...f?{senderDisplayName:f}:{},senderPrincipal:p})}break;case"assistant-text":r.push({kind:"assistant-text",seq:l,text:a.text??"",uuid:a.uuid});break;case"tool_call":{if(a.tool===QV){const u=a.input??{},d=Array.isArray(u.questions)?u.questions:[];i.set(c,r.length),r.push({kind:"question-card",seq:l,toolUseId:c,questions:d});break}m5(r,l,c,a.tool??"",a.input,n);break}case"tool_result":{const u=i.get(c);if(u!==void 0){if(a.askQuestionAnswers){const f=r[u];f.submittedAnswers=a.askQuestionAnswers}i.delete(c);break}const d={kind:"tool-result",seq:l,toolUseId:c,output:a.output};a.error!==void 0&&(d.error=a.error),a.toolResultExtra&&(d.toolResultExtra=a.toolResultExtra),r.push(d);break}case"attachment_memories":a.memories&&a.memories.length>0&&r.push({kind:"memory-callout",seq:l,memories:a.memories});break;case"summary":break;case"turn-end":{const u={kind:"turn-end",seq:l};typeof a.durationMs=="number"&&(u.durationMs=a.durationMs),r.push(u);break}}}return r}const ZV=5e5;function JV(e){const t=ZV-e.length;return e.map(n=>({...n,seq:n.seq+t}))}const eq=/<command-name>([\s\S]*?)<\/command-name>/i,tq=/<command-message>([\s\S]*?)<\/command-message>/i,nq=/<command-args>([\s\S]*?)<\/command-args>/i,rq=/<(local-command-[a-z]+|command-(?:stdout|stderr))>[\s\S]*?<\/\1>/gi;function Ip(e){if(!e)return{commandName:null,commandMessage:null,commandArgs:null,body:""};const t=e.match(eq),n=e.match(tq),r=e.match(nq);let i=e;return t&&(i=i.replace(t[0],"")),n&&(i=i.replace(n[0],"")),r&&(i=i.replace(r[0],"")),i=i.replace(rq,""),i=i.trim(),{commandName:t?t[1].trim():null,commandMessage:n?n[1].trim():null,commandArgs:r?r[1].trim():null,body:i}}function QS(e){const t=Ip(e);return t.commandName?t.commandArgs?`${t.commandName} ${t.commandArgs}`:t.commandName:e}function ZS(e){return e.kind==="user-text"?!0:e.kind!=="user-meta"?!1:e.metaKind==="slash-command"||ap(e.metaKind)}function iq(e,t){const n=t.find(ZS);if(!n)return e;const r=QS(n.text);for(let s=e.length-1;s>=0;s--){const o=e[s];if(ZS(o)&&QS(o.text)===r)return e.slice(0,s)}const i=e[e.length-1];return i!==void 0&&i.kind!=="turn-end"?[...e,{kind:"turn-end",seq:i.seq+1}]:e}function sq(e){return e==="running"||e==="observing"}function v5(e){return e==="running"||e==="running-idle"||e==="observing"}const oq=1e6,aq=5;function x5(e){const t=yi(),n=g.useMemo(()=>new Q_(t),[t]),r=pi("sessions"),i=g.useMemo(()=>r==null?void 0:r.find(E=>E.sessionId===e),[r,e]),s=i==null?void 0:i.toolSessionId,o=i==null?void 0:i.tool,a=f5(e),{events:l,pendingPermissions:c,queued:u,status:d,clearPermission:f,restorePermission:p}=a,m=Uz(),v=HV({api:n,sessionId:e,toolSessionId:s,initialTurns:m==="owner"?void 0:aq,implicitCloseOnUserText:o==="codex"}),w=g.useMemo(()=>v.messages.filter(E=>!E.isSidechain),[v.messages]),x=g.useMemo(()=>JV(g5(w,0,o)),[w,o]),_=c[0]??null,y=g.useMemo(()=>XV(l,(_==null?void 0:_.requestId)??null),[l,_==null?void 0:_.requestId]),S=g.useMemo(()=>iq(x,y),[x,y]),C=g.useMemo(()=>y.map((E,H)=>({...E,seq:oq+H})),[y]),k=g.useMemo(()=>[...S,...C],[S,C]),N=v5(d),T=sq(d),D=(i==null?void 0:i.resolvedModel)??(i==null?void 0:i.model),P=g.useMemo(()=>({sessionLabel:(i==null?void 0:i.label)||(i==null?void 0:i.aiLabel)||(i==null?void 0:i.larkChatName)||(i==null?void 0:i.larkChatId)||e,sessionId:e,...i!=null&&i.larkChatId?{larkChatName:i.larkChatName??i.larkChatId,larkChatType:i.larkChatType??"group"}:{},...D?{model:D}:{},...(()=>{const E=i==null?void 0:i.gitBranch;return E?{gitBranch:E}:{}})(),...(()=>{const E=BV(i);return E!==void 0?{contextPct:E}:{}})(),...i!=null&&i.cwd?{cwd:i.cwd}:{},...(()=>{const E=i==null?void 0:i.permissionMode;return E?{permissionMode:E}:{}})(),procAlive:N,streamInProgress:T,pinnedAt:(i==null?void 0:i.pinnedAt)??null}),[i,e,D,N,T]),O=g.useMemo(()=>t.isOpen?d==="error"?{kind:"error",message:"session error"}:{kind:"ready"}:{kind:"closed"},[t.isOpen,d]),R=g.useCallback(async(E,H)=>{await n.sessionSend(e,E,H)},[n,e]),M=g.useCallback(async E=>{await n.sessionDequeue(e,E)},[n,e]),A=g.useCallback(async()=>(await n.sessionInterrupt(e)).queued??[],[n,e]),L=g.useCallback(async E=>{if(!(i!=null&&i.cwd)||!s)throw new Error("fork requires sessionFile with cwd + toolSessionId");await n.sessionFork({cwd:i.cwd,toolSessionId:s,messageUuid:E})},[n,i==null?void 0:i.cwd,s]),$=g.useCallback(async E=>{await n.sessionRewind({sessionId:e,userMessageId:E,dryRun:!1})},[n,e]),F=g.useCallback(async E=>{await n.sessionUpdate(e,{model:E})},[n,e]),B=g.useCallback(async()=>{await n.sessionNew(e)},[n,e]),z=g.useCallback(async(E,H)=>{const q=c.find(j=>j.requestId===E);q&&f(E);try{await n.permissionRespond({sessionId:e,permissionRequestId:E,allow:H==="allow"})}catch(j){throw!((j==null?void 0:j.message)??"").startsWith("PERMISSION_REQUEST_STALE")&&q&&p(q),j}},[n,e,c,f,p]);return g.useMemo(()=>({lines:k,connState:O,meta:P,historyLoading:v.loading,historyError:v.error,pendingPermissions:c,queued:u,sendText:R,dequeue:M,interrupt:A,fork:L,rewind:$,switchModel:F,clearSession:B,respondPermission:z}),[k,O,P,v.loading,v.error,c,u,R,M,A,L,$,F,B,z])}function lq(e,t,n,r=!0){const i=g.useRef({sid:null,tsid:void 0});g.useEffect(()=>{const s=i.current;i.current={sid:t,tsid:n},!(!r||!n||s.sid===t&&(s.tsid===void 0||s.tsid===null)&&typeof n=="string")&&e.sessionObserve({sessionId:t,toolSessionId:n}).catch(()=>{})},[e,t,n,r])}function cq(e,t,n){const r=g.useRef(e),i=g.useRef(t),s=g.useRef(n);s.current=n,g.useEffect(()=>{const o=r.current,a=i.current;r.current=e,i.current=t;const l=o!==e,c=typeof a=="string"&&t==null;!l&&!c||s.current()},[e,t])}const uq=/^Scheduled (?:recurring job|one-shot task) ([0-9a-f]{8}) \(([^)]+)\)/;function dq(e){const t=new Map,n=new Map,r=new Map;for(const i of e)if(i.kind==="tool_call"&&i.tool==="CronCreate"){const s=i.input;if(!s||typeof s.cron!="string"||typeof s.prompt!="string")continue;const o=i.ts;t.set(i.toolUseId,{cron:s.cron,prompt:s.prompt,recurring:s.recurring!==!1,ts:typeof o=="string"?o:"",toolUseId:i.toolUseId})}else if(i.kind==="tool_call"&&i.tool==="CronDelete"){const s=i.input;if(!s||typeof s.id!="string")continue;n.set(i.toolUseId,s.id)}else if(i.kind==="tool_result"){const s=t.get(i.toolUseId);if(s){if(t.delete(i.toolUseId),i.error||typeof i.output!="string")continue;const a=i.output.match(uq);if(!a)continue;r.set(a[1],{id:a[1],cron:s.cron,prompt:s.prompt,recurring:s.recurring,humanSchedule:a[2],createdAt:s.ts,toolUseId:s.toolUseId});continue}const o=n.get(i.toolUseId);o!==void 0&&(n.delete(i.toolUseId),i.error||r.delete(o))}return Array.from(r.values()).sort((i,s)=>i.createdAt.localeCompare(s.createdAt))}function _5(e){var n;if(e.error)return!1;if(e.pending)return!0;if(e.notifications.length>0)return!1;const t=(n=e.progress)==null?void 0:n.status;return t==="running"?!0:t==="started"?hq(e.input):!1}function hq(e){return!e||typeof e!="object"?!1:e.run_in_background===!0}function fq(e){return e.filter(t=>t.kind==="merged-agent"&&_5(t))}function y5(e){var d;const{tasks:t,lastEventIndex:n}=KV(e);let r=-1;for(let f=e.length-1;f>=0;f--)if(e[f].kind==="todo-checklist"){r=f;break}const i=[],s=new Map,o=new Map,a=new Map,l=new Map,c=new Map,u=(f,p)=>{var _,y,S,C,k,N;const m=i[f],v=c.get(f),w=v!==void 0&&v!==p.toolUseId;if(!w&&(((_=m.progress)==null?void 0:_.status)==="completed"||((y=m.progress)==null?void 0:y.status)==="failed"))return;if(c.set(f,p.toolUseId),l.set(p.agentId,f),w&&(m.pending=!0,(S=m.toolResultExtra)!=null&&S.stats)){const{stats:T,...D}=m.toolResultExtra;m.toolResultExtra=D}const x={agentId:p.agentId,status:p.status};p.description?x.description=p.description:(C=m.progress)!=null&&C.description&&(x.description=m.progress.description),p.lastToolName?x.lastToolName=p.lastToolName:!w&&((k=m.progress)!=null&&k.lastToolName)&&(x.lastToolName=m.progress.lastToolName),p.stats?x.stats=p.stats:!w&&((N=m.progress)!=null&&N.stats)&&(x.stats=m.progress.stats),m.progress=x,(p.status==="completed"||p.status==="failed")&&(m.pending=!1)};for(let f=0;f<e.length;f++){const p=e[f];switch(p.kind){case"tool-call":{const m={kind:"merged-tool",seq:p.seq,tool:p.tool,toolKind:p.toolKind,toolUseId:p.toolUseId,input:p.input,pending:!0};s.set(p.toolUseId,i.length),i.push(m);break}case"tool-result":{const m=s.get(p.toolUseId);if(m!==void 0){const w=i[m];w.output=p.output,w.error=p.error,w.pending=!1,s.delete(p.toolUseId);break}const v=o.get(p.toolUseId);if(v!==void 0){const w=i[v];w.output=p.output,w.error=p.error,w.pending=!1,p.toolResultExtra&&(w.toolResultExtra=p.toolResultExtra),(d=p.toolResultExtra)!=null&&d.agentId&&(l.set(p.toolResultExtra.agentId,v),c.set(v,p.toolUseId));break}break}case"agent-call":{const m={kind:"merged-agent",seq:p.seq,toolUseId:p.toolUseId,description:p.description,input:p.input,pending:!0,notifications:[]},v=i.length;o.set(p.toolUseId,v),i.push(m);const w=a.get(p.toolUseId);w&&(u(v,w),a.delete(p.toolUseId));break}case"agent-progress":{const m=o.get(p.toolUseId)??l.get(p.agentId);if(m!==void 0){u(m,p);break}const v=a.get(p.toolUseId);if((v==null?void 0:v.status)==="completed"||(v==null?void 0:v.status)==="failed")break;a.set(p.toolUseId,p);break}case"agent-notification":{const m=(p.parentToolUseId?o.get(p.parentToolUseId):void 0)??(p.taskId?l.get(p.taskId):void 0);if(m!==void 0){i[m].notifications.push({text:p.text,taskId:p.taskId});break}i.push({kind:"agent-notification",seq:p.seq,text:p.text,taskId:p.taskId,parentToolUseId:p.parentToolUseId});break}case"todo-checklist":{f===r&&p.todos.length>0&&i.push({kind:"todo-checklist",seq:p.seq,toolUseId:p.toolUseId,todos:p.todos});break}case"task-event":{f===n&&t.length>0&&i.push({kind:"plan-card",seq:p.seq,tasks:t});break}default:i.push(p)}}return i}const pq=new Set(["permission-inline","question-card"]);function mq(e){return e.kind==="user-text"?!0:e.kind!=="user-meta"?!1:e.metaKind==="slash-command"||ap(e.metaKind)}function gq(e){return e.kind==="user-text"&&e.continuesTurn===!0}function vq(e,t={}){const n=[];let r=null;const i=(s,o)=>{r&&(n.push(xq(r,s,o)),r=null)};for(const s of e){if(s.kind==="turn-end"){i(s,!0);continue}if(mq(s)&&(r===null||!gq(s))){i(void 0,!0),r={query:s,body:[]};continue}r===null?r={body:[s]}:r.body.push(s)}return i(void 0,t.closeTrailing===!0),n}function xq(e,t,n){const{query:r,body:i}=e,s=_q(i,t,n),o=yq(i,s),a=wq(i,o),l=r??i[0]??t,c={kind:"turn",seq:l?l.seq:0,status:s,process:a,tail:o};return r&&(c.query=r),(t==null?void 0:t.durationMs)!==void 0&&(c.durationMs=t.durationMs),c}function _q(e,t,n){if(!n)return"running";if((t==null?void 0:t.reason)==="interrupted")return"interrupted";const r=A0(e,i=>i.kind==="error");return r>=0&&!e.slice(r+1).some(s=>s.kind==="assistant-text")?"error":"done"}function yq(e,t){if(t==="running"){const r=[];for(let i=e.length-1;i>=0&&pq.has(e[i].kind);i--)r.unshift(e[i]);return r}const n=t==="error"?A0(e,r=>r.kind==="error"):A0(e,r=>r.kind==="assistant-text");return n>=0?[e[n]]:[]}const bq=new Set(["assistant-thinking","user-meta"]);function wq(e,t){const n=new Set(t),r=[];let i=null;const s=()=>{i&&(r.push({kind:"tool-group",seq:i[0].seq,items:i}),i=null)};for(const o of e){if(n.has(o)){s();continue}if(o.kind==="merged-tool"){i?i.push(o):i=[o];continue}if(bq.has(o.kind)){r.push(o);continue}s(),r.push(o)}return s(),r}function A0(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}const Sq={Read:["正在读取","已读取"],Bash:["正在运行","已运行"],Grep:["正在搜索","已搜索"],Glob:["正在搜索","已搜索"],Edit:["正在编辑","已编辑"],Write:["正在写入","已写入"],WebFetch:["正在抓取","已抓取"],WebSearch:["正在搜索","已搜索"],Skill:["正在读取","已读取"]};function kq(e){if(!e||typeof e!="object")return"";const t=e,n=t.command??t.file_path??t.path??t.pattern??t.query??t.url??t.description;if(typeof n=="string")return n;for(const r of Object.values(t))if(typeof r=="string"&&r)return r;return""}function b5(e){const t=Sq[e.tool],n=t?e.pending?t[0]:t[1]:e.pending?`正在执行 ${e.tool}`:`已执行 ${e.tool}`,r=kq(e.input);return r?`${n} ${r}`:n}function Cq({item:e,renderItemDetail:t}){const[n,r]=g.useState(!1),i=n?Yn:Bn,s=n?(t==null?void 0:t(e))??null:null;return h.jsxs("div",{className:"min-w-0 max-w-full",children:[h.jsxs("button",{type:"button",onClick:()=>r(o=>!o),"aria-expanded":n,"data-testid":"tool-call-group-row",className:ne("flex w-full items-center gap-1.5 text-left cursor-pointer min-w-0 py-0.5 text-[13px] hover:text-text-200",e.error?"text-destructive/80":"text-text-400"),children:[e.pending?h.jsx(Ln,{className:"w-3.5 h-3.5 animate-spin shrink-0"}):h.jsx(i,{className:"w-3.5 h-3.5 shrink-0 opacity-60"}),h.jsx("span",{className:"truncate min-w-0",children:b5(e)})]}),n?h.jsx("div",{"data-testid":"tool-call-group-row-detail",className:"pl-5 py-1 min-w-0 space-y-1.5 text-[12px] text-text-300",children:s!==null?s:h.jsxs(h.Fragment,{children:[h.jsx("pre",{className:"min-w-0 max-w-full overflow-auto whitespace-pre-wrap font-mono",children:JSON.stringify(e.input,null,2)}),e.output!==void 0?h.jsx("pre",{className:"min-w-0 max-w-full overflow-auto whitespace-pre-wrap font-mono text-text-400",children:typeof e.output=="string"?e.output:JSON.stringify(e.output,null,2)}):null,e.error?h.jsx("pre",{className:"min-w-0 max-w-full overflow-auto whitespace-pre-wrap font-mono text-destructive",children:e.error}):null]})}):null]})}function Eq({items:e,renderItemDetail:t}){const[n,r]=g.useState(!1);if(e.length===0)return null;const i=e.some(l=>l.pending),s=i?[...e].reverse().find(l=>l.pending):e[e.length-1],o=!i&&e.length>1?` 等 ${e.length} 项`:"",a=n?Yn:Bn;return h.jsxs("div",{"data-testid":"tool-call-group",className:"min-w-0 max-w-full",children:[h.jsxs("button",{type:"button",onClick:()=>r(l=>!l),"aria-expanded":n,"data-testid":"tool-call-group-header",className:"flex w-full items-center gap-1.5 text-left cursor-pointer min-w-0 py-0.5 text-[13px] text-text-400 hover:text-text-200",children:[i&&!n?h.jsx(Ln,{className:"w-3.5 h-3.5 animate-spin shrink-0"}):h.jsx(a,{className:"w-3.5 h-3.5 shrink-0"}),n?h.jsx("span",{className:"min-w-0 truncate opacity-70",children:i?"正在执行":`${e.length} 项`}):h.jsxs("span",{className:ne("truncate min-w-0",i&&"text-text-300"),children:[b5(s),o]})]}),n?h.jsx("div",{className:"mt-0.5 flex flex-col pl-5",children:e.map(l=>h.jsx(Cq,{item:l,renderItemDetail:t},l.toolUseId))}):null]})}function Nq(e){const t=Math.round(e/1e3);if(t<60)return`${t}秒`;const n=Math.floor(t/60),r=t%60;return r>0?`${n}分${r}秒`:`${n}分钟`}function Tq(e,t){const n=t!==void 0?`耗时 ${Nq(t)}`:"";switch(e){case"interrupted":return n?`已中断 · ${n}`:"已中断";case"error":return n?`出错 · ${n}`:"出错";default:return n||"已完成"}}function Iq({status:e="done",durationMs:t,defaultExpanded:n=!1,children:r}){const[i,s]=g.useState(n),o=i?Yn:Bn;return h.jsxs("div",{"data-testid":"turn-process-block",className:"min-w-0 max-w-full border-t border-border pt-2",children:[h.jsxs("button",{type:"button",onClick:()=>s(a=>!a),"aria-expanded":i,"data-testid":"turn-process-block-header",className:ne("flex w-full items-center gap-1 text-left cursor-pointer min-w-0 py-0.5 text-[13px]",e!=="done"?"text-destructive/80 hover:text-destructive":"text-text-400 hover:text-text-200"),children:[h.jsx("span",{className:"truncate min-w-0",children:Tq(e,t)}),h.jsx(o,{className:"w-3.5 h-3.5 shrink-0"})]}),i?h.jsx("div",{"data-testid":"turn-process-body",className:"mt-2 flex flex-col gap-2 border-l-2 border-border pl-3",children:r}):null]})}const Pq=/<(system-reminder|related-dir|clawd-shift-fire)\b[^>]*>[\s\S]*?<\/\1>/gi,Rq=/<builder-preview\b[^>]*\/>/gi,Mq=/<(clawd-dispatch-task|clawd-dispatch-result)\b[^>]*>([\s\S]*?)<\/\1>/gi,Aq=/<\/?(brief|detail|files)>/gi;function w5(e){return e?e.replace(Mq,(t,n,r)=>wz(r.replace(Aq,"")).trim()).replace(Pq,"").replace(Rq,"").trim():""}const jq=w5;function Lq(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Dq=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Oq=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Bq={};function JS(e,t){return(Bq.jsx?Oq:Dq).test(e)}const zq=/[ \t\n\f\r]/g;function $q(e){return typeof e=="object"?e.type==="text"?ek(e.value):!1:ek(e)}function ek(e){return e.replace(zq,"")===""}class Mu{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Mu.prototype.normal={};Mu.prototype.property={};Mu.prototype.space=void 0;function S5(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Mu(n,r,t)}function j0(e){return e.toLowerCase()}class Xn{constructor(t,n){this.attribute=n,this.property=t}}Xn.prototype.attribute="";Xn.prototype.booleanish=!1;Xn.prototype.boolean=!1;Xn.prototype.commaOrSpaceSeparated=!1;Xn.prototype.commaSeparated=!1;Xn.prototype.defined=!1;Xn.prototype.mustUseProperty=!1;Xn.prototype.number=!1;Xn.prototype.overloadedBoolean=!1;Xn.prototype.property="";Xn.prototype.spaceSeparated=!1;Xn.prototype.space=void 0;let Fq=0;const Le=Vo(),Ft=Vo(),L0=Vo(),Z=Vo(),ct=Vo(),Ba=Vo(),tr=Vo();function Vo(){return 2**++Fq}const D0=Object.freeze(Object.defineProperty({__proto__:null,boolean:Le,booleanish:Ft,commaOrSpaceSeparated:tr,commaSeparated:Ba,number:Z,overloadedBoolean:L0,spaceSeparated:ct},Symbol.toStringTag,{value:"Module"})),Ym=Object.keys(D0);class $y extends Xn{constructor(t,n,r,i){let s=-1;if(super(t,n),tk(this,"space",i),typeof r=="number")for(;++s<Ym.length;){const o=Ym[s];tk(this,Ym[s],(r&D0[o])===D0[o])}}}$y.prototype.defined=!0;function tk(e,t,n){n&&(e[t]=n)}function kl(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new $y(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[j0(r)]=r,n[j0(s.attribute)]=r}return new Mu(t,n,e.space)}const k5=kl({properties:{ariaActiveDescendant:null,ariaAtomic:Ft,ariaAutoComplete:null,ariaBusy:Ft,ariaChecked:Ft,ariaColCount:Z,ariaColIndex:Z,ariaColSpan:Z,ariaControls:ct,ariaCurrent:null,ariaDescribedBy:ct,ariaDetails:null,ariaDisabled:Ft,ariaDropEffect:ct,ariaErrorMessage:null,ariaExpanded:Ft,ariaFlowTo:ct,ariaGrabbed:Ft,ariaHasPopup:null,ariaHidden:Ft,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ct,ariaLevel:Z,ariaLive:null,ariaModal:Ft,ariaMultiLine:Ft,ariaMultiSelectable:Ft,ariaOrientation:null,ariaOwns:ct,ariaPlaceholder:null,ariaPosInSet:Z,ariaPressed:Ft,ariaReadOnly:Ft,ariaRelevant:null,ariaRequired:Ft,ariaRoleDescription:ct,ariaRowCount:Z,ariaRowIndex:Z,ariaRowSpan:Z,ariaSelected:Ft,ariaSetSize:Z,ariaSort:null,ariaValueMax:Z,ariaValueMin:Z,ariaValueNow:Z,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function C5(e,t){return t in e?e[t]:t}function E5(e,t){return C5(e,t.toLowerCase())}const Hq=kl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ba,acceptCharset:ct,accessKey:ct,action:null,allow:null,allowFullScreen:Le,allowPaymentRequest:Le,allowUserMedia:Le,alt:null,as:null,async:Le,autoCapitalize:null,autoComplete:ct,autoFocus:Le,autoPlay:Le,blocking:ct,capture:null,charSet:null,checked:Le,cite:null,className:ct,cols:Z,colSpan:null,content:null,contentEditable:Ft,controls:Le,controlsList:ct,coords:Z|Ba,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Le,defer:Le,dir:null,dirName:null,disabled:Le,download:L0,draggable:Ft,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Le,formTarget:null,headers:ct,height:Z,hidden:L0,high:Z,href:null,hrefLang:null,htmlFor:ct,httpEquiv:ct,id:null,imageSizes:null,imageSrcSet:null,inert:Le,inputMode:null,integrity:null,is:null,isMap:Le,itemId:null,itemProp:ct,itemRef:ct,itemScope:Le,itemType:ct,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Le,low:Z,manifest:null,max:null,maxLength:Z,media:null,method:null,min:null,minLength:Z,multiple:Le,muted:Le,name:null,nonce:null,noModule:Le,noValidate:Le,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:Le,optimum:Z,pattern:null,ping:ct,placeholder:null,playsInline:Le,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Le,referrerPolicy:null,rel:ct,required:Le,reversed:Le,rows:Z,rowSpan:Z,sandbox:ct,scope:null,scoped:Le,seamless:Le,selected:Le,shadowRootClonable:Le,shadowRootDelegatesFocus:Le,shadowRootMode:null,shape:null,size:Z,sizes:null,slot:null,span:Z,spellCheck:Ft,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Z,step:null,style:null,tabIndex:Z,target:null,title:null,translate:null,type:null,typeMustMatch:Le,useMap:null,value:Ft,width:Z,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ct,axis:null,background:null,bgColor:null,border:Z,borderColor:null,bottomMargin:Z,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Le,declare:Le,event:null,face:null,frame:null,frameBorder:null,hSpace:Z,leftMargin:Z,link:null,longDesc:null,lowSrc:null,marginHeight:Z,marginWidth:Z,noResize:Le,noHref:Le,noShade:Le,noWrap:Le,object:null,profile:null,prompt:null,rev:null,rightMargin:Z,rules:null,scheme:null,scrolling:Ft,standby:null,summary:null,text:null,topMargin:Z,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Z,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Le,disableRemotePlayback:Le,prefix:null,property:null,results:Z,security:null,unselectable:null},space:"html",transform:E5}),Uq=kl({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:tr,accentHeight:Z,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Z,amplitude:Z,arabicForm:null,ascent:Z,attributeName:null,attributeType:null,azimuth:Z,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Z,by:null,calcMode:null,capHeight:Z,className:ct,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:Z,diffuseConstant:Z,direction:null,display:null,dur:null,divisor:Z,dominantBaseline:null,download:Le,dx:null,dy:null,edgeMode:null,editable:null,elevation:Z,enableBackground:null,end:null,event:null,exponent:Z,externalResourcesRequired:null,fill:null,fillOpacity:Z,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:Ba,g2:Ba,glyphName:Ba,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Z,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Z,horizOriginX:Z,horizOriginY:Z,id:null,ideographic:Z,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Z,k:Z,k1:Z,k2:Z,k3:Z,k4:Z,kernelMatrix:tr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Z,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:Z,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:Z,overlineThickness:Z,paintOrder:null,panose1:null,path:null,pathLength:Z,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ct,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Z,pointsAtY:Z,pointsAtZ:Z,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:tr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:tr,rev:tr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:tr,requiredFeatures:tr,requiredFonts:tr,requiredFormats:tr,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:Z,specularExponent:Z,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Z,strikethroughThickness:Z,string:null,stroke:null,strokeDashArray:tr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Z,strokeOpacity:Z,strokeWidth:null,style:null,surfaceScale:Z,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:tr,tabIndex:Z,tableValues:null,target:null,targetX:Z,targetY:Z,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:tr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Z,underlineThickness:Z,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Z,values:null,vAlphabetic:Z,vMathematical:Z,vectorEffect:null,vHanging:Z,vIdeographic:Z,version:null,vertAdvY:Z,vertOriginX:Z,vertOriginY:Z,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Z,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:C5}),N5=kl({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()}}),T5=kl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:E5}),I5=kl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Wq={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"},Vq=/[A-Z]/g,nk=/-[a-z]/g,qq=/^data[-\w.:]+$/i;function Kq(e,t){const n=j0(t);let r=t,i=Xn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&qq.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(nk,Yq);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!nk.test(s)){let o=s.replace(Vq,Gq);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=$y}return new i(r,t)}function Gq(e){return"-"+e.toLowerCase()}function Yq(e){return e.charAt(1).toUpperCase()}const Xq=S5([k5,Hq,N5,T5,I5],"html"),Fy=S5([k5,Uq,N5,T5,I5],"svg");function Qq(e){return e.join(" ").trim()}var Hy={},rk=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,Zq=/\n/g,Jq=/^\s*/,eK=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,tK=/^:\s*/,nK=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,rK=/^[;\s]*/,iK=/^\s+|\s+$/g,sK=`
|
|
517
517
|
`,ik="/",sk="*",lo="",oK="comment",aK="declaration";function lK(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function i(m){var v=m.match(Zq);v&&(n+=v.length);var w=m.lastIndexOf(sK);r=~w?m.length-w:r+m.length}function s(){var m={line:n,column:r};return function(v){return v.position=new o(m),c(),v}}function o(m){this.start=m,this.end={line:n,column:r},this.source=t.source}o.prototype.content=e;function a(m){var v=new Error(t.source+":"+n+":"+r+": "+m);if(v.reason=m,v.filename=t.source,v.line=n,v.column=r,v.source=e,!t.silent)throw v}function l(m){var v=m.exec(e);if(v){var w=v[0];return i(w),e=e.slice(w.length),v}}function c(){l(Jq)}function u(m){var v;for(m=m||[];v=d();)v!==!1&&m.push(v);return m}function d(){var m=s();if(!(ik!=e.charAt(0)||sk!=e.charAt(1))){for(var v=2;lo!=e.charAt(v)&&(sk!=e.charAt(v)||ik!=e.charAt(v+1));)++v;if(v+=2,lo===e.charAt(v-1))return a("End of comment missing");var w=e.slice(2,v-2);return r+=2,i(w),e=e.slice(v),r+=2,m({type:oK,comment:w})}}function f(){var m=s(),v=l(eK);if(v){if(d(),!l(tK))return a("property missing ':'");var w=l(nK),x=m({type:aK,property:ok(v[0].replace(rk,lo)),value:w?ok(w[0].replace(rk,lo)):lo});return l(rK),x}}function p(){var m=[];u(m);for(var v;v=f();)v!==!1&&(m.push(v),u(m));return m}return c(),p()}function ok(e){return e?e.replace(iK,lo):lo}var cK=lK,uK=vh&&vh.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Hy,"__esModule",{value:!0});Hy.default=hK;const dK=uK(cK);function hK(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,dK.default)(e),i=typeof t=="function";return r.forEach(s=>{if(s.type!=="declaration")return;const{property:o,value:a}=s;i?t(o,a,s):a&&(n=n||{},n[o]=a)}),n}var Pp={};Object.defineProperty(Pp,"__esModule",{value:!0});Pp.camelCase=void 0;var fK=/^--[a-zA-Z0-9_-]+$/,pK=/-([a-z])/g,mK=/^[^-]+$/,gK=/^-(webkit|moz|ms|o|khtml)-/,vK=/^-(ms)-/,xK=function(e){return!e||mK.test(e)||fK.test(e)},_K=function(e,t){return t.toUpperCase()},ak=function(e,t){return"".concat(t,"-")},yK=function(e,t){return t===void 0&&(t={}),xK(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(vK,ak):e=e.replace(gK,ak),e.replace(pK,_K))};Pp.camelCase=yK;var bK=vh&&vh.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},wK=bK(Hy),SK=Pp;function O0(e,t){var n={};return!e||typeof e!="string"||(0,wK.default)(e,function(r,i){r&&i&&(n[(0,SK.camelCase)(r,t)]=i)}),n}O0.default=O0;var kK=O0;const CK=pu(kK),P5=R5("end"),Uy=R5("start");function R5(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 EK(e){const t=Uy(e),n=P5(e);if(t&&n)return{start:t,end:n}}function kc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?lk(e.position):"start"in e||"end"in e?lk(e):"line"in e||"column"in e?B0(e):""}function B0(e){return ck(e&&e.line)+":"+ck(e&&e.column)}function lk(e){return B0(e&&e.start)+"-"+B0(e&&e.end)}function ck(e){return e&&typeof e=="number"?e:1}class Tn extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},o=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(o=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?s.ruleId=r:(s.source=r.slice(0,l),s.ruleId=r.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const a=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=a?a.line:void 0,this.name=kc(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Tn.prototype.file="";Tn.prototype.name="";Tn.prototype.reason="";Tn.prototype.message="";Tn.prototype.stack="";Tn.prototype.column=void 0;Tn.prototype.line=void 0;Tn.prototype.ancestors=void 0;Tn.prototype.cause=void 0;Tn.prototype.fatal=void 0;Tn.prototype.place=void 0;Tn.prototype.ruleId=void 0;Tn.prototype.source=void 0;const Wy={}.hasOwnProperty,NK=new Map,TK=/[A-Z]/g,IK=new Set(["table","tbody","thead","tfoot","tr"]),PK=new Set(["td","th"]),M5="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function RK(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=zK(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=BK(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"?Fy:Xq,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=A5(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function A5(e,t,n){if(t.type==="element")return MK(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return AK(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return LK(e,t,n);if(t.type==="mdxjsEsm")return jK(e,t);if(t.type==="root")return DK(e,t,n);if(t.type==="text")return OK(e,t)}function MK(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Fy,e.schema=i),e.ancestors.push(t);const s=L5(e,t.tagName,!1),o=$K(e,t);let a=qy(e,t);return IK.has(t.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!$q(l):!0})),j5(e,o,s,t),Vy(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function AK(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)}lu(e,t.position)}function jK(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);lu(e,t.position)}function LK(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=Fy,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:L5(e,t.name,!0),o=FK(e,t),a=qy(e,t);return j5(e,o,s,t),Vy(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function DK(e,t,n){const r={};return Vy(r,qy(e,t)),e.create(t,e.Fragment,r,n)}function OK(e,t){return t.value}function j5(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Vy(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function BK(e,t,n){return r;function r(i,s,o,a){const c=Array.isArray(o.children)?n:t;return a?c(s,o,a):c(s,o)}}function zK(e,t){return n;function n(r,i,s,o){const a=Array.isArray(s.children),l=Uy(r);return t(i,s,o,a,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function $K(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&Wy.call(t.properties,i)){const s=HK(e,i,t.properties[i]);if(s){const[o,a]=s;e.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&PK.has(t.tagName)?r=a:n[o]=a}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function FK(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const o=s.expression;o.type;const a=o.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else lu(e,t.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const a=r.value.data.estree.body[0];a.type,s=e.evaluater.evaluateExpression(a.expression)}else lu(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function qy(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:NK;for(;++r<t.children.length;){const s=t.children[r];let o;if(e.passKeys){const l=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(l){const c=i.get(l)||0;o=l+"-"+c,i.set(l,c+1)}}const a=A5(e,s,o);a!==void 0&&n.push(a)}return n}function HK(e,t,n){const r=Kq(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Lq(n):Qq(n)),r.property==="style"){let i=typeof n=="object"?n:UK(e,String(n));return e.stylePropertyNameCase==="css"&&(i=WK(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?Wq[r.property]||r.property:r.attribute,n]}}function UK(e,t){try{return CK(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new Tn("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=M5+"#cannot-parse-style-attribute",i}}function L5(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,o;for(;++s<i.length;){const a=JS(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};o=o?{type:"MemberExpression",object:o,property:a,computed:!!(s&&a.type==="Literal"),optional:!1}:a}r=o}else r=JS(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return Wy.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);lu(e)}function lu(e,t){const n=new Tn("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=M5+"#cannot-handle-mdx-estrees-without-createevaluater",n}function WK(e){const t={};let n;for(n in e)Wy.call(e,n)&&(t[VK(n)]=e[n]);return t}function VK(e){let t=e.replace(TK,qK);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function qK(e){return"-"+e.toLowerCase()}const Xm={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"]},KK={};function Ky(e,t){const n=KK,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return D5(e,r,i)}function D5(e,t,n){if(GK(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 uk(e.children,t,n)}return Array.isArray(e)?uk(e,t,n):""}function uk(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=D5(e[i],t,n);return r.join("")}function GK(e){return!!(e&&typeof e=="object")}const dk=document.createElement("i");function Gy(e){const t="&"+e+";";dk.innerHTML=t;const n=dk.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function ar(e,t,n,r){const i=e.length;let s=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);s<r.length;)o=r.slice(s,s+1e4),o.unshift(t,0),e.splice(...o),s+=1e4,t+=1e4}function yr(e,t){return e.length>0?(ar(e,e.length,0,t),e):t}const hk={}.hasOwnProperty;function O5(e){const t={};let n=-1;for(;++n<e.length;)YK(t,e[n]);return t}function YK(e,t){let n;for(n in t){const i=(hk.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let o;if(s)for(o in s){hk.call(i,o)||(i[o]=[]);const a=s[o];XK(i[o],Array.isArray(a)?a:a?[a]:[])}}}function XK(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);ar(e,0,0,r)}function B5(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 Hr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Rn=Ys(/[A-Za-z]/),Cn=Ys(/[\dA-Za-z]/),QK=Ys(/[#-'*+\--9=?A-Z^-~]/);function hf(e){return e!==null&&(e<32||e===127)}const z0=Ys(/\d/),ZK=Ys(/[\dA-Fa-f]/),JK=Ys(/[!-/:-@[-`{-~]/);function we(e){return e!==null&&e<-2}function lt(e){return e!==null&&(e<0||e===32)}function Ue(e){return e===-2||e===-1||e===32}const Rp=Ys(new RegExp("\\p{P}|\\p{S}","u")),Mo=Ys(/\s/);function Ys(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Cl(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let o="";if(s===37&&Cn(e.charCodeAt(n+1))&&Cn(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(o=String.fromCharCode(s));else if(s>55295&&s<57344){const a=e.charCodeAt(n+1);s<56320&&a>56319&&a<57344?(o=String.fromCharCode(s,a),i=1):o="�"}else o=String.fromCharCode(s);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function qe(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(l){return Ue(l)?(e.enter(n),a(l)):t(l)}function a(l){return Ue(l)&&s++<i?(e.consume(l),a):(e.exit(n),t(l))}}const eG={tokenize:tG};function tG(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"),qe(e,t,"linePrefix")}function i(a){return e.enter("paragraph"),s(a)}function s(a){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,o(a)}function o(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return we(a)?(e.consume(a),e.exit("chunkText"),s):(e.consume(a),o)}}const nG={tokenize:rG},fk={tokenize:iG};function rG(e){const t=this,n=[];let r=0,i,s,o;return a;function a(y){if(r<n.length){const S=n[r];return t.containerState=S[1],e.attempt(S[0].continuation,l,c)(y)}return c(y)}function l(y){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&_();const S=t.events.length;let C=S,k;for(;C--;)if(t.events[C][0]==="exit"&&t.events[C][1].type==="chunkFlow"){k=t.events[C][1].end;break}x(r);let N=S;for(;N<t.events.length;)t.events[N][1].end={...k},N++;return ar(t.events,C+1,0,t.events.slice(S)),t.events.length=N,c(y)}return a(y)}function c(y){if(r===n.length){if(!i)return f(y);if(i.currentConstruct&&i.currentConstruct.concrete)return m(y);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(fk,u,d)(y)}function u(y){return i&&_(),x(r),f(y)}function d(y){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(y)}function f(y){return t.containerState={},e.attempt(fk,p,m)(y)}function p(y){return r++,n.push([t.currentConstruct,t.containerState]),f(y)}function m(y){if(y===null){i&&_(),x(0),e.consume(y);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),v(y)}function v(y){if(y===null){w(e.exit("chunkFlow"),!0),x(0),e.consume(y);return}return we(y)?(e.consume(y),w(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(y),v)}function w(y,S){const C=t.sliceStream(y);if(S&&C.push(null),y.previous=s,s&&(s.next=y),s=y,i.defineSkip(y.start),i.write(C),t.parser.lazy[y.start.line]){let k=i.events.length;for(;k--;)if(i.events[k][1].start.offset<o&&(!i.events[k][1].end||i.events[k][1].end.offset>o))return;const N=t.events.length;let T=N,D,P;for(;T--;)if(t.events[T][0]==="exit"&&t.events[T][1].type==="chunkFlow"){if(D){P=t.events[T][1].end;break}D=!0}for(x(r),k=N;k<t.events.length;)t.events[k][1].end={...P},k++;ar(t.events,T+1,0,t.events.slice(N)),t.events.length=k}}function x(y){let S=n.length;for(;S-- >y;){const C=n[S];t.containerState=C[1],C[0].exit.call(t,e)}n.length=y}function _(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function iG(e,t,n){return qe(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function el(e){if(e===null||lt(e)||Mo(e))return 1;if(Rp(e))return 2}function Mp(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const s=e[i].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const $0={name:"attention",resolveAll:sG,tokenize:oG};function sG(e,t){let n=-1,r,i,s,o,a,l,c,u;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;l=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 d={...e[r][1].end},f={...e[n][1].start};pk(d,-l),pk(f,l),o={type:l>1?"strongSequence":"emphasisSequence",start:d,end:{...e[r][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:f},s={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:l>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[r][1].end={...o.start},e[n][1].start={...a.end},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=yr(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=yr(c,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",s,t]]),c=yr(c,Mp(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=yr(c,[["exit",s,t],["enter",a,t],["exit",a,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,c=yr(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):u=0,ar(e,r-1,n-r+3,c),n=r+c.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function oG(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=el(r);let s;return o;function o(l){return s=l,e.enter("attentionSequence"),a(l)}function a(l){if(l===s)return e.consume(l),a;const c=e.exit("attentionSequence"),u=el(l),d=!u||u===2&&i||n.includes(l),f=!i||i===2&&u||n.includes(r);return c._open=!!(s===42?d:d&&(i||!f)),c._close=!!(s===42?f:f&&(u||!d)),t(l)}}function pk(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const aG={name:"autolink",tokenize:lG};function lG(e,t,n){let r=0;return i;function i(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(p){return Rn(p)?(e.consume(p),o):p===64?n(p):c(p)}function o(p){return p===43||p===45||p===46||Cn(p)?(r=1,a(p)):c(p)}function a(p){return p===58?(e.consume(p),r=0,l):(p===43||p===45||p===46||Cn(p))&&r++<32?(e.consume(p),a):(r=0,c(p))}function l(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||hf(p)?n(p):(e.consume(p),l)}function c(p){return p===64?(e.consume(p),u):QK(p)?(e.consume(p),c):n(p)}function u(p){return Cn(p)?d(p):n(p)}function d(p){return p===46?(e.consume(p),r=0,u):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):f(p)}function f(p){if((p===45||Cn(p))&&r++<63){const m=p===45?f:d;return e.consume(p),m}return n(p)}}const Au={partial:!0,tokenize:cG};function cG(e,t,n){return r;function r(s){return Ue(s)?qe(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||we(s)?t(s):n(s)}}const z5={continuation:{tokenize:dG},exit:hG,name:"blockQuote",tokenize:uG};function uG(e,t,n){const r=this;return i;function i(o){if(o===62){const a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),s}return n(o)}function s(o){return Ue(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function dG(e,t,n){const r=this;return i;function i(o){return Ue(o)?qe(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt(z5,t,n)(o)}}function hG(e){e.exit("blockQuote")}const $5={name:"characterEscape",tokenize:fG};function fG(e,t,n){return r;function r(s){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(s),e.exit("escapeMarker"),i}function i(s){return JK(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const F5={name:"characterReference",tokenize:pG};function pG(e,t,n){const r=this;let i=0,s,o;return a;function a(d){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),l}function l(d){return d===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(d),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),s=31,o=Cn,u(d))}function c(d){return d===88||d===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(d),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,o=ZK,u):(e.enter("characterReferenceValue"),s=7,o=z0,u(d))}function u(d){if(d===59&&i){const f=e.exit("characterReferenceValue");return o===Cn&&!Gy(r.sliceSerialize(f))?n(d):(e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(d)&&i++<s?(e.consume(d),u):n(d)}}const mk={partial:!0,tokenize:gG},gk={concrete:!0,name:"codeFenced",tokenize:mG};function mG(e,t,n){const r=this,i={partial:!0,tokenize:C};let s=0,o=0,a;return l;function l(k){return c(k)}function c(k){const N=r.events[r.events.length-1];return s=N&&N[1].type==="linePrefix"?N[2].sliceSerialize(N[1],!0).length:0,a=k,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),u(k)}function u(k){return k===a?(o++,e.consume(k),u):o<3?n(k):(e.exit("codeFencedFenceSequence"),Ue(k)?qe(e,d,"whitespace")(k):d(k))}function d(k){return k===null||we(k)?(e.exit("codeFencedFence"),r.interrupt?t(k):e.check(mk,v,S)(k)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),f(k))}function f(k){return k===null||we(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(k)):Ue(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),qe(e,p,"whitespace")(k)):k===96&&k===a?n(k):(e.consume(k),f)}function p(k){return k===null||we(k)?d(k):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(k))}function m(k){return k===null||we(k)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(k)):k===96&&k===a?n(k):(e.consume(k),m)}function v(k){return e.attempt(i,S,w)(k)}function w(k){return e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),x}function x(k){return s>0&&Ue(k)?qe(e,_,"linePrefix",s+1)(k):_(k)}function _(k){return k===null||we(k)?e.check(mk,v,S)(k):(e.enter("codeFlowValue"),y(k))}function y(k){return k===null||we(k)?(e.exit("codeFlowValue"),_(k)):(e.consume(k),y)}function S(k){return e.exit("codeFenced"),t(k)}function C(k,N,T){let D=0;return P;function P(L){return k.enter("lineEnding"),k.consume(L),k.exit("lineEnding"),O}function O(L){return k.enter("codeFencedFence"),Ue(L)?qe(k,R,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):R(L)}function R(L){return L===a?(k.enter("codeFencedFenceSequence"),M(L)):T(L)}function M(L){return L===a?(D++,k.consume(L),M):D>=o?(k.exit("codeFencedFenceSequence"),Ue(L)?qe(k,A,"whitespace")(L):A(L)):T(L)}function A(L){return L===null||we(L)?(k.exit("codeFencedFence"),N(L)):T(L)}}}function gG(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const Qm={name:"codeIndented",tokenize:xG},vG={partial:!0,tokenize:_G};function xG(e,t,n){const r=this;return i;function i(c){return e.enter("codeIndented"),qe(e,s,"linePrefix",5)(c)}function s(c){const u=r.events[r.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?o(c):n(c)}function o(c){return c===null?l(c):we(c)?e.attempt(vG,o,l)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||we(c)?(e.exit("codeFlowValue"),o(c)):(e.consume(c),a)}function l(c){return e.exit("codeIndented"),t(c)}}function _G(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):we(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):qe(e,s,"linePrefix",5)(o)}function s(o){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):we(o)?i(o):n(o)}}const yG={name:"codeText",previous:wG,resolve:bG,tokenize:SG};function bG(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 wG(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function SG(e,t,n){let r=0,i,s;return o;function o(d){return e.enter("codeText"),e.enter("codeTextSequence"),a(d)}function a(d){return d===96?(e.consume(d),r++,a):(e.exit("codeTextSequence"),l(d))}function l(d){return d===null?n(d):d===32?(e.enter("space"),e.consume(d),e.exit("space"),l):d===96?(s=e.enter("codeTextSequence"),i=0,u(d)):we(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),l):(e.enter("codeTextData"),c(d))}function c(d){return d===null||d===32||d===96||we(d)?(e.exit("codeTextData"),l(d)):(e.consume(d),c)}function u(d){return d===96?(e.consume(d),i++,u):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(d)):(s.type="codeTextData",c(d))}}class kG{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Hl(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Hl(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Hl(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);Hl(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Hl(this.left,n.reverse())}}}function Hl(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 H5(e){const t={};let n=-1,r,i,s,o,a,l,c;const u=new kG(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type==="chunkFlow"&&u.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,s=0,s<l.length&&l[s][1].type==="lineEndingBlank"&&(s+=2),s<l.length&&l[s][1].type==="content"))for(;++s<l.length&&l[s][1].type!=="content";)l[s][1].type==="chunkText"&&(l[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,CG(u,n)),n=t[n],c=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(o=u.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(u.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...u.get(i)[1].start},a=u.slice(i,n),a.unshift(r),u.splice(i,n-i+1,a))}}return ar(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!c}function CG(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const a=o.events,l=[],c={};let u,d,f=-1,p=n,m=0,v=0;const w=[v];for(;p;){for(;e.get(++i)[1]!==p;);s.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<a.length;)a[f][0]==="exit"&&a[f-1][0]==="enter"&&a[f][1].type===a[f-1][1].type&&a[f][1].start.line!==a[f][1].end.line&&(v=f+1,w.push(v),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):w.pop(),f=w.length;f--;){const x=a.slice(w[f],w[f+1]),_=s.pop();l.push([_,_+x.length-1]),e.splice(_,2,x)}for(l.reverse(),f=-1;++f<l.length;)c[m+l[f][0]]=m+l[f][1],m+=l[f][1]-l[f][0]-1;return c}const EG={resolve:TG,tokenize:IG},NG={partial:!0,tokenize:PG};function TG(e){return H5(e),e}function IG(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?s(a):we(a)?e.check(NG,o,s)(a):(e.consume(a),i)}function s(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function o(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function PG(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),qe(e,s,"linePrefix")}function s(o){if(o===null||we(o))return n(o);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(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function U5(e,t,n,r,i,s,o,a,l){const c=l||Number.POSITIVE_INFINITY;let u=0;return d;function d(x){return x===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(x),e.exit(s),f):x===null||x===32||x===41||hf(x)?n(x):(e.enter(r),e.enter(o),e.enter(a),e.enter("chunkString",{contentType:"string"}),v(x))}function f(x){return x===62?(e.enter(s),e.consume(x),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(x))}function p(x){return x===62?(e.exit("chunkString"),e.exit(a),f(x)):x===null||x===60||we(x)?n(x):(e.consume(x),x===92?m:p)}function m(x){return x===60||x===62||x===92?(e.consume(x),p):p(x)}function v(x){return!u&&(x===null||x===41||lt(x))?(e.exit("chunkString"),e.exit(a),e.exit(o),e.exit(r),t(x)):u<c&&x===40?(e.consume(x),u++,v):x===41?(e.consume(x),u--,v):x===null||x===32||x===40||hf(x)?n(x):(e.consume(x),x===92?w:v)}function w(x){return x===40||x===41||x===92?(e.consume(x),v):v(x)}}function W5(e,t,n,r,i,s){const o=this;let a=0,l;return c;function c(p){return e.enter(r),e.enter(i),e.consume(p),e.exit(i),e.enter(s),u}function u(p){return a>999||p===null||p===91||p===93&&!l||p===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?n(p):p===93?(e.exit(s),e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):we(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),u):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===null||p===91||p===93||we(p)||a++>999?(e.exit("chunkString"),u(p)):(e.consume(p),l||(l=!Ue(p)),p===92?f:d)}function f(p){return p===91||p===92||p===93?(e.consume(p),a++,d):d(p)}}function V5(e,t,n,r,i,s){let o;return a;function a(f){return f===34||f===39||f===40?(e.enter(r),e.enter(i),e.consume(f),e.exit(i),o=f===40?41:f,l):n(f)}function l(f){return f===o?(e.enter(i),e.consume(f),e.exit(i),e.exit(r),t):(e.enter(s),c(f))}function c(f){return f===o?(e.exit(s),l(o)):f===null?n(f):we(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),qe(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),u(f))}function u(f){return f===o||f===null||we(f)?(e.exit("chunkString"),c(f)):(e.consume(f),f===92?d:u)}function d(f){return f===o||f===92?(e.consume(f),u):u(f)}}function Cc(e,t){let n;return r;function r(i){return we(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):Ue(i)?qe(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const RG={name:"definition",tokenize:AG},MG={partial:!0,tokenize:jG};function AG(e,t,n){const r=this;let i;return s;function s(p){return e.enter("definition"),o(p)}function o(p){return W5.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return i=Hr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),l):n(p)}function l(p){return lt(p)?Cc(e,c)(p):c(p)}function c(p){return U5(e,u,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function u(p){return e.attempt(MG,d,d)(p)}function d(p){return Ue(p)?qe(e,f,"whitespace")(p):f(p)}function f(p){return p===null||we(p)?(e.exit("definition"),r.parser.defined.push(i),t(p)):n(p)}}function jG(e,t,n){return r;function r(a){return lt(a)?Cc(e,i)(a):n(a)}function i(a){return V5(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return Ue(a)?qe(e,o,"whitespace")(a):o(a)}function o(a){return a===null||we(a)?t(a):n(a)}}const LG={name:"hardBreakEscape",tokenize:DG};function DG(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return we(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const OG={name:"headingAtx",resolve:BG,tokenize:zG};function BG(e,t){let n=e.length-2,r=3,i,s;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},ar(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function zG(e,t,n){let r=0;return i;function i(u){return e.enter("atxHeading"),s(u)}function s(u){return e.enter("atxHeadingSequence"),o(u)}function o(u){return u===35&&r++<6?(e.consume(u),o):u===null||lt(u)?(e.exit("atxHeadingSequence"),a(u)):n(u)}function a(u){return u===35?(e.enter("atxHeadingSequence"),l(u)):u===null||we(u)?(e.exit("atxHeading"),t(u)):Ue(u)?qe(e,a,"whitespace")(u):(e.enter("atxHeadingText"),c(u))}function l(u){return u===35?(e.consume(u),l):(e.exit("atxHeadingSequence"),a(u))}function c(u){return u===null||u===35||lt(u)?(e.exit("atxHeadingText"),a(u)):(e.consume(u),c)}}const $G=["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"],vk=["pre","script","style","textarea"],FG={concrete:!0,name:"htmlFlow",resolveTo:WG,tokenize:VG},HG={partial:!0,tokenize:KG},UG={partial:!0,tokenize:qG};function WG(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 VG(e,t,n){const r=this;let i,s,o,a,l;return c;function c(j){return u(j)}function u(j){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(j),d}function d(j){return j===33?(e.consume(j),f):j===47?(e.consume(j),s=!0,v):j===63?(e.consume(j),i=3,r.interrupt?t:E):Rn(j)?(e.consume(j),o=String.fromCharCode(j),w):n(j)}function f(j){return j===45?(e.consume(j),i=2,p):j===91?(e.consume(j),i=5,a=0,m):Rn(j)?(e.consume(j),i=4,r.interrupt?t:E):n(j)}function p(j){return j===45?(e.consume(j),r.interrupt?t:E):n(j)}function m(j){const re="CDATA[";return j===re.charCodeAt(a++)?(e.consume(j),a===re.length?r.interrupt?t:R:m):n(j)}function v(j){return Rn(j)?(e.consume(j),o=String.fromCharCode(j),w):n(j)}function w(j){if(j===null||j===47||j===62||lt(j)){const re=j===47,ie=o.toLowerCase();return!re&&!s&&vk.includes(ie)?(i=1,r.interrupt?t(j):R(j)):$G.includes(o.toLowerCase())?(i=6,re?(e.consume(j),x):r.interrupt?t(j):R(j)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(j):s?_(j):y(j))}return j===45||Cn(j)?(e.consume(j),o+=String.fromCharCode(j),w):n(j)}function x(j){return j===62?(e.consume(j),r.interrupt?t:R):n(j)}function _(j){return Ue(j)?(e.consume(j),_):P(j)}function y(j){return j===47?(e.consume(j),P):j===58||j===95||Rn(j)?(e.consume(j),S):Ue(j)?(e.consume(j),y):P(j)}function S(j){return j===45||j===46||j===58||j===95||Cn(j)?(e.consume(j),S):C(j)}function C(j){return j===61?(e.consume(j),k):Ue(j)?(e.consume(j),C):y(j)}function k(j){return j===null||j===60||j===61||j===62||j===96?n(j):j===34||j===39?(e.consume(j),l=j,N):Ue(j)?(e.consume(j),k):T(j)}function N(j){return j===l?(e.consume(j),l=null,D):j===null||we(j)?n(j):(e.consume(j),N)}function T(j){return j===null||j===34||j===39||j===47||j===60||j===61||j===62||j===96||lt(j)?C(j):(e.consume(j),T)}function D(j){return j===47||j===62||Ue(j)?y(j):n(j)}function P(j){return j===62?(e.consume(j),O):n(j)}function O(j){return j===null||we(j)?R(j):Ue(j)?(e.consume(j),O):n(j)}function R(j){return j===45&&i===2?(e.consume(j),$):j===60&&i===1?(e.consume(j),F):j===62&&i===4?(e.consume(j),H):j===63&&i===3?(e.consume(j),E):j===93&&i===5?(e.consume(j),z):we(j)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(HG,q,M)(j)):j===null||we(j)?(e.exit("htmlFlowData"),M(j)):(e.consume(j),R)}function M(j){return e.check(UG,A,q)(j)}function A(j){return e.enter("lineEnding"),e.consume(j),e.exit("lineEnding"),L}function L(j){return j===null||we(j)?M(j):(e.enter("htmlFlowData"),R(j))}function $(j){return j===45?(e.consume(j),E):R(j)}function F(j){return j===47?(e.consume(j),o="",B):R(j)}function B(j){if(j===62){const re=o.toLowerCase();return vk.includes(re)?(e.consume(j),H):R(j)}return Rn(j)&&o.length<8?(e.consume(j),o+=String.fromCharCode(j),B):R(j)}function z(j){return j===93?(e.consume(j),E):R(j)}function E(j){return j===62?(e.consume(j),H):j===45&&i===2?(e.consume(j),E):R(j)}function H(j){return j===null||we(j)?(e.exit("htmlFlowData"),q(j)):(e.consume(j),H)}function q(j){return e.exit("htmlFlow"),t(j)}}function qG(e,t,n){const r=this;return i;function i(o){return we(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s):n(o)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function KG(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Au,t,n)}}const GG={name:"htmlText",tokenize:YG};function YG(e,t,n){const r=this;let i,s,o;return a;function a(E){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(E),l}function l(E){return E===33?(e.consume(E),c):E===47?(e.consume(E),C):E===63?(e.consume(E),y):Rn(E)?(e.consume(E),T):n(E)}function c(E){return E===45?(e.consume(E),u):E===91?(e.consume(E),s=0,m):Rn(E)?(e.consume(E),_):n(E)}function u(E){return E===45?(e.consume(E),p):n(E)}function d(E){return E===null?n(E):E===45?(e.consume(E),f):we(E)?(o=d,F(E)):(e.consume(E),d)}function f(E){return E===45?(e.consume(E),p):d(E)}function p(E){return E===62?$(E):E===45?f(E):d(E)}function m(E){const H="CDATA[";return E===H.charCodeAt(s++)?(e.consume(E),s===H.length?v:m):n(E)}function v(E){return E===null?n(E):E===93?(e.consume(E),w):we(E)?(o=v,F(E)):(e.consume(E),v)}function w(E){return E===93?(e.consume(E),x):v(E)}function x(E){return E===62?$(E):E===93?(e.consume(E),x):v(E)}function _(E){return E===null||E===62?$(E):we(E)?(o=_,F(E)):(e.consume(E),_)}function y(E){return E===null?n(E):E===63?(e.consume(E),S):we(E)?(o=y,F(E)):(e.consume(E),y)}function S(E){return E===62?$(E):y(E)}function C(E){return Rn(E)?(e.consume(E),k):n(E)}function k(E){return E===45||Cn(E)?(e.consume(E),k):N(E)}function N(E){return we(E)?(o=N,F(E)):Ue(E)?(e.consume(E),N):$(E)}function T(E){return E===45||Cn(E)?(e.consume(E),T):E===47||E===62||lt(E)?D(E):n(E)}function D(E){return E===47?(e.consume(E),$):E===58||E===95||Rn(E)?(e.consume(E),P):we(E)?(o=D,F(E)):Ue(E)?(e.consume(E),D):$(E)}function P(E){return E===45||E===46||E===58||E===95||Cn(E)?(e.consume(E),P):O(E)}function O(E){return E===61?(e.consume(E),R):we(E)?(o=O,F(E)):Ue(E)?(e.consume(E),O):D(E)}function R(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(e.consume(E),i=E,M):we(E)?(o=R,F(E)):Ue(E)?(e.consume(E),R):(e.consume(E),A)}function M(E){return E===i?(e.consume(E),i=void 0,L):E===null?n(E):we(E)?(o=M,F(E)):(e.consume(E),M)}function A(E){return E===null||E===34||E===39||E===60||E===61||E===96?n(E):E===47||E===62||lt(E)?D(E):(e.consume(E),A)}function L(E){return E===47||E===62||lt(E)?D(E):n(E)}function $(E){return E===62?(e.consume(E),e.exit("htmlTextData"),e.exit("htmlText"),t):n(E)}function F(E){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),B}function B(E){return Ue(E)?qe(e,z,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):z(E)}function z(E){return e.enter("htmlTextData"),o(E)}}const Yy={name:"labelEnd",resolveAll:JG,resolveTo:eY,tokenize:tY},XG={tokenize:nY},QG={tokenize:rY},ZG={tokenize:iY};function JG(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&&ar(e,0,e.length,n),e}function eY(e,t){let n=e.length,r=0,i,s,o,a;for(;n--;)if(i=e[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(o){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(o=n);const l={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[s][1].start},end:{...e[o][1].end}},u={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[o-2][1].start}};return a=[["enter",l,t],["enter",c,t]],a=yr(a,e.slice(s+1,s+r+3)),a=yr(a,[["enter",u,t]]),a=yr(a,Mp(t.parser.constructs.insideSpan.null,e.slice(s+r+4,o-3),t)),a=yr(a,[["exit",u,t],e[o-2],e[o-1],["exit",c,t]]),a=yr(a,e.slice(o+1)),a=yr(a,[["exit",l,t]]),ar(e,s,e.length,a),e}function tY(e,t,n){const r=this;let i=r.events.length,s,o;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return a;function a(f){return s?s._inactive?d(f):(o=r.parser.defined.includes(Hr(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(f),e.exit("labelMarker"),e.exit("labelEnd"),l):n(f)}function l(f){return f===40?e.attempt(XG,u,o?u:d)(f):f===91?e.attempt(QG,u,o?c:d)(f):o?u(f):d(f)}function c(f){return e.attempt(ZG,u,d)(f)}function u(f){return t(f)}function d(f){return s._balanced=!0,n(f)}}function nY(e,t,n){return r;function r(d){return e.enter("resource"),e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),i}function i(d){return lt(d)?Cc(e,s)(d):s(d)}function s(d){return d===41?u(d):U5(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function o(d){return lt(d)?Cc(e,l)(d):u(d)}function a(d){return n(d)}function l(d){return d===34||d===39||d===40?V5(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):u(d)}function c(d){return lt(d)?Cc(e,u)(d):u(d)}function u(d){return d===41?(e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),e.exit("resource"),t):n(d)}}function rY(e,t,n){const r=this;return i;function i(a){return W5.call(r,e,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes(Hr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function o(a){return n(a)}}function iY(e,t,n){return r;function r(s){return e.enter("reference"),e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),i}function i(s){return s===93?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),t):n(s)}}const sY={name:"labelStartImage",resolveAll:Yy.resolveAll,tokenize:oY};function oY(e,t,n){const r=this;return i;function i(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),s}function s(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),o):n(a)}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const aY={name:"labelStartLink",resolveAll:Yy.resolveAll,tokenize:lY};function lY(e,t,n){const r=this;return i;function i(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),s}function s(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const Zm={name:"lineEnding",tokenize:cY};function cY(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),qe(e,t,"linePrefix")}}const lh={name:"thematicBreak",tokenize:uY};function uY(e,t,n){let r=0,i;return s;function s(c){return e.enter("thematicBreak"),o(c)}function o(c){return i=c,a(c)}function a(c){return c===i?(e.enter("thematicBreakSequence"),l(c)):r>=3&&(c===null||we(c))?(e.exit("thematicBreak"),t(c)):n(c)}function l(c){return c===i?(e.consume(c),r++,l):(e.exit("thematicBreakSequence"),Ue(c)?qe(e,a,"whitespace")(c):a(c))}}const Un={continuation:{tokenize:pY},exit:gY,name:"list",tokenize:fY},dY={partial:!0,tokenize:vY},hY={partial:!0,tokenize:mY};function fY(e,t,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return a;function a(p){const m=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:z0(p)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(lh,n,c)(p):c(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(p)}return n(p)}function l(p){return z0(p)&&++o<10?(e.consume(p),l):(!r.interrupt||o<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),c(p)):n(p)}function c(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(Au,r.interrupt?n:u,e.attempt(dY,f,d))}function u(p){return r.containerState.initialBlankLine=!0,s++,f(p)}function d(p){return Ue(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),f):n(p)}function f(p){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function pY(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Au,i,s);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,qe(e,t,"listItemIndent",r.containerState.size+1)(a)}function s(a){return r.containerState.furtherBlankLines||!Ue(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(hY,t,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,qe(e,e.attempt(Un,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function mY(e,t,n){const r=this;return qe(e,i,"listItemIndent",r.containerState.size+1);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(s):n(s)}}function gY(e){e.exit(this.containerState.type)}function vY(e,t,n){const r=this;return qe(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const o=r.events[r.events.length-1];return!Ue(s)&&o&&o[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const xk={name:"setextUnderline",resolveTo:xY,tokenize:_Y};function xY(e,t){let n=e.length,r,i,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",o,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function _Y(e,t,n){const r=this;let i;return s;function s(c){let u=r.events.length,d;for(;u--;)if(r.events[u][1].type!=="lineEnding"&&r.events[u][1].type!=="linePrefix"&&r.events[u][1].type!=="content"){d=r.events[u][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(e.enter("setextHeadingLine"),i=c,o(c)):n(c)}function o(c){return e.enter("setextHeadingLineSequence"),a(c)}function a(c){return c===i?(e.consume(c),a):(e.exit("setextHeadingLineSequence"),Ue(c)?qe(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||we(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const yY={tokenize:bY};function bY(e){const t=this,n=e.attempt(Au,r,e.attempt(this.parser.constructs.flowInitial,i,qe(e,e.attempt(this.parser.constructs.flow,i,e.attempt(EG,i)),"linePrefix")));return n;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const wY={resolveAll:K5()},SY=q5("string"),kY=q5("text");function q5(e){return{resolveAll:K5(e==="text"?CY:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,o,a);return o;function o(u){return c(u)?s(u):a(u)}function a(u){if(u===null){n.consume(u);return}return n.enter("data"),n.consume(u),l}function l(u){return c(u)?(n.exit("data"),s(u)):(n.consume(u),l)}function c(u){if(u===null)return!0;const d=i[u];let f=-1;if(d)for(;++f<d.length;){const p=d[f];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function K5(e){return t;function t(n,r){let i=-1,s;for(;++i<=n.length;)s===void 0?n[i]&&n[i][1].type==="data"&&(s=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==s+2&&(n[s][1].end=n[i-1][1].end,n.splice(s+2,i-s-2),i=s+2),s=void 0);return e?e(n,r):n}}function CY(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let s=i.length,o=-1,a=0,l;for(;s--;){const c=i[s];if(typeof c=="string"){for(o=c.length;c.charCodeAt(o-1)===32;)a++,o--;if(o)break;o=-1}else if(c===-2)l=!0,a++;else if(c!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){const c={type:n===e.length||l||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?o:r.start._bufferIndex+o,_index:r.start._index+s,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...c.start},r.start.offset===r.end.offset?Object.assign(r,c):(e.splice(n,0,["enter",c,t],["exit",c,t]),n+=2)}n++}return e}const EY={42:Un,43:Un,45:Un,48:Un,49:Un,50:Un,51:Un,52:Un,53:Un,54:Un,55:Un,56:Un,57:Un,62:z5},NY={91:RG},TY={[-2]:Qm,[-1]:Qm,32:Qm},IY={35:OG,42:lh,45:[xk,lh],60:FG,61:xk,95:lh,96:gk,126:gk},PY={38:F5,92:$5},RY={[-5]:Zm,[-4]:Zm,[-3]:Zm,33:sY,38:F5,42:$0,60:[aG,GG],91:aY,92:[LG,$5],93:Yy,95:$0,96:yG},MY={null:[$0,wY]},AY={null:[42,95]},jY={null:[]},LY=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:AY,contentInitial:NY,disable:jY,document:EY,flow:IY,flowInitial:TY,insideSpan:MY,string:PY,text:RY},Symbol.toStringTag,{value:"Module"}));function DY(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let o=[],a=[];const l={attempt:N(C),check:N(k),consume:_,enter:y,exit:S,interrupt:N(k,{interrupt:!0})},c={code:null,containerState:{},defineSkip:v,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d};let u=t.tokenize.call(c,l);return t.resolveAll&&s.push(t),c;function d(O){return o=yr(o,O),w(),o[o.length-1]!==null?[]:(T(t,0),c.events=Mp(s,c.events,c),c.events)}function f(O,R){return BY(p(O),R)}function p(O){return OY(o,O)}function m(){const{_bufferIndex:O,_index:R,line:M,column:A,offset:L}=r;return{_bufferIndex:O,_index:R,line:M,column:A,offset:L}}function v(O){i[O.line]=O.column,P()}function w(){let O;for(;r._index<o.length;){const R=o[r._index];if(typeof R=="string")for(O=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===O&&r._bufferIndex<R.length;)x(R.charCodeAt(r._bufferIndex));else x(R)}}function x(O){u=u(O)}function _(O){we(O)?(r.line++,r.column=1,r.offset+=O===-3?2:1,P()):O!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=O}function y(O,R){const M=R||{};return M.type=O,M.start=m(),c.events.push(["enter",M,c]),a.push(M),M}function S(O){const R=a.pop();return R.end=m(),c.events.push(["exit",R,c]),R}function C(O,R){T(O,R.from)}function k(O,R){R.restore()}function N(O,R){return M;function M(A,L,$){let F,B,z,E;return Array.isArray(A)?q(A):"tokenize"in A?q([A]):H(A);function H(K){return xe;function xe(Ee){const ue=Ee!==null&&K[Ee],je=Ee!==null&&K.null,Ae=[...Array.isArray(ue)?ue:ue?[ue]:[],...Array.isArray(je)?je:je?[je]:[]];return q(Ae)(Ee)}}function q(K){return F=K,B=0,K.length===0?$:j(K[B])}function j(K){return xe;function xe(Ee){return E=D(),z=K,K.partial||(c.currentConstruct=K),K.name&&c.parser.constructs.disable.null.includes(K.name)?ie():K.tokenize.call(R?Object.assign(Object.create(c),R):c,l,re,ie)(Ee)}}function re(K){return O(z,E),L}function ie(K){return E.restore(),++B<F.length?j(F[B]):$}}}function T(O,R){O.resolveAll&&!s.includes(O)&&s.push(O),O.resolve&&ar(c.events,R,c.events.length-R,O.resolve(c.events.slice(R),c)),O.resolveTo&&(c.events=O.resolveTo(c.events,c))}function D(){const O=m(),R=c.previous,M=c.currentConstruct,A=c.events.length,L=Array.from(a);return{from:A,restore:$};function $(){r=O,c.previous=R,c.currentConstruct=M,c.events.length=A,a=L,P()}}function P(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function OY(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let o;if(n===i)o=[e[n].slice(r,s)];else{if(o=e.slice(n,i),r>-1){const a=o[0];typeof a=="string"?o[0]=a.slice(r):o.shift()}s>0&&o.push(e[i].slice(0,s))}return o}function BY(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let o;if(typeof s=="string")o=s;else switch(s){case-5:{o="\r";break}case-4:{o=`
|
|
518
518
|
`;break}case-3:{o=`\r
|
|
519
519
|
`;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&i)continue;o=" ";break}default:o=String.fromCharCode(s)}i=s===-2,r.push(o)}return r.join("")}function zY(e){const r={constructs:O5([LY,...(e||{}).extensions||[]]),content:i(eG),defined:[],document:i(nG),flow:i(yY),lazy:{},string:i(SY),text:i(kY)};return r;function i(s){return o;function o(a){return DY(r,s,a)}}}function $Y(e){for(;!H5(e););return e}const _k=/[\0\t\n\r]/g;function FY(){let e=1,t="",n=!0,r;return i;function i(s,o,a){const l=[];let c,u,d,f,p;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s)),d=0,t="",n&&(s.charCodeAt(0)===65279&&d++,n=void 0);d<s.length;){if(_k.lastIndex=d,c=_k.exec(s),f=c&&c.index!==void 0?c.index:s.length,p=s.charCodeAt(f),!c){t=s.slice(d);break}if(p===10&&d===f&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),d<f&&(l.push(s.slice(d,f)),e+=f-d),p){case 0:{l.push(65533),e++;break}case 9:{for(u=Math.ceil(e/4)*4,l.push(-2);e++<u;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}d=f+1}return a&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const HY=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function UY(e){return e.replace(HY,WY)}function WY(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return B5(n.slice(s?2:1),s?16:10)}return Gy(n)||e}const G5={}.hasOwnProperty;function VY(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),qY(n)($Y(zY(n).document().write(FY()(e,t,!0))))}function qY(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(mt),autolinkProtocol:D,autolinkEmail:D,atxHeading:s(Nt),blockQuote:s(je),characterEscape:D,characterReference:D,codeFenced:s(Ae),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(Ae,o),codeText:s(Oe,o),codeTextData:D,data:D,codeFlowValue:D,definition:s(ve),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(tt),hardBreakEscape:s(st),hardBreakTrailing:s(st),htmlFlow:s(pt,o),htmlFlowData:D,htmlText:s(pt,o),htmlTextData:D,image:s(Dt),label:o,link:s(mt),listItem:s(Xe),listItemValue:f,listOrdered:s(gt,d),listUnordered:s(gt),paragraph:s(nt),reference:j,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(Nt),strong:s(zt),thematicBreak:s(tn)},exit:{atxHeading:l(),atxHeadingSequence:C,autolink:l(),autolinkEmail:ue,autolinkProtocol:Ee,blockQuote:l(),characterEscapeValue:P,characterReferenceMarkerHexadecimal:ie,characterReferenceMarkerNumeric:ie,characterReferenceValue:K,characterReference:xe,codeFenced:l(w),codeFencedFence:v,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:P,codeIndented:l(x),codeText:l(L),codeTextData:P,data:P,definition:l(),definitionDestinationString:S,definitionLabelString:_,definitionTitleString:y,emphasis:l(),hardBreakEscape:l(R),hardBreakTrailing:l(R),htmlFlow:l(M),htmlFlowData:P,htmlText:l(A),htmlTextData:P,image:l(F),label:z,labelText:B,lineEnding:O,link:l($),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:re,resourceDestinationString:E,resourceTitleString:H,resource:q,setextHeading:l(T),setextHeadingLineSequence:N,setextHeadingText:k,strong:l(),thematicBreak:l()}};Y5(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(U){let Q={type:"root",children:[]};const _e={stack:[Q],tokenStack:[],config:t,enter:a,exit:c,buffer:o,resume:u,data:n},Pe=[];let Be=-1;for(;++Be<U.length;)if(U[Be][1].type==="listOrdered"||U[Be][1].type==="listUnordered")if(U[Be][0]==="enter")Pe.push(Be);else{const _t=Pe.pop();Be=i(U,_t,Be)}for(Be=-1;++Be<U.length;){const _t=t[U[Be][0]];G5.call(_t,U[Be][1].type)&&_t[U[Be][1].type].call(Object.assign({sliceSerialize:U[Be][2].sliceSerialize},_e),U[Be][1])}if(_e.tokenStack.length>0){const _t=_e.tokenStack[_e.tokenStack.length-1];(_t[1]||yk).call(_e,void 0,_t[0])}for(Q.position={start:cs(U.length>0?U[0][1].start:{line:1,column:1,offset:0}),end:cs(U.length>0?U[U.length-2][1].end:{line:1,column:1,offset:0})},Be=-1;++Be<t.transforms.length;)Q=t.transforms[Be](Q)||Q;return Q}function i(U,Q,_e){let Pe=Q-1,Be=-1,_t=!1,_n,$t,dn,oe;for(;++Pe<=_e;){const ye=U[Pe];switch(ye[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ye[0]==="enter"?Be++:Be--,oe=void 0;break}case"lineEndingBlank":{ye[0]==="enter"&&(_n&&!oe&&!Be&&!dn&&(dn=Pe),oe=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:oe=void 0}if(!Be&&ye[0]==="enter"&&ye[1].type==="listItemPrefix"||Be===-1&&ye[0]==="exit"&&(ye[1].type==="listUnordered"||ye[1].type==="listOrdered")){if(_n){let Ze=Pe;for($t=void 0;Ze--;){const Tt=U[Ze];if(Tt[1].type==="lineEnding"||Tt[1].type==="lineEndingBlank"){if(Tt[0]==="exit")continue;$t&&(U[$t][1].type="lineEndingBlank",_t=!0),Tt[1].type="lineEnding",$t=Ze}else if(!(Tt[1].type==="linePrefix"||Tt[1].type==="blockQuotePrefix"||Tt[1].type==="blockQuotePrefixWhitespace"||Tt[1].type==="blockQuoteMarker"||Tt[1].type==="listItemIndent"))break}dn&&(!$t||dn<$t)&&(_n._spread=!0),_n.end=Object.assign({},$t?U[$t][1].start:ye[1].end),U.splice($t||Pe,0,["exit",_n,ye[2]]),Pe++,_e++}if(ye[1].type==="listItemPrefix"){const Ze={type:"listItem",_spread:!1,start:Object.assign({},ye[1].start),end:void 0};_n=Ze,U.splice(Pe,0,["enter",Ze,ye[2]]),Pe++,_e++,dn=void 0,oe=!0}}}return U[Q][1]._spread=_t,_e}function s(U,Q){return _e;function _e(Pe){a.call(this,U(Pe),Pe),Q&&Q.call(this,Pe)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(U,Q,_e){this.stack[this.stack.length-1].children.push(U),this.stack.push(U),this.tokenStack.push([Q,_e||void 0]),U.position={start:cs(Q.start),end:void 0}}function l(U){return Q;function Q(_e){U&&U.call(this,_e),c.call(this,_e)}}function c(U,Q){const _e=this.stack.pop(),Pe=this.tokenStack.pop();if(Pe)Pe[0].type!==U.type&&(Q?Q.call(this,U,Pe[0]):(Pe[1]||yk).call(this,U,Pe[0]));else throw new Error("Cannot close `"+U.type+"` ("+kc({start:U.start,end:U.end})+"): it’s not open");_e.position.end=cs(U.end)}function u(){return Ky(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(U){if(this.data.expectingFirstListItemValue){const Q=this.stack[this.stack.length-2];Q.start=Number.parseInt(this.sliceSerialize(U),10),this.data.expectingFirstListItemValue=void 0}}function p(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.lang=U}function m(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.meta=U}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function w(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.value=U.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function x(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.value=U.replace(/(\r?\n|\r)$/g,"")}function _(U){const Q=this.resume(),_e=this.stack[this.stack.length-1];_e.label=Q,_e.identifier=Hr(this.sliceSerialize(U)).toLowerCase()}function y(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.title=U}function S(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.url=U}function C(U){const Q=this.stack[this.stack.length-1];if(!Q.depth){const _e=this.sliceSerialize(U).length;Q.depth=_e}}function k(){this.data.setextHeadingSlurpLineEnding=!0}function N(U){const Q=this.stack[this.stack.length-1];Q.depth=this.sliceSerialize(U).codePointAt(0)===61?1:2}function T(){this.data.setextHeadingSlurpLineEnding=void 0}function D(U){const _e=this.stack[this.stack.length-1].children;let Pe=_e[_e.length-1];(!Pe||Pe.type!=="text")&&(Pe=xn(),Pe.position={start:cs(U.start),end:void 0},_e.push(Pe)),this.stack.push(Pe)}function P(U){const Q=this.stack.pop();Q.value+=this.sliceSerialize(U),Q.position.end=cs(U.end)}function O(U){const Q=this.stack[this.stack.length-1];if(this.data.atHardBreak){const _e=Q.children[Q.children.length-1];_e.position.end=cs(U.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Q.type)&&(D.call(this,U),P.call(this,U))}function R(){this.data.atHardBreak=!0}function M(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.value=U}function A(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.value=U}function L(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.value=U}function $(){const U=this.stack[this.stack.length-1];if(this.data.inReference){const Q=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=Q,delete U.url,delete U.title}else delete U.identifier,delete U.label;this.data.referenceType=void 0}function F(){const U=this.stack[this.stack.length-1];if(this.data.inReference){const Q=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=Q,delete U.url,delete U.title}else delete U.identifier,delete U.label;this.data.referenceType=void 0}function B(U){const Q=this.sliceSerialize(U),_e=this.stack[this.stack.length-2];_e.label=UY(Q),_e.identifier=Hr(Q).toLowerCase()}function z(){const U=this.stack[this.stack.length-1],Q=this.resume(),_e=this.stack[this.stack.length-1];if(this.data.inReference=!0,_e.type==="link"){const Pe=U.children;_e.children=Pe}else _e.alt=Q}function E(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.url=U}function H(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.title=U}function q(){this.data.inReference=void 0}function j(){this.data.referenceType="collapsed"}function re(U){const Q=this.resume(),_e=this.stack[this.stack.length-1];_e.label=Q,_e.identifier=Hr(this.sliceSerialize(U)).toLowerCase(),this.data.referenceType="full"}function ie(U){this.data.characterReferenceType=U.type}function K(U){const Q=this.sliceSerialize(U),_e=this.data.characterReferenceType;let Pe;_e?(Pe=B5(Q,_e==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Pe=Gy(Q);const Be=this.stack[this.stack.length-1];Be.value+=Pe}function xe(U){const Q=this.stack.pop();Q.position.end=cs(U.end)}function Ee(U){P.call(this,U);const Q=this.stack[this.stack.length-1];Q.url=this.sliceSerialize(U)}function ue(U){P.call(this,U);const Q=this.stack[this.stack.length-1];Q.url="mailto:"+this.sliceSerialize(U)}function je(){return{type:"blockquote",children:[]}}function Ae(){return{type:"code",lang:null,meta:null,value:""}}function Oe(){return{type:"inlineCode",value:""}}function ve(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function tt(){return{type:"emphasis",children:[]}}function Nt(){return{type:"heading",depth:0,children:[]}}function st(){return{type:"break"}}function pt(){return{type:"html",value:""}}function Dt(){return{type:"image",title:null,url:"",alt:null}}function mt(){return{type:"link",title:null,url:"",children:[]}}function gt(U){return{type:"list",ordered:U.type==="listOrdered",start:null,spread:U._spread,children:[]}}function Xe(U){return{type:"listItem",spread:U._spread,checked:null,children:[]}}function nt(){return{type:"paragraph",children:[]}}function zt(){return{type:"strong",children:[]}}function xn(){return{type:"text",value:""}}function tn(){return{type:"thematicBreak"}}}function cs(e){return{line:e.line,column:e.column,offset:e.offset}}function Y5(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Y5(e,r):KY(e,r)}}function KY(e,t){let n;for(n in t)if(G5.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 yk(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+kc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+kc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+kc({start:t.start,end:t.end})+") is still open")}function GY(e){const t=this;t.parser=n;function n(r){return VY(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function YY(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 XY(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
package/dist/share-ui/guest.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Clawd 分享</title>
|
|
7
|
-
<script type="module" crossorigin src="/share-ui/assets/guest-
|
|
7
|
+
<script type="module" crossorigin src="/share-ui/assets/guest-BFFxhd6q.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/share-ui/assets/guest-BVnHMXcA.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body style="margin: 0">
|